From c74048425c6cb804c7fb3b607d9e6ed3a2277e49 Mon Sep 17 00:00:00 2001 From: Byte Date: Fri, 21 Oct 2022 15:05:35 +0000 Subject: [PATCH] Updated GWDEntranceRopeUsage plugin to listener (Note: this handles only the case where a rope is used directly on the hole; using the tie-rope option is handled by a separate plugin) --- .../item/withobject/GWDEntranceRopeUsage.java | 35 ------------------- .../withobject/GWDEntranceRopeListener.kt | 28 +++++++++++++++ 2 files changed, 28 insertions(+), 35 deletions(-) delete mode 100644 Server/src/main/java/core/game/interaction/item/withobject/GWDEntranceRopeUsage.java create mode 100644 Server/src/main/kotlin/rs09/game/interaction/item/withobject/GWDEntranceRopeListener.kt diff --git a/Server/src/main/java/core/game/interaction/item/withobject/GWDEntranceRopeUsage.java b/Server/src/main/java/core/game/interaction/item/withobject/GWDEntranceRopeUsage.java deleted file mode 100644 index 2a5a99e46..000000000 --- a/Server/src/main/java/core/game/interaction/item/withobject/GWDEntranceRopeUsage.java +++ /dev/null @@ -1,35 +0,0 @@ -package core.game.interaction.item.withobject; - -import core.game.interaction.NodeUsageEvent; -import core.game.interaction.UseWithHandler; -import core.game.node.scenery.Scenery; -import core.plugin.Initializable; -import core.plugin.Plugin; - -/** - * Handles using a rope on the God wars entrance. - * @author Emperor - */ -@Initializable -public final class GWDEntranceRopeUsage extends UseWithHandler { - - /** - * Constructs a new {@code GWDEntranceRopeUsage} {@code Object}. - */ - public GWDEntranceRopeUsage() { - super(954); - } - - @Override - public Plugin newInstance(Object arg) throws Throwable { - addHandler(26340, OBJECT_TYPE, this); - return this; - } - - @Override - public boolean handle(NodeUsageEvent event) { - Scenery object = (Scenery) event.getUsedWith(); - return object.getInteraction().get(0).getHandler().handle(event.getPlayer(), object, "tie-rope"); - } - -} diff --git a/Server/src/main/kotlin/rs09/game/interaction/item/withobject/GWDEntranceRopeListener.kt b/Server/src/main/kotlin/rs09/game/interaction/item/withobject/GWDEntranceRopeListener.kt new file mode 100644 index 000000000..3fad01c75 --- /dev/null +++ b/Server/src/main/kotlin/rs09/game/interaction/item/withobject/GWDEntranceRopeListener.kt @@ -0,0 +1,28 @@ +package rs09.game.interaction.item.withobject + +import api.removeItem +import api.setVarbit +import org.rs09.consts.Items +import org.rs09.consts.Scenery +import rs09.game.interaction.IntType +import rs09.game.interaction.InteractionListener + +/** + * Listener for using a rope directly on the GWD entrance hole + * @author Byte + */ +@Suppress("unused") +class GWDEntranceRopeListener : InteractionListener { + + override fun defineListeners() { + onUseWith(IntType.SCENERY, Items.ROPE_954, Scenery.HOLE_26340) { player, used, _ -> + if (!removeItem(player, used)) { + return@onUseWith false + } + + setVarbit(player,1048,0,1,true) + + return@onUseWith true + } + } +}