From 39d4fb40075cede9e98d866729844f5165ec1fc7 Mon Sep 17 00:00:00 2001 From: Ceikry Date: Sun, 27 Jun 2021 22:02:23 +0000 Subject: [PATCH] Handle shop --- .../game/interaction/npc/NPCTradePlugin.java | 41 ------------------- .../game/interaction/npc/NPCTradePlugin.kt | 35 ++++++++++++++++ 2 files changed, 35 insertions(+), 41 deletions(-) delete mode 100644 Server/src/main/java/core/game/interaction/npc/NPCTradePlugin.java create mode 100644 Server/src/main/java/core/game/interaction/npc/NPCTradePlugin.kt diff --git a/Server/src/main/java/core/game/interaction/npc/NPCTradePlugin.java b/Server/src/main/java/core/game/interaction/npc/NPCTradePlugin.java deleted file mode 100644 index ab37bc5fa..000000000 --- a/Server/src/main/java/core/game/interaction/npc/NPCTradePlugin.java +++ /dev/null @@ -1,41 +0,0 @@ -package core.game.interaction.npc; - -import core.cache.def.impl.NPCDefinition; -import core.game.component.Component; -import core.game.interaction.OptionHandler; -import core.game.node.Node; -import core.game.node.entity.npc.NPC; -import core.game.node.entity.player.Player; -import core.plugin.Initializable; -import core.plugin.Plugin; -import core.game.node.entity.skill.crafting.TanningProduct; - -/** - * Represents the plugin used for an npc with the trade option. - * @author 'Vexia - * @version 1.0 - */ -@Initializable -public final class NPCTradePlugin extends OptionHandler { - - @Override - public Plugin newInstance(Object arg) throws Throwable { - NPCDefinition.setOptionHandler("trade", this); - return this; - } - - @Override - public boolean handle(Player player, Node node, String option) { - final NPC npc = (NPC) node; - if (npc.getId() == 2824) { - TanningProduct.open(player, 2824); - return true; - } - if(npc.getId() == 7601){ - player.getInterfaceManager().open(new Component(732)); - return true; - } - return node.asNpc().openShop(player); - } - -} diff --git a/Server/src/main/java/core/game/interaction/npc/NPCTradePlugin.kt b/Server/src/main/java/core/game/interaction/npc/NPCTradePlugin.kt new file mode 100644 index 000000000..f2f3bb769 --- /dev/null +++ b/Server/src/main/java/core/game/interaction/npc/NPCTradePlugin.kt @@ -0,0 +1,35 @@ +package core.game.interaction.npc + +import api.ContentAPI +import core.cache.def.impl.NPCDefinition +import core.game.component.Component +import core.plugin.Initializable +import core.game.interaction.OptionHandler +import core.game.node.Node +import core.game.node.entity.npc.NPC +import core.game.node.entity.player.Player +import core.plugin.Plugin +import core.game.node.entity.skill.crafting.TanningProduct +import rs09.game.interaction.InteractionListener + +/** + * Represents the plugin used for an npc with the trade option. + * @author Ceikry + * @version 1.0 + */ +class NPCTradePlugin : InteractionListener() { + override fun defineListeners() { + on(NPC, "trade", "shop"){player, node -> + val npc = node as NPC + if (npc.id == 2824) { + TanningProduct.open(player, 2824) + return@on true + } + if (npc.id == 7601) { + ContentAPI.openInterface(player, 732) + return@on true + } + return@on npc.openShop(player) + } + } +} \ No newline at end of file