Rewrote nettle tea handlers, additionally allowing emptying of cup of tea

This commit is contained in:
Kennynes 2025-11-10 12:30:03 +00:00 committed by Ryan
parent f1f5a97859
commit 618baf0662
5 changed files with 37 additions and 96 deletions

View file

@ -48,6 +48,7 @@ class EmptyOptionListener : InteractionListener {
POTION(Items.POTION_195, Items.VIAL_229, "You empty the vial.", Sounds.LIQUID_2401),
BURNT_STEW(Items.BURNT_STEW_2005, Items.BOWL_1923, "You empty the contents of the bowl onto the floor.", Sounds.LIQUID_2401),
NETTLE_TEA(Items.NETTLE_TEA_4239, Items.BOWL_1923, "You empty the contents of the bowl onto the floor.", Sounds.LIQUID_2401),
CUP_OF_TEA(Items.CUP_OF_TEA_4242, Items.EMPTY_CUP_1980, "You empty the cup of tea.", Sounds.LIQUID_2401),
NETTLE_WATER(Items.NETTLE_WATER_4237, Items.BOWL_1923, "You empty the contents of the bowl onto the floor.", Sounds.LIQUID_2401),
NETTLE_TEA_MILKY(Items.NETTLE_TEA_4240, Items.BOWL_1923, "You empty the contents of the bowl onto the floor.", Sounds.LIQUID_2401),
BURNT_CURRY(Items.BURNT_CURRY_2013, Items.BOWL_1923, "You empty the contents of the bowl onto the floor.", Sounds.LIQUID_2401),

View file

@ -0,0 +1,18 @@
package content.global.skill.cooking
import org.rs09.consts.Items
import core.api.replaceSlot
import core.game.interaction.IntType
import core.game.interaction.InteractionListener
import core.game.node.item.Item
class NettleTeaListener : InteractionListener {
override fun defineListeners() {
onUseWith(IntType.ITEM, Items.EMPTY_CUP_1980, Items.NETTLE_TEA_4239) { player, used, with ->
replaceSlot(player, with.asItem().slot, Item(Items.BOWL_1923), with.asItem())
replaceSlot(player, used.asItem().slot, Item(Items.CUP_OF_TEA_4242), used.asItem())
return@onUseWith true
}
}
}

View file

@ -1,61 +0,0 @@
package content.global.skill.cooking;
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 create nettle tea in a cup.
* @author 'Vexia
* @version 1.0
*/
@Initializable
public final class NettleTeaPlugin extends UseWithHandler {
/**
* Represents the empty cup item.
*/
private static final Item EMPTY_CUP = new Item(1980, 1);
/**
* Represents the nettle tea item.
*/
private static final Item NETTLE_TEA = new Item(4239, 1);
/**
* Represents the bowl item.
*/
private static final Item BOWL = new Item(1923);
/**
* Represents the cup of tea item.
*/
private static final Item CUP_OF_TEA = new Item(4242, 1);
/**
* Constructs a new {@code NettleTeaPlugin} {@code Object}.
*/
public NettleTeaPlugin() {
super(1980);
}
@Override
public Plugin<Object> newInstance(Object arg) throws Throwable {
addHandler(4239, ITEM_TYPE, this);
return this;
}
@Override
public boolean handle(NodeUsageEvent event) {
final Player player = event.getPlayer();
if (player.getInventory().remove(EMPTY_CUP) && player.getInventory().remove(NETTLE_TEA)) {
player.getInventory().add(BOWL);
player.getInventory().add(CUP_OF_TEA);
}
return true;
}
}

View file

@ -0,0 +1,18 @@
package content.global.skill.cooking
import org.rs09.consts.Items
import core.api.replaceSlot
import core.api.removeItem
import core.game.interaction.IntType
import core.game.interaction.InteractionListener
import core.game.node.item.Item
class NettleWaterListener : InteractionListener {
override fun defineListeners() {
onUseWith(IntType.ITEM, Items.BOWL_OF_WATER_1921, Items.NETTLES_4241) { player, used, with ->
replaceSlot(player, used.asItem().slot, Item(Items.NETTLE_WATER_4237), used.asItem())
removeItem(player, with.asItem())
return@onUseWith true
}
}
}

View file

@ -1,35 +0,0 @@
package content.global.skill.cooking;
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;
/**
* @author Adam
*/
@Initializable
public class NettleWaterPlugin extends UseWithHandler {
public NettleWaterPlugin() {
super(1921);
}
@Override
public boolean handle(NodeUsageEvent event) {
final Player player = event.getPlayer();
player.getInventory().remove(new Item(1921, 1));
player.getInventory().remove(new Item(4241, 1));
player.getInventory().add(new Item(4237, 1));
return true;
}
@Override
public Plugin<Object> newInstance(Object arg) throws Throwable {
addHandler(4241, ITEM_TYPE, this);
return this;
}
}