From c7ff6a147aaf38ab823dff779d1c42ba12823a65 Mon Sep 17 00:00:00 2001 From: Byte Date: Sat, 22 Oct 2022 04:50:16 +0000 Subject: [PATCH] Updated EctophialFill plugin to listener --- .../item/withobject/EctophialFillPlugin.java | 52 ------------------- .../item/withobject/EctophialFillListener.kt | 45 ++++++++++++++++ 2 files changed, 45 insertions(+), 52 deletions(-) delete mode 100644 Server/src/main/java/core/game/interaction/item/withobject/EctophialFillPlugin.java create mode 100644 Server/src/main/kotlin/rs09/game/interaction/item/withobject/EctophialFillListener.kt diff --git a/Server/src/main/java/core/game/interaction/item/withobject/EctophialFillPlugin.java b/Server/src/main/java/core/game/interaction/item/withobject/EctophialFillPlugin.java deleted file mode 100644 index 0cf49c711..000000000 --- a/Server/src/main/java/core/game/interaction/item/withobject/EctophialFillPlugin.java +++ /dev/null @@ -1,52 +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; - -/** - * Fills an ectophial. - * @author Vexia - */ -@Initializable -public class EctophialFillPlugin extends UseWithHandler { - - /** - * Constructs a new {@code EctophialFillPlugin} {@code Object} - */ - public EctophialFillPlugin() { - super(4252); - } - - @Override - public Plugin newInstance(Object arg) throws Throwable { - addHandler(5282, OBJECT_TYPE, this); - return this; - } - - @Override - public boolean handle(NodeUsageEvent event) { - final Player player = event.getPlayer(); - player.lock(3); - player.animate(Animation.create(1652)); - player.getAudioManager().send(1132); - GameWorld.getPulser().submit(new Pulse(3, player) { - @Override - public boolean pulse() { - if (player.getInventory().remove(new Item(4252))) { - player.getInventory().add(new Item(4251)); - } - player.sendMessage("You refill the ectophial from the Ectofuntus."); - return true; - } - }); - return true; - } - -} diff --git a/Server/src/main/kotlin/rs09/game/interaction/item/withobject/EctophialFillListener.kt b/Server/src/main/kotlin/rs09/game/interaction/item/withobject/EctophialFillListener.kt new file mode 100644 index 000000000..46b3ccfff --- /dev/null +++ b/Server/src/main/kotlin/rs09/game/interaction/item/withobject/EctophialFillListener.kt @@ -0,0 +1,45 @@ +package rs09.game.interaction.item.withobject + +import api.* +import core.game.node.entity.player.link.audio.Audio +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 + +/** + * Listener for filling empty ectophial + * @author Byte + */ +@Suppress("unused") +class EctophialFillListener : InteractionListener { + + companion object { + private val ANIMATION = Animation(1652) + private val AUDIO = Audio(1132) + } + + override fun defineListeners() { + onUseWith(IntType.SCENERY, Items.ECTOPHIAL_4252, Scenery.ECTOFUNTUS_5282) { player, used, _ -> + lock(player, 5) + animate(player, ANIMATION) + playAudio(player, AUDIO) + + submitIndividualPulse(player, object: Pulse(3) { + override fun pulse(): Boolean { + if (removeItem(player, used)) { + addItem(player, Items.ECTOPHIAL_4251) + sendMessage(player, "You refill the ectophial from the Ectofuntus.") + unlock(player) + return true + } + return false + } + }) + + return@onUseWith true + } + } +}