diff --git a/Server/src/main/kotlin/rs09/game/content/global/action/EquipHandler.kt b/Server/src/main/kotlin/rs09/game/content/global/action/EquipHandler.kt index ab8c0a507..1fb84d975 100644 --- a/Server/src/main/kotlin/rs09/game/content/global/action/EquipHandler.kt +++ b/Server/src/main/kotlin/rs09/game/content/global/action/EquipHandler.kt @@ -1,15 +1,17 @@ package rs09.game.content.global.action import core.game.container.impl.EquipmentContainer +import core.game.node.Node import core.game.node.entity.combat.equipment.WeaponInterface 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.system.task.Pulse import core.game.world.map.zone.ZoneBorders import core.plugin.Plugin import rs09.game.interaction.OptionListener import rs09.game.system.config.ItemConfigParser -import rs09.game.world.GameWorld.ticks +import rs09.game.world.GameWorld import rs09.tools.Items /** @@ -22,49 +24,12 @@ class EquipHandler : OptionListener() { override fun defineListeners() { on(ITEM,"equip","wield","wear"){player,node -> - val item = node.asItem() - - if(item == null || player.inventory[item.slot] != item){ - return@on true - } - - val equipStateListener = item.definition.getConfiguration>("equipment", null) - if(equipStateListener != null){ - val bool = equipStateListener.fireEvent("equip",player,item) - if(bool != true){ - return@on true + GameWorld.Pulser.submit(object : Pulse(){ + override fun pulse(): Boolean { + handleEquip(player,node) + return true } - } - - val lock = player.locks.equipmentLock - if (lock != null && lock.isLocked) { - if (lock.message != null) { - player.packetDispatch.sendMessage(lock.message) - } - return@on true - } - player.setAttribute("equipLock:" + item.id, ticks + 2) - - if (player.equipment.add(item, item.slot, true, true)) { - //check if a brawling glove is being equipped and register it - if (item.id in 13845..13857) { - player.debug("Registering gloves... ID: " + item.id) - player.brawlingGlovesManager.registerGlove(item.id) - } - if (item.id == Items.BLACK_CHAINBODY_1107 && player.getAttribute("diary:falador:black-chain-bought", false) - && ZoneBorders(2969, 3310, 2975, 3314, 0).insideBorder(player) - ) { - player.achievementDiaryManager.finishTask(player, DiaryType.FALADOR, 0, 2) - } - player.dialogueInterpreter.close() - player.audioManager.send(item.definition.getConfiguration(ItemConfigParser.EQUIP_AUDIO, 2244)) - if (player.properties.autocastSpell != null) { - player.properties.autocastSpell = null - val wif = player.getExtension(WeaponInterface::class.java) - wif.selectAutoSpell(-1, true) - wif.openAutocastSelect() - } - } + }) return@on true } @@ -72,6 +37,51 @@ class EquipHandler : OptionListener() { } + fun handleEquip(player: Player,node: Node){ + val item = node.asItem() + + if(item == null || player.inventory[item.slot] != item){ + return + } + + val equipStateListener = item.definition.getConfiguration>("equipment", null) + if(equipStateListener != null){ + val bool = equipStateListener.fireEvent("equip",player,item) + if(bool != true){ + return + } + } + + val lock = player.locks.equipmentLock + if (lock != null && lock.isLocked) { + if (lock.message != null) { + player.packetDispatch.sendMessage(lock.message) + } + return + } + + if (player.equipment.add(item, item.slot, true, true)) { + //check if a brawling glove is being equipped and register it + if (item.id in 13845..13857) { + player.debug("Registering gloves... ID: " + item.id) + player.brawlingGlovesManager.registerGlove(item.id) + } + if (item.id == Items.BLACK_CHAINBODY_1107 && player.getAttribute("diary:falador:black-chain-bought", false) + && ZoneBorders(2969, 3310, 2975, 3314, 0).insideBorder(player) + ) { + player.achievementDiaryManager.finishTask(player, DiaryType.FALADOR, 0, 2) + } + player.dialogueInterpreter.close() + player.audioManager.send(item.definition.getConfiguration(ItemConfigParser.EQUIP_AUDIO, 2244)) + if (player.properties.autocastSpell != null) { + player.properties.autocastSpell = null + val wif = player.getExtension(WeaponInterface::class.java) + wif.selectAutoSpell(-1, true) + wif.openAutocastSelect() + } + } + } + companion object { /** * Unequips an item.