Rewrote the hide tanning interface

This commit is contained in:
Sam Marder
2026-06-20 13:52:50 +00:00
committed by Ryan
parent 2c8885fa60
commit 34e386dbbf
2 changed files with 25 additions and 90 deletions
@@ -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<Object> 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;
}
}
@@ -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
}
}
}