diff --git a/Server/src/main/java/core/game/interaction/item/withobject/PoisonFountainPlugin.java b/Server/src/main/java/core/game/interaction/item/withobject/PoisonFountainPlugin.java deleted file mode 100644 index 6307f16b6..000000000 --- a/Server/src/main/java/core/game/interaction/item/withobject/PoisonFountainPlugin.java +++ /dev/null @@ -1,77 +0,0 @@ -package core.game.interaction.item.withobject; - -import core.game.interaction.NodeUsageEvent; -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 core.game.world.update.flag.context.Animation; -import core.plugin.Initializable; -import core.plugin.Plugin; - -/** - * Represents the poison fountain plugin. - * @author 'Vexia - * @date 24/12/2013 - */ -@Initializable -public class PoisonFountainPlugin extends UseWithHandler { - - /** - * Represents the searching animation. - */ - private static final Animation SEARCH_ANIM = new Animation(881); - - /** - * Represents the poisoned fish food. - */ - private static final Item POISONED_FOOD = new Item(274); - - /** - * Constructs a new {@code PoisonFountainPlugin} {@code Object}. - */ - public PoisonFountainPlugin() { - super(274); - } - - @Override - public Plugin newInstance(Object arg) throws Throwable { - addHandler(153, OBJECT_TYPE, this); - return this; - } - - @Override - public boolean handle(NodeUsageEvent event) { - final Player player = event.getPlayer(); - if (player.getAttribute("piranhas-killed", false)) { - player.getPacketDispatch().sendMessage("The piranhas are dead already."); - return true; - } - if (player.getInventory().remove(POISONED_FOOD)) { - player.lock(); - player.setAttribute("/save:piranhas-killed", true); - player.animate(SEARCH_ANIM); - player.getPacketDispatch().sendMessage("You pour the poisoned fish food into the fountain."); - GameWorld.getPulser().submit(new Pulse(1) { - int counter = 0; - - @Override - public boolean pulse() { - switch (counter++) { - case 1: - player.getPacketDispatch().sendMessage("The piranhas start eating the food..."); - break; - case 2: - player.getPacketDispatch().sendMessage("... then die and float to the surface."); - player.unlock(); - return true; - } - return false; - } - }); - } - return true; - } - -} diff --git a/Server/src/main/kotlin/rs09/game/interaction/item/withobject/PoisonFountainListener.kt b/Server/src/main/kotlin/rs09/game/interaction/item/withobject/PoisonFountainListener.kt new file mode 100644 index 000000000..7db72a5eb --- /dev/null +++ b/Server/src/main/kotlin/rs09/game/interaction/item/withobject/PoisonFountainListener.kt @@ -0,0 +1,57 @@ +package rs09.game.interaction.item.withobject + +import api.* +import core.game.system.task.Pulse +import core.game.world.update.flag.context.Animation +import org.rs09.consts.Items +import org.rs09.consts.Scenery +import rs09.game.interaction.IntType +import rs09.game.interaction.InteractionListener +import rs09.game.world.GameWorld.Pulser + +/** + * Listener for using poisoned fish food on Draynor Manor fountain + * @author Byte + */ +@Suppress("unused") +class PoisonFountainListener : InteractionListener { + + companion object { + private val ANIMATION = Animation(881) + } + + override fun defineListeners() { + onUseWith(IntType.SCENERY, Items.POISONED_FISH_FOOD_274, Scenery.FOUNTAIN_153) { player, used, _ -> + if (getAttribute(player, "piranhas-killed", false)) { + sendMessage(player, "The piranhas are dead already.") + return@onUseWith true + } + + if (!removeItem(player, used)) { + return@onUseWith false + } + + lock(player, 5) + animate(player, ANIMATION) + sendMessage(player, "You pour the poisoned fish food into the fountain.") + setAttribute(player, "/save:piranhas-killed", true) + + submitIndividualPulse(player, object : Pulse(1) { + var counter = 0 + override fun pulse(): Boolean { + when (counter++) { + 1 -> sendMessage(player, "The piranhas start eating the food...") + 2 -> { + sendMessage(player, "... then die and float to the surface.") + unlock(player) + return true + } + } + return false + } + }) + + return@onUseWith true + } + } +}