From 34e386dbbfd7b388739152fa205a172e233b8013 Mon Sep 17 00:00:00 2001 From: Sam Marder Date: Sat, 20 Jun 2026 13:52:50 +0000 Subject: [PATCH] Rewrote the hide tanning interface --- .../handlers/iface/TanningInterface.java | 90 ------------------- .../global/handlers/iface/TanningInterface.kt | 25 ++++++ 2 files changed, 25 insertions(+), 90 deletions(-) delete mode 100644 Server/src/main/content/global/handlers/iface/TanningInterface.java create mode 100644 Server/src/main/content/global/handlers/iface/TanningInterface.kt diff --git a/Server/src/main/content/global/handlers/iface/TanningInterface.java b/Server/src/main/content/global/handlers/iface/TanningInterface.java deleted file mode 100644 index aa15e4b11..000000000 --- a/Server/src/main/content/global/handlers/iface/TanningInterface.java +++ /dev/null @@ -1,90 +0,0 @@ -package content.global.handlers.iface; - -import static core.api.ContentAPIKt.*; -import core.game.component.Component; -import core.game.component.ComponentDefinition; -import core.game.component.ComponentPlugin; -import content.global.skill.crafting.TanningProduct; -import core.game.node.entity.player.Player; -import core.game.node.item.Item; -import core.plugin.Initializable; -import core.plugin.Plugin; -import kotlin.Unit; - -/** - * @author Vexia - * @version 1.2 - */ -@Initializable -public class TanningInterface extends ComponentPlugin { - - /** - * Method used to create a new instance. - * @param arg - * @return - * @throws Throwable - */ - @Override - public Plugin newInstance(Object arg) throws Throwable { - ComponentDefinition.put(324, this); - return this; - } - - @Override - public boolean handle(Player player, Component component, int opcode, int button, int slot, int itemId) { - TanningProduct def = null; - switch (button) { - case 1: - def = TanningProduct.SOFT_LEATHER; - break; - case 2: - def = TanningProduct.HARD_LEATHER; - break; - case 3: - def = TanningProduct.SNAKESKIN; - break; - case 4: - def = TanningProduct.SNAKESKIN2; - break; - case 5: - def = TanningProduct.GREEN_DHIDE; - break; - case 6: - def = TanningProduct.BLUEDHIDE; - break; - case 7: - def = TanningProduct.REDDHIDE; - break; - case 8: - def = TanningProduct.BLACKDHIDE; - break; - } - if (def == null) { - return true; - } - int amount = 0; - final TanningProduct deff = def; - switch (opcode){ - case 155: - amount = 1; - break; - case 196: - amount = 5; - break; - case 124: - amount = 10; - case 199: - sendInputDialogue(player, true, "Enter the amount:", (value) -> { - TanningProduct.tan(player, (int) value, deff); - return Unit.INSTANCE; - }); - break; - case 234: - amount = player.getInventory().getAmount(new Item(def.getItem(), 1)); - break; - } - TanningProduct.tan(player, amount, def); - return true; - } - -} diff --git a/Server/src/main/content/global/handlers/iface/TanningInterface.kt b/Server/src/main/content/global/handlers/iface/TanningInterface.kt new file mode 100644 index 000000000..278e991bf --- /dev/null +++ b/Server/src/main/content/global/handlers/iface/TanningInterface.kt @@ -0,0 +1,25 @@ +package content.global.handlers.iface + +import content.global.skill.crafting.TanningProduct +import core.api.amountInInventory +import core.api.sendInputDialogue +import core.game.interaction.InterfaceListener + +class TanningInterface : InterfaceListener { + override fun defineInterfaceListeners() { + on(324) { player, _, opcode, buttonID, _, _ -> + val product = TanningProduct.forId(buttonID) + + when (opcode) { + 155 -> TanningProduct.tan(player, 1, product) + 196 -> TanningProduct.tan(player, 5, product) + 124 -> TanningProduct.tan(player, 10, product) + 199 -> sendInputDialogue(player, true, "Enter the amount:") { value -> + TanningProduct.tan(player, value as Int, product) + } + 234 -> TanningProduct.tan(player, amountInInventory(player, product.item), product) + } + return@on true + } + } +}