Massive refactor of several different components including networking fixes
This commit is contained in:
@@ -38,8 +38,8 @@ import rs09.game.content.dialogue.DialogueFile
|
||||
import rs09.game.content.global.GlobalKillCounter;
|
||||
import rs09.game.system.SystemLogger
|
||||
import rs09.game.system.config.ItemConfigParser;
|
||||
import rs09.game.world.GameWorld
|
||||
import rs09.game.world.GameWorld.Pulser
|
||||
import rs09.game.world.World
|
||||
import rs09.game.world.World.Pulser
|
||||
import rs09.game.world.repository.Repository
|
||||
|
||||
object ContentAPI {
|
||||
@@ -372,7 +372,7 @@ object ContentAPI {
|
||||
*/
|
||||
@JvmStatic
|
||||
fun getWorldTicks(): Int {
|
||||
return GameWorld.ticks
|
||||
return World.ticks
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -914,7 +914,7 @@ object ContentAPI {
|
||||
*/
|
||||
@JvmStatic
|
||||
fun submitWorldPulse(pulse: Pulse){
|
||||
GameWorld.Pulser.submit(pulse)
|
||||
World.Pulser.submit(pulse)
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,12 +1,10 @@
|
||||
package gui
|
||||
|
||||
import rs09.game.system.SystemLogger
|
||||
import rs09.game.world.GameWorld
|
||||
import rs09.game.world.World
|
||||
import java.awt.BorderLayout
|
||||
import java.awt.Component
|
||||
import java.awt.Dimension
|
||||
import javax.swing.*
|
||||
import javax.swing.border.Border
|
||||
|
||||
object ServerMonitor : JFrame("Server Monitor"){
|
||||
|
||||
@@ -159,7 +157,7 @@ object ServerMonitor : JFrame("Server Monitor"){
|
||||
removeList.add(event)
|
||||
}
|
||||
|
||||
pulseList.text = GameWorld.Pulser.TASKS.toArray().filterNotNull().map { it.javaClass.simpleName + "\n" }
|
||||
pulseList.text = World.Pulser.TASKS.toArray().filterNotNull().map { it.javaClass.simpleName + "\n" }
|
||||
.filter { it.replace("\n", "").isNotEmpty() }.sorted().joinToString("")
|
||||
eventQueue.removeAll(removeList)
|
||||
repaint()
|
||||
|
||||
@@ -1,61 +1,64 @@
|
||||
package rs09
|
||||
|
||||
import core.game.system.SystemManager
|
||||
import core.game.system.SystemState
|
||||
import core.cache.Cache
|
||||
import core.game.ge.GrandExchangeDatabase
|
||||
import core.game.interaction.`object`.dmc.DMCHandler
|
||||
import core.game.node.entity.npc.drop.RareDropTable
|
||||
import core.game.system.mysql.SQLManager
|
||||
import core.gui.ConsoleFrame
|
||||
import core.net.NioReactor
|
||||
import core.net.amsc.WorldCommunicator
|
||||
import core.tools.TimeStamp
|
||||
import gui.ServerMonitor
|
||||
import kotlinx.coroutines.GlobalScope
|
||||
import kotlinx.coroutines.delay
|
||||
import kotlinx.coroutines.launch
|
||||
import rs09.game.content.global.GlobalKillCounter;
|
||||
import rs09.game.ge.GEAutoStock
|
||||
import core.game.world.map.zone.ZoneBuilder
|
||||
import core.net.IoEventHandler
|
||||
import core.net.IoSession
|
||||
import core.net.ServerSocketConnection
|
||||
import core.plugin.CorePluginTypes.StartupPlugin
|
||||
import rs09.game.node.entity.state.newsys.StateRepository
|
||||
import rs09.game.system.SystemLogger
|
||||
import rs09.game.system.config.ConfigParser
|
||||
import rs09.game.system.config.ServerConfigParser
|
||||
import rs09.game.world.GameWorld
|
||||
import rs09.game.world.ImmerseWorld
|
||||
import rs09.game.world.World
|
||||
import rs09.game.world.callback.CallbackHub
|
||||
import rs09.game.world.repository.Repository
|
||||
import rs09.game.world.repository.Repository.players
|
||||
import rs09.net.ms.ManagementServer
|
||||
import rs09.plugin.PluginManager
|
||||
import java.io.File
|
||||
import java.io.FileWriter
|
||||
import java.lang.management.ManagementFactory
|
||||
import java.lang.management.ThreadMXBean
|
||||
import java.net.BindException
|
||||
import java.util.*
|
||||
import java.io.IOException
|
||||
import java.net.InetSocketAddress
|
||||
import java.nio.channels.SelectionKey
|
||||
import java.nio.channels.Selector
|
||||
import java.nio.channels.ServerSocketChannel
|
||||
import java.util.concurrent.ExecutorService
|
||||
import java.util.concurrent.Executors
|
||||
import kotlin.system.exitProcess
|
||||
|
||||
|
||||
/**
|
||||
* The main class, for those that are unable to read the class' name.
|
||||
* @author Emperor
|
||||
* The primary processing backbone for the server.
|
||||
* @author Ceikry
|
||||
*/
|
||||
object Server {
|
||||
/**
|
||||
* The time stamp of when the server started running.
|
||||
* Various fields used for handling and processing incoming connections
|
||||
*/
|
||||
@JvmField
|
||||
var startTime: Long = 0
|
||||
|
||||
var lastHeartbeat = System.currentTimeMillis()
|
||||
|
||||
@JvmStatic
|
||||
var running = false
|
||||
private var service: ExecutorService? = null
|
||||
private var channel: ServerSocketConnection? = null
|
||||
private var eventHandler: IoEventHandler? = null
|
||||
|
||||
/**
|
||||
* The NIO reactor.
|
||||
* The current server state.
|
||||
* In BOOTING state, no networking is active. The only thing taking place is the parsing of cache and config data.
|
||||
* In RUNNING state, networking is active and primary gameplay loops are being ran.
|
||||
* In SHUTDOWN state, players are being processed and disconnected, and things are being cleaned up. Networking is disabled at this time.
|
||||
* Nothing occurs in CLOSED state because that indicates the server is DONE running, entirely, and should be shutdown at this time automatically.
|
||||
*/
|
||||
@JvmStatic
|
||||
var reactor: NioReactor? = null
|
||||
var state = ServerState.BOOTING
|
||||
@JvmStatic
|
||||
set(value) {
|
||||
field = value
|
||||
if(channel != null){
|
||||
channel!!.selector.wakeup() //Wakes up the selector and triggers the state update
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* The main method, in this method we load background utilities such as
|
||||
* cache and our world, then end with starting networking.
|
||||
* @param args The arguments cast on runtime.
|
||||
* @throws Throwable When an exception occurs.
|
||||
*/
|
||||
@Throws(Throwable::class)
|
||||
@JvmStatic
|
||||
fun main(args: Array<String>) {
|
||||
if (args.isNotEmpty()) {
|
||||
@@ -65,102 +68,108 @@ object Server {
|
||||
SystemLogger.logInfo("Using config file: ${"worldprops" + File.separator + "default.conf"}")
|
||||
ServerConfigParser.parse("worldprops" + File.separator + "default.conf")
|
||||
}
|
||||
startTime = System.currentTimeMillis()
|
||||
val t = TimeStamp()
|
||||
SystemLogger.logInfo("Initializing Server Store...")
|
||||
GlobalKillCounter.init()
|
||||
ServerStore.init()
|
||||
SystemLogger.logInfo("Initialized ${ServerStore.counter} store files.")
|
||||
GameWorld.prompt(true)
|
||||
SQLManager.init()
|
||||
Runtime.getRuntime().addShutdownHook(ServerConstants.SHUTDOWN_HOOK)
|
||||
SystemLogger.logInfo("Starting networking...")
|
||||
try {
|
||||
reactor = NioReactor.configure(43594 + GameWorld.settings?.worldId!!)
|
||||
reactor!!.start()
|
||||
} catch (e: BindException) {
|
||||
SystemLogger.logErr("Port " + (43594 + GameWorld.settings?.worldId!!) + " is already in use!")
|
||||
throw e
|
||||
}
|
||||
WorldCommunicator.connect()
|
||||
SystemLogger.logInfo(GameWorld.settings?.name + " flags " + GameWorld.settings?.toString())
|
||||
SystemLogger.logInfo(GameWorld.settings?.name + " started in " + t.duration(false, "") + " milliseconds.")
|
||||
|
||||
GEAutoStock.autostock()
|
||||
val scanner = Scanner(System.`in`)
|
||||
while (state != ServerState.CLOSED) {
|
||||
when (state) {
|
||||
|
||||
running = true
|
||||
GlobalScope.launch {
|
||||
while(scanner.hasNextLine()){
|
||||
val command = scanner.nextLine()
|
||||
when(command){
|
||||
"stop" -> exitProcess(0)
|
||||
"players" -> System.out.println("Players online: " + (Repository.LOGGED_IN_PLAYERS.size))
|
||||
"update" -> SystemManager.flag(SystemState.UPDATING)
|
||||
"help","commands" -> printCommands()
|
||||
"restartworker" -> SystemManager.flag(SystemState.ACTIVE)
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
GlobalScope.launch {
|
||||
delay(20000)
|
||||
while(running){
|
||||
if(System.currentTimeMillis() - lastHeartbeat > 7200 && running){
|
||||
SystemLogger.logErr("Triggering reboot due to heartbeat timeout")
|
||||
SystemLogger.logErr("Creating thread dump...")
|
||||
val dump = threadDump(true, true)
|
||||
FileWriter("latestdump.txt").use {
|
||||
it.write(dump)
|
||||
it.flush()
|
||||
it.close()
|
||||
ServerState.BOOTING -> {
|
||||
val start = System.nanoTime()
|
||||
Cache.init(ServerConstants.CACHE_PATH)
|
||||
ConfigParser().prePlugin()
|
||||
PluginManager.init()
|
||||
ConfigParser().postPlugin()
|
||||
ZoneBuilder.init()
|
||||
ServerStore.init()
|
||||
RareDropTable.init()
|
||||
if(World.settings!!.enable_bots) {
|
||||
ImmerseWorld.init()
|
||||
}
|
||||
exitProcess(0)
|
||||
CallbackHub.call()
|
||||
StateRepository.init()
|
||||
GrandExchangeDatabase.init()
|
||||
World.STARTUP_PLUGINS.forEach { plugin: StartupPlugin? ->
|
||||
plugin?.run()
|
||||
}
|
||||
System.gc() //Cleanup any abandoned references
|
||||
SystemLogger.initTradeLogger() //Start up the trade logger
|
||||
World.clock.start() //Start the world clock, which begins ticking the game
|
||||
Runtime.getRuntime().addShutdownHook(ServerConstants.SHUTDOWN_HOOK)
|
||||
SQLManager.init()
|
||||
state = ServerState.RUNNING
|
||||
val finish = System.nanoTime()
|
||||
|
||||
SystemLogger.logInfo("Server started in ${(finish - start) / 1000000} ms.")
|
||||
}
|
||||
delay(625)
|
||||
|
||||
ServerState.RUNNING -> {
|
||||
//Start up networking
|
||||
if(service == null || channel == null || eventHandler == null){
|
||||
service = Executors.newSingleThreadScheduledExecutor()
|
||||
eventHandler = IoEventHandler(Executors.newFixedThreadPool(1))
|
||||
|
||||
val socket = ServerSocketChannel.open()
|
||||
val selector = Selector.open()
|
||||
socket.bind(InetSocketAddress(World.settings!!.worldId + 43594))
|
||||
socket.configureBlocking(false)
|
||||
socket.register(selector, SelectionKey.OP_ACCEPT)
|
||||
channel = ServerSocketConnection(selector, socket)
|
||||
ManagementServer.connect()
|
||||
}
|
||||
|
||||
try {
|
||||
channel!!.selector.select() //wait for a connection to be ready
|
||||
} catch (e: IOException) {e.printStackTrace()}
|
||||
|
||||
val keyIterator = channel!!.selector.selectedKeys().iterator()
|
||||
|
||||
while(keyIterator.hasNext()){
|
||||
val key = keyIterator.next()
|
||||
keyIterator.remove()
|
||||
try {
|
||||
if (!key.isValid || !key.channel().isOpen) {
|
||||
key.cancel()
|
||||
continue
|
||||
}
|
||||
|
||||
if (key.isConnectable) eventHandler!!.connect(key)
|
||||
if (key.isAcceptable) eventHandler!!.accept(key, channel!!.selector)
|
||||
|
||||
if (key.isReadable) {
|
||||
eventHandler!!.read(key)
|
||||
} else if (key.isWritable) {
|
||||
eventHandler!!.write(key)
|
||||
}
|
||||
} catch (t: Throwable){
|
||||
val session = key.attachment() as? IoSession ?: continue
|
||||
session.disconnect()
|
||||
if(session.player != null){
|
||||
Repository.disconnectionQueue.add(session.player, true)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
ServerState.SHUTDOWN -> {
|
||||
if(players.any { !it.isArtificial }){
|
||||
for(player in players.filter { !it.isArtificial }){
|
||||
Repository.disconnectionQueue.add(player, true)
|
||||
}
|
||||
Repository.disconnectionQueue.update()
|
||||
} else {
|
||||
SystemLogger.flushLogs()
|
||||
ServerStore.save()
|
||||
ManagementServer.disconnect()
|
||||
SystemLogger.logInfo("Shutdown complete.")
|
||||
state = ServerState.CLOSED
|
||||
}
|
||||
}
|
||||
|
||||
else -> break
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
fun heartbeat() {
|
||||
lastHeartbeat = System.currentTimeMillis()
|
||||
}
|
||||
|
||||
fun printCommands(){
|
||||
println("stop - stop the server (saves all accounts and such)")
|
||||
println("players - show online player count")
|
||||
println("update - initiate an update with a countdown visible to players")
|
||||
println("help, commands - show this")
|
||||
println("restartworker - Reboots the major update worker in case of a travesty.")
|
||||
}
|
||||
|
||||
fun autoReconnect() {
|
||||
/*SystemLogger.log("Attempting autoreconnect of server")
|
||||
WorldCommunicator.connect()*/
|
||||
}
|
||||
/**
|
||||
* Gets the startTime.
|
||||
* @return the startTime
|
||||
*/
|
||||
fun getStartTime(): Long {
|
||||
return startTime
|
||||
}
|
||||
|
||||
private fun threadDump(lockedMonitors: Boolean, lockedSynchronizers: Boolean): String? {
|
||||
val threadDump = StringBuffer(System.lineSeparator())
|
||||
val threadMXBean: ThreadMXBean = ManagementFactory.getThreadMXBean()
|
||||
for (threadInfo in threadMXBean.dumpAllThreads(lockedMonitors, lockedSynchronizers)) {
|
||||
threadDump.append(threadInfo.toString())
|
||||
}
|
||||
return threadDump.toString()
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the bastartTime.ZZ
|
||||
* @param startTime the startTime to set.
|
||||
*/
|
||||
fun setStartTime(startTime: Long) {
|
||||
Server.startTime = startTime
|
||||
Runtime.getRuntime().removeShutdownHook(ServerConstants.SHUTDOWN_HOOK)
|
||||
exitProcess(0)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
package rs09
|
||||
|
||||
enum class ServerState {
|
||||
BOOTING,
|
||||
RUNNING,
|
||||
SHUTDOWN,
|
||||
CLOSED
|
||||
}
|
||||
@@ -2,7 +2,7 @@ package rs09.game.ai.general
|
||||
|
||||
import core.game.node.entity.player.Player
|
||||
import core.game.system.task.Pulse
|
||||
import rs09.game.world.GameWorld
|
||||
import rs09.game.world.World
|
||||
import core.game.world.map.Location
|
||||
import core.tools.RandomFunction
|
||||
import rs09.game.ai.AIPBuilder
|
||||
@@ -15,18 +15,18 @@ class GeneralBotCreator {
|
||||
//org/crandor/net/packet/in/InteractionPacket.java <<< This is a very useful class for learning to code bots
|
||||
constructor(loc: Location?, botScript: Script) {
|
||||
botScript.bot = AIPBuilder.create(loc)
|
||||
GameWorld.Pulser.submit(BotScriptPulse(botScript))
|
||||
World.Pulser.submit(BotScriptPulse(botScript))
|
||||
}
|
||||
|
||||
constructor(botScript: Script, bot: AIPlayer?) {
|
||||
botScript.bot = bot
|
||||
GameWorld.Pulser.submit(BotScriptPulse(botScript).also { AIRepository.PulseRepository.add(it) })
|
||||
World.Pulser.submit(BotScriptPulse(botScript).also { AIRepository.PulseRepository.add(it) })
|
||||
}
|
||||
|
||||
constructor(botScript: Script, player: Player, isPlayer: Boolean){
|
||||
botScript.bot = player
|
||||
val pulse = BotScriptPulse(botScript,isPlayer)
|
||||
GameWorld.Pulser.submit(pulse)
|
||||
World.Pulser.submit(pulse)
|
||||
player.setAttribute("/save:not_on_highscores",true)
|
||||
player.setAttribute("botting:script",pulse)
|
||||
}
|
||||
@@ -75,7 +75,7 @@ class GeneralBotCreator {
|
||||
|
||||
inner class TransitionPulse(val script: Script) : Pulse(RandomFunction.random(60,200)){
|
||||
override fun pulse(): Boolean {
|
||||
GameWorld.Pulser.submit(BotScriptPulse(script.newInstance()).also { AIRepository.PulseRepository.add(it) })
|
||||
World.Pulser.submit(BotScriptPulse(script.newInstance()).also { AIRepository.PulseRepository.add(it) })
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
||||
@@ -36,7 +36,7 @@ import rs09.game.interaction.InteractionListener
|
||||
import rs09.game.interaction.InteractionListeners
|
||||
import rs09.game.system.SystemLogger
|
||||
import rs09.game.system.config.ItemConfigParser
|
||||
import rs09.game.world.GameWorld
|
||||
import rs09.game.world.World
|
||||
import rs09.game.world.repository.Repository
|
||||
import rs09.tools.stringtools.colorize
|
||||
import java.util.*
|
||||
@@ -552,7 +552,7 @@ class ScriptAPI(private val bot: Player) {
|
||||
bot.visualize(ANIMATIONUP, GRAPHICSUP)
|
||||
bot.impactHandler.disabledTicks = 4
|
||||
val location = loc
|
||||
GameWorld.Pulser.submit(object : Pulse(4, bot) {
|
||||
World.Pulser.submit(object : Pulse(4, bot) {
|
||||
override fun pulse(): Boolean {
|
||||
bot.unlock()
|
||||
bot.properties.teleportLocation = location
|
||||
|
||||
@@ -4,11 +4,10 @@ import core.game.interaction.DestinationFlag
|
||||
import core.game.interaction.MovementPulse
|
||||
import core.game.node.scenery.Scenery
|
||||
import core.game.node.entity.combat.CombatStyle
|
||||
import rs09.game.node.entity.combat.CombatSwingHandler
|
||||
import core.game.node.entity.skill.Skills
|
||||
import core.game.node.item.Item
|
||||
import core.game.system.task.Pulse
|
||||
import rs09.game.world.GameWorld
|
||||
import rs09.game.world.World
|
||||
import core.game.world.map.Location
|
||||
import core.game.world.map.RegionManager
|
||||
import core.game.world.map.zone.ZoneBorders
|
||||
@@ -494,7 +493,7 @@ class Adventurer(val style: CombatStyle): Script() {
|
||||
if (ge != null && !bot.bank.isEmpty) {
|
||||
counter = 0
|
||||
scriptAPI.randomWalkTo(geloc, 3)
|
||||
GameWorld.Pulser.submit(GEPulse())
|
||||
World.Pulser.submit(GEPulse())
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
@@ -15,7 +15,7 @@ import rs09.game.ai.AIPlayer
|
||||
import rs09.game.ai.general.ScriptAPI
|
||||
import rs09.game.interaction.InteractionListener
|
||||
import rs09.game.interaction.InteractionListeners
|
||||
import rs09.game.world.GameWorld
|
||||
import rs09.game.world.World
|
||||
import kotlin.random.Random
|
||||
|
||||
@PlayerCompatible
|
||||
@@ -146,7 +146,7 @@ class LobsterCatcher : Script() {
|
||||
bot.visualize(ANIMATION, GRAPHICS)
|
||||
bot.impactHandler.disabledTicks = 4
|
||||
val location = Location.create(2819, 3437, 0)
|
||||
GameWorld.Pulser.submit(object : Pulse(4, bot) {
|
||||
World.Pulser.submit(object : Pulse(4, bot) {
|
||||
override fun pulse(): Boolean {
|
||||
bot.unlock()
|
||||
bot.properties.teleportLocation = location
|
||||
|
||||
@@ -11,9 +11,8 @@ import kotlinx.coroutines.GlobalScope
|
||||
import kotlinx.coroutines.launch
|
||||
import rs09.game.content.activity.pestcontrol.PestControlHelper.GATE_ENTRIES
|
||||
import rs09.game.content.activity.pestcontrol.PestControlHelper.getMyPestControlSession1
|
||||
import rs09.game.world.GameWorld
|
||||
import rs09.game.world.World
|
||||
import java.util.*
|
||||
import java.util.concurrent.Executors
|
||||
|
||||
|
||||
class CombatState(val bot: PestControlTestBot) {
|
||||
@@ -117,7 +116,7 @@ class CombatState(val bot: PestControlTestBot) {
|
||||
diffX /= 2
|
||||
diffY /= 2
|
||||
}
|
||||
GameWorld.Pulser.submit(object : MovementPulse(bot, bot.location.transform(diffX, diffY, 0), Pathfinder.SMART) {
|
||||
World.Pulser.submit(object : MovementPulse(bot, bot.location.transform(diffX, diffY, 0), Pathfinder.SMART) {
|
||||
override fun pulse(): Boolean {
|
||||
return true
|
||||
}
|
||||
|
||||
+2
-3
@@ -11,9 +11,8 @@ import kotlinx.coroutines.GlobalScope
|
||||
import kotlinx.coroutines.launch
|
||||
import rs09.game.content.activity.pestcontrol.PestControlHelper.GATE_ENTRIES
|
||||
import rs09.game.content.activity.pestcontrol.PestControlHelper.getMyPestControlSession2
|
||||
import rs09.game.world.GameWorld
|
||||
import rs09.game.world.World
|
||||
import java.util.*
|
||||
import java.util.concurrent.Executors
|
||||
|
||||
class CombatStateIntermediate(val bot: PestControlTestBot2) {
|
||||
private val Random = Random()
|
||||
@@ -117,7 +116,7 @@ class CombatStateIntermediate(val bot: PestControlTestBot2) {
|
||||
diffX /= 2
|
||||
diffY /= 2
|
||||
}
|
||||
GameWorld.Pulser.submit(object : MovementPulse(bot, bot.location.transform(diffX, diffY, 0), Pathfinder.SMART) {
|
||||
World.Pulser.submit(object : MovementPulse(bot, bot.location.transform(diffX, diffY, 0), Pathfinder.SMART) {
|
||||
override fun pulse(): Boolean {
|
||||
return true
|
||||
}
|
||||
|
||||
@@ -5,7 +5,7 @@ import core.game.node.entity.combat.CombatSpell
|
||||
import core.game.node.entity.player.link.SpellBookManager
|
||||
import core.game.node.entity.player.link.appearance.Gender
|
||||
import core.game.node.item.Item
|
||||
import rs09.game.world.GameWorld
|
||||
import rs09.game.world.World
|
||||
import core.game.world.map.Location
|
||||
import core.tools.RandomFunction
|
||||
import rs09.game.ai.AIPlayer
|
||||
@@ -496,7 +496,7 @@ class PvMBotsBuilder {
|
||||
spawnDragonKiller(new Location(3417, 3561, 1));
|
||||
//Brimhaven dragons
|
||||
spawnDragonKiller(new Location(2704, 9450));
|
||||
spawnDragonKiller(new Location(2704, 9450));*/println("[" + GameWorld.settings?.name + "]: PvMBotsBuilder: Spawned " + botsSpawned + " bots.")
|
||||
spawnDragonKiller(new Location(2704, 9450));*/println("[" + World.settings?.name + "]: PvMBotsBuilder: Spawned " + botsSpawned + " bots.")
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -9,7 +9,7 @@ import core.game.system.task.Pulse
|
||||
import core.game.world.update.flag.context.Animation
|
||||
import org.rs09.consts.Items
|
||||
import rs09.game.interaction.InteractionListener
|
||||
import rs09.game.world.GameWorld
|
||||
import rs09.game.world.World
|
||||
|
||||
private val VALID_LOGS = intArrayOf(Items.LOGS_1511, Items.OAK_LOGS_1521,Items.WILLOW_LOGS_1519,Items.MAPLE_LOGS_1517,Items.YEW_LOGS_1515,Items.MAGIC_LOGS_1513)
|
||||
private val FILL_ANIM = Animation(9136)
|
||||
@@ -94,7 +94,7 @@ class AFUBeaconListeners : InteractionListener(){
|
||||
}
|
||||
}
|
||||
|
||||
GameWorld.Pulser.submit(object : Pulse() {
|
||||
World.Pulser.submit(object : Pulse() {
|
||||
var counter = 0
|
||||
override fun pulse(): Boolean {
|
||||
when (counter++) {
|
||||
@@ -125,7 +125,7 @@ class AFUBeaconListeners : InteractionListener(){
|
||||
|
||||
if(player.inventory.contains(Items.TINDERBOX_590,1)){
|
||||
player.lock()
|
||||
GameWorld.Pulser.submit(object: Pulse(){
|
||||
World.Pulser.submit(object: Pulse(){
|
||||
var counter = 0
|
||||
override fun pulse(): Boolean {
|
||||
when(counter++){
|
||||
@@ -173,7 +173,7 @@ class AFUBeaconListeners : InteractionListener(){
|
||||
val logs = getLogs(player, 5)
|
||||
if (logs.id != 0 && player.inventory.remove(logs)) {
|
||||
player.lock()
|
||||
GameWorld.Pulser.submit(object: Pulse(){
|
||||
World.Pulser.submit(object: Pulse(){
|
||||
var counter = 0
|
||||
override fun pulse(): Boolean {
|
||||
when(counter++){
|
||||
|
||||
@@ -3,7 +3,7 @@ package rs09.game.content.activity.allfiredup
|
||||
import core.game.node.entity.player.Player
|
||||
import core.game.node.item.Item
|
||||
import core.game.system.task.Pulse
|
||||
import rs09.game.world.GameWorld
|
||||
import rs09.game.world.World
|
||||
import core.plugin.Plugin
|
||||
import org.rs09.consts.Items
|
||||
import rs09.tools.stringtools.colorize
|
||||
@@ -20,7 +20,7 @@ class AFUSession(val player: Player) {
|
||||
|
||||
fun init() {
|
||||
isActive = true
|
||||
GameWorld.Pulser.submit(object: Pulse(){
|
||||
World.Pulser.submit(object: Pulse(){
|
||||
override fun pulse(): Boolean {
|
||||
player.setAttribute("afu-pulse",this)
|
||||
beaconTimers.forEach {timer ->
|
||||
|
||||
+9
-9
@@ -2,7 +2,7 @@ package rs09.game.content.activity.fishingtrawler
|
||||
|
||||
import core.game.node.entity.player.Player
|
||||
import core.game.system.task.Pulse
|
||||
import rs09.game.world.GameWorld
|
||||
import rs09.game.world.World
|
||||
import core.game.world.map.Location
|
||||
import core.game.world.map.build.DynamicRegion
|
||||
import core.game.world.map.zone.ZoneRestriction
|
||||
@@ -17,11 +17,11 @@ import rs09.tools.stringtools.colorize
|
||||
* Handles the fishing trawler "waiting room"
|
||||
* @author Ceikry
|
||||
*/
|
||||
private val WAIT_TIME = if(GameWorld.settings?.isDevMode == true) 10 else 203
|
||||
private val WAIT_TIME = if(World.settings?.isDevMode == true) 10 else 203
|
||||
private val waitingPlayers = ArrayList<Player>()
|
||||
private val sessions = ArrayList<FishingTrawlerSession>()
|
||||
private var activity: FishingTrawlerActivity? = null
|
||||
private var nextStart = GameWorld.ticks + WAIT_TIME
|
||||
private var nextStart = World.ticks + WAIT_TIME
|
||||
@Initializable
|
||||
class FishingTrawlerActivity : ActivityPlugin("fishing trawler",false,false,true,ZoneRestriction.CANNON,ZoneRestriction.FIRES,ZoneRestriction.FOLLOWERS,ZoneRestriction.RANDOM_EVENTS) {
|
||||
|
||||
@@ -29,20 +29,20 @@ class FishingTrawlerActivity : ActivityPlugin("fishing trawler",false,false,true
|
||||
activity = this
|
||||
}
|
||||
override fun configure() {
|
||||
GameWorld.Pulser.submit(
|
||||
World.Pulser.submit(
|
||||
object : Pulse(1){
|
||||
override fun pulse(): Boolean {
|
||||
if((nextStart - GameWorld.ticks) % 100 == 0){
|
||||
if((nextStart - World.ticks) % 100 == 0){
|
||||
for(player in waitingPlayers) {
|
||||
player.sendMessage (colorize("%R${ticksToSeconds(nextStart - GameWorld.ticks) / 60} minutes until next game."))
|
||||
player.sendMessage (colorize("%R${ticksToSeconds(nextStart - World.ticks) / 60} minutes until next game."))
|
||||
}
|
||||
}
|
||||
if(GameWorld.ticks >= nextStart && waitingPlayers.isNotEmpty()){
|
||||
if(World.ticks >= nextStart && waitingPlayers.isNotEmpty()){
|
||||
val session = FishingTrawlerSession(DynamicRegion.create(8011), activity!!)
|
||||
session.start(waitingPlayers)
|
||||
sessions.add(session)
|
||||
waitingPlayers.clear()
|
||||
nextStart = GameWorld.ticks + WAIT_TIME
|
||||
nextStart = World.ticks + WAIT_TIME
|
||||
}
|
||||
sessions.removeIf { session ->
|
||||
if(!session.isActive && session.inactiveTicks >= 100){
|
||||
@@ -68,7 +68,7 @@ class FishingTrawlerActivity : ActivityPlugin("fishing trawler",false,false,true
|
||||
|
||||
fun addPlayer(player: Player){
|
||||
if(waitingPlayers.isEmpty()) {
|
||||
nextStart = GameWorld.ticks + WAIT_TIME
|
||||
nextStart = World.ticks + WAIT_TIME
|
||||
player.dialogueInterpreter.sendDialogue("Trawler will leave in 2 minutes.","If you have a team get them on board now!")
|
||||
}
|
||||
waitingPlayers.add(player)
|
||||
|
||||
+3
-3
@@ -8,7 +8,7 @@ import core.game.node.entity.player.Player
|
||||
import core.game.node.entity.state.EntityState
|
||||
import core.game.node.item.Item
|
||||
import core.game.system.task.Pulse
|
||||
import rs09.game.world.GameWorld
|
||||
import rs09.game.world.World
|
||||
import core.game.world.map.Location
|
||||
import core.game.world.map.build.DynamicRegion
|
||||
import core.game.world.update.flag.context.Animation
|
||||
@@ -64,7 +64,7 @@ class FishingTrawlerSession(var region: DynamicRegion, val activity: FishingTraw
|
||||
initHoles()
|
||||
initMurphy(29,25)
|
||||
initGulls()
|
||||
GameWorld.Pulser.submit(TrawlerPulse(this))
|
||||
World.Pulser.submit(TrawlerPulse(this))
|
||||
for(player in pl){
|
||||
player.interfaceManager.openOverlay(Component(OVERLAY_ID))
|
||||
player.interfaceManager.open(Component(TUTORIAL_ID))
|
||||
@@ -78,7 +78,7 @@ class FishingTrawlerSession(var region: DynamicRegion, val activity: FishingTraw
|
||||
|
||||
fun swapBoatType(fromRegion: Int){
|
||||
val newRegion = DynamicRegion.create(fromRegion)
|
||||
GameWorld.Pulser.submit(SwapBoatPulse(players,newRegion))
|
||||
World.Pulser.submit(SwapBoatPulse(players,newRegion))
|
||||
}
|
||||
|
||||
class SwapBoatPulse(val playerList: ArrayList<Player>,val newRegion: DynamicRegion) : Pulse(3){
|
||||
|
||||
@@ -3,16 +3,15 @@ package rs09.game.content.activity.fog
|
||||
import core.game.component.Component
|
||||
import core.game.node.entity.player.Player
|
||||
import core.game.node.item.Item
|
||||
import rs09.game.world.GameWorld
|
||||
import rs09.game.world.World
|
||||
import core.plugin.Initializable
|
||||
import core.game.content.dialogue.DialoguePlugin
|
||||
import org.rs09.consts.Components
|
||||
import rs09.game.interaction.FOGRewardsInterface
|
||||
|
||||
@Initializable
|
||||
class ReggieDialogue(player: Player? = null) : DialoguePlugin(player){
|
||||
override fun open(vararg args: Any?): Boolean {
|
||||
if(GameWorld.settings?.allow_token_purchase == true){
|
||||
if(World.settings?.allow_token_purchase == true){
|
||||
options("Can I see your shop?","Nevermind.","Can I buy some tokens?")
|
||||
} else {
|
||||
options("Can I see your shop?","Nevermind.")
|
||||
|
||||
+2
-2
@@ -11,7 +11,7 @@ import core.plugin.Initializable
|
||||
import core.plugin.Plugin
|
||||
import core.tools.RandomFunction
|
||||
import org.rs09.consts.Items
|
||||
import rs09.game.world.GameWorld
|
||||
import rs09.game.world.World
|
||||
|
||||
val gnomeItems = arrayOf(
|
||||
Items.FRUIT_BATTA_2277, Items.TOAD_BATTA_2255, Items.CHEESE_PLUSTOM_BATTA_2259, Items.WORM_BATTA_2253, Items.VEGETABLE_BATTA_2281,
|
||||
@@ -87,7 +87,7 @@ class GCRewardTokenHandler : OptionHandler() {
|
||||
}
|
||||
|
||||
player.dialogueInterpreter.sendDialogue("You put in for delivery of $amount items. Wait a bit...")
|
||||
GameWorld.Pulser.submit(DeliveryPulse(player,itemList))
|
||||
World.Pulser.submit(DeliveryPulse(player,itemList))
|
||||
player.setAttribute("/save:$GC_BASE_ATTRIBUTE:$GC_REDEEMABLE_FOOD", playerCharges - amount)
|
||||
}
|
||||
|
||||
|
||||
+2
-2
@@ -10,7 +10,7 @@ import core.game.world.update.flag.context.Animation
|
||||
import core.plugin.Initializable
|
||||
import core.plugin.Plugin
|
||||
import org.rs09.consts.Items
|
||||
import rs09.game.world.GameWorld
|
||||
import rs09.game.world.World
|
||||
|
||||
/**
|
||||
* Handles cook options for battas
|
||||
@@ -43,7 +43,7 @@ class GnomeBattaCooker : UseWithHandler(Items.RAW_BATTA_2250,9478,9480,9482,9483
|
||||
}
|
||||
|
||||
fun cook(player: Player, raw: Item, product: Item){
|
||||
GameWorld.Pulser.submit(object : Pulse(){
|
||||
World.Pulser.submit(object : Pulse(){
|
||||
var counter = 0
|
||||
override fun pulse(): Boolean {
|
||||
when(counter++){
|
||||
|
||||
+2
-2
@@ -10,7 +10,7 @@ import core.game.world.update.flag.context.Animation
|
||||
import core.plugin.Initializable
|
||||
import core.plugin.Plugin
|
||||
import org.rs09.consts.Items
|
||||
import rs09.game.world.GameWorld
|
||||
import rs09.game.world.World
|
||||
|
||||
@Initializable
|
||||
class GnomeBowlCooker : UseWithHandler(Items.RAW_GNOMEBOWL_2178,9558,9559,9561,9563) {
|
||||
@@ -38,7 +38,7 @@ class GnomeBowlCooker : UseWithHandler(Items.RAW_GNOMEBOWL_2178,9558,9559,9561,9
|
||||
}
|
||||
|
||||
fun cook(player: Player, raw: Item, product: Item){
|
||||
GameWorld.Pulser.submit(object : Pulse(){
|
||||
World.Pulser.submit(object : Pulse(){
|
||||
var counter = 0
|
||||
override fun pulse(): Boolean {
|
||||
when(counter++){
|
||||
|
||||
+2
-2
@@ -5,7 +5,7 @@ import core.game.interaction.UseWithHandler
|
||||
import core.game.node.entity.player.Player
|
||||
import core.game.node.item.Item
|
||||
import core.game.system.task.Pulse
|
||||
import rs09.game.world.GameWorld
|
||||
import rs09.game.world.World
|
||||
import core.game.world.update.flag.context.Animation
|
||||
import core.plugin.Initializable
|
||||
import core.plugin.Plugin
|
||||
@@ -34,7 +34,7 @@ class CocktailCooker : UseWithHandler(UNCOOKED_CHOC_SAT, UNCOOKED_DRUN_DRA) {
|
||||
}
|
||||
|
||||
private fun cook(drink: CookedDrinks, player: Player, raw: Item){
|
||||
GameWorld.Pulser.submit(object : Pulse(){
|
||||
World.Pulser.submit(object : Pulse(){
|
||||
var counter = 0
|
||||
override fun pulse(): Boolean {
|
||||
when(counter++){
|
||||
|
||||
+2
-2
@@ -5,7 +5,7 @@ import core.game.interaction.UseWithHandler
|
||||
import core.game.node.entity.player.Player
|
||||
import core.game.node.item.Item
|
||||
import core.game.system.task.Pulse
|
||||
import rs09.game.world.GameWorld
|
||||
import rs09.game.world.World
|
||||
import core.game.world.update.flag.context.Animation
|
||||
import core.plugin.Initializable
|
||||
import core.plugin.Plugin
|
||||
@@ -46,7 +46,7 @@ class GnomeCrunchyCooker : UseWithHandler(9577,9579,9581,9583, 2202){
|
||||
}
|
||||
|
||||
private fun cook(product: Int, raw: Item, player: Player){
|
||||
GameWorld.Pulser.submit(object : Pulse(){
|
||||
World.Pulser.submit(object : Pulse(){
|
||||
var counter = 0
|
||||
override fun pulse(): Boolean {
|
||||
when(counter++){
|
||||
|
||||
@@ -6,7 +6,7 @@ import core.game.system.task.Pulse
|
||||
import core.game.world.map.Location
|
||||
import core.tools.RandomFunction
|
||||
import org.rs09.consts.Components
|
||||
import rs09.game.world.GameWorld
|
||||
import rs09.game.world.World
|
||||
|
||||
class PlunderSession(val player: Player) {
|
||||
var door1Open: Boolean = false
|
||||
@@ -24,7 +24,7 @@ class PlunderSession(val player: Player) {
|
||||
|
||||
fun init(){
|
||||
player.setAttribute("plunder-session",this)
|
||||
GameWorld.Pulser.submit(PlunderPulse(player))
|
||||
World.Pulser.submit(PlunderPulse(player))
|
||||
player.interfaceManager.openOverlay(Component(Components.NTK_OVERLAY_428))
|
||||
isActive = true
|
||||
}
|
||||
|
||||
@@ -21,10 +21,9 @@ import core.game.world.update.flag.context.Graphics;
|
||||
import core.plugin.Initializable
|
||||
import core.tools.RandomFunction
|
||||
import org.rs09.consts.Items
|
||||
import rs09.game.content.dialogue.DialogueFile
|
||||
import rs09.game.interaction.InteractionListener
|
||||
import rs09.game.interaction.InterfaceListener
|
||||
import rs09.game.world.GameWorld;
|
||||
import rs09.game.world.World;
|
||||
|
||||
val AVACH_NIMPORTO_LOC = Location.create(1637, 4709)
|
||||
val PORTAL = 29534
|
||||
@@ -109,7 +108,7 @@ object VinesweeperTeleport {
|
||||
player.audioManager.send(125)
|
||||
Projectile.create(npc, player, 109).send()
|
||||
npc.sendChat("Avach nimporto!")
|
||||
GameWorld.Pulser.submit(object : Pulse(1) {
|
||||
World.Pulser.submit(object : Pulse(1) {
|
||||
var counter = 0
|
||||
override fun pulse(): Boolean {
|
||||
when (counter++) {
|
||||
@@ -207,7 +206,7 @@ class VinesweeperListener : InteractionListener() {
|
||||
on(HOLES, SCENERY, "inspect") { player, node ->
|
||||
player.animate(Animation(8710))
|
||||
player.lock(5)
|
||||
GameWorld.Pulser.submit(object : Pulse(5) {
|
||||
World.Pulser.submit(object : Pulse(5) {
|
||||
override fun pulse(): Boolean {
|
||||
val msg = when(RandomFunction.random(0, 7)) {
|
||||
0 -> "You don't see anything interesting. You can't be sure if there's a seed there or not."
|
||||
@@ -248,10 +247,10 @@ class VinesweeperListener : InteractionListener() {
|
||||
npc.sendChat("Squeak!")
|
||||
npc.lock(3)
|
||||
player.skills.addExperience(Skills.HUNTER, 30.0)
|
||||
GameWorld.Pulser.submit(object : Pulse(3) {
|
||||
World.Pulser.submit(object : Pulse(3) {
|
||||
override fun pulse(): Boolean {
|
||||
//npc.setInvisible(true)
|
||||
npc.respawnTick = GameWorld.ticks + 50
|
||||
npc.respawnTick = World.ticks + 50
|
||||
npc.location = npc.properties.spawnLocation
|
||||
return true
|
||||
}
|
||||
@@ -325,7 +324,7 @@ class VinesweeperNPC : AbstractNPC {
|
||||
} else {
|
||||
sendChat("Hmm. Looks like there's a plant here.")
|
||||
lock(3)
|
||||
GameWorld.Pulser.submit(object : Pulse(3) {
|
||||
World.Pulser.submit(object : Pulse(3) {
|
||||
override fun pulse(): Boolean {
|
||||
sendChat("Gracious me! This one's dead")
|
||||
SceneryBuilder.replace(scenery, scenery.transform(HOLES[0]))
|
||||
@@ -356,7 +355,7 @@ class VinesweeperNPC : AbstractNPC {
|
||||
animate(Animation(451))
|
||||
if(SEED_LOCS.contains(dest.loc)) {
|
||||
val npc = this
|
||||
GameWorld.Pulser.submit(object : Pulse(3) {
|
||||
World.Pulser.submit(object : Pulse(3) {
|
||||
override fun pulse(): Boolean {
|
||||
sendChat("Ah! A seed. Points for everyone near me!")
|
||||
val level = dest.player.skills.getStaticLevel(Skills.FARMING)
|
||||
@@ -379,7 +378,7 @@ class VinesweeperNPC : AbstractNPC {
|
||||
SceneryBuilder.replace(scenery, scenery.transform(HOLES[0]))
|
||||
var i = 0
|
||||
val lines = arrayOf("Hmm, no seeds planted here, I'm afraid.", "I'll have to keep this 'ere flag. Sorry.")
|
||||
GameWorld.Pulser.submit(object : Pulse(3) {
|
||||
World.Pulser.submit(object : Pulse(3) {
|
||||
override fun pulse(): Boolean {
|
||||
sendChat(lines[i++])
|
||||
return i >= lines.size
|
||||
|
||||
@@ -3,7 +3,7 @@ package rs09.game.content.ame
|
||||
import core.game.node.entity.player.Player
|
||||
import core.game.world.map.zone.ZoneRestriction
|
||||
import rs09.game.system.SystemLogger
|
||||
import rs09.game.world.GameWorld
|
||||
import rs09.game.world.World
|
||||
|
||||
private const val DELAY_TICKS = 6000 //60 minutes
|
||||
class RandomEventManager(val player: Player) {
|
||||
@@ -12,28 +12,28 @@ class RandomEventManager(val player: Player) {
|
||||
|
||||
fun tick(){
|
||||
if(player.isArtificial) return
|
||||
if(GameWorld.ticks > nextSpawn) fireEvent()
|
||||
if(World.ticks > nextSpawn) fireEvent()
|
||||
}
|
||||
|
||||
fun fireEvent(){
|
||||
if(player.zoneMonitor.isRestricted(ZoneRestriction.RANDOM_EVENTS)){
|
||||
nextSpawn = GameWorld.ticks + 3000
|
||||
nextSpawn = World.ticks + 3000
|
||||
return
|
||||
}
|
||||
val ame = RandomEvents.values().random()
|
||||
event = ame.npc.create(player,ame.loot,ame.type)
|
||||
if(event!!.spawnLocation == null){
|
||||
nextSpawn = GameWorld.ticks + 3000
|
||||
nextSpawn = World.ticks + 3000
|
||||
return
|
||||
}
|
||||
event!!.init()
|
||||
nextSpawn = GameWorld.ticks + DELAY_TICKS
|
||||
nextSpawn = World.ticks + DELAY_TICKS
|
||||
SystemLogger.logRE("Fired ${event!!.name} for ${player.username}")
|
||||
}
|
||||
|
||||
fun init(){
|
||||
if(player.isArtificial) return
|
||||
nextSpawn = GameWorld.ticks + DELAY_TICKS
|
||||
nextSpawn = World.ticks + DELAY_TICKS
|
||||
SystemLogger.logRE("Initialized REManager for ${player.username}")
|
||||
}
|
||||
}
|
||||
@@ -5,14 +5,12 @@ import core.game.interaction.MovementPulse
|
||||
import core.game.node.entity.npc.NPC
|
||||
import core.game.node.entity.player.Player
|
||||
import core.game.node.item.Item
|
||||
import core.game.system.task.Pulse
|
||||
import core.game.world.map.Location
|
||||
import core.game.world.map.RegionManager
|
||||
import core.game.world.map.path.Pathfinder
|
||||
import core.game.world.update.flag.context.Graphics
|
||||
import rs09.game.content.ame.events.MysteriousOldManNPC
|
||||
import rs09.game.content.global.WeightBasedTable
|
||||
import rs09.game.world.GameWorld.Pulser
|
||||
import rs09.tools.secondsToTicks
|
||||
import kotlin.random.Random
|
||||
import kotlin.reflect.full.createInstance
|
||||
|
||||
@@ -12,7 +12,7 @@ import kotlinx.coroutines.GlobalScope
|
||||
import kotlinx.coroutines.launch
|
||||
import org.rs09.consts.Items
|
||||
import rs09.game.content.activity.gnomecooking.*
|
||||
import rs09.game.world.GameWorld
|
||||
import rs09.game.world.World
|
||||
import rs09.tools.stringtools.colorize
|
||||
import java.util.concurrent.TimeUnit
|
||||
|
||||
@@ -161,7 +161,7 @@ class AluftGianneSnrDialogue(player: Player? = null) : DialoguePlugin(player) {
|
||||
player.setAttribute("$GC_BASE_ATTRIBUTE:$GC_JOB_ORDINAL", job.ordinal)
|
||||
player.setAttribute("$GC_BASE_ATTRIBUTE:$GC_NEEDED_ITEM", item)
|
||||
player.dialogueInterpreter.sendDialogue("I need to deliver a ${item.name.toLowerCase()} to ${NPC(job.npc_id).name.toLowerCase()},", "who is ${job.tip}")
|
||||
GameWorld.Pulser.submit(GnomeRestaurantPulse(player, if (level == GnomeTipper.LEVEL.HARD) 11L else 6L))
|
||||
World.Pulser.submit(GnomeRestaurantPulse(player, if (level == GnomeTipper.LEVEL.HARD) 11L else 6L))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,14 +7,12 @@ import core.game.node.entity.player.Player
|
||||
import core.game.node.entity.player.link.audio.Audio
|
||||
import core.game.node.entity.player.link.diary.DiaryType
|
||||
import core.game.node.entity.skill.slayer.SlayerEquipmentFlags
|
||||
import core.game.system.task.Pulse
|
||||
import core.game.world.map.zone.ZoneBorders
|
||||
import core.plugin.Plugin
|
||||
import org.rs09.consts.Items
|
||||
import rs09.game.interaction.InteractionListener
|
||||
import rs09.game.interaction.InteractionListeners
|
||||
import rs09.game.system.config.ItemConfigParser
|
||||
import rs09.game.world.GameWorld
|
||||
|
||||
/**
|
||||
* Represents the equipment equipping handler plugin.
|
||||
|
||||
@@ -15,7 +15,7 @@ import org.rs09.consts.Items
|
||||
import rs09.game.ai.AIRepository.Companion.getItems
|
||||
import rs09.game.system.SystemLogger
|
||||
import rs09.game.system.config.GroundSpawnLoader
|
||||
import rs09.game.world.GameWorld
|
||||
import rs09.game.world.World
|
||||
|
||||
/**
|
||||
* A class used to handle the picking up of ground items.
|
||||
@@ -38,7 +38,7 @@ object PickupHandler {
|
||||
player.packetDispatch.sendMessage("Too late!")
|
||||
return true
|
||||
}
|
||||
if (player.getAttribute("droppedItem:" + item.id, 0) > GameWorld.ticks) { //Splinter
|
||||
if (player.getAttribute("droppedItem:" + item.id, 0) > World.ticks) { //Splinter
|
||||
SystemLogger.logAlert("$player tried to do the drop & quick pick-up Ground Item dupe.")
|
||||
return true
|
||||
}
|
||||
|
||||
@@ -6,7 +6,7 @@ import core.game.node.entity.player.Player
|
||||
import core.game.node.entity.player.link.diary.DiaryType
|
||||
import core.game.node.item.Item
|
||||
import core.game.system.task.Pulse
|
||||
import rs09.game.world.GameWorld
|
||||
import rs09.game.world.World
|
||||
import core.game.world.map.Location
|
||||
import core.game.world.update.flag.context.Animation
|
||||
import core.game.world.update.flag.context.Graphics
|
||||
@@ -41,7 +41,7 @@ object EssenceTeleport {
|
||||
player.audioManager.send(125)
|
||||
Projectile.create(npc, player, 109).send()
|
||||
npc.sendChat("Senventior Disthinte Molesko!")
|
||||
GameWorld.Pulser.submit(object : Pulse(1) {
|
||||
World.Pulser.submit(object : Pulse(1) {
|
||||
var counter = 0
|
||||
override fun pulse(): Boolean {
|
||||
when (counter++) {
|
||||
|
||||
+5
-5
@@ -11,7 +11,7 @@ import org.rs09.consts.Items
|
||||
import org.rs09.consts.NPCs
|
||||
import rs09.game.content.global.worldevents.WorldEvent
|
||||
import rs09.game.system.config.GroundSpawnLoader
|
||||
import rs09.game.world.GameWorld
|
||||
import rs09.game.world.World
|
||||
import rs09.game.world.repository.Repository
|
||||
import rs09.tools.secondsToTicks
|
||||
import java.util.*
|
||||
@@ -77,12 +77,12 @@ class EasterEvent : WorldEvent("easter") {
|
||||
bunny.init()
|
||||
}
|
||||
easterBunny.init()
|
||||
GameWorld.settings?.message_model = 715
|
||||
GameWorld.settings?.message_string = "Happy Easter!"
|
||||
GameWorld.Pulser.submit(object : Pulse(){
|
||||
World.settings?.message_model = 715
|
||||
World.settings?.message_string = "Happy Easter!"
|
||||
World.Pulser.submit(object : Pulse(){
|
||||
override fun pulse(): Boolean {
|
||||
if(delay == 1){
|
||||
delay = secondsToTicks(if(GameWorld.settings?.isDevMode == true) 60 else 3600)
|
||||
delay = secondsToTicks(if(World.settings?.isDevMode == true) 60 else 3600)
|
||||
}
|
||||
for(item in spawnedItems){
|
||||
GroundItemManager.destroy(item)
|
||||
|
||||
+3
-6
@@ -1,11 +1,8 @@
|
||||
package rs09.game.content.global.worldevents.holiday.halloween
|
||||
|
||||
import core.game.node.entity.npc.NPC
|
||||
import core.game.world.map.Location
|
||||
import rs09.game.content.global.worldevents.PluginSet
|
||||
import rs09.game.content.global.worldevents.WorldEvent
|
||||
import rs09.game.world.GameWorld
|
||||
import java.util.*
|
||||
import rs09.game.world.World
|
||||
|
||||
class SimpleHalloweenEvent : WorldEvent("hween"){
|
||||
override fun checkActive(): Boolean {
|
||||
@@ -17,8 +14,8 @@ class SimpleHalloweenEvent : WorldEvent("hween"){
|
||||
GrimDialogue()
|
||||
)
|
||||
super.initialize()
|
||||
GameWorld.settings?.message_model = 800
|
||||
GameWorld.settings?.message_string = "A mysterious figure has appeared in Draynor! You should go investigate!"
|
||||
World.settings?.message_model = 800
|
||||
World.settings?.message_string = "A mysterious figure has appeared in Draynor! You should go investigate!"
|
||||
log("Initialized.")
|
||||
}
|
||||
}
|
||||
+2
-2
@@ -16,7 +16,7 @@ import rs09.ServerStore.getInt
|
||||
import rs09.ServerStore.getString
|
||||
import rs09.game.content.dialogue.DialogueFile
|
||||
import rs09.game.interaction.InteractionListener
|
||||
import rs09.game.world.GameWorld
|
||||
import rs09.game.world.World
|
||||
import rs09.tools.END_DIALOGUE
|
||||
|
||||
class TrickOrTreatHandler : InteractionListener() {
|
||||
@@ -48,7 +48,7 @@ class TrickOrTreatHandler : InteractionListener() {
|
||||
stage = END_DIALOGUE
|
||||
}
|
||||
|
||||
10 -> npcl(FacialExpression.EVIL_LAUGH, "I CHOOSE TRICK!").also { player.lock(); GameWorld.submit(object : Pulse() {
|
||||
10 -> npcl(FacialExpression.EVIL_LAUGH, "I CHOOSE TRICK!").also { player.lock(); World.submit(object : Pulse() {
|
||||
var counter = 0
|
||||
override fun pulse(): Boolean {
|
||||
//gfx 1898
|
||||
|
||||
@@ -7,7 +7,6 @@ import core.game.content.dialogue.FacialExpression
|
||||
import core.game.node.entity.player.Player
|
||||
import core.game.node.item.Item
|
||||
import core.game.system.task.Pulse
|
||||
import rs09.game.world.GameWorld
|
||||
import rs09.tools.END_DIALOGUE
|
||||
|
||||
class LarryHandler(player: Player? = null) : DialoguePlugin(player){
|
||||
|
||||
+3
-5
@@ -1,17 +1,15 @@
|
||||
package rs09.game.content.global.worldevents.penguinhns
|
||||
|
||||
import core.game.system.task.Pulse
|
||||
import org.json.simple.JSONObject
|
||||
import rs09.ServerStore
|
||||
import rs09.game.content.global.worldevents.PluginSet
|
||||
import rs09.game.content.global.worldevents.WorldEvent
|
||||
import rs09.game.content.global.worldevents.WorldEvents
|
||||
import rs09.game.world.GameWorld
|
||||
import rs09.game.world.World
|
||||
|
||||
class PenguinHNSEvent : WorldEvent("penguin-hns"){
|
||||
val manager = PenguinManager()
|
||||
var lastTrigger: Int = 0
|
||||
var tickDelay = if(GameWorld.settings?.isDevMode == true) 100 else 100000
|
||||
var tickDelay = if(World.settings?.isDevMode == true) 100 else 100000
|
||||
|
||||
override fun checkActive(): Boolean {
|
||||
return true //this event is always active.
|
||||
@@ -34,7 +32,7 @@ class PenguinHNSEvent : WorldEvent("penguin-hns"){
|
||||
override fun fireEvent() {
|
||||
log("Loading penguins...")
|
||||
manager.rebuildVars()
|
||||
lastTrigger = GameWorld.ticks
|
||||
lastTrigger = World.ticks
|
||||
log("Penguins loaded.")
|
||||
}
|
||||
|
||||
|
||||
+2
-8
@@ -1,16 +1,10 @@
|
||||
package rs09.game.content.global.worldevents.penguinhns
|
||||
|
||||
import core.game.interaction.DestinationFlag
|
||||
import core.game.interaction.MovementPulse
|
||||
import core.game.interaction.Option
|
||||
import core.game.node.entity.npc.NPC
|
||||
import core.game.node.entity.player.Player
|
||||
import core.game.system.task.Pulse
|
||||
import rs09.game.world.GameWorld
|
||||
import rs09.game.world.World
|
||||
import core.game.world.update.flag.context.Animation
|
||||
import core.plugin.Plugin
|
||||
import core.game.content.quest.PluginInteraction
|
||||
import core.game.content.quest.PluginInteractionManager
|
||||
import rs09.game.interaction.InteractionListener
|
||||
|
||||
class PenguinSpyingHandler : InteractionListener(){
|
||||
@@ -21,7 +15,7 @@ class PenguinSpyingHandler : InteractionListener(){
|
||||
if(PenguinManager.hasTagged(player, npc.location)){
|
||||
player.sendMessage("You've already tagged this penguin.")
|
||||
} else {
|
||||
GameWorld.submit(SpyPulse(player, npc))
|
||||
World.submit(SpyPulse(player, npc))
|
||||
}
|
||||
return@on true
|
||||
}
|
||||
|
||||
+3
-3
@@ -9,7 +9,7 @@ import rs09.ServerStore
|
||||
import rs09.game.content.global.worldevents.PluginSet
|
||||
import rs09.game.content.global.worldevents.WorldEvent
|
||||
import rs09.game.content.global.worldevents.WorldEvents
|
||||
import rs09.game.world.GameWorld
|
||||
import rs09.game.world.World
|
||||
|
||||
|
||||
/**
|
||||
@@ -19,7 +19,7 @@ import rs09.game.world.GameWorld
|
||||
*/
|
||||
class ShootingStarEvent : WorldEvent("shooting-stars") {
|
||||
val star = ShootingStar()
|
||||
val tickDelay = if(GameWorld.settings?.isDevMode == true) 200 else 25000
|
||||
val tickDelay = if(World.settings?.isDevMode == true) 200 else 25000
|
||||
|
||||
|
||||
override fun initialize() {
|
||||
@@ -32,7 +32,7 @@ class ShootingStarEvent : WorldEvent("shooting-stars") {
|
||||
ShootingStarLogin()
|
||||
)
|
||||
super.initialize()
|
||||
GameWorld.Pulser.submit(StarPulse())
|
||||
World.Pulser.submit(StarPulse())
|
||||
log("Shooting Star event has been initialized.")
|
||||
}
|
||||
|
||||
|
||||
+2
-2
@@ -10,7 +10,7 @@ import core.game.node.entity.skill.gather.SkillingTool
|
||||
import core.game.node.item.Item
|
||||
import core.tools.RandomFunction
|
||||
import org.rs09.consts.Items
|
||||
import rs09.game.world.GameWorld
|
||||
import rs09.game.world.World
|
||||
import rs09.game.world.repository.Repository
|
||||
import rs09.tools.stringtools.colorize
|
||||
|
||||
@@ -81,7 +81,7 @@ class ShootingStarMiningPulse(player: Player?, node: Scenery?, val star: Shootin
|
||||
if (!checkReward()) {
|
||||
return false
|
||||
}
|
||||
if (GameWorld.settings?.isDevMode == true) {
|
||||
if (World.settings?.isDevMode == true) {
|
||||
star.dustLeft = 1
|
||||
}
|
||||
star.decDust()
|
||||
|
||||
@@ -8,7 +8,7 @@ import core.game.node.entity.player.link.diary.DiaryType
|
||||
import core.game.node.item.GroundItemManager
|
||||
import core.game.node.item.Item
|
||||
import rs09.game.content.quest.free.princealirescue.NedPARDialogue
|
||||
import rs09.game.world.GameWorld.settings
|
||||
import rs09.game.world.World.settings
|
||||
import rs09.tools.DIALOGUE_INITIAL_OPTIONS_HANDLE
|
||||
import rs09.tools.END_DIALOGUE
|
||||
|
||||
|
||||
+1
-1
@@ -6,7 +6,7 @@ import core.game.system.task.Pulse
|
||||
import core.game.world.map.Location
|
||||
import org.rs09.consts.Items
|
||||
import rs09.game.interaction.InteractionListener
|
||||
import rs09.game.world.GameWorld.Pulser
|
||||
import rs09.game.world.World.Pulser
|
||||
import kotlin.math.abs
|
||||
import kotlin.math.atan2
|
||||
|
||||
|
||||
+2
-3
@@ -3,10 +3,9 @@ package rs09.game.content.quest.members.thefremenniktrials
|
||||
import core.game.node.entity.impl.Animator
|
||||
import core.game.node.entity.npc.NPC
|
||||
import core.game.node.entity.player.Player
|
||||
import core.game.node.entity.player.info.PlayerDetails
|
||||
import core.game.node.item.Item
|
||||
import core.game.system.task.Pulse
|
||||
import rs09.game.world.GameWorld
|
||||
import rs09.game.world.World
|
||||
import core.game.world.map.Location
|
||||
import core.game.world.update.flag.context.Animation
|
||||
import core.plugin.Initializable
|
||||
@@ -73,7 +72,7 @@ class ManniDialogue(player: Player? = null) : DialoguePlugin(player){
|
||||
2 -> {player("No, I don't think I am.");stage = 1000}
|
||||
}
|
||||
103 -> {npc("As you wish outerlander; I will drink first, then you will","drink.");stage++}
|
||||
104 -> {GameWorld.submit(DrinkingPulse(player,curNPC,player?.getAttribute("fremtrials:keg-mixed",false))); end()}
|
||||
104 -> {World.submit(DrinkingPulse(player,curNPC,player?.getAttribute("fremtrials:keg-mixed",false))); end()}
|
||||
|
||||
1000 -> end()
|
||||
}
|
||||
|
||||
+3
-3
@@ -17,8 +17,8 @@ import org.rs09.consts.NPCs
|
||||
import org.rs09.primextends.getNext
|
||||
import org.rs09.primextends.isLast
|
||||
import rs09.game.interaction.InteractionListener
|
||||
import rs09.game.world.GameWorld
|
||||
import rs09.game.world.GameWorld.Pulser
|
||||
import rs09.game.world.World
|
||||
import rs09.game.world.World.Pulser
|
||||
|
||||
class TFTInteractionListeners : InteractionListener(){
|
||||
|
||||
@@ -81,7 +81,7 @@ class TFTInteractionListeners : InteractionListener(){
|
||||
|
||||
onUseWith(ITEM,KNIFE,TREE_BRANCH){player,knife,_ ->
|
||||
if (player.inventory.containsItem(knife.asItem())) {
|
||||
GameWorld.submit(BranchFletchingPulse(player))
|
||||
World.submit(BranchFletchingPulse(player))
|
||||
} else {
|
||||
player.sendMessage("You need a knife to do this.")
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@ import core.game.node.entity.Entity
|
||||
import core.game.node.entity.combat.ImpactHandler
|
||||
import core.game.node.entity.player.Player
|
||||
import core.game.system.task.Pulse
|
||||
import rs09.game.world.GameWorld
|
||||
import rs09.game.world.World
|
||||
import core.game.world.map.Location
|
||||
import core.game.world.map.zone.MapZone
|
||||
import core.game.world.map.zone.ZoneBorders
|
||||
@@ -50,7 +50,7 @@ class CaveZone : MapZone("TLT Cave Zone", true), Plugin<Unit> {
|
||||
fun trigger(player: Player){
|
||||
if(RandomFunction.random(1,6) <= 2) {
|
||||
player.animator.animate(Animation(1950), Graphics(572,1,3))
|
||||
GameWorld.Pulser.submit(object : Pulse(5) {
|
||||
World.Pulser.submit(object : Pulse(5) {
|
||||
override fun pulse(): Boolean {
|
||||
player.unlock()
|
||||
player.properties.teleportLocation = Location.create(3159, 9546, 0)
|
||||
|
||||
+2
-2
@@ -5,7 +5,7 @@ import core.game.node.entity.player.Player
|
||||
import core.game.system.task.Pulse
|
||||
import core.game.world.map.Location
|
||||
import org.rs09.consts.Components
|
||||
import rs09.game.world.GameWorld
|
||||
import rs09.game.world.World
|
||||
|
||||
/**
|
||||
* Small object for the goblin follow options
|
||||
@@ -20,7 +20,7 @@ object GoblinFollower {
|
||||
}
|
||||
|
||||
private fun travel(player: Player,location: Location){
|
||||
GameWorld.Pulser.submit(object: Pulse(){
|
||||
World.Pulser.submit(object: Pulse(){
|
||||
var counter = 0
|
||||
override fun pulse(): Boolean {
|
||||
when(counter++){
|
||||
|
||||
+1
-1
@@ -15,7 +15,7 @@ import core.game.world.map.build.DynamicRegion
|
||||
import core.game.world.update.flag.context.Animation
|
||||
import core.plugin.Initializable
|
||||
import rs09.game.camerautils.PlayerCamera
|
||||
import rs09.game.world.GameWorld.Pulser
|
||||
import rs09.game.world.World.Pulser
|
||||
|
||||
private const val DUKE = 2088
|
||||
private const val MISTAG = 2089
|
||||
|
||||
+2
-2
@@ -5,7 +5,7 @@ import core.game.interaction.UseWithHandler
|
||||
import core.game.node.entity.skill.Skills
|
||||
import core.game.node.entity.skill.gather.SkillingTool
|
||||
import core.game.system.task.Pulse
|
||||
import rs09.game.world.GameWorld
|
||||
import rs09.game.world.World
|
||||
import core.plugin.Initializable
|
||||
import core.plugin.Plugin
|
||||
|
||||
@@ -40,7 +40,7 @@ class PickaxeOnRubble : UseWithHandler(1265,1267,1269,1271,1273,1275){
|
||||
}
|
||||
|
||||
player.lock()
|
||||
GameWorld.Pulser.submit(object : Pulse(){
|
||||
World.Pulser.submit(object : Pulse(){
|
||||
var counter = 0
|
||||
override fun pulse(): Boolean {
|
||||
when(counter++){
|
||||
|
||||
+2
-2
@@ -7,7 +7,7 @@ import core.game.world.update.flag.context.Animation
|
||||
import org.rs09.consts.Items
|
||||
import org.rs09.consts.NPCs
|
||||
import rs09.game.interaction.InteractionListener
|
||||
import rs09.game.world.GameWorld
|
||||
import rs09.game.world.World
|
||||
|
||||
/**
|
||||
* handles pickpocketing sigmund during the lost tribe quest
|
||||
@@ -19,7 +19,7 @@ class PickpocketSigmund : InteractionListener(){
|
||||
override fun defineListeners() {
|
||||
on(SIGMUND,NPC,"pickpocket"){player, node ->
|
||||
player.lock()
|
||||
GameWorld.Pulser.submit(object : Pulse(){
|
||||
World.Pulser.submit(object : Pulse(){
|
||||
var counter = 0
|
||||
override fun pulse(): Boolean {
|
||||
when(counter++){
|
||||
|
||||
@@ -8,7 +8,7 @@ import core.game.system.task.Pulse
|
||||
import core.game.world.map.Location
|
||||
import core.plugin.Initializable
|
||||
import org.rs09.consts.Components
|
||||
import rs09.game.world.GameWorld
|
||||
import rs09.game.world.World
|
||||
|
||||
@Initializable
|
||||
class DwarvenBoatmanDialogue(player: Player? = null) : DialoguePlugin(player) {
|
||||
@@ -28,7 +28,7 @@ class DwarvenBoatmanDialogue(player: Player? = null) : DialoguePlugin(player) {
|
||||
11 -> npc("How do you even know about-")
|
||||
12 -> npc("Gah, nevermind! Just climb","on board!")
|
||||
13 -> player("Thank you!")
|
||||
14 -> end().also { GameWorld.Pulser.submit(travelPulse(player)) }
|
||||
14 -> end().also { World.Pulser.submit(travelPulse(player)) }
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
@@ -7,17 +7,17 @@ import core.game.system.task.Pulse
|
||||
import core.game.world.map.Direction
|
||||
import core.game.world.map.Location
|
||||
import org.rs09.consts.Components
|
||||
import rs09.game.world.GameWorld
|
||||
import rs09.game.world.World
|
||||
|
||||
object KeldagrimCartMethods {
|
||||
@JvmStatic
|
||||
fun goToKeldagrim(player: Player){
|
||||
GameWorld.Pulser.submit(TravelToKeldagrimPulse(player))
|
||||
World.Pulser.submit(TravelToKeldagrimPulse(player))
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
fun leaveKeldagrimTo(player: Player, dest: Location){
|
||||
GameWorld.Pulser.submit(TravelFromKeldagrimPulse(player,dest))
|
||||
World.Pulser.submit(TravelFromKeldagrimPulse(player,dest))
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -10,7 +10,7 @@ import core.game.world.map.Location
|
||||
import core.game.world.update.flag.context.Animation
|
||||
import org.rs09.consts.Items
|
||||
import rs09.game.interaction.InteractionListener
|
||||
import rs09.game.world.GameWorld.Pulser
|
||||
import rs09.game.world.World.Pulser
|
||||
|
||||
private const val LOADER = 11162
|
||||
private const val BONE_GRINDER = 11163
|
||||
|
||||
@@ -13,9 +13,6 @@ import core.game.node.entity.player.info.PlayerDetails
|
||||
import core.game.node.entity.player.link.audio.Audio
|
||||
import core.game.node.item.Item
|
||||
import rs09.game.system.SystemLogger
|
||||
import core.game.system.task.Pulse
|
||||
import rs09.game.world.GameWorld
|
||||
import core.game.world.callback.CallBack
|
||||
import rs09.game.world.repository.Repository
|
||||
import core.net.packet.PacketRepository
|
||||
import core.net.packet.context.ContainerContext
|
||||
@@ -34,7 +31,6 @@ import java.lang.Integer.min
|
||||
import java.util.*
|
||||
import java.util.concurrent.locks.ReentrantLock
|
||||
import javax.script.ScriptEngineManager
|
||||
import kotlin.collections.ArrayList
|
||||
|
||||
object OfferManager {
|
||||
/**
|
||||
|
||||
@@ -2,7 +2,7 @@ package rs09.game.interaction
|
||||
|
||||
import core.game.component.Component
|
||||
import core.game.node.entity.player.Player
|
||||
import rs09.game.world.GameWorld
|
||||
import rs09.game.world.World
|
||||
|
||||
/**
|
||||
* Handles the corporeal beast warning interface
|
||||
@@ -14,9 +14,9 @@ class CorporealBeastWarningInterface : InterfaceListener(){
|
||||
|
||||
override fun defineListeners() {
|
||||
on(COMPONENT_ID,17){player,component,_,_,_,_ ->
|
||||
if(player.getAttribute("corp-beast-cave-delay",0) <= GameWorld.ticks) {
|
||||
if(player.getAttribute("corp-beast-cave-delay",0) <= World.ticks) {
|
||||
player.properties.teleportLocation = player.location.transform(4, 0, 0).also { close(player,component) }
|
||||
player.setAttribute("corp-beast-cave-delay",GameWorld.ticks + 5)
|
||||
player.setAttribute("corp-beast-cave-delay",World.ticks + 5)
|
||||
} else {
|
||||
close(player,component)
|
||||
}
|
||||
|
||||
@@ -9,9 +9,8 @@ import core.game.node.entity.skill.Skills
|
||||
import core.game.system.task.Pulse
|
||||
import core.game.world.update.flag.context.ChatMessage
|
||||
import core.game.world.update.flag.player.ChatFlag
|
||||
import core.net.amsc.MSPacketRepository
|
||||
import core.net.amsc.WorldCommunicator
|
||||
import rs09.game.world.GameWorld.Pulser
|
||||
import core.net.ms.MSPacketRepository
|
||||
import rs09.game.world.World.Pulser
|
||||
import rs09.net.packet.`in`.QCPacketType
|
||||
import java.nio.ByteBuffer
|
||||
|
||||
@@ -69,11 +68,7 @@ object QCRepository {
|
||||
|
||||
|
||||
if(forClan) {
|
||||
if (WorldCommunicator.isEnabled()) {
|
||||
MSPacketRepository.sendClanMessage(player, qcString)
|
||||
} else {
|
||||
player?.communication?.clan?.message(player, qcString)
|
||||
}
|
||||
MSPacketRepository.sendClanMessage(player, qcString)
|
||||
} else {
|
||||
val ctx = ChatMessage(player, qcString, 0, qcString.length)
|
||||
ctx.isQuickChat = true
|
||||
|
||||
@@ -10,7 +10,7 @@ import core.game.world.map.Location
|
||||
import core.game.world.map.RegionManager
|
||||
import core.tools.RandomFunction
|
||||
import rs09.game.interaction.InterfaceListener
|
||||
import rs09.game.world.GameWorld
|
||||
import rs09.game.world.World
|
||||
|
||||
val RING_1 = arrayOf('a','d','c','b')
|
||||
val RING_2 = arrayOf('i','l','k','j')
|
||||
@@ -122,7 +122,7 @@ class FairyRingInterface : InterfaceListener(){
|
||||
if (!RegionManager.isTeleportPermitted(tile) || RegionManager.getObject(tile) != null) {
|
||||
tile = Location.create(2412, 4431, 0)
|
||||
}
|
||||
GameWorld.Pulser.submit(object : Pulse(4, player) {
|
||||
World.Pulser.submit(object : Pulse(4, player) {
|
||||
override fun pulse(): Boolean {
|
||||
ContentAPI.sendPlayerDialogue(player, "Wow, fairy magic sure is useful, I hardly moved at all!", FacialExpression.AMAZED)
|
||||
return true
|
||||
|
||||
@@ -10,7 +10,7 @@ import core.game.node.entity.player.Player
|
||||
import core.game.node.entity.player.info.Rights
|
||||
import org.rs09.consts.Components
|
||||
import rs09.game.interaction.InterfaceListener
|
||||
import rs09.game.world.GameWorld.settings
|
||||
import rs09.game.world.World.settings
|
||||
|
||||
class MainGameInterface : InterfaceListener() {
|
||||
val TOPLEVEL = Components.TOPLEVEL_548
|
||||
|
||||
@@ -1,23 +1,14 @@
|
||||
package rs09.game.interaction.item
|
||||
|
||||
import api.ContentAPI
|
||||
import core.cache.def.impl.ItemDefinition
|
||||
import core.game.content.global.travel.glider.GliderPulse
|
||||
import core.game.content.global.travel.glider.Gliders
|
||||
import core.game.interaction.OptionHandler
|
||||
import core.game.node.Node
|
||||
import core.game.node.entity.player.Player
|
||||
import core.game.node.entity.skill.Skills
|
||||
import core.game.node.item.Item
|
||||
import core.game.system.task.Pulse
|
||||
import core.game.world.map.Location
|
||||
import core.game.world.update.flag.context.Animation
|
||||
import core.game.world.update.flag.context.Graphics
|
||||
import core.plugin.Initializable
|
||||
import core.plugin.Plugin
|
||||
import org.rs09.consts.Items
|
||||
import rs09.game.interaction.InteractionListener
|
||||
import rs09.game.world.GameWorld
|
||||
|
||||
private const val SQUASH_GRAPHICS_BEGIN = 767
|
||||
private const val SQUASH_GRAPHICS_END = 769
|
||||
|
||||
@@ -10,7 +10,7 @@ import core.game.system.task.Pulse
|
||||
import core.game.world.update.flag.context.Animation
|
||||
import org.rs09.consts.Items
|
||||
import rs09.game.interaction.InteractionListener
|
||||
import rs09.game.world.GameWorld
|
||||
import rs09.game.world.World
|
||||
import java.util.concurrent.TimeUnit
|
||||
|
||||
private const val CHEST = 2827
|
||||
@@ -20,7 +20,7 @@ class GutanothChestInteractionHandler : InteractionListener(){
|
||||
|
||||
on(CHEST,SCENERY,"open"){ player, node ->
|
||||
val delay = player.getAttribute("gutanoth-chest-delay", 0L)
|
||||
GameWorld.Pulser.submit(ChestPulse(player,System.currentTimeMillis() > delay, node as Scenery))
|
||||
World.Pulser.submit(ChestPulse(player,System.currentTimeMillis() > delay, node as Scenery))
|
||||
return@on true
|
||||
}
|
||||
|
||||
|
||||
@@ -8,7 +8,7 @@ import core.game.system.task.Pulse
|
||||
import core.game.world.update.flag.context.Animation
|
||||
import org.rs09.consts.Items
|
||||
import rs09.game.interaction.InteractionListener
|
||||
import rs09.game.world.GameWorld
|
||||
import rs09.game.world.World
|
||||
|
||||
/**
|
||||
* Handles the chopping down of dense jungle, mainly to grant access to the Kharazi Jungle.
|
||||
@@ -25,7 +25,7 @@ class JungleBushHandler : InteractionListener(){
|
||||
on(ids,SCENERY,"chop-down"){ player, node ->
|
||||
val toChop = node.asScenery()
|
||||
if(checkRequirement(player)){
|
||||
GameWorld.Pulser.submit(object : Pulse(0){
|
||||
World.Pulser.submit(object : Pulse(0){
|
||||
var ticks = 0
|
||||
override fun pulse(): Boolean {
|
||||
when(ticks++){
|
||||
|
||||
@@ -14,7 +14,7 @@ import core.game.world.update.flag.context.Graphics
|
||||
import core.plugin.Initializable
|
||||
import core.plugin.Plugin
|
||||
import org.rs09.consts.Items
|
||||
import rs09.game.world.GameWorld
|
||||
import rs09.game.world.World
|
||||
import rs09.tools.stringtools.colorize
|
||||
|
||||
val snowball = Item(Items.SNOWBALL_11951)
|
||||
@@ -43,13 +43,13 @@ class PeltOptionPlugin : OptionHandler() {
|
||||
|
||||
if(player.inventory.remove(snowball) || player.equipment.remove(snowball)){
|
||||
player.lock()
|
||||
GameWorld.Pulser.submit(object : Pulse(hitDelay + 1){
|
||||
World.Pulser.submit(object : Pulse(hitDelay + 1){
|
||||
override fun pulse(): Boolean {
|
||||
other?.animator?.graphics(Graphics(1282))
|
||||
return true
|
||||
}
|
||||
})
|
||||
GameWorld.Pulser.submit(object : Pulse() {
|
||||
World.Pulser.submit(object : Pulse() {
|
||||
var counter = 0
|
||||
override fun pulse(): Boolean {
|
||||
when (counter++) {
|
||||
|
||||
+2
-2
@@ -13,7 +13,7 @@ import core.game.system.task.Pulse
|
||||
import core.game.world.map.Direction
|
||||
import core.game.world.map.Location
|
||||
import core.game.world.update.flag.context.Animation
|
||||
import rs09.game.world.GameWorld
|
||||
import rs09.game.world.World
|
||||
|
||||
object BrimhavenUtils {
|
||||
fun getVineDestination(player: Player, node: Scenery): Location {
|
||||
@@ -53,7 +53,7 @@ object BrimhavenUtils {
|
||||
ContentAPI.teleport(p, loc)
|
||||
}
|
||||
|
||||
GameWorld.Pulser.submit(object : Pulse(3, player) {
|
||||
World.Pulser.submit(object : Pulse(3, player) {
|
||||
var stage = if (dir == Direction.NORTH) -1 else 0
|
||||
var direction = dir
|
||||
override fun pulse(): Boolean {
|
||||
|
||||
@@ -17,7 +17,7 @@ import core.game.node.entity.skill.Skills
|
||||
import core.game.node.entity.state.EntityState
|
||||
import core.game.node.item.Item
|
||||
import core.game.system.task.Pulse
|
||||
import rs09.game.world.GameWorld
|
||||
import rs09.game.world.World
|
||||
import core.game.world.update.flag.context.Animation
|
||||
import core.tools.RandomFunction
|
||||
|
||||
@@ -122,7 +122,7 @@ class CombatPulse(
|
||||
}
|
||||
combatTimeOut = 0
|
||||
entity.face(victim)
|
||||
if (nextAttack <= GameWorld.ticks) {
|
||||
if (nextAttack <= World.ticks) {
|
||||
victim ?: return false
|
||||
val v: Entity = victim!!
|
||||
var handler = temporaryHandler
|
||||
@@ -310,7 +310,7 @@ class CombatPulse(
|
||||
* @param ticks The amount of ticks.
|
||||
*/
|
||||
fun setNextAttack(ticks: Int) {
|
||||
nextAttack = GameWorld.ticks + ticks
|
||||
nextAttack = World.ticks + ticks
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -349,7 +349,7 @@ class CombatPulse(
|
||||
|
||||
override fun stop() {
|
||||
super.stop()
|
||||
entity!!.setAttribute("combat-stop", GameWorld.ticks)
|
||||
entity!!.setAttribute("combat-stop", World.ticks)
|
||||
if (victim != null) {
|
||||
lastVictim = victim
|
||||
}
|
||||
@@ -426,7 +426,7 @@ class CombatPulse(
|
||||
if (set != null && set.effect(entity, victim, state)) {
|
||||
set.visualize(entity, victim)
|
||||
}
|
||||
GameWorld.Pulser.submit(object : Pulse(delay - 1, entity, victim) {
|
||||
World.Pulser.submit(object : Pulse(delay - 1, entity, victim) {
|
||||
var impact = false
|
||||
override fun pulse(): Boolean {
|
||||
if (DeathTask.isDead(victim)) {
|
||||
|
||||
@@ -1,8 +1,5 @@
|
||||
package rs09.game.node.entity.combat.handlers
|
||||
|
||||
import api.ContentAPI
|
||||
import api.EquipmentSlot
|
||||
import core.game.container.Container
|
||||
import core.game.container.impl.EquipmentContainer
|
||||
import core.game.content.quest.tutorials.tutorialisland.TutorialSession
|
||||
import core.game.content.quest.tutorials.tutorialisland.TutorialStage
|
||||
@@ -28,7 +25,7 @@ import core.tools.RandomFunction
|
||||
import rs09.game.node.entity.combat.CombatSwingHandler
|
||||
import rs09.game.node.entity.skill.skillcapeperks.SkillcapePerks
|
||||
import rs09.game.system.SystemLogger
|
||||
import rs09.game.world.GameWorld
|
||||
import rs09.game.world.World
|
||||
import java.util.*
|
||||
import kotlin.math.ceil
|
||||
import kotlin.math.floor
|
||||
@@ -182,7 +179,7 @@ open class RangeSwingHandler
|
||||
victim!!.impactHandler.handleImpact(entity, hit, CombatStyle.RANGE, state)
|
||||
if (state.secondaryHit > -1) {
|
||||
val hitt = state.secondaryHit
|
||||
GameWorld.Pulser.submit(object : Pulse(1, victim) {
|
||||
World.Pulser.submit(object : Pulse(1, victim) {
|
||||
override fun pulse(): Boolean {
|
||||
victim.impactHandler.handleImpact(entity, hitt, CombatStyle.RANGE, state)
|
||||
return true
|
||||
|
||||
@@ -9,12 +9,12 @@ import core.game.node.entity.player.info.login.Response
|
||||
import core.game.system.SystemManager
|
||||
import core.game.system.monitor.PlayerMonitor
|
||||
import core.game.system.task.Pulse
|
||||
import core.net.amsc.MSPacketRepository
|
||||
import core.net.amsc.ManagementServerState
|
||||
import core.net.amsc.WorldCommunicator
|
||||
import core.net.ms.MSPacketRepository
|
||||
import rs09.game.system.SystemLogger
|
||||
import rs09.game.world.GameWorld
|
||||
import rs09.game.world.World
|
||||
import rs09.game.world.repository.Repository
|
||||
import rs09.net.ms.ManagementServer
|
||||
import rs09.net.ms.ManagementState
|
||||
import java.util.concurrent.TimeUnit
|
||||
import java.util.concurrent.locks.Lock
|
||||
import java.util.concurrent.locks.ReentrantLock
|
||||
@@ -115,7 +115,7 @@ class LoginParser(
|
||||
return
|
||||
}
|
||||
//Repository.getPlayerNames().put(player.getName(), player);
|
||||
GameWorld.Pulser.submit(object : Pulse(1) {
|
||||
World.Pulser.submit(object : Pulse(1) {
|
||||
override fun pulse(): Boolean {
|
||||
try {
|
||||
if (details.session.isActive) {
|
||||
@@ -176,7 +176,7 @@ class LoginParser(
|
||||
player.configManager.init()
|
||||
LoginConfiguration.configureGameWorld(player)
|
||||
Repository.playerNames[player.name] = player
|
||||
GameWorld.Pulser.submit(object : Pulse(1) {
|
||||
World.Pulser.submit(object : Pulse(1) {
|
||||
override fun pulse(): Boolean {
|
||||
if (!Repository.players.contains(player)) {
|
||||
Repository.players.add(player)
|
||||
@@ -196,7 +196,7 @@ class LoginParser(
|
||||
SystemLogger.logWarn("LOGGED_IN_PLAYERS contains ${details.username}")
|
||||
return flag(Response.ALREADY_ONLINE)
|
||||
}
|
||||
if (WorldCommunicator.getState() == ManagementServerState.CONNECTING) {
|
||||
if (ManagementServer.state == ManagementState.CONNECTING) {
|
||||
return flag(Response.LOGIN_SERVER_OFFLINE)
|
||||
}
|
||||
if (!details.session.isActive) {
|
||||
@@ -236,6 +236,6 @@ class LoginParser(
|
||||
* @param type The login type.
|
||||
*/
|
||||
init {
|
||||
timeStamp = GameWorld.ticks
|
||||
timeStamp = World.ticks
|
||||
}
|
||||
}
|
||||
@@ -8,7 +8,6 @@ import core.game.node.entity.player.link.SpellBookManager
|
||||
import core.game.node.entity.player.link.emote.Emotes
|
||||
import core.game.node.entity.player.link.grave.GraveType
|
||||
import core.game.node.entity.player.link.music.MusicEntry
|
||||
import core.game.node.entity.skill.slayer.SlayerEquipmentFlags
|
||||
import kotlinx.coroutines.GlobalScope
|
||||
import kotlinx.coroutines.launch
|
||||
import org.json.simple.JSONArray
|
||||
@@ -18,7 +17,7 @@ import rs09.ServerConstants
|
||||
import rs09.game.node.entity.skill.farming.CompostBins
|
||||
import rs09.game.node.entity.skill.farming.FarmingPatch
|
||||
import rs09.game.system.SystemLogger
|
||||
import rs09.game.world.GameWorld
|
||||
import rs09.game.world.World
|
||||
import java.io.FileReader
|
||||
import java.util.*
|
||||
|
||||
@@ -369,8 +368,8 @@ class PlayerSaveParser(val player: Player) {
|
||||
player.skills.parse(skillData)
|
||||
player.skills.experienceGained = saveFile!!["totalEXP"].toString().toDouble()
|
||||
player.skills.experienceMutiplier = saveFile!!["exp_multiplier"].toString().toDouble()
|
||||
if (GameWorld.settings?.default_xp_rate != 5.0) {
|
||||
player.skills.experienceMutiplier = GameWorld.settings?.default_xp_rate!!
|
||||
if (World.settings?.default_xp_rate != 5.0) {
|
||||
player.skills.experienceMutiplier = World.settings?.default_xp_rate!!
|
||||
}
|
||||
val divisor: Double
|
||||
if(player.skills.experienceMutiplier >= 10 && !player.attributes.containsKey("permadeath")){ //exclude permadeath HCIMs from XP squish
|
||||
|
||||
+4
-4
@@ -19,7 +19,7 @@ import core.game.world.map.Location
|
||||
import core.game.world.update.flag.context.Animation
|
||||
import core.game.world.update.flag.context.Graphics
|
||||
import core.plugin.Initializable
|
||||
import rs09.game.world.GameWorld
|
||||
import rs09.game.world.World
|
||||
import rs09.plugin.PluginManager
|
||||
|
||||
/**
|
||||
@@ -92,7 +92,7 @@ class BarbarianOutpostCourse
|
||||
ContentAPI.sendMessage(player, "You cannot do that from here.")
|
||||
return
|
||||
}
|
||||
if (ropeDelay > GameWorld.ticks) {
|
||||
if (ropeDelay > World.ticks) {
|
||||
ContentAPI.sendMessage(player, "The rope is being used.")
|
||||
return
|
||||
}
|
||||
@@ -100,7 +100,7 @@ class BarbarianOutpostCourse
|
||||
AgilityHandler.fail(player, 0, Location.create(2549, 9951, 0), null, getHitAmount(player), "You slip and fall to the pit below.")
|
||||
return
|
||||
}
|
||||
ropeDelay = GameWorld.ticks + 2
|
||||
ropeDelay = World.ticks + 2
|
||||
player.packetDispatch.sendSceneryAnimation(`object`, Animation.create(497), true)
|
||||
AgilityHandler.forceWalk(player, 0, player.location, Location.create(2551, 3549, 0), Animation.create(751), 50, 22.0, "You skillfully swing across.", 1)
|
||||
}
|
||||
@@ -117,7 +117,7 @@ class BarbarianOutpostCourse
|
||||
AgilityHandler.walk(player, if (failed) -1 else 1, Location.create(2551, 3546, 0), end, Animation.create(155), if (failed) 0.0 else 13.5, if (failed) null else "...You make it safely to the other side.")
|
||||
if (failed) {
|
||||
AgilityHandler.walk(player, -1, player.location, Location.create(2545, 3546, 0), Animation.create(155), 0.0, null)
|
||||
GameWorld.Pulser.submit(getSwimPulse(player))
|
||||
World.Pulser.submit(getSwimPulse(player))
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,7 +13,7 @@ import core.game.system.task.LogoutTask
|
||||
import core.game.world.map.Location
|
||||
import core.game.world.update.flag.context.Animation
|
||||
import core.plugin.Initializable
|
||||
import rs09.game.world.GameWorld
|
||||
import rs09.game.world.World
|
||||
|
||||
/**
|
||||
* Handles the gnome stronghold agility course.
|
||||
@@ -80,11 +80,11 @@ class GnomeStrongholdCourse
|
||||
ContentAPI.sendMessage(player, "You can't do that from here.")
|
||||
return true
|
||||
}
|
||||
if (USED_PIPES[index] > GameWorld.ticks) {
|
||||
if (USED_PIPES[index] > World.ticks) {
|
||||
ContentAPI.sendMessage(player, "The pipe is being used.")
|
||||
return true
|
||||
}
|
||||
USED_PIPES[index] = GameWorld.ticks + 10
|
||||
USED_PIPES[index] = World.ticks + 10
|
||||
|
||||
player.lock()
|
||||
//Animations and force walking
|
||||
|
||||
@@ -15,7 +15,7 @@ import core.game.world.map.Location
|
||||
import core.game.world.map.RegionManager
|
||||
import core.game.world.update.flag.context.Animation
|
||||
import core.plugin.Initializable
|
||||
import rs09.game.world.GameWorld
|
||||
import rs09.game.world.World
|
||||
|
||||
/**
|
||||
* Handles the wilderness agility course.
|
||||
@@ -68,7 +68,7 @@ class WildernessCourse
|
||||
* @param object the object.
|
||||
*/
|
||||
private fun handleEntranceObstacle(player: Player, `object`: Scenery) {
|
||||
GameWorld.Pulser.submit(object : Pulse(1, player) {
|
||||
World.Pulser.submit(object : Pulse(1, player) {
|
||||
var counter = 0
|
||||
val fail = AgilityHandler.hasFailed(player, 1, 0.3)
|
||||
override fun pulse(): Boolean {
|
||||
@@ -112,7 +112,7 @@ class WildernessCourse
|
||||
return
|
||||
}
|
||||
player.lock(10)
|
||||
GameWorld.Pulser.submit(object : Pulse(1, player) {
|
||||
World.Pulser.submit(object : Pulse(1, player) {
|
||||
var counter = 0
|
||||
override fun pulse(): Boolean {
|
||||
val x = 3004
|
||||
@@ -156,7 +156,7 @@ class WildernessCourse
|
||||
ContentAPI.sendMessage(player, "You cannot do that from here.")
|
||||
return
|
||||
}
|
||||
if (ropeDelay > GameWorld.ticks) {
|
||||
if (ropeDelay > World.ticks) {
|
||||
ContentAPI.sendMessage(player, "The rope is being used.")
|
||||
return
|
||||
}
|
||||
@@ -164,7 +164,7 @@ class WildernessCourse
|
||||
AgilityHandler.fail(player, 0, Location.create(3005, 10357, 0), null, getHitAmount(player), "You slip and fall to the pit below.")
|
||||
return
|
||||
}
|
||||
ropeDelay = GameWorld.ticks + 2
|
||||
ropeDelay = World.ticks + 2
|
||||
player.packetDispatch.sendSceneryAnimation(`object`, Animation.create(497), true)
|
||||
AgilityHandler.forceWalk(player, 1, player.location, Location.create(3005, 3958, 0), Animation.create(751), 50, 20.0, "You skillfully swing across.", 1)
|
||||
}
|
||||
@@ -209,7 +209,7 @@ class WildernessCourse
|
||||
ContentAPI.sendMessage(player, "You walk carefully across the slippery log...")
|
||||
AgilityHandler.walk(player, if (failed) -1 else 3, player.location, end, Animation.create(155), if (failed) 0.0 else 20.0, if (failed) null else "You skillfully edge across the gap.")
|
||||
if (failed) {
|
||||
GameWorld.Pulser.submit(object : Pulse(5, player) {
|
||||
World.Pulser.submit(object : Pulse(5, player) {
|
||||
override fun pulse(): Boolean {
|
||||
player.faceLocation(Location.create(2998, 3944, 0))
|
||||
AgilityHandler.fail(player, 3, Location.create(2998, 10345, 0), Animation.create(770), getHitAmount(player), "You slip and fall onto the spikes below.")
|
||||
@@ -227,7 +227,7 @@ class WildernessCourse
|
||||
*/
|
||||
private fun handleRockClimb(player: Player, `object`: Scenery) {
|
||||
AgilityHandler.forceWalk(player, 4, Location.create(2994, 3937, 0), Location.create(2994, 3933, 0), Animation.create(740), 8, 0.0, "You reach the top.")
|
||||
GameWorld.Pulser.submit(object : Pulse(4, player) {
|
||||
World.Pulser.submit(object : Pulse(4, player) {
|
||||
override fun pulse(): Boolean {
|
||||
player.animator.reset()
|
||||
return true
|
||||
|
||||
+2
-2
@@ -6,7 +6,7 @@ import core.game.node.entity.player.Player
|
||||
import core.game.node.entity.skill.agility.AgilityHandler
|
||||
import core.game.node.entity.skill.agility.AgilityShortcut
|
||||
import core.game.system.task.Pulse
|
||||
import rs09.game.world.GameWorld
|
||||
import rs09.game.world.World
|
||||
import core.game.world.map.Location
|
||||
import core.game.world.update.flag.context.Animation
|
||||
import core.game.world.update.flag.player.FaceLocationFlag
|
||||
@@ -87,7 +87,7 @@ class BasaltRockShortcut : AgilityShortcut {
|
||||
}
|
||||
|
||||
override fun run(player: Player, obj: Scenery, option: String, failed: Boolean) {
|
||||
GameWorld.Pulser.submit(object : Pulse(1, player) {
|
||||
World.Pulser.submit(object : Pulse(1, player) {
|
||||
override fun pulse(): Boolean {
|
||||
when (obj.id) {
|
||||
|
||||
|
||||
+2
-2
@@ -6,7 +6,7 @@ import core.game.node.entity.player.link.diary.DiaryType
|
||||
import core.game.node.entity.skill.agility.AgilityHandler
|
||||
import core.game.node.entity.skill.agility.AgilityShortcut
|
||||
import core.game.system.task.Pulse
|
||||
import rs09.game.world.GameWorld
|
||||
import rs09.game.world.World
|
||||
import core.game.world.update.flag.context.Animation
|
||||
import core.plugin.Initializable
|
||||
import core.plugin.Plugin
|
||||
@@ -66,7 +66,7 @@ class PipeShortcut : AgilityShortcut {
|
||||
/**
|
||||
* Pulse that starts the object interaction when clicked on one of these shortcuts
|
||||
*/
|
||||
GameWorld.Pulser.submit(object : Pulse(1, player) {
|
||||
World.Pulser.submit(object : Pulse(1, player) {
|
||||
override fun pulse(): Boolean {
|
||||
when (obj.id) {
|
||||
|
||||
|
||||
+1
-1
@@ -12,7 +12,7 @@ import core.game.node.entity.skill.construction.HousingStyle
|
||||
import core.game.node.item.Item
|
||||
import core.plugin.Initializable
|
||||
import org.rs09.consts.Items
|
||||
import rs09.game.world.GameWorld.settings
|
||||
import rs09.game.world.World.settings
|
||||
import rs09.tools.END_DIALOGUE
|
||||
import rs09.tools.START_DIALOGUE
|
||||
|
||||
|
||||
+2
-2
@@ -16,7 +16,7 @@ import core.game.system.task.Pulse
|
||||
import core.game.world.update.flag.context.Animation
|
||||
import core.plugin.Initializable
|
||||
import core.plugin.Plugin
|
||||
import rs09.game.world.GameWorld
|
||||
import rs09.game.world.World
|
||||
import rs09.plugin.PluginManager.definePlugin
|
||||
|
||||
/**
|
||||
@@ -127,7 +127,7 @@ class LecternPlugin : OptionHandler() {
|
||||
override fun handle(player: Player, node: Node, option: String): Boolean {
|
||||
val id = node.asScenery().id
|
||||
player.setAttribute("ttb:objectid", id)
|
||||
GameWorld.Pulser.submit(object : Pulse(){
|
||||
World.Pulser.submit(object : Pulse(){
|
||||
var counter = 0
|
||||
override fun pulse(): Boolean {
|
||||
when(counter++){
|
||||
|
||||
+1
-1
@@ -13,7 +13,7 @@ import core.plugin.Plugin
|
||||
import core.tools.RandomFunction
|
||||
import rs09.game.content.global.worldevents.WorldEvents
|
||||
import rs09.game.content.global.worldevents.shootingstar.ShootingStarEvent
|
||||
import rs09.game.world.GameWorld.Pulser
|
||||
import rs09.game.world.World.Pulser
|
||||
import java.util.concurrent.TimeUnit
|
||||
|
||||
@Initializable
|
||||
|
||||
@@ -3,7 +3,6 @@ package rs09.game.node.entity.skill.gather.fishing
|
||||
import core.game.content.global.SkillingPets
|
||||
import core.game.content.quest.tutorials.tutorialisland.TutorialSession
|
||||
import core.game.content.quest.tutorials.tutorialisland.TutorialStage
|
||||
import core.game.container.Container
|
||||
import core.game.node.entity.npc.NPC
|
||||
import core.game.node.entity.player.Player
|
||||
import core.game.node.entity.player.link.diary.DiaryType
|
||||
@@ -23,7 +22,7 @@ import rs09.game.node.entity.player.info.stats.STATS_BASE
|
||||
import rs09.game.node.entity.player.info.stats.STATS_FISH
|
||||
import rs09.game.node.entity.skill.skillcapeperks.SkillcapePerks
|
||||
import rs09.game.node.entity.skill.skillcapeperks.SkillcapePerks.Companion.isActive
|
||||
import rs09.game.world.GameWorld.Pulser
|
||||
import rs09.game.world.World.Pulser
|
||||
import rs09.tools.stringtools.colorize
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,10 +1,6 @@
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import api.ContentAPI
|
||||
import core.cache.def.impl.NPCDefinition
|
||||
import core.cache.def.impl.SceneryDefinition
|
||||
import core.game.interaction.OptionHandler
|
||||
import core.game.node.Node
|
||||
import core.game.node.entity.Entity
|
||||
import core.game.node.entity.combat.CombatStyle
|
||||
import core.game.node.entity.impl.Animator.Priority;
|
||||
@@ -18,14 +14,12 @@ import core.game.system.task.Pulse
|
||||
import core.game.world.map.Direction
|
||||
import core.game.world.map.Location
|
||||
import core.game.world.update.flag.context.Animation
|
||||
import core.game.world.update.flag.context.Graphics
|
||||
import core.plugin.Initializable
|
||||
import core.plugin.Plugin
|
||||
import core.tools.RandomFunction
|
||||
import org.rs09.consts.Items
|
||||
import org.rs09.consts.NPCs
|
||||
import rs09.game.interaction.InteractionListener
|
||||
import rs09.game.world.GameWorld
|
||||
import rs09.game.world.World
|
||||
|
||||
/*@Initializable
|
||||
class HunterPitfall : OptionHandler() {
|
||||
@@ -201,7 +195,7 @@ class PitfallListeners : InteractionListener() {
|
||||
return true
|
||||
}
|
||||
}
|
||||
GameWorld.Pulser.submit(collapsePulse)
|
||||
World.Pulser.submit(collapsePulse)
|
||||
return@on true
|
||||
}
|
||||
on(SPIKED_PIT, SCENERY, "jump") { player, node ->
|
||||
|
||||
+2
-2
@@ -13,7 +13,7 @@ import core.game.world.update.flag.context.Animation
|
||||
import core.tools.RandomFunction
|
||||
import org.rs09.consts.Items
|
||||
import rs09.game.system.SystemLogger
|
||||
import rs09.game.world.GameWorld
|
||||
import rs09.game.world.World
|
||||
import java.util.*
|
||||
|
||||
/**
|
||||
@@ -163,7 +163,7 @@ abstract class HunterTracking : OptionHandler(){
|
||||
fun reward(player: Player, success: Boolean) {
|
||||
player.lock()
|
||||
player.animator.animate(if(success) KEBBIT_ANIM else MISS_ANIM)
|
||||
GameWorld.Pulser.submit(object : Pulse(KEBBIT_ANIM.duration){
|
||||
World.Pulser.submit(object : Pulse(KEBBIT_ANIM.duration){
|
||||
override fun pulse(): Boolean {
|
||||
if(hasTrail(player) && success){
|
||||
for(item in rewards){
|
||||
|
||||
@@ -8,7 +8,7 @@ import core.game.node.item.Item
|
||||
import core.game.world.update.flag.context.Animation
|
||||
import core.game.world.update.flag.context.Graphics
|
||||
import rs09.game.interaction.Listener
|
||||
import rs09.game.world.GameWorld
|
||||
import rs09.game.world.World
|
||||
|
||||
abstract class SpellListener(val bookName: String) : Listener {
|
||||
companion object {
|
||||
@@ -34,7 +34,7 @@ abstract class SpellListener(val bookName: String) : Listener {
|
||||
}
|
||||
|
||||
fun requires(player: Player, magicLevel: Int = 0, runes: Array<Item> = arrayOf<Item>(), specialEquipment: IntArray = intArrayOf()){
|
||||
if(player.getAttribute("magic-delay",0) > GameWorld.ticks){
|
||||
if(player.getAttribute("magic-delay",0) > World.ticks){
|
||||
throw IllegalStateException()
|
||||
}
|
||||
if(player.getAttribute("tablet-spell",false)){
|
||||
@@ -80,7 +80,7 @@ abstract class SpellListener(val bookName: String) : Listener {
|
||||
}
|
||||
|
||||
fun setDelay(player: Player,isTeleport: Boolean = false){
|
||||
if(!isTeleport) player.setAttribute("magic-delay",GameWorld.ticks + 3) else player.setAttribute("magic-delay",GameWorld.ticks + 5)
|
||||
if(!isTeleport) player.setAttribute("magic-delay",World.ticks + 3) else player.setAttribute("magic-delay",World.ticks + 5)
|
||||
}
|
||||
|
||||
fun interrupt(player: Player){
|
||||
|
||||
+7
-7
@@ -18,7 +18,7 @@ import core.game.world.update.flag.context.Graphics
|
||||
import core.tools.RandomFunction
|
||||
import org.rs09.consts.NPCs
|
||||
import rs09.game.interaction.InteractionListener
|
||||
import rs09.game.world.GameWorld
|
||||
import rs09.game.world.World
|
||||
|
||||
/**
|
||||
* A plugin used to handle the abyss.
|
||||
@@ -105,7 +105,7 @@ class AbyssPlugin : InteractionListener() {
|
||||
}
|
||||
player.animate(Animation(733))
|
||||
player.lock()
|
||||
GameWorld.Pulser.submit(object : Pulse(1, player) {
|
||||
World.Pulser.submit(object : Pulse(1, player) {
|
||||
var count = 0
|
||||
override fun pulse(): Boolean {
|
||||
when (count) {
|
||||
@@ -150,7 +150,7 @@ class AbyssPlugin : InteractionListener() {
|
||||
}
|
||||
player.animate(tool.getAnimation())
|
||||
player.lock()
|
||||
GameWorld.Pulser.submit(object : Pulse(1, player) {
|
||||
World.Pulser.submit(object : Pulse(1, player) {
|
||||
var count = 0
|
||||
override fun pulse(): Boolean {
|
||||
when (count) {
|
||||
@@ -191,7 +191,7 @@ class AbyssPlugin : InteractionListener() {
|
||||
}
|
||||
player.animate(tool.getAnimation())
|
||||
player.lock()
|
||||
GameWorld.Pulser.submit(object : Pulse(1, player) {
|
||||
World.Pulser.submit(object : Pulse(1, player) {
|
||||
var count = 0
|
||||
override fun pulse(): Boolean {
|
||||
when (count) {
|
||||
@@ -232,7 +232,7 @@ class AbyssPlugin : InteractionListener() {
|
||||
`object` ?: return
|
||||
player.animate(Animation(1331))
|
||||
player.lock()
|
||||
GameWorld.Pulser.submit(object : Pulse(1, player) {
|
||||
World.Pulser.submit(object : Pulse(1, player) {
|
||||
var count = 0
|
||||
override fun pulse(): Boolean {
|
||||
when (count) {
|
||||
@@ -303,7 +303,7 @@ class AbyssPlugin : InteractionListener() {
|
||||
val index: Int = RandomFunction.random(emotes.size)
|
||||
player.animate(Animation(emotes[index]))
|
||||
player.lock()
|
||||
GameWorld.Pulser.submit(object : Pulse(1, player) {
|
||||
World.Pulser.submit(object : Pulse(1, player) {
|
||||
var count = 0
|
||||
override fun pulse(): Boolean {
|
||||
when (count) {
|
||||
@@ -458,7 +458,7 @@ class AbyssPlugin : InteractionListener() {
|
||||
npc.sendChat("Veniens! Sallakar! Rinnesset!")
|
||||
player.skills.decrementPrayerPoints(100.0)
|
||||
player.skullManager.checkSkull(player)
|
||||
GameWorld.Pulser.submit(object : Pulse(2, player) {
|
||||
World.Pulser.submit(object : Pulse(2, player) {
|
||||
override fun pulse(): Boolean {
|
||||
player.properties.teleportLocation = Location.create(3021, 4847, 0)
|
||||
npc.updateMasks.reset()
|
||||
|
||||
@@ -8,7 +8,7 @@ import core.game.node.entity.player.link.TeleportManager
|
||||
import core.game.node.entity.skill.runecrafting.Altar
|
||||
import core.game.world.map.zone.impl.DarkZone
|
||||
import core.plugin.Initializable
|
||||
import rs09.game.world.GameWorld
|
||||
import rs09.game.world.World
|
||||
|
||||
enum class SkillcapePerks(val attribute: String, val effect: ((Player) -> Unit)? = null) {
|
||||
BAREFISTED_SMITHING("cape_perks:barefisted-smithing"),
|
||||
@@ -112,7 +112,7 @@ enum class SkillcapePerks(val attribute: String, val effect: ((Player) -> Unit)?
|
||||
}
|
||||
|
||||
fun activate(player: Player){
|
||||
if(GameWorld.settings?.skillcape_perks != true){
|
||||
if(World.settings?.skillcape_perks != true){
|
||||
return
|
||||
}
|
||||
if(!isActive(this,player)){
|
||||
@@ -124,7 +124,7 @@ enum class SkillcapePerks(val attribute: String, val effect: ((Player) -> Unit)?
|
||||
}
|
||||
|
||||
fun operate(player: Player){
|
||||
if(GameWorld.settings?.skillcape_perks != true){
|
||||
if(World.settings?.skillcape_perks != true){
|
||||
player.sendMessage("This item can not be operated.")
|
||||
return
|
||||
}
|
||||
|
||||
@@ -3,7 +3,7 @@ package rs09.game.node.entity.state.newsys
|
||||
import core.game.node.entity.player.Player
|
||||
import core.game.system.task.Pulse
|
||||
import org.json.simple.JSONObject
|
||||
import rs09.game.world.GameWorld.Pulser
|
||||
import rs09.game.world.World.Pulser
|
||||
|
||||
/**
|
||||
* A class representing a state that the player or some associated thing can be in.
|
||||
|
||||
@@ -7,7 +7,7 @@ import core.tools.RandomFunction
|
||||
import org.json.simple.JSONObject
|
||||
import rs09.game.node.entity.state.newsys.PlayerState
|
||||
import rs09.game.node.entity.state.newsys.State
|
||||
import rs09.game.world.GameWorld
|
||||
import rs09.game.world.World
|
||||
|
||||
@PlayerState("disease")
|
||||
class DiseasedState(player: Player? = null) : State(player){
|
||||
@@ -31,7 +31,7 @@ class DiseasedState(player: Player? = null) : State(player){
|
||||
|
||||
override fun createPulse() {
|
||||
player ?: return
|
||||
if(player.getAttribute("immunity:disease",0) > GameWorld.ticks){
|
||||
if(player.getAttribute("immunity:disease",0) > World.ticks){
|
||||
return
|
||||
}
|
||||
if(hitsLeft <= 0) return
|
||||
|
||||
+5
-5
@@ -5,7 +5,7 @@ import core.game.system.task.Pulse
|
||||
import org.json.simple.JSONObject
|
||||
import rs09.game.node.entity.state.newsys.PlayerState
|
||||
import rs09.game.node.entity.state.newsys.State
|
||||
import rs09.game.world.GameWorld;
|
||||
import rs09.game.world.World;
|
||||
|
||||
@PlayerState("godcharge")
|
||||
class GodspellChargedState(player: Player? = null) : State(player) {
|
||||
@@ -13,24 +13,24 @@ class GodspellChargedState(player: Player? = null) : State(player) {
|
||||
var startTick: Int = 0
|
||||
|
||||
override fun save(root: JSONObject) {
|
||||
root.put("ticks_elapsed", GameWorld.ticks - startTick)
|
||||
root.put("ticks_elapsed", World.ticks - startTick)
|
||||
}
|
||||
|
||||
override fun parse(_data: JSONObject) {
|
||||
if(_data.containsKey("ticks_elapsed")){
|
||||
startTick = GameWorld.ticks - _data["ticks_elapsed"].toString().toInt()
|
||||
startTick = World.ticks - _data["ticks_elapsed"].toString().toInt()
|
||||
}
|
||||
}
|
||||
|
||||
override fun newInstance(player: Player?): State {
|
||||
var ret = GodspellChargedState(player)
|
||||
ret.startTick = GameWorld.ticks
|
||||
ret.startTick = World.ticks
|
||||
return ret
|
||||
}
|
||||
|
||||
override fun createPulse() {
|
||||
player ?: return
|
||||
if(GameWorld.ticks - startTick >= DURATION) return
|
||||
if(World.ticks - startTick >= DURATION) return
|
||||
pulse = object : Pulse(DURATION) {
|
||||
override fun pulse(): Boolean {
|
||||
player.sendMessage("Your magical charge fades away.")
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package rs09.game.system.command
|
||||
|
||||
import core.game.node.entity.player.Player
|
||||
import rs09.game.world.GameWorld
|
||||
import rs09.game.world.World
|
||||
|
||||
/**
|
||||
* Base class for Commands in the new system. Can pass a lambda as part of the constructor or after the constructor.
|
||||
@@ -10,7 +10,7 @@ import rs09.game.world.GameWorld
|
||||
class Command(val name: String, val privilege: Privilege, val handle: (Player, Array<String>) -> Unit) {
|
||||
fun attemptHandling(player: Player, args: Array<String>?){
|
||||
args ?: return
|
||||
if(player.rights.ordinal >= privilege.ordinal || GameWorld.settings?.isDevMode == true){
|
||||
if(player.rights.ordinal >= privilege.ordinal || World.settings?.isDevMode == true){
|
||||
handle(player,args)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,7 +9,7 @@ import core.game.node.entity.skill.Skills
|
||||
import rs09.game.system.command.CommandPlugin
|
||||
import core.game.system.command.CommandSet
|
||||
import core.game.system.task.Pulse
|
||||
import rs09.game.world.GameWorld
|
||||
import rs09.game.world.World
|
||||
import rs09.game.world.ImmerseWorld
|
||||
import core.game.world.map.Location
|
||||
import core.game.world.map.RegionManager
|
||||
@@ -119,7 +119,7 @@ class AIPCommandPlugin : CommandPlugin() {
|
||||
player.communication.clan.clanWar.fireEvent("join", aip)
|
||||
}
|
||||
}
|
||||
GameWorld.Pulser.submit(object : Pulse(1) {
|
||||
World.Pulser.submit(object : Pulse(1) {
|
||||
override fun pulse(): Boolean {
|
||||
aip.follow(l)
|
||||
return true
|
||||
|
||||
@@ -24,7 +24,7 @@ import core.net.packet.out.Varbit
|
||||
import core.plugin.Initializable
|
||||
import core.plugin.Plugin
|
||||
import rs09.game.system.command.CommandPlugin
|
||||
import rs09.game.world.GameWorld
|
||||
import rs09.game.world.World
|
||||
import java.awt.Toolkit
|
||||
import java.awt.datatransfer.StringSelection
|
||||
|
||||
@@ -293,7 +293,7 @@ class VisualCommand : CommandPlugin() {
|
||||
"loop_inter" -> {
|
||||
val st = toInteger(args!![1]!!)
|
||||
val en = if (args.size > 2) toInteger(args[2]!!) else 740
|
||||
GameWorld.Pulser.submit(object : Pulse(3, player) {
|
||||
World.Pulser.submit(object : Pulse(3, player) {
|
||||
var id = st
|
||||
override fun pulse(): Boolean {
|
||||
// PacketRepository.send(Interface.class, new InterfaceContext(player, 548, 77, id, false));
|
||||
@@ -307,7 +307,7 @@ class VisualCommand : CommandPlugin() {
|
||||
"loop_iconfig" -> {
|
||||
val st = toInteger(args!![1]!!)
|
||||
val en = if (args.size > 2) toInteger(args[2]!!) else 740
|
||||
GameWorld.Pulser.submit(object : Pulse(3, player) {
|
||||
World.Pulser.submit(object : Pulse(3, player) {
|
||||
var id = 0
|
||||
override fun pulse(): Boolean {
|
||||
// PacketRepository.send(Interface.class, new InterfaceContext(player, 548, 77, id, false));
|
||||
@@ -321,7 +321,7 @@ class VisualCommand : CommandPlugin() {
|
||||
"loop_itemoni" -> {
|
||||
val st = toInteger(args!![1]!!)
|
||||
val en = if (args.size > 2) toInteger(args[2]!!) else 740
|
||||
GameWorld.Pulser.submit(object : Pulse(1, player) {
|
||||
World.Pulser.submit(object : Pulse(1, player) {
|
||||
var id = 0
|
||||
override fun pulse(): Boolean {
|
||||
// PacketRepository.send(Interface.class, new InterfaceContext(player, 548, 77, id, false));
|
||||
@@ -371,7 +371,7 @@ class VisualCommand : CommandPlugin() {
|
||||
"loop_oa" -> {
|
||||
val startId = toInteger(args!![1]!!)
|
||||
val endId = if (args.size > 2) toInteger(args[2]!!) else 11000
|
||||
GameWorld.Pulser.submit(object : Pulse(3, player) {
|
||||
World.Pulser.submit(object : Pulse(3, player) {
|
||||
var id = startId
|
||||
override fun pulse(): Boolean {
|
||||
val `object` = RegionManager.getObject(player!!.location)
|
||||
@@ -389,7 +389,7 @@ class VisualCommand : CommandPlugin() {
|
||||
"loop_anim" -> {
|
||||
val start = toInteger(args!![1]!!)
|
||||
val end = if (args.size > 2) toInteger(args[2]!!) else 11000
|
||||
GameWorld.Pulser.submit(object : Pulse(3, player) {
|
||||
World.Pulser.submit(object : Pulse(3, player) {
|
||||
var id = start
|
||||
override fun pulse(): Boolean {
|
||||
player!!.animate(Animation.create(id))
|
||||
@@ -402,7 +402,7 @@ class VisualCommand : CommandPlugin() {
|
||||
"loop_gfx" -> {
|
||||
val s = toInteger(args!![1]!!)
|
||||
val e = if (args.size > 2) toInteger(args[2]!!) else 11000
|
||||
GameWorld.Pulser.submit(object : Pulse(3, player) {
|
||||
World.Pulser.submit(object : Pulse(3, player) {
|
||||
var id = s
|
||||
override fun pulse(): Boolean {
|
||||
Projectile.create(player!!.location, player.location.transform(0, 3, 0), id, 42, 36, 46, 75, 5, 11).send()
|
||||
|
||||
@@ -6,7 +6,7 @@ import core.game.world.update.flag.context.Animation
|
||||
import core.plugin.Initializable
|
||||
import rs09.game.system.command.Command
|
||||
import rs09.game.system.command.CommandPlugin.Companion.toInteger
|
||||
import rs09.game.world.GameWorld
|
||||
import rs09.game.world.World
|
||||
import java.util.*
|
||||
|
||||
@Initializable
|
||||
@@ -40,7 +40,7 @@ class AnimationCommandSet : CommandSet(Command.Privilege.ADMIN) {
|
||||
notify(player, "Really...? $end times...? Looping 25 times instead.")
|
||||
end = 25
|
||||
}
|
||||
GameWorld.Pulser.submit(object : Pulse(3, player) {
|
||||
World.Pulser.submit(object : Pulse(3, player) {
|
||||
var id = start
|
||||
override fun pulse(): Boolean {
|
||||
player.animate(Animation.create(id))
|
||||
|
||||
@@ -7,14 +7,14 @@ import rs09.game.ai.general.GeneralBotCreator
|
||||
import rs09.game.ai.general.scriptrepository.PlayerScripts
|
||||
import rs09.game.ai.general.scriptrepository.Script
|
||||
import rs09.game.system.command.Command
|
||||
import rs09.game.world.GameWorld
|
||||
import rs09.game.world.World
|
||||
import rs09.tools.stringtools.colorize
|
||||
|
||||
@Initializable
|
||||
class BottingCommandSet : CommandSet(Command.Privilege.STANDARD) {
|
||||
override fun defineCommands() {
|
||||
define("scripts"){player, _ ->
|
||||
if(GameWorld.settings?.enabled_botting != true){
|
||||
if(World.settings?.enabled_botting != true){
|
||||
player.sendChat("I just tried to do something silly!")
|
||||
return@define
|
||||
}
|
||||
@@ -39,7 +39,7 @@ class BottingCommandSet : CommandSet(Command.Privilege.STANDARD) {
|
||||
player.interfaceManager.open(Component(Components.QUESTJOURNAL_SCROLL_275))
|
||||
}
|
||||
define("script"){player,args ->
|
||||
if(GameWorld.settings?.enabled_botting != true){
|
||||
if(World.settings?.enabled_botting != true){
|
||||
player.sendChat("I just tried to do something very silly!")
|
||||
return@define
|
||||
}
|
||||
|
||||
@@ -10,10 +10,9 @@ import core.game.world.map.RegionManager
|
||||
import core.game.world.update.flag.context.Animation
|
||||
import core.plugin.Initializable
|
||||
import rs09.game.content.dialogue.DialogueFile
|
||||
import rs09.game.interaction.InteractionListeners
|
||||
import rs09.game.interaction.SpadeDigListener
|
||||
import rs09.game.system.command.Command
|
||||
import rs09.game.world.GameWorld
|
||||
import rs09.game.world.World
|
||||
import rs09.tools.END_DIALOGUE
|
||||
import java.util.*
|
||||
|
||||
@@ -106,7 +105,7 @@ class FunCommandSet : CommandSet(Command.Privilege.ADMIN) {
|
||||
player.appearance.rideCart(boneMode)
|
||||
if (player.appearance.isRidingMinecart) {
|
||||
var i = 0
|
||||
GameWorld.Pulser.submit(object : Pulse(1, player) {
|
||||
World.Pulser.submit(object : Pulse(1, player) {
|
||||
override fun pulse(): Boolean {
|
||||
if (i++ % 12 == 0) player.sendChat("I want to get off Mr. Bones Wild Ride.")
|
||||
player.moveStep()
|
||||
|
||||
@@ -4,7 +4,7 @@ import core.game.node.entity.player.Player
|
||||
import core.game.node.entity.player.info.Rights
|
||||
import rs09.game.system.command.Command
|
||||
import core.game.system.task.Pulse
|
||||
import rs09.game.world.GameWorld
|
||||
import rs09.game.world.World
|
||||
import core.game.world.map.Location
|
||||
import rs09.game.world.repository.Repository
|
||||
import core.plugin.Initializable
|
||||
@@ -66,7 +66,7 @@ class ModerationCommandSet : CommandSet(Command.Privilege.MODERATOR){
|
||||
|
||||
notify(player, "Jailing ${otherPlayer!!.username} for $timeSeconds seconds.")
|
||||
notify(otherPlayer, "${player.username} has jailed you for $timeSeconds seconds.")
|
||||
GameWorld.Pulser.submit(object : Pulse(3){
|
||||
World.Pulser.submit(object : Pulse(3){
|
||||
val originalLoc = otherPlayer.location
|
||||
val releaseTime = System.currentTimeMillis() + TimeUnit.SECONDS.toMillis(timeSeconds.toLong())
|
||||
override fun pulse(): Boolean {
|
||||
|
||||
@@ -10,7 +10,7 @@ import org.json.simple.JSONObject
|
||||
import org.json.simple.parser.JSONParser
|
||||
import rs09.ServerConstants
|
||||
import rs09.game.system.SystemLogger
|
||||
import rs09.game.world.GameWorld
|
||||
import rs09.game.world.World
|
||||
import rs09.game.world.repository.Repository
|
||||
import java.io.FileReader
|
||||
import java.nio.ByteBuffer
|
||||
@@ -86,7 +86,7 @@ class GroundSpawnLoader {
|
||||
}
|
||||
|
||||
override fun respawn() {
|
||||
GameWorld.Pulser.submit(object : Pulse(respawnDuration) {
|
||||
World.Pulser.submit(object : Pulse(respawnDuration) {
|
||||
override fun pulse(): Boolean {
|
||||
GroundItemManager.create(this@GroundSpawn)
|
||||
return true
|
||||
|
||||
@@ -2,13 +2,11 @@ package rs09.game.system.config
|
||||
|
||||
import com.moandjiezana.toml.Toml
|
||||
import core.game.world.map.Location
|
||||
import core.tools.StringUtils
|
||||
import core.tools.mysql.Database
|
||||
import rs09.JSONUtils.Companion.parsePath
|
||||
import rs09.ServerConstants
|
||||
import rs09.game.system.SystemLogger
|
||||
import rs09.game.world.GameSettings
|
||||
import rs09.game.world.GameWorld
|
||||
import rs09.game.world.WorldSettings
|
||||
import rs09.game.world.World
|
||||
import java.io.File
|
||||
import kotlin.system.exitProcess
|
||||
|
||||
@@ -29,8 +27,8 @@ object ServerConfigParser {
|
||||
} else {
|
||||
try {
|
||||
tomlData = Toml().read(confFile)
|
||||
parseGameSettings()
|
||||
parseServerSettings()
|
||||
parseGameSettings()
|
||||
} catch (e: java.lang.IllegalStateException) {
|
||||
SystemLogger.logErr("Passed config file is not a TOML file. Path: ${confFile!!.canonicalPath}")
|
||||
SystemLogger.logErr("Exception received: $e")
|
||||
@@ -44,7 +42,7 @@ object ServerConfigParser {
|
||||
tomlData ?: return
|
||||
val data = tomlData!!
|
||||
|
||||
GameWorld.settings = GameSettings(
|
||||
World.settings = WorldSettings(
|
||||
name = ServerConstants.SERVER_NAME,
|
||||
isBeta = data.getBoolean("world.debug"),
|
||||
isDevMode = data.getBoolean("world.dev"),
|
||||
@@ -98,6 +96,7 @@ object ServerConfigParser {
|
||||
ServerConstants.HOME_LOCATION = parseLocation(data.getString("world.home_location"))
|
||||
ServerConstants.START_LOCATION = parseLocation(data.getString("world.new_player_location"))
|
||||
ServerConstants.DAILY_RESTART = data.getBoolean("world.daily_restart")
|
||||
ServerConstants.ALLOW_GUI = data.getBoolean("world.start_gui")
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -1,185 +0,0 @@
|
||||
package rs09.game.world
|
||||
|
||||
import core.cache.Cache
|
||||
import core.cache.def.impl.SceneryDefinition
|
||||
import core.game.ge.GrandExchangeDatabase
|
||||
import core.game.node.entity.npc.drop.RareDropTable
|
||||
import core.game.node.entity.player.Player
|
||||
import core.game.system.SystemManager
|
||||
import core.game.system.SystemState
|
||||
import core.game.system.task.Pulse
|
||||
import core.game.system.task.TaskExecutor
|
||||
import core.game.world.map.Location
|
||||
import core.game.world.map.RegionManager
|
||||
import core.plugin.CorePluginTypes.StartupPlugin
|
||||
import core.tools.RandomFunction
|
||||
import core.tools.mysql.DatabaseManager
|
||||
import rs09.game.ai.general.scriptrepository.PlayerScripts
|
||||
import rs09.ServerConstants
|
||||
import rs09.game.node.entity.state.newsys.StateRepository
|
||||
import rs09.game.system.SystemLogger
|
||||
import rs09.game.system.SystemLogger.logInfo
|
||||
import rs09.game.system.config.ConfigParser
|
||||
import rs09.game.world.callback.CallbackHub
|
||||
import rs09.game.world.repository.Repository
|
||||
import rs09.plugin.PluginManager
|
||||
import rs09.worker.MajorUpdateWorker
|
||||
import java.text.SimpleDateFormat
|
||||
import java.util.*
|
||||
import java.util.function.Consumer
|
||||
|
||||
/**
|
||||
* Represents the game world.
|
||||
* @author Ceikry
|
||||
*/
|
||||
object GameWorld {
|
||||
|
||||
/**
|
||||
* The major update worker.
|
||||
*/
|
||||
@JvmStatic
|
||||
val majorUpdateWorker = MajorUpdateWorker()
|
||||
|
||||
@JvmStatic
|
||||
val STARTUP_PLUGINS: List<StartupPlugin> = ArrayList()
|
||||
private val configParser = ConfigParser()
|
||||
@JvmStatic
|
||||
var PCBotsSpawned = false
|
||||
@JvmStatic
|
||||
var PCnBotsSpawned = false
|
||||
@JvmStatic
|
||||
var PCiBotsSpawned = false
|
||||
/**
|
||||
* The game settings to use.
|
||||
*/
|
||||
@JvmStatic
|
||||
var settings: GameSettings? = null
|
||||
/**
|
||||
* The current amount of (600ms) cycles elapsed.
|
||||
*/
|
||||
@JvmStatic
|
||||
var ticks = 0
|
||||
@JvmStatic
|
||||
var databaseManager: DatabaseManager? = null
|
||||
private set
|
||||
|
||||
@JvmStatic
|
||||
var Pulser = PulseRunner()
|
||||
|
||||
/**
|
||||
* Submits a pulse.
|
||||
*
|
||||
* @param pulse the pulse.
|
||||
*/
|
||||
@Deprecated("", ReplaceWith("Pulser.submit(pulse!!)", "core.game.world.GameWorld.Pulser"))
|
||||
fun submit(pulse: Pulse?) {
|
||||
Pulser.submit(pulse!!)
|
||||
}
|
||||
|
||||
fun pulse() {
|
||||
ticks++
|
||||
if (ticks % 50 == 0) {
|
||||
TaskExecutor.execute {
|
||||
val player = Repository.players
|
||||
try {
|
||||
player.stream().filter { obj: Player? -> Objects.nonNull(obj) }.filter { p: Player -> !p.isArtificial && p.isPlaying }.forEach { p: Player? -> Repository.disconnectionQueue.save(p!!, false) }
|
||||
} catch (t: Throwable) {
|
||||
t.printStackTrace()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun checkDay(): Int {
|
||||
val weeklySdf = SimpleDateFormat("u")
|
||||
return weeklySdf.format(Date()).toInt()
|
||||
}
|
||||
|
||||
/**
|
||||
* Prompts the [GameWorld] to begin it's initialization.
|
||||
*
|
||||
* @param directory the directory to the properties.
|
||||
* @throws Throwable when the exception occurs.
|
||||
*/
|
||||
@Throws(Throwable::class)
|
||||
fun prompt(directory: String?) {
|
||||
prompt(true, directory)
|
||||
}
|
||||
|
||||
/**
|
||||
* Prompts the game world.
|
||||
*
|
||||
* @param running if running.
|
||||
* @throws Throwable the throwable.
|
||||
*/
|
||||
@Throws(Throwable::class)
|
||||
@JvmStatic
|
||||
fun prompt(running: Boolean) {
|
||||
prompt(running, "server.properties")
|
||||
}
|
||||
|
||||
/**
|
||||
* Prompts the [GameWorld] to begin its initialization.
|
||||
*
|
||||
* @param run If the server should be running.
|
||||
* @param directory the path to the dir.
|
||||
* @throws Throwable When an exception occurs.
|
||||
*/
|
||||
@Throws(Throwable::class)
|
||||
fun prompt(run: Boolean, directory: String?){
|
||||
SystemLogger.logInfo("Prompting ${settings?.name} Game World...")
|
||||
Cache.init(ServerConstants.CACHE_PATH)
|
||||
databaseManager = DatabaseManager(ServerConstants.DATABASE)
|
||||
databaseManager!!.connect()
|
||||
GrandExchangeDatabase.init()
|
||||
configParser.prePlugin()
|
||||
PluginManager.init()
|
||||
configParser.postPlugin()
|
||||
RareDropTable.init()
|
||||
logInfo("Initialized Rare Drop Table from " + ServerConstants.RDT_DATA_PATH)
|
||||
if (settings!!.enable_bots) {
|
||||
ImmerseWorld.init()
|
||||
}
|
||||
CallbackHub.call()
|
||||
STARTUP_PLUGINS.forEach(Consumer { plugin: StartupPlugin? ->
|
||||
plugin?.run()
|
||||
})
|
||||
if (run) {
|
||||
SystemManager.flag(if (settings?.isDevMode == true) SystemState.PRIVATE else SystemState.ACTIVE)
|
||||
}
|
||||
SceneryDefinition.getDefinitions().values.forEach(Consumer { obj: SceneryDefinition -> obj.examine })
|
||||
System.gc()
|
||||
PlayerScripts.init()
|
||||
StateRepository.init()
|
||||
SystemLogger.initTradeLogger()
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when the server shuts down.
|
||||
*
|
||||
* @throws Throwable When an exception occurs.
|
||||
*/
|
||||
@Throws(Throwable::class)
|
||||
fun shutdown() {
|
||||
SystemManager.flag(SystemState.TERMINATED)
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if its the economy world.
|
||||
*
|
||||
* @return `True` if so.
|
||||
*/
|
||||
@JvmStatic
|
||||
val isEconomyWorld: Boolean
|
||||
get() = false
|
||||
|
||||
private fun generateLocation(): Location {
|
||||
val random_location = Location(3075 + RandomFunction.random(-15, 15), 3954 + RandomFunction.random(-15, 15), 0)
|
||||
if (!RegionManager.isTeleportPermitted(random_location)) {
|
||||
return generateLocation()
|
||||
}
|
||||
return if (RegionManager.getObject(random_location) != null) {
|
||||
generateLocation()
|
||||
} else random_location
|
||||
}
|
||||
}
|
||||
@@ -27,7 +27,7 @@ object ImmerseWorld {
|
||||
}
|
||||
fun immerseAdventurer(){
|
||||
val lumbridge = Location.create(3221, 3219, 0)
|
||||
for(i in (0..(GameWorld.settings?.max_adv_bots ?: 50))){
|
||||
for(i in (0..(World.settings?.max_adv_bots ?: 50))){
|
||||
GeneralBotCreator(Adventurer(CombatStyle.MELEE), assembler.MeleeAdventurer(CombatBotAssembler.Tier.LOW,lumbridge))
|
||||
GeneralBotCreator(Adventurer(CombatStyle.MELEE), assembler.MeleeAdventurer(CombatBotAssembler.Tier.MED,lumbridge))
|
||||
GeneralBotCreator(Adventurer(CombatStyle.RANGE), assembler.RangeAdventurer(CombatBotAssembler.Tier.MED,lumbridge))
|
||||
|
||||
@@ -0,0 +1,155 @@
|
||||
package rs09.game.world
|
||||
|
||||
import api.ContentAPI
|
||||
import core.cache.Cache
|
||||
import core.cache.def.impl.SceneryDefinition
|
||||
import core.game.ge.GrandExchangeDatabase
|
||||
import core.game.node.entity.npc.drop.RareDropTable
|
||||
import core.game.node.entity.player.Player
|
||||
import core.game.system.SystemManager
|
||||
import core.game.system.SystemState
|
||||
import core.game.system.task.Pulse
|
||||
import core.game.system.task.TaskExecutor
|
||||
import core.game.world.map.Location
|
||||
import core.game.world.map.RegionManager
|
||||
import core.plugin.CorePluginTypes.Managers
|
||||
import core.plugin.CorePluginTypes.StartupPlugin
|
||||
import core.tools.RandomFunction
|
||||
import core.tools.mysql.DatabaseManager
|
||||
import kotlinx.coroutines.GlobalScope
|
||||
import kotlinx.coroutines.launch
|
||||
import rs09.Server
|
||||
import rs09.game.ai.general.scriptrepository.PlayerScripts
|
||||
import rs09.ServerConstants
|
||||
import rs09.ServerStore
|
||||
import rs09.game.ai.general.GeneralBotCreator
|
||||
import rs09.game.node.entity.state.newsys.StateRepository
|
||||
import rs09.game.system.SystemLogger
|
||||
import rs09.game.system.SystemLogger.logInfo
|
||||
import rs09.game.system.config.ConfigParser
|
||||
import rs09.game.world.callback.CallbackHub
|
||||
import rs09.game.world.repository.Repository
|
||||
import rs09.game.world.update.UpdateSequence
|
||||
import rs09.net.packet.PacketWriteQueue
|
||||
import rs09.plugin.PluginManager
|
||||
import rs09.tools.stringtools.colorize
|
||||
import rs09.worker.WorldClock
|
||||
import java.text.SimpleDateFormat
|
||||
import java.util.*
|
||||
import java.util.function.Consumer
|
||||
import kotlin.system.exitProcess
|
||||
|
||||
/**
|
||||
* Represents the game world.
|
||||
* @author Ceikry
|
||||
*/
|
||||
object World {
|
||||
@JvmStatic
|
||||
val clock = WorldClock()
|
||||
|
||||
@JvmStatic
|
||||
val STARTUP_PLUGINS: List<StartupPlugin> = ArrayList()
|
||||
|
||||
@JvmStatic
|
||||
var PCnBotsSpawned = false
|
||||
|
||||
@JvmStatic
|
||||
var PCiBotsSpawned = false
|
||||
|
||||
@JvmStatic
|
||||
var settings: WorldSettings? = null
|
||||
|
||||
@JvmStatic
|
||||
var ticks = 0
|
||||
|
||||
@JvmStatic
|
||||
var databaseManager: DatabaseManager? = null
|
||||
private set
|
||||
|
||||
val sequence = UpdateSequence()
|
||||
|
||||
@JvmStatic
|
||||
var Pulser = PulseRunner()
|
||||
|
||||
/**
|
||||
* Submits a pulse.
|
||||
*
|
||||
* @param pulse the pulse.
|
||||
*/
|
||||
@Deprecated("", ReplaceWith("Pulser.submit(pulse!!)", "core.game.world.GameWorld.Pulser"))
|
||||
fun submit(pulse: Pulse?) {
|
||||
Pulser.submit(pulse!!)
|
||||
}
|
||||
|
||||
fun tick() {
|
||||
ticks++
|
||||
if (ticks % 50 == 0) {
|
||||
TaskExecutor.execute {
|
||||
val player = Repository.players
|
||||
try {
|
||||
player.stream().filter { obj: Player? -> Objects.nonNull(obj) }.filter { p: Player -> !p.isArtificial && p.isPlaying }.forEach { p: Player? -> Repository.disconnectionQueue.save(p!!, false) }
|
||||
} catch (t: Throwable) {
|
||||
t.printStackTrace()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
val rmlist = ArrayList<Pulse>()
|
||||
val list = ArrayList(Pulser.TASKS)
|
||||
|
||||
//run our pulses
|
||||
for(pulse in list) {
|
||||
val b = System.currentTimeMillis()
|
||||
if (pulse == null || pulse.update()) rmlist.add(pulse)
|
||||
|
||||
val time = System.currentTimeMillis() - b
|
||||
|
||||
if(time >= 100){
|
||||
if(pulse is GeneralBotCreator.BotScriptPulse){
|
||||
SystemLogger.logWarn("CRITICALLY Long Botscript Tick: ${pulse.botScript.javaClass.name} - $time ms")
|
||||
} else {
|
||||
SystemLogger.logWarn("CRITICALLY long running pulse: ${pulse.javaClass.name} - $time ms")
|
||||
}
|
||||
}
|
||||
else if(time >= 30){
|
||||
if(pulse is GeneralBotCreator.BotScriptPulse){
|
||||
SystemLogger.logWarn("Long Botscript Tick: ${pulse.botScript.javaClass.name} - $time ms")
|
||||
} else {
|
||||
SystemLogger.logWarn("Long Running Pulse: ${pulse.javaClass.name} - $time ms")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//remove all null or finished pulses from the list
|
||||
rmlist.forEach {
|
||||
if(Pulser.TASKS.contains(it)) World.Pulser.TASKS.remove(it)
|
||||
}
|
||||
|
||||
rmlist.clear()
|
||||
//perform our update sequence where we write masks, etc
|
||||
try {
|
||||
sequence.start()
|
||||
sequence.run()
|
||||
sequence.end()
|
||||
GlobalScope.launch {
|
||||
PacketWriteQueue.flush()
|
||||
}
|
||||
} catch (e: Exception){
|
||||
e.printStackTrace()
|
||||
}
|
||||
//disconnect all players waiting to be disconnected
|
||||
Repository.disconnectionQueue.update()
|
||||
//tick all manager plugins
|
||||
Managers.tick()
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if its the economy world.
|
||||
*
|
||||
* @return `True` if so.
|
||||
*/
|
||||
@JvmStatic
|
||||
val isEconomyWorld: Boolean
|
||||
get() = false
|
||||
|
||||
}
|
||||
+3
-3
@@ -9,7 +9,7 @@ import java.util.*
|
||||
* Represents the game settings used for this game instance.
|
||||
* @author Vexia
|
||||
*/
|
||||
class GameSettings
|
||||
class WorldSettings
|
||||
/**
|
||||
* Constructs a new `GameSettings` `Object`.
|
||||
* @param name the name.
|
||||
@@ -112,7 +112,7 @@ class GameSettings
|
||||
* @return the settings object.
|
||||
* @author Ceikry
|
||||
*/
|
||||
fun parse(data: JSONObject): GameSettings? {
|
||||
fun parse(data: JSONObject): WorldSettings? {
|
||||
val name = ServerConstants.SERVER_NAME
|
||||
val debug = data["debug"] as Boolean
|
||||
val dev = data["dev"] as Boolean
|
||||
@@ -135,7 +135,7 @@ class GameSettings
|
||||
val allow_token_purchase = data["allow_token_purchase"] as Boolean
|
||||
val message_of_the_week_identifier = data["message_of_the_week_identifier"].toString().toInt()
|
||||
val message_of_the_week_text = data["message_of_the_week_text"].toString()
|
||||
return GameSettings(
|
||||
return WorldSettings(
|
||||
name,
|
||||
debug,
|
||||
dev,
|
||||
@@ -16,7 +16,6 @@ object CallbackHub {
|
||||
private var calls: MutableList<CallBack> = ArrayList()
|
||||
|
||||
fun call(): Boolean {
|
||||
calls.add(ZoneBuilder())
|
||||
calls.add(GrandExchange)
|
||||
calls.add(ImpetuousImpulses())
|
||||
for (call in calls) {
|
||||
|
||||
@@ -4,7 +4,7 @@ import core.game.node.entity.player.Player
|
||||
import core.game.node.entity.player.info.login.PlayerParser
|
||||
import core.game.system.task.TaskExecutor
|
||||
import rs09.game.system.SystemLogger
|
||||
import rs09.game.world.GameWorld
|
||||
import rs09.game.world.World
|
||||
import java.util.*
|
||||
import java.util.concurrent.ConcurrentHashMap
|
||||
|
||||
@@ -22,7 +22,7 @@ class DisconnectionQueue {
|
||||
* Updates all entries.
|
||||
*/
|
||||
fun update() {
|
||||
if (queue.isEmpty() || GameWorld.ticks % 3 != 0 && GameWorld.settings?.isDevMode != true) {
|
||||
if (queue.isEmpty() || World.ticks % 3 != 0 && World.settings?.isDevMode != true) {
|
||||
return
|
||||
}
|
||||
//make a copy of current entries as to avoid concurrency exceptions
|
||||
@@ -183,7 +183,7 @@ class DisconnectionQueue {
|
||||
* @param clear If the player should be cleared.
|
||||
*/
|
||||
init {
|
||||
timeStamp = GameWorld.ticks
|
||||
timeStamp = World.ticks
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@ import core.game.node.entity.player.Player
|
||||
import core.game.world.map.RegionManager
|
||||
import core.net.packet.IoBuffer
|
||||
import core.net.packet.PacketHeader
|
||||
import rs09.game.world.GameWorld
|
||||
import rs09.game.world.World
|
||||
import java.nio.ByteBuffer
|
||||
import java.util.*
|
||||
|
||||
@@ -72,7 +72,7 @@ object NPCRenderer {
|
||||
buffer.putBits(14, npc.id)
|
||||
buffer.putBits(5, offsetX)
|
||||
if (npc.aggressiveHandler != null) {
|
||||
npc.aggressiveHandler.playerTolerance[player.index] = GameWorld.ticks
|
||||
npc.aggressiveHandler.playerTolerance[player.index] = World.ticks
|
||||
}
|
||||
localNPCs.add(npc)
|
||||
}
|
||||
|
||||
@@ -14,12 +14,12 @@ import core.game.system.task.TaskExecutor
|
||||
import core.net.Constants
|
||||
import core.net.IoReadEvent
|
||||
import core.net.IoSession
|
||||
import core.net.amsc.WorldCommunicator
|
||||
import core.tools.StringUtils
|
||||
import rs09.ServerConstants
|
||||
import rs09.game.node.entity.player.info.login.LoginParser
|
||||
import rs09.game.system.SystemLogger
|
||||
import rs09.game.world.repository.Repository
|
||||
import rs09.net.ms.ManagementServer
|
||||
import java.lang.Runnable
|
||||
import java.math.BigInteger
|
||||
import java.nio.ByteBuffer
|
||||
@@ -136,11 +136,7 @@ class LoginReadEvent
|
||||
val parser = LoginParser(details, LoginType.fromType(opcode))
|
||||
details.session = session
|
||||
details.info.translate(UIDInfo(details.ipAddress, ByteBufferUtils.getString(buffer), ByteBufferUtils.getString(buffer), ByteBufferUtils.getString(buffer)))
|
||||
if (WorldCommunicator.isEnabled()) {
|
||||
WorldCommunicator.register(parser)
|
||||
} else {
|
||||
TaskExecutor.executeSQL {parser.run()}
|
||||
}
|
||||
ManagementServer.attemptLogin(parser)
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -0,0 +1,177 @@
|
||||
package rs09.net.ms
|
||||
|
||||
import core.game.node.entity.player.info.login.Response
|
||||
import core.net.IoEventHandler
|
||||
import core.net.IoSession
|
||||
import core.net.ServerSocketConnection
|
||||
import core.net.ms.MSPacketRepository
|
||||
import core.net.producer.MSHSEventProducer
|
||||
import kotlinx.coroutines.GlobalScope
|
||||
import kotlinx.coroutines.launch
|
||||
import rs09.game.node.entity.player.info.login.LoginParser
|
||||
import rs09.game.system.SystemLogger
|
||||
import rs09.game.world.World
|
||||
import java.net.InetSocketAddress
|
||||
import java.nio.channels.SelectionKey
|
||||
import java.nio.channels.Selector
|
||||
import java.nio.channels.SocketChannel
|
||||
import java.util.concurrent.Executors
|
||||
import kotlin.Exception
|
||||
import kotlin.system.exitProcess
|
||||
|
||||
/**
|
||||
* Server-side model of the management server.
|
||||
* Responsible for connecting to and processing interactions with the MS.
|
||||
* @author Ceikry
|
||||
*/
|
||||
object ManagementServer {
|
||||
val service = Executors.newSingleThreadExecutor()
|
||||
val eventHandler = IoEventHandler(service)
|
||||
var channel: ServerSocketConnection? = null
|
||||
|
||||
@JvmField
|
||||
var session: IoSession? = null
|
||||
|
||||
@JvmField
|
||||
val handshakeProducer = MSHSEventProducer()
|
||||
|
||||
private val loginAttempts = HashMap<String,LoginParser>()
|
||||
|
||||
/**
|
||||
* The current state of our connection with the management server.
|
||||
* In DISCONNECTED state, we are not communicating with the MS at all.
|
||||
* In CONNECTED state, we have made connection with the MS and are sending and receiving info.
|
||||
* In CONNECTING state, we are attempting to form a connection with the MS and are not yet sending or receiving data.
|
||||
*/
|
||||
var state = ManagementState.CONNECTING
|
||||
@JvmStatic
|
||||
set(value) {
|
||||
if(value != ManagementState.DISCONNECTED && (field == ManagementState.DISCONNECTED || field == ManagementState.DISCONNECTING)){
|
||||
return
|
||||
}
|
||||
field = value
|
||||
if(channel != null) channel!!.selector.wakeup()
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
fun attemptLogin(parser: LoginParser){
|
||||
if(state == ManagementState.DISCONNECTED){
|
||||
parser.details.session!!.write(Response.LOGIN_SERVER_OFFLINE, true)
|
||||
return
|
||||
}
|
||||
|
||||
val lastAttempt = loginAttempts[parser.details.username]?.timeStamp ?: -50
|
||||
|
||||
if(World.ticks - lastAttempt < 50){
|
||||
SystemLogger.logAlert("User tried to log in too frequently: ${parser.details.username}")
|
||||
parser.details.session!!.write(Response.ALREADY_ONLINE, true)
|
||||
return
|
||||
}
|
||||
|
||||
loginAttempts[parser.details.username] = parser
|
||||
|
||||
GlobalScope.launch {
|
||||
if(!parser.details.parse()){
|
||||
parser.details.session!!.write(Response.LOGIN_SERVER_OFFLINE, true)
|
||||
return@launch
|
||||
}
|
||||
MSPacketRepository.sendPlayerRegistry(parser)
|
||||
}
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
fun finishLoginAttempt(username: String): LoginParser? {
|
||||
return loginAttempts.remove(username)
|
||||
}
|
||||
|
||||
fun connect() {
|
||||
SystemLogger.logInfo("[MS] Sending world registration request")
|
||||
Thread {
|
||||
while(state != ManagementState.DISCONNECTED){
|
||||
when(state){
|
||||
|
||||
ManagementState.CONNECTING, ManagementState.CONNECTED -> {
|
||||
if(session == null || this.channel == null) {
|
||||
val selector = Selector.open()
|
||||
val channel = SocketChannel.open()
|
||||
channel.configureBlocking(false)
|
||||
channel.socket().keepAlive = true
|
||||
channel.socket().tcpNoDelay = true
|
||||
channel.connect(InetSocketAddress(World.settings!!.msAddress, 5555))
|
||||
channel.register(selector, SelectionKey.OP_CONNECT)
|
||||
this.channel = ServerSocketConnection(selector, channel)
|
||||
}
|
||||
|
||||
try {
|
||||
channel!!.selector.select() //Await a connection response
|
||||
} catch (e: Exception) {e.printStackTrace()}
|
||||
|
||||
val keyIterator = channel!!.selector.selectedKeys().iterator()
|
||||
while(keyIterator.hasNext()){
|
||||
val key = keyIterator.next()
|
||||
keyIterator.remove()
|
||||
try {
|
||||
if(!key.isValid || !key.channel().isOpen){
|
||||
key.cancel()
|
||||
continue
|
||||
}
|
||||
|
||||
if(key.isConnectable && state == ManagementState.CONNECTING){
|
||||
val ch = key.channel() as SocketChannel
|
||||
if(ch.finishConnect()){
|
||||
key.interestOps(key.interestOps() xor SelectionKey.OP_CONNECT)
|
||||
key.interestOps(key.interestOps() or SelectionKey.OP_READ)
|
||||
session = IoSession(key, service)
|
||||
key.attach(session)
|
||||
session!!.producer = handshakeProducer
|
||||
session!!.write(true)
|
||||
}
|
||||
}
|
||||
|
||||
if(key.isReadable) eventHandler.read(key)
|
||||
if(key.isWritable) eventHandler.write(key)
|
||||
} catch (e: Exception){
|
||||
key.cancel()
|
||||
if(session != null){
|
||||
session!!.disconnect()
|
||||
state = ManagementState.DISCONNECTED
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ManagementState.DISCONNECTING -> {
|
||||
if(session != null) session!!.disconnect()
|
||||
if(channel != null) channel!!.socket.close()
|
||||
state = ManagementState.DISCONNECTED
|
||||
}
|
||||
|
||||
ManagementState.DISCONNECTED -> {}
|
||||
}
|
||||
}
|
||||
}.start()
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
fun flagConnected(){
|
||||
state = ManagementState.CONNECTED
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
fun flagCantConnect(){
|
||||
exitProcess(0)
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
fun disconnect() {
|
||||
state = ManagementState.DISCONNECTING
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
fun getStateValue(): Int {
|
||||
return when(state){
|
||||
ManagementState.CONNECTING -> 1
|
||||
else -> 2
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
package rs09.net.ms
|
||||
|
||||
enum class ManagementState {
|
||||
CONNECTING,
|
||||
CONNECTED,
|
||||
DISCONNECTING,
|
||||
DISCONNECTED
|
||||
}
|
||||
@@ -5,7 +5,7 @@ import core.net.packet.IncomingPacket
|
||||
import core.net.packet.IoBuffer
|
||||
import rs09.game.interaction.QCRepository
|
||||
import rs09.game.system.SystemLogger
|
||||
import rs09.game.world.GameWorld
|
||||
import rs09.game.world.World
|
||||
|
||||
/**
|
||||
* Decodes the quick chat packet
|
||||
@@ -56,7 +56,7 @@ class QuickChatPacketHandler : IncomingPacket {
|
||||
|
||||
//Prints the values of each byte in the buffer to server log
|
||||
//If the world is in dev mode
|
||||
if(GameWorld.settings?.isDevMode == true) {
|
||||
if(World.settings?.isDevMode == true) {
|
||||
SystemLogger.logInfo("Begin QuickChat Packet Buffer Dump---------")
|
||||
SystemLogger.logInfo("Packet Type: ${packetType.name} Chat Type: ${if(forClan) "Clan" else "Public"}")
|
||||
x?.array()?.forEach {
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user