diff --git a/Server/src/main/java/core/game/interaction/item/withitem/CrystalKeyCreatePlugin.java b/Server/src/main/java/core/game/interaction/item/withitem/CrystalKeyCreatePlugin.java deleted file mode 100644 index 63e8275c0..000000000 --- a/Server/src/main/java/core/game/interaction/item/withitem/CrystalKeyCreatePlugin.java +++ /dev/null @@ -1,46 +0,0 @@ -package core.game.interaction.item.withitem; - -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.plugin.Initializable; -import core.plugin.Plugin; - -/** - * Represents the plugin used to handle the creation of a crystal key. - * @author 'Vexia - * @version 1.0 - */ -@Initializable -public final class CrystalKeyCreatePlugin extends UseWithHandler { - - /** - * Represents the crystal key item. - */ - private static final Item KEY = new Item(989, 1); - - /** - * Constructs a new {@code CrystalKeyCreatePlugin} {@code Object}. - */ - public CrystalKeyCreatePlugin() { - super(985); - } - - @Override - public boolean handle(NodeUsageEvent event) { - final Player player = event.getPlayer(); - if (player.getInventory().remove(event.getBaseItem(), event.getUsedItem())) { - player.getInventory().add(KEY); - player.getPacketDispatch().sendMessage("You join the loop half of a key and the tooth half of a key to make a crystal key."); - } - return true; - } - - @Override - public Plugin newInstance(Object arg) throws Throwable { - addHandler(987, ITEM_TYPE, this); - return this; - } - -} diff --git a/Server/src/main/kotlin/rs09/game/interaction/item/withitem/CrystalKeyCreateListener.kt b/Server/src/main/kotlin/rs09/game/interaction/item/withitem/CrystalKeyCreateListener.kt new file mode 100644 index 000000000..006b4cfca --- /dev/null +++ b/Server/src/main/kotlin/rs09/game/interaction/item/withitem/CrystalKeyCreateListener.kt @@ -0,0 +1,33 @@ +package rs09.game.interaction.item.withitem + +import api.addItem +import api.removeItem +import api.sendMessage +import org.rs09.consts.Items +import rs09.game.interaction.IntType +import rs09.game.interaction.InteractionListener + +/** + * Listener for creating a crystal key + * @author Byte + */ +@Suppress("unused") +class CrystalKeyCreateListener : InteractionListener { + + override fun defineListeners() { + onUseWith(IntType.ITEM, Items.LOOP_HALF_OF_A_KEY_987, Items.TOOTH_HALF_OF_A_KEY_985) { player, used, with -> + if (!removeItem(player, used)) { + return@onUseWith false + } + + if (!removeItem(player, with)) { + return@onUseWith false + } + + addItem(player, Items.CRYSTAL_KEY_989) + sendMessage(player, "You join the loop half of a key and the tooth half of a key to make a crystal key.") + + return@onUseWith true + } + } +}