From 9bbc3d34faa6e3dc0759e086293ca4588f671229 Mon Sep 17 00:00:00 2001 From: Syndromeramo Date: Mon, 21 Jul 2025 10:15:36 -0500 Subject: [PATCH 01/24] Cake refactor --- .../global/skill/cooking/CakeListener.kt | 34 +++++++++ .../skill/cooking/CakeMakingPlugin.java | 69 ------------------- 2 files changed, 34 insertions(+), 69 deletions(-) create mode 100644 Server/src/main/content/global/skill/cooking/CakeListener.kt delete mode 100644 Server/src/main/content/global/skill/cooking/CakeMakingPlugin.java diff --git a/Server/src/main/content/global/skill/cooking/CakeListener.kt b/Server/src/main/content/global/skill/cooking/CakeListener.kt new file mode 100644 index 000000000..3cf0e7a0f --- /dev/null +++ b/Server/src/main/content/global/skill/cooking/CakeListener.kt @@ -0,0 +1,34 @@ +package content.global.skill.cooking + +import core.api.addItem +import core.api.inInventory +import core.api.removeItem +import core.api.sendMessage +import core.game.interaction.IntType +import core.game.interaction.InteractionListener +import org.rs09.consts.Items + +class CakeListener : InteractionListener { + val cakeArr = intArrayOf( + Items.EGG_1944, + Items.BUCKET_OF_MILK_1927, + Items.POT_OF_FLOUR_1933 + ) + + override fun defineListeners() { + onUseWith(IntType.ITEM, cakeArr, Items.CAKE_TIN_1887) { player, _, _ -> + if(inInventory(player, Items.EGG_1944) && inInventory(player, Items.BUCKET_OF_MILK_1927) && inInventory(player, Items.POT_OF_FLOUR_1933) && inInventory(player, Items.CAKE_TIN_1887)) { + removeItem(player, Items.EGG_1944) + removeItem(player, Items.BUCKET_OF_MILK_1927) + removeItem(player, Items.POT_OF_FLOUR_1933) + removeItem(player, Items.CAKE_TIN_1887) + addItem(player, Items.EMPTY_POT_1931) + addItem(player, Items.UNCOOKED_CAKE_1889) + addItem(player, Items.BUCKET_1925) + sendMessage(player, "You mix the milk, flour and egg together to make a raw cake mix.") + return@onUseWith true + } + return@onUseWith false + } + } +} \ No newline at end of file diff --git a/Server/src/main/content/global/skill/cooking/CakeMakingPlugin.java b/Server/src/main/content/global/skill/cooking/CakeMakingPlugin.java deleted file mode 100644 index 084abf4c4..000000000 --- a/Server/src/main/content/global/skill/cooking/CakeMakingPlugin.java +++ /dev/null @@ -1,69 +0,0 @@ -package content.global.skill.cooking; - -import core.game.interaction.NodeUsageEvent; -import core.game.interaction.UseWithHandler; -import core.game.node.item.Item; -import core.plugin.Initializable; -import core.plugin.Plugin; - -/** - * Represents the plugin used to make a cake. - * @author 'Vexia - * @version 1.0 - */ -@Initializable -public final class CakeMakingPlugin extends UseWithHandler { - - /** - * Represents the bucket of milk item. - */ - private static final Item BUCKET_OF_MILK = new Item(1927); - - /** - * Represents the egg item. - */ - private static final Item EGG = new Item(1944); - - /** - * Represents the cake tin item. - */ - private static final Item CAKE_TIN = new Item(1887); - - /** - * Represents the pot of flour item. - */ - private static final Item POT_OF_FLOUR = new Item(1933); - - /** - * Represents the uncooked cake item. - */ - private static final Item UNCOOKED_CAKE = new Item(1889); - - /** - * Constructs a new {@code CakeMakingPlugin} {@code Object}. - */ - public CakeMakingPlugin() { - super(1933); - } - - @Override - public Plugin newInstance(Object arg) throws Throwable { - addHandler(1887, ITEM_TYPE, this); - return this; - } - - @Override - public boolean handle(NodeUsageEvent event) { - if (event.getUsedItem().getId() == 1887 && ((Item) event.getUsedWith()).getId() == 1933 || event.getUsedWith().getName().equalsIgnoreCase("cake tin") && ((Item) event.getUsedItem()).getName().equalsIgnoreCase("pot of flour")) { - if (event.getPlayer().getInventory().contains(1933, 1) && event.getPlayer().getInventory().contains(1927, 1) && event.getPlayer().getInventory().contains(1944, 1)) { - if (event.getPlayer().getInventory().remove(BUCKET_OF_MILK, EGG, CAKE_TIN, POT_OF_FLOUR)) { - event.getPlayer().getInventory().add(UNCOOKED_CAKE); - event.getPlayer().getPacketDispatch().sendMessage("You mix the milk, flour and egg together to make a raw cake mix."); - return true; - } - } - } - return false; - } - -} From afc2ef9f2c3c4e3fb289f0a5894c813f2dc4809d Mon Sep 17 00:00:00 2001 From: Syndromeramo Date: Mon, 21 Jul 2025 17:43:37 -0500 Subject: [PATCH 02/24] Refactored Coconut Milk process. --- .../global/skill/cooking/CoconutListener.kt | 34 +++++++++++ .../skill/cooking/CoconutMakePlugin.java | 56 ------------------- 2 files changed, 34 insertions(+), 56 deletions(-) create mode 100644 Server/src/main/content/global/skill/cooking/CoconutListener.kt delete mode 100644 Server/src/main/content/global/skill/cooking/CoconutMakePlugin.java diff --git a/Server/src/main/content/global/skill/cooking/CoconutListener.kt b/Server/src/main/content/global/skill/cooking/CoconutListener.kt new file mode 100644 index 000000000..1aab0ee29 --- /dev/null +++ b/Server/src/main/content/global/skill/cooking/CoconutListener.kt @@ -0,0 +1,34 @@ +package content.global.skill.cooking + +import core.api.addItem +import core.api.inInventory +import core.api.removeItem +import core.api.sendMessage +import core.game.interaction.IntType +import core.game.interaction.InteractionListener +import org.rs09.consts.Items + +class CoconutListener : InteractionListener { + + override fun defineListeners() { + onUseWith(IntType.ITEM, Items.COCONUT_5974, Items.HAMMER_2347) { player, used, _ -> + if(removeItem(player, used.asItem())) { + addItem(player, Items.COCONUT_5976) + sendMessage(player, "You crush the coconut with a hammer.") + return@onUseWith true + } + return@onUseWith false + } + onUseWith(IntType.ITEM, Items.COCONUT_5976, Items.VIAL_229) { player, _, _ -> + if(inInventory(player, Items.COCONUT_5976) && inInventory(player, Items.VIAL_229)) { + removeItem(player, Items.COCONUT_5976) + addItem(player, Items.COCONUT_SHELL_5978) + removeItem(player, Items.VIAL_229) + addItem(player, Items.COCONUT_MILK_5935) + sendMessage(player, "You overturn the coconut into a vial.") + return@onUseWith true + } + return@onUseWith false + } + } +} \ No newline at end of file diff --git a/Server/src/main/content/global/skill/cooking/CoconutMakePlugin.java b/Server/src/main/content/global/skill/cooking/CoconutMakePlugin.java deleted file mode 100644 index 7520ff115..000000000 --- a/Server/src/main/content/global/skill/cooking/CoconutMakePlugin.java +++ /dev/null @@ -1,56 +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 make a coconut. - * @author 'Vexia - * @version 1.0 - */ -@Initializable -public final class CoconutMakePlugin extends UseWithHandler { - - /** - * Represents the items related to coconut making plugin. - */ - private static final Item[] ITEMS = new Item[] { new Item(5974, 1), new Item(5976, 1), new Item(229), new Item(5935, 1), new Item(5978) }; - - /** - * Constructs a new {@code CoconutMakePlugin} {@code Object}. - */ - public CoconutMakePlugin() { - super(5974, 5976); - } - - @Override - public Plugin newInstance(Object arg) throws Throwable { - addHandler(2347, ITEM_TYPE, this); - addHandler(229, ITEM_TYPE, this); - return this; - } - - @Override - public boolean handle(NodeUsageEvent event) { - final Player player = event.getPlayer(); - final Item usedWith = (Item) event.getUsedWith(); - if (usedWith.getId() == 5974 && event.getUsedItem().getId() == 2347 || usedWith.getId() == 2347 && event.getUsedItem().getId() == 5974) { - player.getInventory().remove(ITEMS[0]); - player.getInventory().add(ITEMS[1]); - player.getPacketDispatch().sendMessage("You crush the coconut with a hammer."); - } - if (usedWith.getId() == 5976 && event.getUsedItem().getId() == 229 || usedWith.getId() == 229 && event.getUsedItem().getId() == 5976) { - player.getInventory().remove(ITEMS[1]); - player.getInventory().remove(ITEMS[2]); - player.getInventory().add(ITEMS[3]); - player.getInventory().add(ITEMS[4]); - player.getPacketDispatch().sendMessage("You overturn the coconut into a vial."); - } - return true; - } - -} From 4292442dbd42398a10b8dad5c480d608d4b5f4b8 Mon Sep 17 00:00:00 2001 From: Syndromeramo Date: Mon, 21 Jul 2025 18:31:00 -0500 Subject: [PATCH 03/24] Refactored Skewered Foods. --- .../skill/cooking/SkeweredFoodListener.kt | 32 +++++ .../skill/cooking/SkeweredFoodPlugin.java | 115 ------------------ 2 files changed, 32 insertions(+), 115 deletions(-) create mode 100644 Server/src/main/content/global/skill/cooking/SkeweredFoodListener.kt delete mode 100644 Server/src/main/content/global/skill/cooking/SkeweredFoodPlugin.java diff --git a/Server/src/main/content/global/skill/cooking/SkeweredFoodListener.kt b/Server/src/main/content/global/skill/cooking/SkeweredFoodListener.kt new file mode 100644 index 000000000..99cde703c --- /dev/null +++ b/Server/src/main/content/global/skill/cooking/SkeweredFoodListener.kt @@ -0,0 +1,32 @@ +package content.global.skill.cooking + +import core.api.* +import core.game.interaction.IntType +import core.game.interaction.InteractionListener +import core.game.node.entity.skill.Skills +import org.rs09.consts.Items + +class SkeweredFoodListener : InteractionListener { + val skewerMap = hashMapOf( + Items.RAW_CHOMPY_2876 to Items.SKEWERED_CHOMPY_7230, + Items.RAW_RABBIT_3226 to Items.SKEWERED_RABBIT_7224, + Items.RAW_BIRD_MEAT_9978 to Items.SKEWERED_BIRD_MEAT_9984, + Items.RAW_BEAST_MEAT_9986 to Items.SKEWERED_BEAST_9992 + ) + + override fun defineListeners() { + onUseWith(IntType.ITEM, skewerMap.keys.toIntArray(), Items.IRON_SPIT_7225) { player, used, _ -> + if (getDynLevel(player, Skills.FIREMAKING) < 20) { + player.packetDispatch.sendMessage("You need a Firemaking level of at least 20 in order to do this.") + return@onUseWith true + } + if(inInventory(player, used.id) && inInventory(player, Items.IRON_SPIT_7225)) { + removeItem(player, used.id) + removeItem(player, Items.IRON_SPIT_7225) + skewerMap[used.id]?.let { addItem(player, it) } + return@onUseWith true + } + return@onUseWith false + } + } +} \ No newline at end of file diff --git a/Server/src/main/content/global/skill/cooking/SkeweredFoodPlugin.java b/Server/src/main/content/global/skill/cooking/SkeweredFoodPlugin.java deleted file mode 100644 index 8f02bfcb9..000000000 --- a/Server/src/main/content/global/skill/cooking/SkeweredFoodPlugin.java +++ /dev/null @@ -1,115 +0,0 @@ -package content.global.skill.cooking; - -import core.game.node.entity.skill.Skills; -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; -import org.rs09.consts.Items; - -/** - * Represents the plugin used to make skwered items. - * @author 'Vexia - * @date 22/12/2013 - */ -@Initializable -public class SkeweredFoodPlugin extends UseWithHandler { - - /** - * Represents the level required. - */ - private final int LEVEL = 20; - - /** - * Constructs a new {@code SkeweredFoodPlugin} {@code Object}. - */ - public SkeweredFoodPlugin() { - super(7225); - } - - @Override - public Plugin newInstance(Object arg) throws Throwable { - for (SkeweredSet set : SkeweredSet.values()) { - addHandler(set.getRaw().getId(), ITEM_TYPE, this); - } - return this; - } - - @Override - public boolean handle(NodeUsageEvent event) { - final Player player = event.getPlayer(); - if (player.getSkills().getLevel(Skills.FIREMAKING) < LEVEL) { - player.getPacketDispatch().sendMessage("You meed a Firemaking level of at least " + LEVEL + " in order to do this."); - return true; - } - final SkeweredSet set = SkeweredSet.forItem(event.getBaseItem().getId() == 7225 ? event.getUsedItem() : event.getBaseItem()); - if (player.getInventory().remove(event.getBaseItem()) && player.getInventory().remove(event.getUsedItem())) { - player.getInventory().add(set.getProduct()); - } - return true; - } - - /** - * Represents a set of skwered items. - * @author 'Vexia - * @date 22/12/2013 - */ - public enum SkeweredSet { - CHOMPY(new Item(Items.RAW_CHOMPY_2876), new Item(Items.SKEWERED_CHOMPY_7230)), - RABBIT(new Item(Items.RAW_RABBIT_3226), new Item(Items.SKEWERED_RABBIT_7224)), - BIRD(new Item(Items.RAW_BIRD_MEAT_9978), new Item(Items.SKEWERED_BIRD_MEAT_9984)), - BEAST(new Item(Items.RAW_BEAST_MEAT_9986), new Item(Items.SKEWERED_BEAST_9992)); - - /** - * Represents the raw item. - */ - private final Item raw; - - /** - * Represents the product item. - */ - private final Item product; - - /** - * Constructs a new {@code SkeweredFoodPlugin} {@code Object}. - * @param raw the raw item. - * @param product the product. - */ - private SkeweredSet(Item raw, Item product) { - this.raw = raw; - this.product = product; - } - - /** - * Gets the raw. - * @return The raw. - */ - public Item getRaw() { - return raw; - } - - /** - * Gets the product. - * @return The product. - */ - public Item getProduct() { - return product; - } - - /** - * Gets the skwered set. - * @param item the item. - * @return the set. - */ - public static SkeweredSet forItem(final Item item) { - for (SkeweredSet set : values()) { - if (set.getRaw().getId() == item.getId()) { - return set; - } - } - return null; - } - } -} From ed8a096dcf12541359714575e8c0358c36e7055d Mon Sep 17 00:00:00 2001 From: Syndromeramo Date: Mon, 21 Jul 2025 18:49:38 -0500 Subject: [PATCH 04/24] Refactored Watermelon cutting. --- .../global/skill/cooking/CoconutListener.kt | 10 ++-- .../skill/cooking/WatermelonSliceListener.kt | 20 +++++++ .../skill/cooking/WatermelonSlicePlugin.java | 59 ------------------- 3 files changed, 25 insertions(+), 64 deletions(-) create mode 100644 Server/src/main/content/global/skill/cooking/WatermelonSliceListener.kt delete mode 100644 Server/src/main/content/global/skill/cooking/WatermelonSlicePlugin.java diff --git a/Server/src/main/content/global/skill/cooking/CoconutListener.kt b/Server/src/main/content/global/skill/cooking/CoconutListener.kt index 1aab0ee29..cc3a86a89 100644 --- a/Server/src/main/content/global/skill/cooking/CoconutListener.kt +++ b/Server/src/main/content/global/skill/cooking/CoconutListener.kt @@ -12,18 +12,18 @@ class CoconutListener : InteractionListener { override fun defineListeners() { onUseWith(IntType.ITEM, Items.COCONUT_5974, Items.HAMMER_2347) { player, used, _ -> - if(removeItem(player, used.asItem())) { + if(removeItem(player, used.id)) { addItem(player, Items.COCONUT_5976) sendMessage(player, "You crush the coconut with a hammer.") return@onUseWith true } return@onUseWith false } - onUseWith(IntType.ITEM, Items.COCONUT_5976, Items.VIAL_229) { player, _, _ -> - if(inInventory(player, Items.COCONUT_5976) && inInventory(player, Items.VIAL_229)) { - removeItem(player, Items.COCONUT_5976) + onUseWith(IntType.ITEM, Items.COCONUT_5976, Items.VIAL_229) { player, used, with -> + if(inInventory(player, used.id) && inInventory(player, with.id)) { + removeItem(player, used.id) addItem(player, Items.COCONUT_SHELL_5978) - removeItem(player, Items.VIAL_229) + removeItem(player, with.id) addItem(player, Items.COCONUT_MILK_5935) sendMessage(player, "You overturn the coconut into a vial.") return@onUseWith true diff --git a/Server/src/main/content/global/skill/cooking/WatermelonSliceListener.kt b/Server/src/main/content/global/skill/cooking/WatermelonSliceListener.kt new file mode 100644 index 000000000..12f1ee22d --- /dev/null +++ b/Server/src/main/content/global/skill/cooking/WatermelonSliceListener.kt @@ -0,0 +1,20 @@ +package content.global.skill.cooking + +import core.api.* +import core.game.interaction.IntType +import core.game.interaction.InteractionListener +import org.rs09.consts.Items + +class WatermelonSliceListener : InteractionListener { + + override fun defineListeners() { + onUseWith(IntType.ITEM, Items.WATERMELON_5982, Items.KNIFE_946) { player, used, _ -> + if(removeItem(player, used.asItem())) { + addItemOrDrop(player, Items.WATERMELON_SLICE_5984, 3) + sendMessage(player, "You slice the watermelon into three slices.") + return@onUseWith true + } + return@onUseWith false + } + } +} \ No newline at end of file diff --git a/Server/src/main/content/global/skill/cooking/WatermelonSlicePlugin.java b/Server/src/main/content/global/skill/cooking/WatermelonSlicePlugin.java deleted file mode 100644 index d8273968f..000000000 --- a/Server/src/main/content/global/skill/cooking/WatermelonSlicePlugin.java +++ /dev/null @@ -1,59 +0,0 @@ -package content.global.skill.cooking; - -import core.game.interaction.NodeUsageEvent; -import core.game.interaction.UseWithHandler; -import core.game.node.item.GroundItemManager; -import core.game.node.item.Item; -import core.plugin.Initializable; -import core.plugin.Plugin; - -/** - * Represents the plugin used to slice a watermelon. - * @author 'Vexia - * @version 1.0 - */ -@Initializable -public final class WatermelonSlicePlugin extends UseWithHandler { - - /** - * Represents the knife item. - */ - private static final Item KNIFE = new Item(946); - - /** - * Represents the watermelon item. - */ - private static final Item WATERMELON = new Item(5982); - - /** - * Represents the watermelon slice item. - */ - private static final Item WATERMELON_SLICE = new Item(5984); - - /** - * Constructs a new {@code WatermelonSlicePlugin.java} {@code Object}. - */ - public WatermelonSlicePlugin() { - super(KNIFE.getId()); - } - - @Override - public Plugin newInstance(Object arg) throws Throwable { - addHandler(5982, ITEM_TYPE, this); - return this; - } - - @Override - public boolean handle(NodeUsageEvent event) { - if (event.getPlayer().getInventory().remove(WATERMELON)) { - for (int i = 0; i < 3; i++) { - if (!event.getPlayer().getInventory().add(WATERMELON_SLICE)) { - GroundItemManager.create(WATERMELON_SLICE, event.getPlayer()); - } - } - event.getPlayer().getPacketDispatch().sendMessage("You slice the watermelon into three slices."); - } - return true; - } - -} From e96031655309fd844b771be2a1b1c3cd73a49e69 Mon Sep 17 00:00:00 2001 From: Syndromeramo Date: Wed, 23 Jul 2025 14:15:05 -0500 Subject: [PATCH 05/24] Logic cleanup. Refactored Wine Fermenting. --- .../global/skill/cooking/CoconutListener.kt | 5 +- .../skill/cooking/SkeweredFoodListener.kt | 8 +-- .../skill/cooking/WineFermentListener.kt | 30 +++++++++ .../skill/cooking/WineFermentPlugin.java | 63 ------------------- 4 files changed, 34 insertions(+), 72 deletions(-) create mode 100644 Server/src/main/content/global/skill/cooking/WineFermentListener.kt delete mode 100644 Server/src/main/content/global/skill/cooking/WineFermentPlugin.java diff --git a/Server/src/main/content/global/skill/cooking/CoconutListener.kt b/Server/src/main/content/global/skill/cooking/CoconutListener.kt index cc3a86a89..5f7da66d4 100644 --- a/Server/src/main/content/global/skill/cooking/CoconutListener.kt +++ b/Server/src/main/content/global/skill/cooking/CoconutListener.kt @@ -1,7 +1,6 @@ package content.global.skill.cooking import core.api.addItem -import core.api.inInventory import core.api.removeItem import core.api.sendMessage import core.game.interaction.IntType @@ -20,10 +19,8 @@ class CoconutListener : InteractionListener { return@onUseWith false } onUseWith(IntType.ITEM, Items.COCONUT_5976, Items.VIAL_229) { player, used, with -> - if(inInventory(player, used.id) && inInventory(player, with.id)) { - removeItem(player, used.id) + if(removeItem(player, used.id) && removeItem(player, with.id)) { addItem(player, Items.COCONUT_SHELL_5978) - removeItem(player, with.id) addItem(player, Items.COCONUT_MILK_5935) sendMessage(player, "You overturn the coconut into a vial.") return@onUseWith true diff --git a/Server/src/main/content/global/skill/cooking/SkeweredFoodListener.kt b/Server/src/main/content/global/skill/cooking/SkeweredFoodListener.kt index 99cde703c..16bcebbdb 100644 --- a/Server/src/main/content/global/skill/cooking/SkeweredFoodListener.kt +++ b/Server/src/main/content/global/skill/cooking/SkeweredFoodListener.kt @@ -15,14 +15,12 @@ class SkeweredFoodListener : InteractionListener { ) override fun defineListeners() { - onUseWith(IntType.ITEM, skewerMap.keys.toIntArray(), Items.IRON_SPIT_7225) { player, used, _ -> + onUseWith(IntType.ITEM, skewerMap.keys.toIntArray(), Items.IRON_SPIT_7225) { player, used, with -> if (getDynLevel(player, Skills.FIREMAKING) < 20) { - player.packetDispatch.sendMessage("You need a Firemaking level of at least 20 in order to do this.") + sendMessage(player, "You need a Firemaking level of at least 20 in order to do this.") return@onUseWith true } - if(inInventory(player, used.id) && inInventory(player, Items.IRON_SPIT_7225)) { - removeItem(player, used.id) - removeItem(player, Items.IRON_SPIT_7225) + if(removeItem(player, used.id) && removeItem(player, with.id)) { skewerMap[used.id]?.let { addItem(player, it) } return@onUseWith true } diff --git a/Server/src/main/content/global/skill/cooking/WineFermentListener.kt b/Server/src/main/content/global/skill/cooking/WineFermentListener.kt new file mode 100644 index 000000000..34241aa60 --- /dev/null +++ b/Server/src/main/content/global/skill/cooking/WineFermentListener.kt @@ -0,0 +1,30 @@ +package content.global.skill.cooking + +import content.global.skill.cooking.fermenting.WineFermentingPulse +import core.api.addItem +import core.api.getDynLevel +import core.api.removeItem +import core.api.sendMessage +import core.game.interaction.IntType +import core.game.interaction.InteractionListener +import core.game.node.entity.skill.Skills +import core.game.world.GameWorld.Pulser +import org.rs09.consts.Items + +class WineFermentListener : InteractionListener { + + override fun defineListeners() { + onUseWith(IntType.ITEM, Items.GRAPES_1987, Items.JUG_OF_WATER_1937) { player, used, with -> + if (getDynLevel(player, Skills.COOKING) < 35) { + sendMessage(player, "You need a cooking level of 35 to do this.") + return@onUseWith true + } + if(removeItem(player, used.id) && removeItem(player, with.id)) { + addItem(player, Items.UNFERMENTED_WINE_1995) + Pulser.submit(WineFermentingPulse(1, player)) + return@onUseWith true + } + return@onUseWith false + } + } +} \ No newline at end of file diff --git a/Server/src/main/content/global/skill/cooking/WineFermentPlugin.java b/Server/src/main/content/global/skill/cooking/WineFermentPlugin.java deleted file mode 100644 index b2e96678d..000000000 --- a/Server/src/main/content/global/skill/cooking/WineFermentPlugin.java +++ /dev/null @@ -1,63 +0,0 @@ -package content.global.skill.cooking; - -import core.plugin.Initializable; -import core.game.node.entity.skill.Skills; -import content.global.skill.cooking.fermenting.WineFermentingPulse; -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.game.world.GameWorld; -import core.plugin.Plugin; - -/** - * Represents the plugin used to ferment wine. - * @author 'Vexia - * @version 1.0 - */ -@Initializable -public final class WineFermentPlugin extends UseWithHandler { - - /** - * Represents the grapes item. - */ - private static final Item GRAPES = new Item(1987, 1); - - /** - * Represents the jug of water item. - */ - private static final Item JUG_OF_WATER = new Item(1937, 1); - - /** - * Represents the unfermented wine item. - */ - private static final Item UNFERMENTED_WINE = new Item(1995, 1); - - /** - * Constructs a new {@code WineFermentPlugin} {@code Object}. - */ - public WineFermentPlugin() { - super(1937); - } - - @Override - public Plugin newInstance(Object arg) throws Throwable { - addHandler(1987, ITEM_TYPE, this); - return this; - } - - @Override - public boolean handle(NodeUsageEvent event) { - final Player player = event.getPlayer(); - if (player.getSkills().getLevel(Skills.COOKING) < 35) { - player.getPacketDispatch().sendMessage("You need a cooking level of 35 to do this."); - return true; - } - if (player.getInventory().remove(GRAPES, JUG_OF_WATER)) { - player.getInventory().add(UNFERMENTED_WINE); - GameWorld.getPulser().submit(new WineFermentingPulse(1, player)); - } - return true; - } - -} From 56f6f6b848cafcd82b246f275969163f796c742c Mon Sep 17 00:00:00 2001 From: Syndromeramo Date: Wed, 23 Jul 2025 20:15:43 -0500 Subject: [PATCH 06/24] Chocolate Cake Refactor. --- .../cooking/recipe/cake/ChocolateCake.java | 72 ------------------- .../recipe/cake/ChocolateCakeListener.kt | 55 ++++++++++++++ 2 files changed, 55 insertions(+), 72 deletions(-) delete mode 100644 Server/src/main/content/global/skill/cooking/recipe/cake/ChocolateCake.java create mode 100644 Server/src/main/content/global/skill/cooking/recipe/cake/ChocolateCakeListener.kt diff --git a/Server/src/main/content/global/skill/cooking/recipe/cake/ChocolateCake.java b/Server/src/main/content/global/skill/cooking/recipe/cake/ChocolateCake.java deleted file mode 100644 index 97ef11d88..000000000 --- a/Server/src/main/content/global/skill/cooking/recipe/cake/ChocolateCake.java +++ /dev/null @@ -1,72 +0,0 @@ -package content.global.skill.cooking.recipe.cake; - -import content.global.skill.cooking.recipe.Recipe; -import core.game.node.entity.skill.Skills; -import core.game.interaction.NodeUsageEvent; -import core.game.node.entity.player.Player; -import core.game.node.item.Item; - -/** - * Represents the chocolate cake recipe. This recipe consists of adding a - * chocolate bar to a cake. - * @author 'Vexia - * @date 22/12/2013 - */ -public class ChocolateCake extends Recipe { - - /** - * Represents the cake item. - */ - private static final Item CAKE = new Item(1891); - - /** - * Represents the chocolate cake item. - */ - private static final Item CHOCOLATE_CAKE = new Item(1897); - - /** - * Represents the chocolate bar item. - */ - private static final Item CHOCOLATE_BAR = new Item(1973); - - @Override - public void mix(final Player player, final NodeUsageEvent event) { - if (player.getSkills().getLevel(Skills.COOKING) < 50) { - player.getDialogueInterpreter().sendDialogue("You need a Cooking level of 50 in order to do that."); - return; - } - super.mix(player, event); - player.getSkills().addExperience(Skills.COOKING, 30, true); - } - - @Override - public Item getBase() { - return CAKE; - } - - @Override - public Item getProduct() { - return CHOCOLATE_CAKE; - } - - @Override - public Item[] getIngredients() { - return new Item[] { CHOCOLATE_BAR }; - } - - @Override - public Item[] getParts() { - return new Item[] {}; - } - - @Override - public String getMixMessage(NodeUsageEvent event) { - return "You add chocolate to the cake."; - } - - @Override - public boolean isSingular() { - return true; - } - -} diff --git a/Server/src/main/content/global/skill/cooking/recipe/cake/ChocolateCakeListener.kt b/Server/src/main/content/global/skill/cooking/recipe/cake/ChocolateCakeListener.kt new file mode 100644 index 000000000..32d0193cb --- /dev/null +++ b/Server/src/main/content/global/skill/cooking/recipe/cake/ChocolateCakeListener.kt @@ -0,0 +1,55 @@ +package content.global.skill.cooking.recipe.cake + +import core.api.* +import core.game.interaction.IntType +import core.game.interaction.InteractionListener +import core.game.node.entity.skill.Skills +import org.rs09.consts.Items +import kotlin.math.min + +class ChocolateCakeListener : InteractionListener { + + val chocolate = intArrayOf(Items.CHOCOLATE_BAR_1973, Items.CHOCOLATE_DUST_1975) + + override fun defineListeners() { + onUseWith(IntType.ITEM, Items.CAKE_1891, *chocolate) { player, used, with -> + val product = Items.CHOCOLATE_CAKE_1897 + + if (!hasLevelDyn(player, Skills.COOKING, 50)) { + sendMessage(player, "You need a Cooking level of 50 in order to do that.") + return@onUseWith true + } + + // Avoids sending dialogue if only one can be created + if (amountInInventory(player, used.id) == 1 || amountInInventory(player, with.id) == 1) { + if (removeItem(player, used.id) && removeItem(player, with.id)) { + addItem(player, product) + rewardXP(player, Skills.COOKING, 30.0) + } + return@onUseWith true + } + + sendSkillDialogue(player) { + withItems(product) + create { _, amount -> + + runTask(player, 2, amount) { + if (amount < 1) return@runTask + + if (removeItem(player, used.id) && removeItem(player, with.id)) { + addItem(player, product) + rewardXP(player, Skills.COOKING, 30.0) + } + return@runTask + } + } + + calculateMaxAmount { _ -> + min(amountInInventory(player, with.id), amountInInventory(player, used.id)) + } + } + + return@onUseWith true + } + } +} \ No newline at end of file From 756be9a023ef3e9efeb2c050038530a3eeb5c651 Mon Sep 17 00:00:00 2001 From: Syndromeramo Date: Wed, 23 Jul 2025 22:14:22 -0500 Subject: [PATCH 07/24] Refactored Pies. --- .../global/skill/cooking/PieShellPlugin.java | 56 ---------- .../global/skill/cooking/recipe/Recipe.java | 3 - .../skill/cooking/recipe/pie/PieListener.kt | 105 ++++++++++++++++++ .../skill/cooking/recipe/pie/PieRecipe.java | 38 ------- .../cooking/recipe/pie/PieShellListener.kt | 48 ++++++++ .../cooking/recipe/pie/impl/AdmiralPie.java | 64 ----------- .../cooking/recipe/pie/impl/ApplePie.java | 34 ------ .../cooking/recipe/pie/impl/FishPie.java | 64 ----------- .../cooking/recipe/pie/impl/GardenPie.java | 64 ----------- .../cooking/recipe/pie/impl/MeatPie.java | 58 ---------- .../skill/cooking/recipe/pie/impl/MudPie.java | 64 ----------- .../cooking/recipe/pie/impl/RedberryPie.java | 33 ------ .../cooking/recipe/pie/impl/SummerPie.java | 64 ----------- .../cooking/recipe/pie/impl/WildPie.java | 64 ----------- 14 files changed, 153 insertions(+), 606 deletions(-) delete mode 100644 Server/src/main/content/global/skill/cooking/PieShellPlugin.java create mode 100644 Server/src/main/content/global/skill/cooking/recipe/pie/PieListener.kt delete mode 100644 Server/src/main/content/global/skill/cooking/recipe/pie/PieRecipe.java create mode 100644 Server/src/main/content/global/skill/cooking/recipe/pie/PieShellListener.kt delete mode 100644 Server/src/main/content/global/skill/cooking/recipe/pie/impl/AdmiralPie.java delete mode 100644 Server/src/main/content/global/skill/cooking/recipe/pie/impl/ApplePie.java delete mode 100644 Server/src/main/content/global/skill/cooking/recipe/pie/impl/FishPie.java delete mode 100644 Server/src/main/content/global/skill/cooking/recipe/pie/impl/GardenPie.java delete mode 100644 Server/src/main/content/global/skill/cooking/recipe/pie/impl/MeatPie.java delete mode 100644 Server/src/main/content/global/skill/cooking/recipe/pie/impl/MudPie.java delete mode 100644 Server/src/main/content/global/skill/cooking/recipe/pie/impl/RedberryPie.java delete mode 100644 Server/src/main/content/global/skill/cooking/recipe/pie/impl/SummerPie.java delete mode 100644 Server/src/main/content/global/skill/cooking/recipe/pie/impl/WildPie.java diff --git a/Server/src/main/content/global/skill/cooking/PieShellPlugin.java b/Server/src/main/content/global/skill/cooking/PieShellPlugin.java deleted file mode 100644 index 4278836e8..000000000 --- a/Server/src/main/content/global/skill/cooking/PieShellPlugin.java +++ /dev/null @@ -1,56 +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 pie shell making plugin. - * @author 'Vexia - * @version 1.0 - */ -@Initializable -public final class PieShellPlugin extends UseWithHandler { - - /** - * Represents the pie sell item. - */ - private static final Item PIE_SHELL = new Item(2315, 1); - - /** - * Represents the pie dish item. - */ - private static final Item PIE_DISH = new Item(2313, 1); - - /** - * Represents the pastry dough item. - */ - private static final Item PASTRY_DOUGH = new Item(1953, 1); - - /** - * Constructs a new {@code PieMakingPlugin} {@code Object}. - */ - public PieShellPlugin() { - super(1953); - } - - @Override - public Plugin newInstance(Object arg) throws Throwable { - addHandler(2313, ITEM_TYPE, this); - return this; - } - - @Override - public boolean handle(NodeUsageEvent event) { - final Player player = event.getPlayer(); - if (player.getInventory().remove(PASTRY_DOUGH, PIE_DISH)) { - player.getInventory().add(PIE_SHELL); - player.getPacketDispatch().sendMessage("You put the pastry dough into the pie dish to make a pie shell."); - } - return true; - } - -} diff --git a/Server/src/main/content/global/skill/cooking/recipe/Recipe.java b/Server/src/main/content/global/skill/cooking/recipe/Recipe.java index 3e2eff513..3dd96677e 100644 --- a/Server/src/main/content/global/skill/cooking/recipe/Recipe.java +++ b/Server/src/main/content/global/skill/cooking/recipe/Recipe.java @@ -9,7 +9,6 @@ import content.global.skill.cooking.recipe.potato.impl.*; import content.global.skill.cooking.recipe.stew.CurryRecipe; import content.global.skill.cooking.recipe.stew.StewRecipe; import content.global.skill.cooking.recipe.topping.impl.*; -import content.global.skill.cooking.recipe.cake.ChocolateCake; import core.game.interaction.NodeUsageEvent; import core.game.node.entity.player.Player; import core.game.node.item.Item; @@ -30,10 +29,8 @@ public abstract class Recipe { // - Making pie shells a recipe would make make-x for them just work // - Making pineapple cutting a recipe would probably fix their make-x making all with any option public static final Recipe[] RECIPES = new Recipe[] { - new RedberryPie(), new MeatPie(), new ApplePie(), new MudPie(), new GardenPie(), new FishPie(), new AdmiralPie(), new WildPie(), new SummerPie(), new StewRecipe(), new CurryRecipe(), new PlainPizza(), new MeatPizza(), new AnchovyPizza(), new PineapplePizza(), - new ChocolateCake(), new ButterPotato(), new ChilliPotato(), new CheesePotato(), new EggPotato(), new MushroomPotato(), new TunaPotato(), new SpicySauce(), new ChilliConCarne(), new UncookedEgg(), new EggAndTomato(), new MushroomAndOnion(), new ChoppedOnion(), new SlicedMushroom(), new ChoppedTuna(), new TunaAndCorn(), new OomlieWrap() }; diff --git a/Server/src/main/content/global/skill/cooking/recipe/pie/PieListener.kt b/Server/src/main/content/global/skill/cooking/recipe/pie/PieListener.kt new file mode 100644 index 000000000..6b4eab55a --- /dev/null +++ b/Server/src/main/content/global/skill/cooking/recipe/pie/PieListener.kt @@ -0,0 +1,105 @@ +package content.global.skill.cooking.recipe.pie + +import core.api.* +import core.game.interaction.IntType +import core.game.interaction.InteractionListener +import core.game.node.entity.skill.Skills +import org.rs09.consts.Items +import kotlin.math.min + +class PieListener : InteractionListener { + + val base = PieProduct.values().map { it.base }.toIntArray() + val added = PieProduct.values().map { it.added }.toIntArray() + + override fun defineListeners() { + onUseWith(IntType.ITEM, base, *added) { player, used, with -> + val pie = PieProduct.productMap[used.id] ?: return@onUseWith true + + if (pie.added != with.id) { + return@onUseWith false + } + + if (!hasLevelDyn(player, Skills.COOKING, pie.minimumLevel)) { + sendMessage(player, "You need a Cooking level of ${pie.minimumLevel} to make this.") + return@onUseWith true + } + + // Avoids sending dialogue if only one can be created + if (amountInInventory(player, used.id) == 1 || amountInInventory(player, with.id) == 1) { + if (removeItem(player, pie.base) && removeItem(player, pie.added)) { + addItem(player, pie.product) + if (used.id == Items.COMPOST_6032) addItem(player, Items.BUCKET_1925) + if (with.id == Items.BUCKET_OF_WATER_1929) addItem(player, Items.BUCKET_1925) + sendMessage(player, "You fill the pie with ${pie.message}.") + } + return@onUseWith true + } + + sendSkillDialogue(player) { + withItems(pie.product) + create { _, amount -> + + runTask(player, 2, amount) { + if (amount < 1) return@runTask + + if (removeItem(player, pie.base) && removeItem(player, pie.added)) { + addItem(player, pie.product) + if (used.id == Items.COMPOST_6032) addItem(player, Items.BUCKET_1925) + if (with.id == Items.BUCKET_OF_WATER_1929) addItem(player, Items.BUCKET_1925) + sendMessage(player, "You fill the pie with ${pie.message}.") + } + return@runTask + } + } + + calculateMaxAmount { _ -> + min(amountInInventory(player, with.id), amountInInventory(player, used.id)) + } + } + + return@onUseWith true + } + } + + enum class PieProduct( + val base: Int, + val added: Int, + val product: Int, + val minimumLevel: Int, + val message: String, + ) { + REDBERRY_PIE(Items.REDBERRIES_1951, Items.PIE_SHELL_2315, Items.UNCOOKED_BERRY_PIE_2321, 10, "redberries"), + MEAT_PIE(Items.COOKED_MEAT_2142, Items.PIE_SHELL_2315, Items.UNCOOKED_MEAT_PIE_2319, 20, "meat"), + MUD_PIE_1(Items.COMPOST_6032, Items.PIE_SHELL_2315, Items.PART_MUD_PIE_7164, 29, "compost"), + MUD_PIE_2(Items.PART_MUD_PIE_7164, Items.BUCKET_OF_WATER_1929, Items.PART_MUD_PIE_7166, 29, "water"), + MUD_PIE_3(Items.PART_MUD_PIE_7166, Items.CLAY_434, Items.RAW_MUD_PIE_7168, 29, "clay"), + APPLE_PIE(Items.COOKING_APPLE_1955, Items.PIE_SHELL_2315, Items.UNCOOKED_APPLE_PIE_2317, 30, "cooking apple"), + GARDEN_PIE_1(Items.TOMATO_1982, Items.PIE_SHELL_2315, Items.PART_GARDEN_PIE_7172, 34, "tomato"), + GARDEN_PIE_2(Items.PART_GARDEN_PIE_7172, Items.ONION_1957, Items.PART_GARDEN_PIE_7174, 34, "onion"), + GARDEN_PIE_3(Items.PART_GARDEN_PIE_7174, Items.CABBAGE_1965, Items.RAW_GARDEN_PIE_7176, 34, "cabbage"), + FISH_PIE_1(Items.TROUT_333, Items.PIE_SHELL_2315, Items.PART_FISH_PIE_7182, 47, "trout"), + FISH_PIE_2(Items.PART_FISH_PIE_7182, Items.COD_339, Items.PART_FISH_PIE_7184, 47, "cod"), + FISH_PIE_3(Items.PART_FISH_PIE_7184, Items.POTATO_1942, Items.RAW_FISH_PIE_7186, 47, "potato"), + ADMIRAL_PIE_1(Items.SALMON_329, Items.PIE_SHELL_2315, Items.PART_ADMIRAL_PIE_7192, 70, "salmon"), + ADMIRAL_PIE_2(Items.PART_ADMIRAL_PIE_7192, Items.TUNA_361, Items.PART_ADMIRAL_PIE_7194, 70, "tuna"), + ADMIRAL_PIE_3(Items.PART_ADMIRAL_PIE_7194, Items.POTATO_1942, Items.RAW_ADMIRAL_PIE_7196, 70, "potato"), + WILD_PIE_1(Items.RAW_BEAR_MEAT_2136, Items.PIE_SHELL_2315, Items.PART_WILD_PIE_7202, 85, "raw bear meat"), + WILD_PIE_2(Items.PART_WILD_PIE_7202, Items.RAW_CHOMPY_2876, Items.PART_WILD_PIE_7204, 85, "raw chompy"), + WILD_PIE_3(Items.PART_WILD_PIE_7204, Items.RAW_RABBIT_3226, Items.RAW_WILD_PIE_7206, 85, "raw rabbit"), + SUMMER_PIE_1(Items.STRAWBERRY_5504, Items.PIE_SHELL_2315, Items.PART_SUMMER_PIE_7212, 95, "strawberry"), + SUMMER_PIE_2(Items.PART_SUMMER_PIE_7212, Items.WATERMELON_5982, Items.PART_SUMMER_PIE_7214, 95, "watermelon"), + SUMMER_PIE_3(Items.PART_SUMMER_PIE_7214, Items.COOKING_APPLE_1955, Items.RAW_SUMMER_PIE_7216, 95, "apple"), + ; + + companion object { + val productMap = HashMap() + + init { + for (pie in PieProduct.values()) { + productMap[pie.base] = pie + } + } + } + } +} \ No newline at end of file diff --git a/Server/src/main/content/global/skill/cooking/recipe/pie/PieRecipe.java b/Server/src/main/content/global/skill/cooking/recipe/pie/PieRecipe.java deleted file mode 100644 index 878a3333f..000000000 --- a/Server/src/main/content/global/skill/cooking/recipe/pie/PieRecipe.java +++ /dev/null @@ -1,38 +0,0 @@ -package content.global.skill.cooking.recipe.pie; - -import content.global.skill.cooking.recipe.Recipe; -import core.game.interaction.NodeUsageEvent; -import core.game.node.item.Item; - -/** - * Represents the generic recipe for a pie. - * @author 'Vexia - * @date 21/12/2013 - */ -public abstract class PieRecipe extends Recipe { - - /** - * Represents the pie shell item. - */ - protected static final Item PIE_SHELL = new Item(2315); - - @Override - public Item[] getParts() { - return new Item[] {}; - } - - @Override - public Item getBase() { - return PIE_SHELL; - } - - @Override - public String getMixMessage(final NodeUsageEvent event) { - return "You fill the pie with " + (event.getBaseItem().getId() == 2315 ? event.getUsedItem().getName().toLowerCase() : event.getBaseItem().getName().toLowerCase()) + "."; - } - - @Override - public boolean isSingular() { - return true; - } -} diff --git a/Server/src/main/content/global/skill/cooking/recipe/pie/PieShellListener.kt b/Server/src/main/content/global/skill/cooking/recipe/pie/PieShellListener.kt new file mode 100644 index 000000000..3f239c563 --- /dev/null +++ b/Server/src/main/content/global/skill/cooking/recipe/pie/PieShellListener.kt @@ -0,0 +1,48 @@ +package content.global.skill.cooking.recipe.pie + +import core.api.* +import core.game.interaction.IntType +import core.game.interaction.InteractionListener +import core.game.node.entity.skill.Skills +import org.rs09.consts.Items +import kotlin.math.min + +class PieShellListener : InteractionListener { + + override fun defineListeners() { + onUseWith(IntType.ITEM, Items.PIE_DISH_2313, Items.PASTRY_DOUGH_1953) { player, used, with -> + val product = Items.PIE_SHELL_2315 + + // Avoids sending dialogue if only one can be created + if (amountInInventory(player, used.id) == 1 || amountInInventory(player, with.id) == 1) { + if (removeItem(player, used.id) && removeItem(player, with.id)) { + addItem(player, product) + sendMessage(player, "You put the pastry dough into the pie dish to make a pie shell.") + } + return@onUseWith true + } + + sendSkillDialogue(player) { + withItems(product) + create { _, amount -> + + runTask(player, 2, amount) { + if (amount < 1) return@runTask + + if (removeItem(player, used.id) && removeItem(player, with.id)) { + addItem(player, product) + sendMessage(player, "You put the pastry dough into the pie dish to make a pie shell.") + } + return@runTask + } + } + + calculateMaxAmount { _ -> + min(amountInInventory(player, with.id), amountInInventory(player, used.id)) + } + } + + return@onUseWith true + } + } +} \ No newline at end of file diff --git a/Server/src/main/content/global/skill/cooking/recipe/pie/impl/AdmiralPie.java b/Server/src/main/content/global/skill/cooking/recipe/pie/impl/AdmiralPie.java deleted file mode 100644 index 9cc6a98eb..000000000 --- a/Server/src/main/content/global/skill/cooking/recipe/pie/impl/AdmiralPie.java +++ /dev/null @@ -1,64 +0,0 @@ -package content.global.skill.cooking.recipe.pie.impl; - -import content.global.skill.cooking.recipe.pie.PieRecipe; -import core.game.node.item.Item; - -/** - * Represents the admiral pie recipe. This recipe conists of pixing a salmon, - * tuna and potato together. - * @author 'Vexia - * @date 21/12/2013 - */ -public class AdmiralPie extends PieRecipe { - - /** - * Represents the uncooked redberry pie. - */ - private static final Item UNCOOKED_PIE = new Item(7196); - - /** - * Represents the salmon ingredient item. - */ - private static final Item SALMON = new Item(329); - - /** - * Represents the tuna ingredient item. - */ - private static final Item TUNA = new Item(361); - - /** - * Represents the potato item. - */ - private static final Item POTATO = new Item(1942); - - /** - * Represents the part one pie item. - */ - private static final Item PART_ONE = new Item(7192); - - /** - * Represents the part two pie item. - */ - private static final Item PART_TWO = new Item(7194); - - @Override - public Item getProduct() { - return UNCOOKED_PIE; - } - - @Override - public Item[] getIngredients() { - return new Item[] { SALMON, TUNA, POTATO }; - } - - @Override - public Item[] getParts() { - return new Item[] { PIE_SHELL, PART_ONE, PART_TWO, UNCOOKED_PIE }; - } - - @Override - public boolean isSingular() { - return false; - } - -} diff --git a/Server/src/main/content/global/skill/cooking/recipe/pie/impl/ApplePie.java b/Server/src/main/content/global/skill/cooking/recipe/pie/impl/ApplePie.java deleted file mode 100644 index e44917445..000000000 --- a/Server/src/main/content/global/skill/cooking/recipe/pie/impl/ApplePie.java +++ /dev/null @@ -1,34 +0,0 @@ -package content.global.skill.cooking.recipe.pie.impl; - -import content.global.skill.cooking.recipe.pie.PieRecipe; -import core.game.node.item.Item; - -/** - * Represents the apple pie recipe. This recipe consists of cooking apples and a - * pie shell. - * @author 'Vexia - * @date 21/12/2013 - */ -public class ApplePie extends PieRecipe { - - /** - * Represents the uncooked redberry pie. - */ - private static final Item UNCOOKED_PIE = new Item(2317); - - /** - * Represents the cooking apple item. - */ - private static final Item COOKING_APPLE = new Item(1955); - - @Override - public Item getProduct() { - return UNCOOKED_PIE; - } - - @Override - public Item[] getIngredients() { - return new Item[] { COOKING_APPLE }; - } - -} diff --git a/Server/src/main/content/global/skill/cooking/recipe/pie/impl/FishPie.java b/Server/src/main/content/global/skill/cooking/recipe/pie/impl/FishPie.java deleted file mode 100644 index 7a1dad02f..000000000 --- a/Server/src/main/content/global/skill/cooking/recipe/pie/impl/FishPie.java +++ /dev/null @@ -1,64 +0,0 @@ -package content.global.skill.cooking.recipe.pie.impl; - -import content.global.skill.cooking.recipe.pie.PieRecipe; -import core.game.node.item.Item; - -/** - * Represents the garden pie recipe. This pie consists of mixing, tomato, onion, - * and cabbage together. - * @author 'Vexia - * @date 21/12/2013 - */ -public class FishPie extends PieRecipe { - - /** - * Represents the uncooked redberry pie. - */ - private static final Item UNCOOKED_PIE = new Item(7186); - - /** - * Represents the trout item ingredient. - */ - private static final Item TROUT = new Item(333); - - /** - * Represents the cod item ingredient. - */ - private static final Item COD = new Item(339); - - /** - * Represents the potato item. - */ - private static final Item POTATO = new Item(1942); - - /** - * Represents the part one pie item. - */ - private static final Item PART_ONE = new Item(7182); - - /** - * Represents the part two pie item. - */ - private static final Item PART_TWO = new Item(7184); - - @Override - public Item getProduct() { - return UNCOOKED_PIE; - } - - @Override - public Item[] getIngredients() { - return new Item[] { TROUT, COD, POTATO }; - } - - @Override - public Item[] getParts() { - return new Item[] { PIE_SHELL, PART_ONE, PART_TWO, UNCOOKED_PIE }; - } - - @Override - public boolean isSingular() { - return false; - } - -} diff --git a/Server/src/main/content/global/skill/cooking/recipe/pie/impl/GardenPie.java b/Server/src/main/content/global/skill/cooking/recipe/pie/impl/GardenPie.java deleted file mode 100644 index 90fbe7e23..000000000 --- a/Server/src/main/content/global/skill/cooking/recipe/pie/impl/GardenPie.java +++ /dev/null @@ -1,64 +0,0 @@ -package content.global.skill.cooking.recipe.pie.impl; - -import content.global.skill.cooking.recipe.pie.PieRecipe; -import core.game.node.item.Item; - -/** - * Represents the garden pie recipe. This pie consists of mixing, tomato, onion, - * and cabbage together. - * @author 'Vexia - * @date 21/12/2013 - */ -public class GardenPie extends PieRecipe { - - /** - * Represents the uncooked redberry pie. - */ - private static final Item UNCOOKED_PIE = new Item(7176); - - /** - * Represents the tomato ingredient item. - */ - private static final Item TOMATO = new Item(1982); - - /** - * Represents the onion ingredient item. - */ - private static final Item ONION = new Item(1957); - - /** - * Represents the cabbage ingredient item. - */ - private static final Item CABBAGE = new Item(1965); - - /** - * Represents the part one pie item. - */ - private static final Item PART_ONE = new Item(7172); - - /** - * Represents the part two pie item. - */ - private static final Item PART_TWO = new Item(7174); - - @Override - public Item getProduct() { - return UNCOOKED_PIE; - } - - @Override - public Item[] getIngredients() { - return new Item[] { TOMATO, ONION, CABBAGE }; - } - - @Override - public Item[] getParts() { - return new Item[] { PIE_SHELL, PART_ONE, PART_TWO, UNCOOKED_PIE }; - } - - @Override - public boolean isSingular() { - return false; - } - -} diff --git a/Server/src/main/content/global/skill/cooking/recipe/pie/impl/MeatPie.java b/Server/src/main/content/global/skill/cooking/recipe/pie/impl/MeatPie.java deleted file mode 100644 index 1edb223fd..000000000 --- a/Server/src/main/content/global/skill/cooking/recipe/pie/impl/MeatPie.java +++ /dev/null @@ -1,58 +0,0 @@ -package content.global.skill.cooking.recipe.pie.impl; - -import content.global.skill.cooking.recipe.pie.PieRecipe; -import core.game.interaction.NodeUsageEvent; -import core.game.node.entity.player.Player; -import core.game.node.item.Item; - -/** - * Represents the meat pie recipe. - * @author 'Vexia - * @date 21/12/2013 - */ -public class MeatPie extends PieRecipe { - - /** - * Represents the uncooked redberry pie. - */ - private static final Item UNCOOKED_PIE = new Item(2319); - - /** - * Represents the cooked meat item. - */ - private static final Item COOKED_MEAT = new Item(2142); - - /** - * Represents the cooked chicken item. - */ - private static final Item COOKED_CHICKEN = new Item(2140); - - /** - * Represents the cooked rabbit. - */ - private static final Item COOKED_RABBIT = new Item(3228); - - @Override - public void mix(final Player player, final NodeUsageEvent event) { - if (player.getInventory().remove(event.getUsedItem()) && player.getInventory().remove(event.getBaseItem())) { - player.getInventory().add(getProduct()); - player.getPacketDispatch().sendMessage(getMixMessage(event)); - return; - } - } - - @Override - public Item getProduct() { - return UNCOOKED_PIE; - } - - @Override - public Item[] getIngredients() { - return new Item[] { COOKED_MEAT, COOKED_CHICKEN, COOKED_RABBIT }; - } - - @Override - public String getMixMessage(final NodeUsageEvent event) { - return "You fill the pie with meat."; - } -} diff --git a/Server/src/main/content/global/skill/cooking/recipe/pie/impl/MudPie.java b/Server/src/main/content/global/skill/cooking/recipe/pie/impl/MudPie.java deleted file mode 100644 index 64a542f46..000000000 --- a/Server/src/main/content/global/skill/cooking/recipe/pie/impl/MudPie.java +++ /dev/null @@ -1,64 +0,0 @@ -package content.global.skill.cooking.recipe.pie.impl; - -import content.global.skill.cooking.recipe.pie.PieRecipe; -import core.game.node.item.Item; - -/** - * Represents the mud pie recipe. A mud pie consists of mixing compost, water - * and clay together. - * @author 'Vexia - * @date 21/12/2013 - */ -public class MudPie extends PieRecipe { - - /** - * Represents the uncooked redberry pie. - */ - private static final Item UNCOOKED_PIE = new Item(7168); - - /** - * Represents the compost item. - */ - private static final Item COMPOST = new Item(6032); - - /** - * Represents the bucket of water item. - */ - private static final Item BUCKET_OF_WATER = new Item(1929); - - /** - * Represents the clay item. - */ - private static final Item CLAY = new Item(434); - - /** - * Represents the part one pie item. - */ - private static final Item PART_ONE = new Item(7164); - - /** - * Represents the part two pie item. - */ - private static final Item PART_TWO = new Item(7166); - - @Override - public Item getProduct() { - return UNCOOKED_PIE; - } - - @Override - public Item[] getIngredients() { - return new Item[] { COMPOST, BUCKET_OF_WATER, CLAY }; - } - - @Override - public Item[] getParts() { - return new Item[] { PIE_SHELL, PART_ONE, PART_TWO, UNCOOKED_PIE }; - } - - @Override - public boolean isSingular() { - return false; - } - -} diff --git a/Server/src/main/content/global/skill/cooking/recipe/pie/impl/RedberryPie.java b/Server/src/main/content/global/skill/cooking/recipe/pie/impl/RedberryPie.java deleted file mode 100644 index 6ebbd04f6..000000000 --- a/Server/src/main/content/global/skill/cooking/recipe/pie/impl/RedberryPie.java +++ /dev/null @@ -1,33 +0,0 @@ -package content.global.skill.cooking.recipe.pie.impl; - -import content.global.skill.cooking.recipe.pie.PieRecipe; -import core.game.node.item.Item; - -/** - * Represents a redberry pie recipe. - * @author 'Vexia - * @date 21/12/2013 - */ -public class RedberryPie extends PieRecipe { - - /** - * Represents the uncooked redberry pie. - */ - private static final Item UNCOOKED_PIE = new Item(2321); - - /** - * Represents the redberries pie. - */ - private static final Item REDBERRIES = new Item(1951); - - @Override - public Item getProduct() { - return UNCOOKED_PIE; - } - - @Override - public Item[] getIngredients() { - return new Item[] { REDBERRIES }; - } - -} diff --git a/Server/src/main/content/global/skill/cooking/recipe/pie/impl/SummerPie.java b/Server/src/main/content/global/skill/cooking/recipe/pie/impl/SummerPie.java deleted file mode 100644 index 14996852a..000000000 --- a/Server/src/main/content/global/skill/cooking/recipe/pie/impl/SummerPie.java +++ /dev/null @@ -1,64 +0,0 @@ -package content.global.skill.cooking.recipe.pie.impl; - -import content.global.skill.cooking.recipe.pie.PieRecipe; -import core.game.node.item.Item; - -/** - * Represents the summer pie recipe. This recipe consists of mixing stawberry, - * watermelon, and an apple. - * @author 'Vexia - * @date 21/12/2013 - */ -public class SummerPie extends PieRecipe { - - /** - * Represents the uncooked redberry pie. - */ - private static final Item UNCOOKED_PIE = new Item(7216); - - /** - * Represents the strawberry item. - */ - private static final Item STRAWBERRY = new Item(5504); - - /** - * Represents the watermelon item. - */ - private static final Item WATERMELON = new Item(5982); - - /** - * Represents the cooking apple item. - */ - private static final Item COOKING_APPLE = new Item(1955); - - /** - * Represents the part one pie item. - */ - private static final Item PART_ONE = new Item(7212); - - /** - * Represents the part two pie item. - */ - private static final Item PART_TWO = new Item(7214); - - @Override - public Item getProduct() { - return UNCOOKED_PIE; - } - - @Override - public Item[] getIngredients() { - return new Item[] { STRAWBERRY, WATERMELON, COOKING_APPLE }; - } - - @Override - public Item[] getParts() { - return new Item[] { PIE_SHELL, PART_ONE, PART_TWO, UNCOOKED_PIE }; - } - - @Override - public boolean isSingular() { - return false; - } - -} diff --git a/Server/src/main/content/global/skill/cooking/recipe/pie/impl/WildPie.java b/Server/src/main/content/global/skill/cooking/recipe/pie/impl/WildPie.java deleted file mode 100644 index 3b4decaa2..000000000 --- a/Server/src/main/content/global/skill/cooking/recipe/pie/impl/WildPie.java +++ /dev/null @@ -1,64 +0,0 @@ -package content.global.skill.cooking.recipe.pie.impl; - -import content.global.skill.cooking.recipe.pie.PieRecipe; -import core.game.node.item.Item; - -/** - * Represents the wild pie recipe. This recipe consists of mixing raw beat meat, - * raw chomp, and raw rabbit into a pie shell. - * @author 'Vexia - * @date 21/12/2013 - */ -public class WildPie extends PieRecipe { - - /** - * Represents the uncooked redberry pie. - */ - private static final Item UNCOOKED_PIE = new Item(7206); - - /** - * Represents the raw bear meat item. - */ - private static final Item BEAR_MEAT = new Item(2136); - - /** - * Represents the raw chompy meat item. - */ - private static final Item CHOMPY_MEAT = new Item(2876); - - /** - * Represents the raw rabbit meat item. - */ - private static final Item RABBIT_MEAT = new Item(3226); - - /** - * Represents the part one pie item. - */ - private static final Item PART_ONE = new Item(7202); - - /** - * Represents the part two pie item. - */ - private static final Item PART_TWO = new Item(7204); - - @Override - public Item getProduct() { - return UNCOOKED_PIE; - } - - @Override - public Item[] getIngredients() { - return new Item[] { BEAR_MEAT, CHOMPY_MEAT, RABBIT_MEAT }; - } - - @Override - public Item[] getParts() { - return new Item[] { PIE_SHELL, PART_ONE, PART_TWO, UNCOOKED_PIE }; - } - - @Override - public boolean isSingular() { - return false; - } - -} From c1d76fecc79d6f797fad46ec5154cf4efb4bc35b Mon Sep 17 00:00:00 2001 From: Syndromeramo Date: Wed, 23 Jul 2025 22:14:46 -0500 Subject: [PATCH 08/24] Refactored Pies. --- Server/src/main/content/global/skill/cooking/recipe/Recipe.java | 1 - 1 file changed, 1 deletion(-) diff --git a/Server/src/main/content/global/skill/cooking/recipe/Recipe.java b/Server/src/main/content/global/skill/cooking/recipe/Recipe.java index 3dd96677e..8a41f7fcf 100644 --- a/Server/src/main/content/global/skill/cooking/recipe/Recipe.java +++ b/Server/src/main/content/global/skill/cooking/recipe/Recipe.java @@ -1,6 +1,5 @@ package content.global.skill.cooking.recipe; -import content.global.skill.cooking.recipe.pie.impl.*; import content.global.skill.cooking.recipe.pizza.impl.AnchovyPizza; import content.global.skill.cooking.recipe.pizza.impl.MeatPizza; import content.global.skill.cooking.recipe.pizza.impl.PineapplePizza; From 9e4e7f41d63a1c6441a4457fa979bc53a174d28b Mon Sep 17 00:00:00 2001 From: Syndromeramo Date: Wed, 23 Jul 2025 23:22:41 -0500 Subject: [PATCH 09/24] Refactored Pizzas. --- .../global/skill/cooking/recipe/Recipe.java | 5 -- .../cooking/recipe/pizza/PizzaListener.kt | 90 +++++++++++++++++++ .../cooking/recipe/pizza/PizzaRecipe.java | 63 ------------- .../recipe/pizza/impl/AnchovyPizza.java | 44 --------- .../cooking/recipe/pizza/impl/MeatPizza.java | 49 ---------- .../recipe/pizza/impl/PineapplePizza.java | 55 ------------ .../cooking/recipe/pizza/impl/PlainPizza.java | 81 ----------------- 7 files changed, 90 insertions(+), 297 deletions(-) create mode 100644 Server/src/main/content/global/skill/cooking/recipe/pizza/PizzaListener.kt delete mode 100644 Server/src/main/content/global/skill/cooking/recipe/pizza/PizzaRecipe.java delete mode 100644 Server/src/main/content/global/skill/cooking/recipe/pizza/impl/AnchovyPizza.java delete mode 100644 Server/src/main/content/global/skill/cooking/recipe/pizza/impl/MeatPizza.java delete mode 100644 Server/src/main/content/global/skill/cooking/recipe/pizza/impl/PineapplePizza.java delete mode 100644 Server/src/main/content/global/skill/cooking/recipe/pizza/impl/PlainPizza.java diff --git a/Server/src/main/content/global/skill/cooking/recipe/Recipe.java b/Server/src/main/content/global/skill/cooking/recipe/Recipe.java index 8a41f7fcf..8d58dc3cc 100644 --- a/Server/src/main/content/global/skill/cooking/recipe/Recipe.java +++ b/Server/src/main/content/global/skill/cooking/recipe/Recipe.java @@ -1,9 +1,5 @@ package content.global.skill.cooking.recipe; -import content.global.skill.cooking.recipe.pizza.impl.AnchovyPizza; -import content.global.skill.cooking.recipe.pizza.impl.MeatPizza; -import content.global.skill.cooking.recipe.pizza.impl.PineapplePizza; -import content.global.skill.cooking.recipe.pizza.impl.PlainPizza; import content.global.skill.cooking.recipe.potato.impl.*; import content.global.skill.cooking.recipe.stew.CurryRecipe; import content.global.skill.cooking.recipe.stew.StewRecipe; @@ -29,7 +25,6 @@ public abstract class Recipe { // - Making pineapple cutting a recipe would probably fix their make-x making all with any option public static final Recipe[] RECIPES = new Recipe[] { new StewRecipe(), new CurryRecipe(), - new PlainPizza(), new MeatPizza(), new AnchovyPizza(), new PineapplePizza(), new ButterPotato(), new ChilliPotato(), new CheesePotato(), new EggPotato(), new MushroomPotato(), new TunaPotato(), new SpicySauce(), new ChilliConCarne(), new UncookedEgg(), new EggAndTomato(), new MushroomAndOnion(), new ChoppedOnion(), new SlicedMushroom(), new ChoppedTuna(), new TunaAndCorn(), new OomlieWrap() }; diff --git a/Server/src/main/content/global/skill/cooking/recipe/pizza/PizzaListener.kt b/Server/src/main/content/global/skill/cooking/recipe/pizza/PizzaListener.kt new file mode 100644 index 000000000..e0818910e --- /dev/null +++ b/Server/src/main/content/global/skill/cooking/recipe/pizza/PizzaListener.kt @@ -0,0 +1,90 @@ +package content.global.skill.cooking.recipe.pizza + +import core.api.* +import core.game.interaction.IntType +import core.game.interaction.InteractionListener +import core.game.node.entity.skill.Skills +import org.rs09.consts.Items +import kotlin.math.min + +class PizzaListener : InteractionListener { + + val base = PizzaProduct.values().map { it.base }.toIntArray() + val added = PizzaProduct.values().map { it.added }.toIntArray() + + override fun defineListeners() { + onUseWith(IntType.ITEM, base, *added) { player, used, with -> + val pizza = PizzaProduct.productMap[used.id] ?: return@onUseWith true + + if (pizza.added != with.id) { + return@onUseWith false + } + + if (!hasLevelDyn(player, Skills.COOKING, pizza.minimumLevel)) { + sendMessage(player, "You need a Cooking level of at least ${pizza.minimumLevel} in order to do this.") + return@onUseWith true + } + + // Avoids sending dialogue if only one can be created + if (amountInInventory(player, used.id) == 1 || amountInInventory(player, with.id) == 1) { + if (removeItem(player, pizza.base) && removeItem(player, pizza.added)) { + addItem(player, pizza.product) + rewardXP(player, Skills.COOKING, pizza.experience) + sendMessage(player, "You add the ${pizza.message} to the pizza.") + } + return@onUseWith true + } + + sendSkillDialogue(player) { + withItems(pizza.product) + create { _, amount -> + + runTask(player, 2, amount) { + if (amount < 1) return@runTask + + if (removeItem(player, pizza.base) && removeItem(player, pizza.added)) { + addItem(player, pizza.product) + rewardXP(player, Skills.COOKING, pizza.experience) + sendMessage(player, "You add the ${pizza.message} to the pizza.") + } + return@runTask + } + } + + calculateMaxAmount { _ -> + min(amountInInventory(player, with.id), amountInInventory(player, used.id)) + } + } + + return@onUseWith true + } + } + + enum class PizzaProduct( + val base: Int, + val added: Int, + val product: Int, + val minimumLevel: Int, + val experience: Double, + val message: String, + ) { + PIZZA_1(Items.TOMATO_1982, Items.PIZZA_BASE_2283, Items.INCOMPLETE_PIZZA_2285, 35, 0.0,"tomato"), + PIZZA_2(Items.CHEESE_1985, Items.INCOMPLETE_PIZZA_2285, Items.UNCOOKED_PIZZA_2287, 35, 0.0, "cheese"), + MEAT_PIZZA_1(Items.COOKED_MEAT_2142, Items.PLAIN_PIZZA_2289, Items.MEAT_PIZZA_2293, 45, 26.0, "meat"), + MEAT_PIZZA_2(Items.COOKED_CHICKEN_2140, Items.PLAIN_PIZZA_2289, Items.MEAT_PIZZA_2293, 45, 26.0, "cooked chicken"), + ANCHOVY_PIZZA(Items.ANCHOVIES_319, Items.PLAIN_PIZZA_2289, Items.ANCHOVY_PIZZA_2297, 55, 39.0, "anchovies"), + PINEAPPLE_PIZZA_1(Items.PINEAPPLE_CHUNKS_2116, Items.PLAIN_PIZZA_2289, Items.PINEAPPLE_PIZZA_2301, 65, 52.0, "pineapple"), + PINEAPPLE_PIZZA_2(Items.PINEAPPLE_RING_2118, Items.PLAIN_PIZZA_2289, Items.PINEAPPLE_PIZZA_2301, 65, 52.0, "pineapple"), + ; + + companion object { + val productMap = HashMap() + + init { + for (pizza in PizzaProduct.values()) { + productMap[pizza.base] = pizza + } + } + } + } +} \ No newline at end of file diff --git a/Server/src/main/content/global/skill/cooking/recipe/pizza/PizzaRecipe.java b/Server/src/main/content/global/skill/cooking/recipe/pizza/PizzaRecipe.java deleted file mode 100644 index 5a1385a35..000000000 --- a/Server/src/main/content/global/skill/cooking/recipe/pizza/PizzaRecipe.java +++ /dev/null @@ -1,63 +0,0 @@ -package content.global.skill.cooking.recipe.pizza; - -import core.game.node.entity.skill.Skills; -import content.global.skill.cooking.recipe.Recipe; -import core.game.interaction.NodeUsageEvent; -import core.game.node.entity.player.Player; -import core.game.node.item.Item; - -/** - * Represents the generic recipe for a pizza. - * @author ceikry - */ -public abstract class PizzaRecipe extends Recipe { - - /** - * Represents the plain pizza. - */ - protected static final Item PLAIN_PIZZA = new Item(2289); - - /** - * Method used to get the experience gained from adding the final - * ingredient. - * @return the experience. - */ - public abstract double getExperience(); - - /** - * Method used to get the level required. - * @return the level required. - */ - public abstract int getLevel(); - - @Override - public void mix(final Player player, final NodeUsageEvent event) { - if (player.getSkills().getLevel(Skills.COOKING) < getLevel()) { - player.getDialogueInterpreter().sendDialogue("You need a Cooking level of at least " + getLevel() + " in order to do this."); - return; - } - super.singleMix(player, event); - player.getSkills().addExperience(Skills.COOKING, getExperience(), true); - } - - @Override - public Item[] getParts() { - return new Item[] {}; - } - - @Override - public Item getBase() { - return PLAIN_PIZZA; - } - - @Override - public String getMixMessage(final NodeUsageEvent event) { - return "You add " + event.getBaseItem().getName().toLowerCase() + " to the pizza."; - } - - @Override - public boolean isSingular() { - return true; - } - -} diff --git a/Server/src/main/content/global/skill/cooking/recipe/pizza/impl/AnchovyPizza.java b/Server/src/main/content/global/skill/cooking/recipe/pizza/impl/AnchovyPizza.java deleted file mode 100644 index 4a70625ff..000000000 --- a/Server/src/main/content/global/skill/cooking/recipe/pizza/impl/AnchovyPizza.java +++ /dev/null @@ -1,44 +0,0 @@ -package content.global.skill.cooking.recipe.pizza.impl; - -import content.global.skill.cooking.recipe.pizza.PizzaRecipe; -import core.game.node.item.Item; - -/** - * Represents the anchovy pizza. This recipe consists of adding anchovies to a - * plain pizza. - * @author 'Vexia - * @date 22/12/2013 - */ -public class AnchovyPizza extends PizzaRecipe { - - /** - * Represents the anchovy pizza item. - */ - private static final Item ANCHOVY_PIZZA = new Item(2297); - - /** - * Represents the anchovies item. - */ - private static final Item ANCHOVIES = new Item(319); - - @Override - public double getExperience() { - return 39; - } - - @Override - public Item getProduct() { - return ANCHOVY_PIZZA; - } - - @Override - public Item[] getIngredients() { - return new Item[] { ANCHOVIES }; - } - - @Override - public int getLevel() { - return 55; - } - -} diff --git a/Server/src/main/content/global/skill/cooking/recipe/pizza/impl/MeatPizza.java b/Server/src/main/content/global/skill/cooking/recipe/pizza/impl/MeatPizza.java deleted file mode 100644 index b79096137..000000000 --- a/Server/src/main/content/global/skill/cooking/recipe/pizza/impl/MeatPizza.java +++ /dev/null @@ -1,49 +0,0 @@ -package content.global.skill.cooking.recipe.pizza.impl; - -import content.global.skill.cooking.recipe.pizza.PizzaRecipe; -import core.game.node.item.Item; - -/** - * Represents the meat pizza recipe. This recipe consists of adding cooked meat - * to a plain pizza. - * @author 'Vexia - * @date 22/12/2013 - */ -public class MeatPizza extends PizzaRecipe { - - /** - * Represents the meat pizza item. - */ - private static final Item MEAT_PIZZA = new Item(2293); - - /** - * Represents the cooked meat item. - */ - private static final Item COOKED_MEAT = new Item(2142); - - /** - * Represents the cooked chicken item. - */ - private static final Item COOKED_CHICKEN = new Item(2140); - - @Override - public double getExperience() { - return 26; - } - - @Override - public int getLevel() { - return 45; - } - - @Override - public Item getProduct() { - return MEAT_PIZZA; - } - - @Override - public Item[] getIngredients() { - return new Item[] { COOKED_MEAT, COOKED_CHICKEN }; - } - -} diff --git a/Server/src/main/content/global/skill/cooking/recipe/pizza/impl/PineapplePizza.java b/Server/src/main/content/global/skill/cooking/recipe/pizza/impl/PineapplePizza.java deleted file mode 100644 index 7e4746e2f..000000000 --- a/Server/src/main/content/global/skill/cooking/recipe/pizza/impl/PineapplePizza.java +++ /dev/null @@ -1,55 +0,0 @@ -package content.global.skill.cooking.recipe.pizza.impl; - -import content.global.skill.cooking.recipe.pizza.PizzaRecipe; -import core.game.interaction.NodeUsageEvent; -import core.game.node.item.Item; - -/** - * Represents the pineapple pizza recipe. This recipe consists of mixing either - * pineapple chunks or pineapple rings. - * @author 'Vexia - * @date 22/12/2013 - */ -public class PineapplePizza extends PizzaRecipe { - - /** - * Represents the pineapple pizza item. - */ - private static final Item PINEAPPLE_PIZZA = new Item(2301); - - /** - * Represents the pineapple ring item. - */ - private static final Item PINEAPPLE_RING = new Item(2118); - - /** - * Represents the pineapple chunk item. - */ - private static final Item PINEAPPLE_CHUNKS = new Item(2116); - - @Override - public double getExperience() { - return 52; - } - - @Override - public int getLevel() { - return 65; - } - - @Override - public Item getProduct() { - return PINEAPPLE_PIZZA; - } - - @Override - public Item[] getIngredients() { - return new Item[] { PINEAPPLE_CHUNKS, PINEAPPLE_RING }; - } - - @Override - public String getMixMessage(NodeUsageEvent event) { - return "You add the " + event.getBaseItem().getName().toLowerCase() + " to the pizza."; - } - -} diff --git a/Server/src/main/content/global/skill/cooking/recipe/pizza/impl/PlainPizza.java b/Server/src/main/content/global/skill/cooking/recipe/pizza/impl/PlainPizza.java deleted file mode 100644 index 8d624dca3..000000000 --- a/Server/src/main/content/global/skill/cooking/recipe/pizza/impl/PlainPizza.java +++ /dev/null @@ -1,81 +0,0 @@ -package content.global.skill.cooking.recipe.pizza.impl; - -import core.game.node.entity.skill.Skills; -import content.global.skill.cooking.recipe.Recipe; -import core.game.interaction.NodeUsageEvent; -import core.game.node.entity.player.Player; -import core.game.node.item.Item; - -/** - * Represents the plain pizza recipe. This recipe consists of mixing tomato, and - * cheese to a pizza base. - * @author 'Vexia - * @date 22/12/2013 - */ -public class PlainPizza extends Recipe { - - /** - * Represents the pizza base. - */ - private static final Item PIZZA_BASE = new Item(2283); - - /** - * Represents the uncooked pizza. - */ - private static final Item UNCOOKED_PIZZA = new Item(2287); - - /** - * Represents the incomplete pizza. - */ - private static final Item INCOMPLETE_PIZZA = new Item(2285); - - /** - * Represents the tomato ingredient item. - */ - private static final Item TOMATO = new Item(1982); - - /** - * Represents the cheese item. - */ - private static final Item CHEESE = new Item(1985); - - @Override - public void mix(final Player player, final NodeUsageEvent event) { - if (player.getSkills().getLevel(Skills.COOKING) < 35) { - player.getDialogueInterpreter().sendDialogue("You need a Cooking level of at least " + 35 + " in order to do this."); - return; - } - super.mix(player, event); - } - - @Override - public Item getBase() { - return PIZZA_BASE; - } - - @Override - public Item getProduct() { - return UNCOOKED_PIZZA; - } - - @Override - public Item[] getIngredients() { - return new Item[] { TOMATO, CHEESE }; - } - - @Override - public Item[] getParts() { - return new Item[] { PIZZA_BASE, INCOMPLETE_PIZZA, UNCOOKED_PIZZA }; - } - - @Override - public String getMixMessage(NodeUsageEvent event) { - return "You add the " + event.getBaseItem().getName().toLowerCase() + " to the pizza."; - } - - @Override - public boolean isSingular() { - return false; - } - -} From 7cc7a691a8637f204f5517a7b272e45ad16d6d3d Mon Sep 17 00:00:00 2001 From: Syndromeramo Date: Thu, 24 Jul 2025 21:29:34 -0500 Subject: [PATCH 10/24] Refactored Oomlie Wraps. Standardized dialogue logic. --- .../skill/cooking/recipe/OomlieWrap.java | 57 ------------------- .../cooking/recipe/OomlieWrapListener.kt | 51 +++++++++++++++++ .../global/skill/cooking/recipe/Recipe.java | 2 +- .../skill/cooking/recipe/pie/PieListener.kt | 4 +- .../cooking/recipe/pizza/PizzaListener.kt | 4 +- 5 files changed, 56 insertions(+), 62 deletions(-) delete mode 100644 Server/src/main/content/global/skill/cooking/recipe/OomlieWrap.java create mode 100644 Server/src/main/content/global/skill/cooking/recipe/OomlieWrapListener.kt diff --git a/Server/src/main/content/global/skill/cooking/recipe/OomlieWrap.java b/Server/src/main/content/global/skill/cooking/recipe/OomlieWrap.java deleted file mode 100644 index d5e8ee5f7..000000000 --- a/Server/src/main/content/global/skill/cooking/recipe/OomlieWrap.java +++ /dev/null @@ -1,57 +0,0 @@ -package content.global.skill.cooking.recipe; - -import org.rs09.consts.Items; -import core.game.node.entity.skill.Skills; -import core.game.interaction.NodeUsageEvent; -import core.game.node.entity.player.Player; -import core.game.node.item.Item; - -/** - * @author afaroutdude - */ -public class OomlieWrap extends Recipe { - - private static final Item OOMLIE_WRAP = new Item(Items.WRAPPED_OOMLIE_2341); - private static final Item RAW_OOMLIE = new Item(Items.RAW_OOMLIE_2337); - private static final Item PALM_LEAF = new Item(Items.PALM_LEAF_2339); - - @Override - public void mix(final Player player, final NodeUsageEvent event) { - if (player.getSkills().getLevel(Skills.COOKING) < 50) { - player.getDialogueInterpreter().sendDialogue("You need a Cooking level of 50 in order to do that."); - return; - } - super.mix(player, event); - } - - @Override - public Item getBase() { - return RAW_OOMLIE; - } - - @Override - public Item getProduct() { - return OOMLIE_WRAP; - } - - @Override - public Item[] getIngredients() { - return new Item[] { PALM_LEAF }; - } - - @Override - public Item[] getParts() { - return new Item[] {}; - } - - @Override - public String getMixMessage(NodeUsageEvent event) { - return "You wrap the raw oomlie in the palm leaf."; - } - - @Override - public boolean isSingular() { - return true; - } - -} diff --git a/Server/src/main/content/global/skill/cooking/recipe/OomlieWrapListener.kt b/Server/src/main/content/global/skill/cooking/recipe/OomlieWrapListener.kt new file mode 100644 index 000000000..b126a835d --- /dev/null +++ b/Server/src/main/content/global/skill/cooking/recipe/OomlieWrapListener.kt @@ -0,0 +1,51 @@ +package content.global.skill.cooking.recipe + +import core.api.* +import core.game.interaction.IntType +import core.game.interaction.InteractionListener +import core.game.node.entity.skill.Skills +import org.rs09.consts.Items +import kotlin.math.min + +class OomlieWrapListener : InteractionListener { + + override fun defineListeners() { + onUseWith(IntType.ITEM, Items.RAW_OOMLIE_2337, Items.PALM_LEAF_2339) { player, used, with -> + if (!hasLevelDyn(player, Skills.COOKING, 50)) { + sendMessage(player, "You need a Cooking level of at least 50 in order to do that.") + return@onUseWith true + } + + // Avoids sending dialogue if only one can be created + if (amountInInventory(player, used.id) == 1 || amountInInventory(player, with.id) == 1) { + if (removeItem(player, used.id) && removeItem(player, with.id)) { + addItem(player, Items.WRAPPED_OOMLIE_2341) + sendMessage(player, "You wrap the raw oomlie in the palm leaf.") + } + return@onUseWith true + } + + sendSkillDialogue(player) { + withItems(Items.WRAPPED_OOMLIE_2341) + create { _, amount -> + + runTask(player, 2, amount) { + if (amount < 1) return@runTask + + if (removeItem(player, used.id) && removeItem(player, with.id)) { + addItem(player, Items.WRAPPED_OOMLIE_2341) + sendMessage(player, "You wrap the raw oomlie in the palm leaf.") + } + return@runTask + } + } + + calculateMaxAmount { _ -> + min(amountInInventory(player, with.id), amountInInventory(player, used.id)) + } + } + + return@onUseWith true + } + } +} \ No newline at end of file diff --git a/Server/src/main/content/global/skill/cooking/recipe/Recipe.java b/Server/src/main/content/global/skill/cooking/recipe/Recipe.java index 8d58dc3cc..26b32d6a9 100644 --- a/Server/src/main/content/global/skill/cooking/recipe/Recipe.java +++ b/Server/src/main/content/global/skill/cooking/recipe/Recipe.java @@ -26,7 +26,7 @@ public abstract class Recipe { public static final Recipe[] RECIPES = new Recipe[] { new StewRecipe(), new CurryRecipe(), new ButterPotato(), new ChilliPotato(), new CheesePotato(), new EggPotato(), new MushroomPotato(), new TunaPotato(), - new SpicySauce(), new ChilliConCarne(), new UncookedEgg(), new EggAndTomato(), new MushroomAndOnion(), new ChoppedOnion(), new SlicedMushroom(), new ChoppedTuna(), new TunaAndCorn(), new OomlieWrap() + new SpicySauce(), new ChilliConCarne(), new UncookedEgg(), new EggAndTomato(), new MushroomAndOnion(), new ChoppedOnion(), new SlicedMushroom(), new ChoppedTuna(), new TunaAndCorn() }; /** diff --git a/Server/src/main/content/global/skill/cooking/recipe/pie/PieListener.kt b/Server/src/main/content/global/skill/cooking/recipe/pie/PieListener.kt index 6b4eab55a..e927e9f4a 100644 --- a/Server/src/main/content/global/skill/cooking/recipe/pie/PieListener.kt +++ b/Server/src/main/content/global/skill/cooking/recipe/pie/PieListener.kt @@ -27,7 +27,7 @@ class PieListener : InteractionListener { // Avoids sending dialogue if only one can be created if (amountInInventory(player, used.id) == 1 || amountInInventory(player, with.id) == 1) { - if (removeItem(player, pie.base) && removeItem(player, pie.added)) { + if (removeItem(player, used.id) && removeItem(player, with.id)) { addItem(player, pie.product) if (used.id == Items.COMPOST_6032) addItem(player, Items.BUCKET_1925) if (with.id == Items.BUCKET_OF_WATER_1929) addItem(player, Items.BUCKET_1925) @@ -43,7 +43,7 @@ class PieListener : InteractionListener { runTask(player, 2, amount) { if (amount < 1) return@runTask - if (removeItem(player, pie.base) && removeItem(player, pie.added)) { + if (removeItem(player, used.id) && removeItem(player, with.id)) { addItem(player, pie.product) if (used.id == Items.COMPOST_6032) addItem(player, Items.BUCKET_1925) if (with.id == Items.BUCKET_OF_WATER_1929) addItem(player, Items.BUCKET_1925) diff --git a/Server/src/main/content/global/skill/cooking/recipe/pizza/PizzaListener.kt b/Server/src/main/content/global/skill/cooking/recipe/pizza/PizzaListener.kt index e0818910e..646ddd986 100644 --- a/Server/src/main/content/global/skill/cooking/recipe/pizza/PizzaListener.kt +++ b/Server/src/main/content/global/skill/cooking/recipe/pizza/PizzaListener.kt @@ -27,7 +27,7 @@ class PizzaListener : InteractionListener { // Avoids sending dialogue if only one can be created if (amountInInventory(player, used.id) == 1 || amountInInventory(player, with.id) == 1) { - if (removeItem(player, pizza.base) && removeItem(player, pizza.added)) { + if (removeItem(player, used.id) && removeItem(player, with.id)) { addItem(player, pizza.product) rewardXP(player, Skills.COOKING, pizza.experience) sendMessage(player, "You add the ${pizza.message} to the pizza.") @@ -42,7 +42,7 @@ class PizzaListener : InteractionListener { runTask(player, 2, amount) { if (amount < 1) return@runTask - if (removeItem(player, pizza.base) && removeItem(player, pizza.added)) { + if (removeItem(player, used.id) && removeItem(player, with.id)) { addItem(player, pizza.product) rewardXP(player, Skills.COOKING, pizza.experience) sendMessage(player, "You add the ${pizza.message} to the pizza.") From e20848e0d055b243910a030beb2702e9b5b134ef Mon Sep 17 00:00:00 2001 From: Syndromeramo Date: Fri, 25 Jul 2025 15:27:52 -0500 Subject: [PATCH 11/24] Stew/Curry Refactor (in progress) Attempt to make a standardized cooking mix function. --- .../skill/cooking/recipe/MixIngredients.kt | 46 ++++++++++ .../global/skill/cooking/recipe/Recipe.java | 3 - .../recipe/cake/ChocolateCakeListener.kt | 51 +++------- .../cooking/recipe/stew/CurryListener.kt | 71 ++++++++++++++ .../cooking/recipe/stew/CurryRecipe.java | 89 ------------------ .../skill/cooking/recipe/stew/StewListener.kt | 84 +++++++++++++++++ .../skill/cooking/recipe/stew/StewRecipe.java | 92 ------------------- 7 files changed, 212 insertions(+), 224 deletions(-) create mode 100644 Server/src/main/content/global/skill/cooking/recipe/MixIngredients.kt create mode 100644 Server/src/main/content/global/skill/cooking/recipe/stew/CurryListener.kt delete mode 100644 Server/src/main/content/global/skill/cooking/recipe/stew/CurryRecipe.java create mode 100644 Server/src/main/content/global/skill/cooking/recipe/stew/StewListener.kt delete mode 100644 Server/src/main/content/global/skill/cooking/recipe/stew/StewRecipe.java diff --git a/Server/src/main/content/global/skill/cooking/recipe/MixIngredients.kt b/Server/src/main/content/global/skill/cooking/recipe/MixIngredients.kt new file mode 100644 index 000000000..0be6eacd2 --- /dev/null +++ b/Server/src/main/content/global/skill/cooking/recipe/MixIngredients.kt @@ -0,0 +1,46 @@ +package content.global.skill.cooking.recipe + +import core.api.* +import core.game.node.entity.player.Player +import core.game.node.entity.skill.Skills +import kotlin.math.min + +fun mixIngredients(player: Player, used: Int, with: Int, product: Int, level: Int, experience: Double, message: String, failMessage: String): Boolean { + if (!hasLevelDyn(player, Skills.COOKING, level)) { + sendMessage(player, failMessage) + return true + } + + // Avoids sending dialogue if only one can be created + if (amountInInventory(player, used) == 1 || amountInInventory(player, with) == 1) { + if (removeItem(player, used) && removeItem(player, with)) { + addItem(player, product) + sendMessage(player, message) + rewardXP(player, Skills.COOKING, experience) + } + return true + } + + sendSkillDialogue(player) { + withItems(product) + create { _, amount -> + + runTask(player, 2, amount) { + if (amount < 1) return@runTask + + if (removeItem(player, used) && removeItem(player, with)) { + addItem(player, product) + sendMessage(player, message) + rewardXP(player, Skills.COOKING, experience) + } + return@runTask + } + } + + calculateMaxAmount { _ -> + min(amountInInventory(player, used), amountInInventory(player, with)) + } + } + + return true +} \ No newline at end of file diff --git a/Server/src/main/content/global/skill/cooking/recipe/Recipe.java b/Server/src/main/content/global/skill/cooking/recipe/Recipe.java index 26b32d6a9..f9a3ad2be 100644 --- a/Server/src/main/content/global/skill/cooking/recipe/Recipe.java +++ b/Server/src/main/content/global/skill/cooking/recipe/Recipe.java @@ -1,8 +1,6 @@ package content.global.skill.cooking.recipe; import content.global.skill.cooking.recipe.potato.impl.*; -import content.global.skill.cooking.recipe.stew.CurryRecipe; -import content.global.skill.cooking.recipe.stew.StewRecipe; import content.global.skill.cooking.recipe.topping.impl.*; import core.game.interaction.NodeUsageEvent; import core.game.node.entity.player.Player; @@ -24,7 +22,6 @@ public abstract class Recipe { // - Making pie shells a recipe would make make-x for them just work // - Making pineapple cutting a recipe would probably fix their make-x making all with any option public static final Recipe[] RECIPES = new Recipe[] { - new StewRecipe(), new CurryRecipe(), new ButterPotato(), new ChilliPotato(), new CheesePotato(), new EggPotato(), new MushroomPotato(), new TunaPotato(), new SpicySauce(), new ChilliConCarne(), new UncookedEgg(), new EggAndTomato(), new MushroomAndOnion(), new ChoppedOnion(), new SlicedMushroom(), new ChoppedTuna(), new TunaAndCorn() }; diff --git a/Server/src/main/content/global/skill/cooking/recipe/cake/ChocolateCakeListener.kt b/Server/src/main/content/global/skill/cooking/recipe/cake/ChocolateCakeListener.kt index 32d0193cb..ba6f08f84 100644 --- a/Server/src/main/content/global/skill/cooking/recipe/cake/ChocolateCakeListener.kt +++ b/Server/src/main/content/global/skill/cooking/recipe/cake/ChocolateCakeListener.kt @@ -1,11 +1,9 @@ package content.global.skill.cooking.recipe.cake -import core.api.* +import content.global.skill.cooking.recipe.mixIngredients import core.game.interaction.IntType import core.game.interaction.InteractionListener -import core.game.node.entity.skill.Skills import org.rs09.consts.Items -import kotlin.math.min class ChocolateCakeListener : InteractionListener { @@ -13,43 +11,16 @@ class ChocolateCakeListener : InteractionListener { override fun defineListeners() { onUseWith(IntType.ITEM, Items.CAKE_1891, *chocolate) { player, used, with -> - val product = Items.CHOCOLATE_CAKE_1897 - - if (!hasLevelDyn(player, Skills.COOKING, 50)) { - sendMessage(player, "You need a Cooking level of 50 in order to do that.") - return@onUseWith true - } - - // Avoids sending dialogue if only one can be created - if (amountInInventory(player, used.id) == 1 || amountInInventory(player, with.id) == 1) { - if (removeItem(player, used.id) && removeItem(player, with.id)) { - addItem(player, product) - rewardXP(player, Skills.COOKING, 30.0) - } - return@onUseWith true - } - - sendSkillDialogue(player) { - withItems(product) - create { _, amount -> - - runTask(player, 2, amount) { - if (amount < 1) return@runTask - - if (removeItem(player, used.id) && removeItem(player, with.id)) { - addItem(player, product) - rewardXP(player, Skills.COOKING, 30.0) - } - return@runTask - } - } - - calculateMaxAmount { _ -> - min(amountInInventory(player, with.id), amountInInventory(player, used.id)) - } - } - - return@onUseWith true + val level = 50 + return@onUseWith mixIngredients( + player, + used.id, + with.id, + Items.CHOCOLATE_CAKE_1897, + level, + 0.0, + "", + "You need a Cooking level of $level in order to do that.") } } } \ No newline at end of file diff --git a/Server/src/main/content/global/skill/cooking/recipe/stew/CurryListener.kt b/Server/src/main/content/global/skill/cooking/recipe/stew/CurryListener.kt new file mode 100644 index 000000000..5a0d0ef0a --- /dev/null +++ b/Server/src/main/content/global/skill/cooking/recipe/stew/CurryListener.kt @@ -0,0 +1,71 @@ +package content.global.skill.cooking.recipe.stew + +import core.api.* +import core.game.interaction.IntType +import core.game.interaction.InteractionListener +import core.game.node.entity.skill.Skills +import core.game.node.item.Item +import org.rs09.consts.Items +import kotlin.math.min + +class CurryListener : InteractionListener { + + val added = intArrayOf(Items.CURRY_LEAF_5970, Items.SPICE_2007) + + override fun defineListeners() { + onUseWith(IntType.ITEM, Items.UNCOOKED_STEW_2001, *added) { player, used, with -> + val product = Items.UNCOOKED_CURRY_2009 + val amountAdded = when (with.id) { + Items.CURRY_LEAF_5970 -> 3 + Items.SPICE_2007 -> 1 + else -> 0 + } + val amountAvailable = when (with.id) { + Items.CURRY_LEAF_5970 -> amountInInventory(player, with.id)/3 + Items.SPICE_2007 -> amountInInventory(player, with.id) + else -> 0 + } + + if (!hasLevelDyn(player, Skills.COOKING, 60)) { + sendMessage(player, "You need a Cooking level of at least 60 in order to do this.") + return@onUseWith true + } + + if (amountAvailable == 0) { + sendMessage(player, "You do not have three curry leaves.") //inauthentic dialogue + return@onUseWith true + } + + // Avoids sending dialogue if only one can be created + if (amountInInventory(player, used.id) == 1 || amountAvailable == 1) { + if (removeItem(player, used.id) && removeItem(player, Item(with.id, amountAdded))) { + addItem(player, product) + sendMessage(player, "You mix the spice with the stew.") + } + return@onUseWith true + } + + sendSkillDialogue(player) { + withItems(product) + create { _, amount -> + + runTask(player, 2, amount) { + if (amount < 1) return@runTask + + if (removeItem(player, used.id) && removeItem(player, Item(with.id, amountAdded))) { + addItem(player, product) + sendMessage(player, "You mix the spice with the stew.") + } + return@runTask + } + } + + calculateMaxAmount { _ -> + min(amountInInventory(player, used.id), amountAvailable) + } + } + + return@onUseWith true + } + } +} \ No newline at end of file diff --git a/Server/src/main/content/global/skill/cooking/recipe/stew/CurryRecipe.java b/Server/src/main/content/global/skill/cooking/recipe/stew/CurryRecipe.java deleted file mode 100644 index 4ea78825d..000000000 --- a/Server/src/main/content/global/skill/cooking/recipe/stew/CurryRecipe.java +++ /dev/null @@ -1,89 +0,0 @@ -package content.global.skill.cooking.recipe.stew; - -import content.global.skill.cooking.recipe.Recipe; -import core.game.interaction.NodeUsageEvent; -import core.game.node.entity.player.Player; -import core.game.node.item.Item; - -/** - * Represents the curry recipe. This recipe consists of mixing 3 curry leaves or - * a spice into a stew. - * @author 'Vexia - * @date 22/12/2013 - */ -public class CurryRecipe extends Recipe { - - /** - * Represents the uncooked curry item. - */ - private static final Item UNCOOKED_CURRY = new Item(2009); - - /** - * Represents the uncooked stew item. - */ - private static final Item UNCOOKED_STEW = new Item(2001); - - /** - * Represents the spice item. - */ - private static final Item SPICE = new Item(2007); - - /** - * Represents the curry leaf. - */ - private static final Item CURRY_LEAF = new Item(5970); - - @Override - public void mix(Player player, NodeUsageEvent event) { - if (event.getBaseItem().getId() == CURRY_LEAF.getId() || event.getUsedItem().getId() == CURRY_LEAF.getId()) { - Item stew = event.getBaseItem().getId() == UNCOOKED_STEW.getId() ? event.getBaseItem() : event.getUsedItem(); - if (stew.getCharge() == 1000) { - stew.setCharge(1); - } - int charge = stew.getCharge(); - if (charge < 3) { - player.getInventory().remove(CURRY_LEAF); - stew.setCharge(charge + 1); - } else { - if (player.getInventory().remove(stew) && player.getInventory().remove(CURRY_LEAF)) { - player.getInventory().add(UNCOOKED_CURRY); - } - } - return; - } - if (player.getInventory().remove(event.getBaseItem()) && player.getInventory().remove(event.getUsedItem())) { - player.getInventory().add(getProduct()); - } - } - - @Override - public Item getBase() { - return UNCOOKED_STEW; - } - - @Override - public Item getProduct() { - return UNCOOKED_CURRY; - } - - @Override - public Item[] getIngredients() { - return new Item[] { SPICE, CURRY_LEAF }; - } - - @Override - public Item[] getParts() { - return new Item[] { UNCOOKED_STEW }; - } - - @Override - public String getMixMessage(NodeUsageEvent event) { - return "You mix the spice with the stew."; - } - - @Override - public boolean isSingular() { - return true; - } - -} diff --git a/Server/src/main/content/global/skill/cooking/recipe/stew/StewListener.kt b/Server/src/main/content/global/skill/cooking/recipe/stew/StewListener.kt new file mode 100644 index 000000000..9601ba556 --- /dev/null +++ b/Server/src/main/content/global/skill/cooking/recipe/stew/StewListener.kt @@ -0,0 +1,84 @@ +package content.global.skill.cooking.recipe.stew + +import core.api.* +import core.game.interaction.IntType +import core.game.interaction.InteractionListener +import core.game.node.entity.skill.Skills +import org.rs09.consts.Items +import kotlin.math.min + +class StewListener : InteractionListener { + + val base = StewProduct.values().map { it.base }.toIntArray() + val added = StewProduct.values().map { it.added }.toIntArray() + + override fun defineListeners() { + onUseWith(IntType.ITEM, base, *added) { player, used, with -> + val stew = StewProduct.productMap[used.id] ?: return@onUseWith true + + if (stew.added != with.id) { + return@onUseWith false + } + + if (!hasLevelDyn(player, Skills.COOKING, stew.minimumLevel)) { + sendMessage(player, "You need a Cooking level of at least ${stew.minimumLevel} in order to do this.") + return@onUseWith true + } + + // Avoids sending dialogue if only one can be created + if (amountInInventory(player, used.id) == 1 || amountInInventory(player, with.id) == 1) { + if (removeItem(player, used.id) && removeItem(player, with.id)) { + addItem(player, stew.product) + sendMessage(player, "You cut up the ${stew.message} and put it into the stew.") + } + return@onUseWith true + } + + sendSkillDialogue(player) { + withItems(stew.product) + create { _, amount -> + + runTask(player, 2, amount) { + if (amount < 1) return@runTask + + if (removeItem(player, used.id) && removeItem(player, with.id)) { + addItem(player, stew.product) + sendMessage(player, "You cut up the ${stew.message} and put it into the stew.") + } + return@runTask + } + } + + calculateMaxAmount { _ -> + min(amountInInventory(player, with.id), amountInInventory(player, used.id)) + } + } + + return@onUseWith true + } + } + + enum class StewProduct( + val base: Int, + val added: Int, + val product: Int, + val minimumLevel: Int, + val message: String, + ) { + STEW_1(Items.POTATO_1942, Items.BOWL_OF_WATER_1921, Items.INCOMPLETE_STEW_1997, 25, "potato"), + STEW_2(Items.INCOMPLETE_STEW_1997, Items.COOKED_MEAT_2142, Items.UNCOOKED_STEW_2001, 25, "meat"), + STEW_3(Items.COOKED_MEAT_2142, Items.BOWL_OF_WATER_1921, Items.INCOMPLETE_STEW_1999, 25, "meat"), + STEW_4(Items.INCOMPLETE_STEW_1999, Items.POTATO_1942, Items.UNCOOKED_STEW_2001, 25, "potato"), + ; + + companion object { + val productMap = HashMap() + + init { + for (stew in StewProduct.values()) { + productMap[stew.base] = stew + } + } + } + } +} \ No newline at end of file diff --git a/Server/src/main/content/global/skill/cooking/recipe/stew/StewRecipe.java b/Server/src/main/content/global/skill/cooking/recipe/stew/StewRecipe.java deleted file mode 100644 index 4073bcc0e..000000000 --- a/Server/src/main/content/global/skill/cooking/recipe/stew/StewRecipe.java +++ /dev/null @@ -1,92 +0,0 @@ -package content.global.skill.cooking.recipe.stew; - -import content.global.skill.cooking.recipe.Recipe; -import core.game.interaction.NodeUsageEvent; -import core.game.node.entity.player.Player; -import core.game.node.item.Item; - -/** - * Represents the stew recipe. This recipe consists of mixing meat and a raw - * potato in a bowl of water. - * @author 'Vexia - * @date 22/12/2013 - */ -public class StewRecipe extends Recipe { - - /** - * Represents the uncooked stew item. - */ - private static final Item UNCOOKED_STEW = new Item(2001); - - /** - * Represents the bowl of water item. - */ - private static final Item BOWL_OF_WATER = new Item(1921); - - /** - * Represents the meat item. - */ - private static final Item MEAT = new Item(2142); - - /** - * Represents the potato item. - */ - private static final Item POTATO = new Item(1942); - - /** - * Represents the incomplete stew. - */ - private static final Item INCOMPLETE_STEW = new Item(1997); - - /** - * Represents the second incomplete stew. - */ - private static final Item INCOMPLETE_STEW2 = new Item(1999); - - @Override - public void mix(Player player, NodeUsageEvent event) { - Item first = event.getUsedItem(); - Item second = event.getBaseItem(); - if(first != null && second != null) { - if (player.getInventory().remove(first) && player.getInventory().remove(second)) { - if (first.getId() == BOWL_OF_WATER.getId() || second.getId() == BOWL_OF_WATER.getId()) { - player.getInventory().add(first.getId() == POTATO.getId() ? INCOMPLETE_STEW : first.getId() == MEAT.getId() ? INCOMPLETE_STEW2 : second.getId() == POTATO.getId() ? INCOMPLETE_STEW : second.getId() == MEAT.getId() ? INCOMPLETE_STEW2 : null); - } else { - player.getInventory().add(UNCOOKED_STEW); - } - player.getPacketDispatch().sendMessage(getMixMessage(event)); - } - } - } - - @Override - public Item getBase() { - return BOWL_OF_WATER; - } - - @Override - public Item getProduct() { - return UNCOOKED_STEW; - } - - @Override - public Item[] getIngredients() { - return new Item[] { MEAT, POTATO, MEAT, POTATO }; - } - - @Override - public Item[] getParts() { - return new Item[] { BOWL_OF_WATER, BOWL_OF_WATER, INCOMPLETE_STEW, INCOMPLETE_STEW2 }; - } - - @Override - public String getMixMessage(NodeUsageEvent event) { - return "You cut up the " + (event.getUsedItem().getName().toLowerCase().contains("incomplete") ? event.getBaseItem().getName().toLowerCase() : event.getUsedItem().getName().toLowerCase().replace("cooked", "").trim()) + " and put it into the stew."; - } - - @Override - public boolean isSingular() { - return false; - } - -} From 5a4aa7a274a7af2889654fe24448a8fae258e261 Mon Sep 17 00:00:00 2001 From: Syndromeramo Date: Fri, 25 Jul 2025 15:27:52 -0500 Subject: [PATCH 12/24] Stew/Curry Refactor (in progress) Attempt to make a standardized cooking mix function. --- .../content/global/skill/cooking/recipe/MixIngredients.kt | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Server/src/main/content/global/skill/cooking/recipe/MixIngredients.kt b/Server/src/main/content/global/skill/cooking/recipe/MixIngredients.kt index 0be6eacd2..da7486b62 100644 --- a/Server/src/main/content/global/skill/cooking/recipe/MixIngredients.kt +++ b/Server/src/main/content/global/skill/cooking/recipe/MixIngredients.kt @@ -28,7 +28,9 @@ fun mixIngredients(player: Player, used: Int, with: Int, product: Int, level: In runTask(player, 2, amount) { if (amount < 1) return@runTask - if (removeItem(player, used) && removeItem(player, with)) { + if (inInventory(player, used) && inInventory(player, with)) { + removeItem(player, used) + removeItem(player, with) addItem(player, product) sendMessage(player, message) rewardXP(player, Skills.COOKING, experience) From 4ed749cd09aa2f8f1a875085557d51a8d5fbc11e Mon Sep 17 00:00:00 2001 From: Syndromeramo Date: Fri, 25 Jul 2025 19:12:31 -0500 Subject: [PATCH 13/24] Work on MixIngredients script --- .../global/skill/cooking/recipe/MixIngredients.kt | 15 +++++++++++---- .../cooking/recipe/cake/ChocolateCakeListener.kt | 2 +- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/Server/src/main/content/global/skill/cooking/recipe/MixIngredients.kt b/Server/src/main/content/global/skill/cooking/recipe/MixIngredients.kt index da7486b62..55c4e2e65 100644 --- a/Server/src/main/content/global/skill/cooking/recipe/MixIngredients.kt +++ b/Server/src/main/content/global/skill/cooking/recipe/MixIngredients.kt @@ -6,6 +6,10 @@ import core.game.node.entity.skill.Skills import kotlin.math.min fun mixIngredients(player: Player, used: Int, with: Int, product: Int, level: Int, experience: Double, message: String, failMessage: String): Boolean { + fun getMaxAmount(_unused: Int = 0): Int { + return min(amountInInventory(player, with), amountInInventory(player, used)) + } + if (!hasLevelDyn(player, Skills.COOKING, level)) { sendMessage(player, failMessage) return true @@ -25,9 +29,14 @@ fun mixIngredients(player: Player, used: Int, with: Int, product: Int, level: In withItems(product) create { _, amount -> - runTask(player, 2, amount) { + runTask(player, 2, min(amount, getMaxAmount())) { if (amount < 1) return@runTask + if (!hasLevelDyn(player, Skills.COOKING, level)) { + sendMessage(player, failMessage) + return@runTask + } + if (inInventory(player, used) && inInventory(player, with)) { removeItem(player, used) removeItem(player, with) @@ -39,9 +48,7 @@ fun mixIngredients(player: Player, used: Int, with: Int, product: Int, level: In } } - calculateMaxAmount { _ -> - min(amountInInventory(player, used), amountInInventory(player, with)) - } + calculateMaxAmount(::getMaxAmount) } return true diff --git a/Server/src/main/content/global/skill/cooking/recipe/cake/ChocolateCakeListener.kt b/Server/src/main/content/global/skill/cooking/recipe/cake/ChocolateCakeListener.kt index ba6f08f84..e656a8573 100644 --- a/Server/src/main/content/global/skill/cooking/recipe/cake/ChocolateCakeListener.kt +++ b/Server/src/main/content/global/skill/cooking/recipe/cake/ChocolateCakeListener.kt @@ -18,7 +18,7 @@ class ChocolateCakeListener : InteractionListener { with.id, Items.CHOCOLATE_CAKE_1897, level, - 0.0, + 30.0, "", "You need a Cooking level of $level in order to do that.") } From d6438a2b1e182c0c2603df5a6069e3ad75361823 Mon Sep 17 00:00:00 2001 From: Syndromeramo Date: Fri, 25 Jul 2025 21:39:59 -0500 Subject: [PATCH 14/24] MixHandler set up as standardized way to mix recipes. --- .../global/skill/cooking/recipe/MixHandler.kt | 34 ++++++++++++ .../skill/cooking/recipe/MixIngredients.kt | 55 ------------------- .../global/skill/cooking/recipe/MixScript.kt | 45 +++++++++++++++ .../recipe/cake/ChocolateCakeListener.kt | 36 ++++++++++-- 4 files changed, 109 insertions(+), 61 deletions(-) create mode 100644 Server/src/main/content/global/skill/cooking/recipe/MixHandler.kt delete mode 100644 Server/src/main/content/global/skill/cooking/recipe/MixIngredients.kt create mode 100644 Server/src/main/content/global/skill/cooking/recipe/MixScript.kt diff --git a/Server/src/main/content/global/skill/cooking/recipe/MixHandler.kt b/Server/src/main/content/global/skill/cooking/recipe/MixHandler.kt new file mode 100644 index 000000000..d3179f0d6 --- /dev/null +++ b/Server/src/main/content/global/skill/cooking/recipe/MixHandler.kt @@ -0,0 +1,34 @@ +package content.global.skill.cooking.recipe + +import core.api.* +import core.game.dialogue.SkillDialogueHandler +import core.game.node.entity.player.Player +import core.game.node.entity.skill.Skills +import kotlin.math.min + +fun mixHandler(player: Player, used: Int, with: Int, product: Int, level: Int, experience: Double, message: String, failMessage: String): SkillDialogueHandler { + val handler: SkillDialogueHandler = + object : + SkillDialogueHandler(player, SkillDialogue.ONE_OPTION, product.asItem()) { + override fun create(amount: Int, index: Int) { + if (!playerMeetsInitialRequirements()) return + MixScript(player, used, with, product, amount, level, experience, message, failMessage).invoke() + } + + private fun playerMeetsInitialRequirements(): Boolean { + if (getDynLevel(player, Skills.COOKING) < level) { + sendDialogue(player, failMessage) + return false + } + return true + } + + override fun getAll(index: Int): Int { + return min( + amountInInventory(player, used), + amountInInventory(player, with) + ) + } + } + return handler +} diff --git a/Server/src/main/content/global/skill/cooking/recipe/MixIngredients.kt b/Server/src/main/content/global/skill/cooking/recipe/MixIngredients.kt deleted file mode 100644 index 55c4e2e65..000000000 --- a/Server/src/main/content/global/skill/cooking/recipe/MixIngredients.kt +++ /dev/null @@ -1,55 +0,0 @@ -package content.global.skill.cooking.recipe - -import core.api.* -import core.game.node.entity.player.Player -import core.game.node.entity.skill.Skills -import kotlin.math.min - -fun mixIngredients(player: Player, used: Int, with: Int, product: Int, level: Int, experience: Double, message: String, failMessage: String): Boolean { - fun getMaxAmount(_unused: Int = 0): Int { - return min(amountInInventory(player, with), amountInInventory(player, used)) - } - - if (!hasLevelDyn(player, Skills.COOKING, level)) { - sendMessage(player, failMessage) - return true - } - - // Avoids sending dialogue if only one can be created - if (amountInInventory(player, used) == 1 || amountInInventory(player, with) == 1) { - if (removeItem(player, used) && removeItem(player, with)) { - addItem(player, product) - sendMessage(player, message) - rewardXP(player, Skills.COOKING, experience) - } - return true - } - - sendSkillDialogue(player) { - withItems(product) - create { _, amount -> - - runTask(player, 2, min(amount, getMaxAmount())) { - if (amount < 1) return@runTask - - if (!hasLevelDyn(player, Skills.COOKING, level)) { - sendMessage(player, failMessage) - return@runTask - } - - if (inInventory(player, used) && inInventory(player, with)) { - removeItem(player, used) - removeItem(player, with) - addItem(player, product) - sendMessage(player, message) - rewardXP(player, Skills.COOKING, experience) - } - return@runTask - } - } - - calculateMaxAmount(::getMaxAmount) - } - - return true -} \ No newline at end of file diff --git a/Server/src/main/content/global/skill/cooking/recipe/MixScript.kt b/Server/src/main/content/global/skill/cooking/recipe/MixScript.kt new file mode 100644 index 000000000..7835e994f --- /dev/null +++ b/Server/src/main/content/global/skill/cooking/recipe/MixScript.kt @@ -0,0 +1,45 @@ +package content.global.skill.cooking.recipe + +import core.api.* +import core.game.node.entity.player.Player +import core.game.node.entity.skill.Skills + +class MixScript( + private val player: Player, + private val used: Int, + private val with: Int, + private val product: Int, + private val sets: Int, + private val level: Int, + private val experience: Double, + private val message: String, + private val failMessage: String +) { + + private val delay = 2 + + fun invoke() { + queueScript(player, delay) { stage -> Int + if (getDynLevel(player, Skills.COOKING) < level) { + sendDialogue(player, failMessage) + return@queueScript stopExecuting(player) + } + + if (inInventory(player, used) && inInventory(player, with)) { + removeItem(player, used) + removeItem(player, with) + sendMessage(player, message) + rewardXP(player, Skills.COOKING, experience) + addItem(player, product) + } else { + return@queueScript stopExecuting(player) + } + + if (stage >= sets - 1) { + return@queueScript stopExecuting(player) + } + + return@queueScript delayScript(player, delay) + } + } +} \ No newline at end of file diff --git a/Server/src/main/content/global/skill/cooking/recipe/cake/ChocolateCakeListener.kt b/Server/src/main/content/global/skill/cooking/recipe/cake/ChocolateCakeListener.kt index e656a8573..a7912c6ea 100644 --- a/Server/src/main/content/global/skill/cooking/recipe/cake/ChocolateCakeListener.kt +++ b/Server/src/main/content/global/skill/cooking/recipe/cake/ChocolateCakeListener.kt @@ -1,8 +1,10 @@ package content.global.skill.cooking.recipe.cake -import content.global.skill.cooking.recipe.mixIngredients +import content.global.skill.cooking.recipe.mixHandler +import core.api.* import core.game.interaction.IntType import core.game.interaction.InteractionListener +import core.game.node.entity.skill.Skills import org.rs09.consts.Items class ChocolateCakeListener : InteractionListener { @@ -11,16 +13,38 @@ class ChocolateCakeListener : InteractionListener { override fun defineListeners() { onUseWith(IntType.ITEM, Items.CAKE_1891, *chocolate) { player, used, with -> + val product = Items.CHOCOLATE_CAKE_1897 val level = 50 - return@onUseWith mixIngredients( + val experience = 30.0 + val message = "" + val failMessage = "You need a Cooking level of $level in order to do that." + + // Avoids sending dialogue if only one can be created + if (amountInInventory(player, used.id) == 1 || amountInInventory(player, with.id) == 1) { + if (getDynLevel(player, Skills.COOKING) < level) { + sendDialogue(player, failMessage) + return@onUseWith true + } + + if (removeItem(player, used.id) && removeItem(player, with.id)) { + sendMessage(player, message) + rewardXP(player, Skills.COOKING, experience) + addItem(player, product) + } + return@onUseWith true + } + + mixHandler( player, used.id, with.id, - Items.CHOCOLATE_CAKE_1897, + product, level, - 30.0, - "", - "You need a Cooking level of $level in order to do that.") + experience, + message, + failMessage + ).open() + return@onUseWith true } } } \ No newline at end of file From a0ab209ffe6af072ae10d84dd71865b034b5168e Mon Sep 17 00:00:00 2001 From: Syndromeramo Date: Fri, 25 Jul 2025 21:49:48 -0500 Subject: [PATCH 15/24] MixHandler set up as standardized way to mix recipes. --- .../global/skill/cooking/recipe/MixHandler.kt | 31 ++++++++++++++++++- .../recipe/cake/ChocolateCakeListener.kt | 24 ++------------ 2 files changed, 33 insertions(+), 22 deletions(-) diff --git a/Server/src/main/content/global/skill/cooking/recipe/MixHandler.kt b/Server/src/main/content/global/skill/cooking/recipe/MixHandler.kt index d3179f0d6..02ace8eb2 100644 --- a/Server/src/main/content/global/skill/cooking/recipe/MixHandler.kt +++ b/Server/src/main/content/global/skill/cooking/recipe/MixHandler.kt @@ -6,7 +6,36 @@ import core.game.node.entity.player.Player import core.game.node.entity.skill.Skills import kotlin.math.min -fun mixHandler(player: Player, used: Int, with: Int, product: Int, level: Int, experience: Double, message: String, failMessage: String): SkillDialogueHandler { +fun standardMix(player: Player, used: Int, with: Int, product: Int, level: Int, experience: Double, message: String, failMessage: String): Boolean { + // Avoids sending dialogue if only one can be created + if (amountInInventory(player, used) == 1 || amountInInventory(player, with) == 1) { + if (getDynLevel(player, Skills.COOKING) < level) { + sendDialogue(player, failMessage) + return true + } + + if (removeItem(player, used) && removeItem(player, with)) { + sendMessage(player, message) + rewardXP(player, Skills.COOKING, experience) + addItem(player, product) + } + return true + } + + mixHandler( + player, + used, + with, + product, + level, + experience, + message, + failMessage + ).open() + return true +} + +private fun mixHandler(player: Player, used: Int, with: Int, product: Int, level: Int, experience: Double, message: String, failMessage: String): SkillDialogueHandler { val handler: SkillDialogueHandler = object : SkillDialogueHandler(player, SkillDialogue.ONE_OPTION, product.asItem()) { diff --git a/Server/src/main/content/global/skill/cooking/recipe/cake/ChocolateCakeListener.kt b/Server/src/main/content/global/skill/cooking/recipe/cake/ChocolateCakeListener.kt index a7912c6ea..1fd3a2185 100644 --- a/Server/src/main/content/global/skill/cooking/recipe/cake/ChocolateCakeListener.kt +++ b/Server/src/main/content/global/skill/cooking/recipe/cake/ChocolateCakeListener.kt @@ -1,10 +1,8 @@ package content.global.skill.cooking.recipe.cake -import content.global.skill.cooking.recipe.mixHandler -import core.api.* +import content.global.skill.cooking.recipe.standardMix import core.game.interaction.IntType import core.game.interaction.InteractionListener -import core.game.node.entity.skill.Skills import org.rs09.consts.Items class ChocolateCakeListener : InteractionListener { @@ -19,22 +17,7 @@ class ChocolateCakeListener : InteractionListener { val message = "" val failMessage = "You need a Cooking level of $level in order to do that." - // Avoids sending dialogue if only one can be created - if (amountInInventory(player, used.id) == 1 || amountInInventory(player, with.id) == 1) { - if (getDynLevel(player, Skills.COOKING) < level) { - sendDialogue(player, failMessage) - return@onUseWith true - } - - if (removeItem(player, used.id) && removeItem(player, with.id)) { - sendMessage(player, message) - rewardXP(player, Skills.COOKING, experience) - addItem(player, product) - } - return@onUseWith true - } - - mixHandler( + return@onUseWith standardMix( player, used.id, with.id, @@ -43,8 +26,7 @@ class ChocolateCakeListener : InteractionListener { experience, message, failMessage - ).open() - return@onUseWith true + ) } } } \ No newline at end of file From cde383678b08b5ee29c6dfe76d7674ca44efd581 Mon Sep 17 00:00:00 2001 From: Syndromeramo Date: Fri, 25 Jul 2025 22:20:44 -0500 Subject: [PATCH 16/24] MixHandler updated for refactored mix recipes. --- .../global/skill/cooking/recipe/MixHandler.kt | 3 + .../global/skill/cooking/recipe/MixScript.kt | 10 ++++ .../skill/cooking/recipe/pie/PieListener.kt | 57 ++++++------------- .../cooking/recipe/pie/PieShellListener.kt | 45 +++++---------- .../cooking/recipe/pizza/PizzaListener.kt | 52 ++++++----------- 5 files changed, 60 insertions(+), 107 deletions(-) diff --git a/Server/src/main/content/global/skill/cooking/recipe/MixHandler.kt b/Server/src/main/content/global/skill/cooking/recipe/MixHandler.kt index 02ace8eb2..faca4f187 100644 --- a/Server/src/main/content/global/skill/cooking/recipe/MixHandler.kt +++ b/Server/src/main/content/global/skill/cooking/recipe/MixHandler.kt @@ -4,6 +4,7 @@ import core.api.* import core.game.dialogue.SkillDialogueHandler import core.game.node.entity.player.Player import core.game.node.entity.skill.Skills +import org.rs09.consts.Items import kotlin.math.min fun standardMix(player: Player, used: Int, with: Int, product: Int, level: Int, experience: Double, message: String, failMessage: String): Boolean { @@ -18,6 +19,8 @@ fun standardMix(player: Player, used: Int, with: Int, product: Int, level: Int, sendMessage(player, message) rewardXP(player, Skills.COOKING, experience) addItem(player, product) + containerIngredient(player, used) + containerIngredient(player, with) } return true } diff --git a/Server/src/main/content/global/skill/cooking/recipe/MixScript.kt b/Server/src/main/content/global/skill/cooking/recipe/MixScript.kt index 7835e994f..07e7eba5a 100644 --- a/Server/src/main/content/global/skill/cooking/recipe/MixScript.kt +++ b/Server/src/main/content/global/skill/cooking/recipe/MixScript.kt @@ -3,6 +3,7 @@ package content.global.skill.cooking.recipe import core.api.* import core.game.node.entity.player.Player import core.game.node.entity.skill.Skills +import org.rs09.consts.Items class MixScript( private val player: Player, @@ -31,6 +32,8 @@ class MixScript( sendMessage(player, message) rewardXP(player, Skills.COOKING, experience) addItem(player, product) + containerIngredient(player, used) + containerIngredient(player, with) } else { return@queueScript stopExecuting(player) } @@ -42,4 +45,11 @@ class MixScript( return@queueScript delayScript(player, delay) } } +} + +fun containerIngredient(player: Player, ingredient: Int): Boolean{ + return when (ingredient) { + Items.BUCKET_OF_WATER_1929, Items.COMPOST_6032 -> addItem(player, Items.BUCKET_1925) + else -> false + } } \ No newline at end of file diff --git a/Server/src/main/content/global/skill/cooking/recipe/pie/PieListener.kt b/Server/src/main/content/global/skill/cooking/recipe/pie/PieListener.kt index e927e9f4a..e7dfd4ae5 100644 --- a/Server/src/main/content/global/skill/cooking/recipe/pie/PieListener.kt +++ b/Server/src/main/content/global/skill/cooking/recipe/pie/PieListener.kt @@ -1,11 +1,9 @@ package content.global.skill.cooking.recipe.pie -import core.api.* +import content.global.skill.cooking.recipe.standardMix import core.game.interaction.IntType import core.game.interaction.InteractionListener -import core.game.node.entity.skill.Skills import org.rs09.consts.Items -import kotlin.math.min class PieListener : InteractionListener { @@ -20,45 +18,22 @@ class PieListener : InteractionListener { return@onUseWith false } - if (!hasLevelDyn(player, Skills.COOKING, pie.minimumLevel)) { - sendMessage(player, "You need a Cooking level of ${pie.minimumLevel} to make this.") - return@onUseWith true - } + val product = pie.product + val level = pie.minimumLevel + val experience = 0.0 + val message = "You fill the pie with ${pie.message}." + val failMessage = "You need a Cooking level of ${pie.minimumLevel} to make this." - // Avoids sending dialogue if only one can be created - if (amountInInventory(player, used.id) == 1 || amountInInventory(player, with.id) == 1) { - if (removeItem(player, used.id) && removeItem(player, with.id)) { - addItem(player, pie.product) - if (used.id == Items.COMPOST_6032) addItem(player, Items.BUCKET_1925) - if (with.id == Items.BUCKET_OF_WATER_1929) addItem(player, Items.BUCKET_1925) - sendMessage(player, "You fill the pie with ${pie.message}.") - } - return@onUseWith true - } - - sendSkillDialogue(player) { - withItems(pie.product) - create { _, amount -> - - runTask(player, 2, amount) { - if (amount < 1) return@runTask - - if (removeItem(player, used.id) && removeItem(player, with.id)) { - addItem(player, pie.product) - if (used.id == Items.COMPOST_6032) addItem(player, Items.BUCKET_1925) - if (with.id == Items.BUCKET_OF_WATER_1929) addItem(player, Items.BUCKET_1925) - sendMessage(player, "You fill the pie with ${pie.message}.") - } - return@runTask - } - } - - calculateMaxAmount { _ -> - min(amountInInventory(player, with.id), amountInInventory(player, used.id)) - } - } - - return@onUseWith true + return@onUseWith standardMix( + player, + used.id, + with.id, + product, + level, + experience, + message, + failMessage + ) } } diff --git a/Server/src/main/content/global/skill/cooking/recipe/pie/PieShellListener.kt b/Server/src/main/content/global/skill/cooking/recipe/pie/PieShellListener.kt index 3f239c563..0b077dcfb 100644 --- a/Server/src/main/content/global/skill/cooking/recipe/pie/PieShellListener.kt +++ b/Server/src/main/content/global/skill/cooking/recipe/pie/PieShellListener.kt @@ -1,5 +1,6 @@ package content.global.skill.cooking.recipe.pie +import content.global.skill.cooking.recipe.standardMix import core.api.* import core.game.interaction.IntType import core.game.interaction.InteractionListener @@ -12,37 +13,21 @@ class PieShellListener : InteractionListener { override fun defineListeners() { onUseWith(IntType.ITEM, Items.PIE_DISH_2313, Items.PASTRY_DOUGH_1953) { player, used, with -> val product = Items.PIE_SHELL_2315 + val level = 1 + val experience = 0.0 + val message = "You put the pastry dough into the pie dish to make a pie shell." + val failMessage = "" - // Avoids sending dialogue if only one can be created - if (amountInInventory(player, used.id) == 1 || amountInInventory(player, with.id) == 1) { - if (removeItem(player, used.id) && removeItem(player, with.id)) { - addItem(player, product) - sendMessage(player, "You put the pastry dough into the pie dish to make a pie shell.") - } - return@onUseWith true - } - - sendSkillDialogue(player) { - withItems(product) - create { _, amount -> - - runTask(player, 2, amount) { - if (amount < 1) return@runTask - - if (removeItem(player, used.id) && removeItem(player, with.id)) { - addItem(player, product) - sendMessage(player, "You put the pastry dough into the pie dish to make a pie shell.") - } - return@runTask - } - } - - calculateMaxAmount { _ -> - min(amountInInventory(player, with.id), amountInInventory(player, used.id)) - } - } - - return@onUseWith true + return@onUseWith standardMix( + player, + used.id, + with.id, + product, + level, + experience, + message, + failMessage + ) } } } \ No newline at end of file diff --git a/Server/src/main/content/global/skill/cooking/recipe/pizza/PizzaListener.kt b/Server/src/main/content/global/skill/cooking/recipe/pizza/PizzaListener.kt index 646ddd986..dc6e8c9c1 100644 --- a/Server/src/main/content/global/skill/cooking/recipe/pizza/PizzaListener.kt +++ b/Server/src/main/content/global/skill/cooking/recipe/pizza/PizzaListener.kt @@ -1,5 +1,6 @@ package content.global.skill.cooking.recipe.pizza +import content.global.skill.cooking.recipe.standardMix import core.api.* import core.game.interaction.IntType import core.game.interaction.InteractionListener @@ -20,43 +21,22 @@ class PizzaListener : InteractionListener { return@onUseWith false } - if (!hasLevelDyn(player, Skills.COOKING, pizza.minimumLevel)) { - sendMessage(player, "You need a Cooking level of at least ${pizza.minimumLevel} in order to do this.") - return@onUseWith true - } + val product = pizza.product + val level = pizza.minimumLevel + val experience = pizza.experience + val message = "You add the ${pizza.message} to the pizza." + val failMessage = "You need a Cooking level of at least ${pizza.minimumLevel} in order to do this." - // Avoids sending dialogue if only one can be created - if (amountInInventory(player, used.id) == 1 || amountInInventory(player, with.id) == 1) { - if (removeItem(player, used.id) && removeItem(player, with.id)) { - addItem(player, pizza.product) - rewardXP(player, Skills.COOKING, pizza.experience) - sendMessage(player, "You add the ${pizza.message} to the pizza.") - } - return@onUseWith true - } - - sendSkillDialogue(player) { - withItems(pizza.product) - create { _, amount -> - - runTask(player, 2, amount) { - if (amount < 1) return@runTask - - if (removeItem(player, used.id) && removeItem(player, with.id)) { - addItem(player, pizza.product) - rewardXP(player, Skills.COOKING, pizza.experience) - sendMessage(player, "You add the ${pizza.message} to the pizza.") - } - return@runTask - } - } - - calculateMaxAmount { _ -> - min(amountInInventory(player, with.id), amountInInventory(player, used.id)) - } - } - - return@onUseWith true + return@onUseWith standardMix( + player, + used.id, + with.id, + product, + level, + experience, + message, + failMessage + ) } } From 6774a7d29e3b95adb817bc2eecde2b31442f74ce Mon Sep 17 00:00:00 2001 From: Syndromeramo Date: Fri, 25 Jul 2025 22:25:41 -0500 Subject: [PATCH 17/24] MixHandler updated for refactored mix recipes. --- .../cooking/recipe/OomlieWrapListener.kt | 52 ++++++------------- .../cooking/recipe/pie/PieShellListener.kt | 3 -- .../cooking/recipe/pizza/PizzaListener.kt | 3 -- 3 files changed, 15 insertions(+), 43 deletions(-) diff --git a/Server/src/main/content/global/skill/cooking/recipe/OomlieWrapListener.kt b/Server/src/main/content/global/skill/cooking/recipe/OomlieWrapListener.kt index b126a835d..43ea4b81c 100644 --- a/Server/src/main/content/global/skill/cooking/recipe/OomlieWrapListener.kt +++ b/Server/src/main/content/global/skill/cooking/recipe/OomlieWrapListener.kt @@ -1,51 +1,29 @@ package content.global.skill.cooking.recipe -import core.api.* import core.game.interaction.IntType import core.game.interaction.InteractionListener -import core.game.node.entity.skill.Skills import org.rs09.consts.Items -import kotlin.math.min class OomlieWrapListener : InteractionListener { override fun defineListeners() { onUseWith(IntType.ITEM, Items.RAW_OOMLIE_2337, Items.PALM_LEAF_2339) { player, used, with -> - if (!hasLevelDyn(player, Skills.COOKING, 50)) { - sendMessage(player, "You need a Cooking level of at least 50 in order to do that.") - return@onUseWith true - } + val product = Items.WRAPPED_OOMLIE_2341 + val level = 50 + val experience = 0.0 + val message = "You wrap the raw oomlie in the palm leaf." + val failMessage = "You need a Cooking level of at least $level in order to do that." - // Avoids sending dialogue if only one can be created - if (amountInInventory(player, used.id) == 1 || amountInInventory(player, with.id) == 1) { - if (removeItem(player, used.id) && removeItem(player, with.id)) { - addItem(player, Items.WRAPPED_OOMLIE_2341) - sendMessage(player, "You wrap the raw oomlie in the palm leaf.") - } - return@onUseWith true - } - - sendSkillDialogue(player) { - withItems(Items.WRAPPED_OOMLIE_2341) - create { _, amount -> - - runTask(player, 2, amount) { - if (amount < 1) return@runTask - - if (removeItem(player, used.id) && removeItem(player, with.id)) { - addItem(player, Items.WRAPPED_OOMLIE_2341) - sendMessage(player, "You wrap the raw oomlie in the palm leaf.") - } - return@runTask - } - } - - calculateMaxAmount { _ -> - min(amountInInventory(player, with.id), amountInInventory(player, used.id)) - } - } - - return@onUseWith true + return@onUseWith standardMix( + player, + used.id, + with.id, + product, + level, + experience, + message, + failMessage + ) } } } \ No newline at end of file diff --git a/Server/src/main/content/global/skill/cooking/recipe/pie/PieShellListener.kt b/Server/src/main/content/global/skill/cooking/recipe/pie/PieShellListener.kt index 0b077dcfb..713b5c499 100644 --- a/Server/src/main/content/global/skill/cooking/recipe/pie/PieShellListener.kt +++ b/Server/src/main/content/global/skill/cooking/recipe/pie/PieShellListener.kt @@ -1,12 +1,9 @@ package content.global.skill.cooking.recipe.pie import content.global.skill.cooking.recipe.standardMix -import core.api.* import core.game.interaction.IntType import core.game.interaction.InteractionListener -import core.game.node.entity.skill.Skills import org.rs09.consts.Items -import kotlin.math.min class PieShellListener : InteractionListener { diff --git a/Server/src/main/content/global/skill/cooking/recipe/pizza/PizzaListener.kt b/Server/src/main/content/global/skill/cooking/recipe/pizza/PizzaListener.kt index dc6e8c9c1..3ace9e567 100644 --- a/Server/src/main/content/global/skill/cooking/recipe/pizza/PizzaListener.kt +++ b/Server/src/main/content/global/skill/cooking/recipe/pizza/PizzaListener.kt @@ -1,12 +1,9 @@ package content.global.skill.cooking.recipe.pizza import content.global.skill.cooking.recipe.standardMix -import core.api.* import core.game.interaction.IntType import core.game.interaction.InteractionListener -import core.game.node.entity.skill.Skills import org.rs09.consts.Items -import kotlin.math.min class PizzaListener : InteractionListener { From d81f0a691a9092a1d24e7f6fca0e475cdb33dfe0 Mon Sep 17 00:00:00 2001 From: Syndromeramo Date: Fri, 25 Jul 2025 23:44:32 -0500 Subject: [PATCH 18/24] Redo of MixListener logic to accommodate for multiple of an ingredient used in one mix. --- .../global/skill/cooking/recipe/MixHandler.kt | 21 ++++--- .../global/skill/cooking/recipe/MixScript.kt | 11 ++-- .../cooking/recipe/OomlieWrapListener.kt | 4 +- .../recipe/cake/ChocolateCakeListener.kt | 4 +- .../skill/cooking/recipe/pie/PieListener.kt | 4 +- .../cooking/recipe/pie/PieShellListener.kt | 4 +- .../cooking/recipe/pizza/PizzaListener.kt | 4 +- .../cooking/recipe/stew/CurryListener.kt | 63 +++++-------------- .../skill/cooking/recipe/stew/StewListener.kt | 53 +++++----------- 9 files changed, 60 insertions(+), 108 deletions(-) diff --git a/Server/src/main/content/global/skill/cooking/recipe/MixHandler.kt b/Server/src/main/content/global/skill/cooking/recipe/MixHandler.kt index faca4f187..d2c50ee6a 100644 --- a/Server/src/main/content/global/skill/cooking/recipe/MixHandler.kt +++ b/Server/src/main/content/global/skill/cooking/recipe/MixHandler.kt @@ -4,12 +4,17 @@ import core.api.* import core.game.dialogue.SkillDialogueHandler import core.game.node.entity.player.Player import core.game.node.entity.skill.Skills -import org.rs09.consts.Items +import core.game.node.item.Item import kotlin.math.min -fun standardMix(player: Player, used: Int, with: Int, product: Int, level: Int, experience: Double, message: String, failMessage: String): Boolean { +fun standardMix(player: Player, used: Item, with: Item, product: Int, level: Int, experience: Double, message: String, failMessage: String): Boolean { + // Avoids sending dialogue if not enough ingredients to create (relevant only for curry leaves) + if (amountInInventory(player, used.id) < used.amount || amountInInventory(player, with.id) < with.amount) { + return true + } + // Avoids sending dialogue if only one can be created - if (amountInInventory(player, used) == 1 || amountInInventory(player, with) == 1) { + if (amountInInventory(player, used.id) == used.amount || amountInInventory(player, with.id) == with.amount) { if (getDynLevel(player, Skills.COOKING) < level) { sendDialogue(player, failMessage) return true @@ -19,8 +24,8 @@ fun standardMix(player: Player, used: Int, with: Int, product: Int, level: Int, sendMessage(player, message) rewardXP(player, Skills.COOKING, experience) addItem(player, product) - containerIngredient(player, used) - containerIngredient(player, with) + containerIngredient(player, used.id) + containerIngredient(player, with.id) } return true } @@ -38,7 +43,7 @@ fun standardMix(player: Player, used: Int, with: Int, product: Int, level: Int, return true } -private fun mixHandler(player: Player, used: Int, with: Int, product: Int, level: Int, experience: Double, message: String, failMessage: String): SkillDialogueHandler { +private fun mixHandler(player: Player, used: Item, with: Item, product: Int, level: Int, experience: Double, message: String, failMessage: String): SkillDialogueHandler { val handler: SkillDialogueHandler = object : SkillDialogueHandler(player, SkillDialogue.ONE_OPTION, product.asItem()) { @@ -57,8 +62,8 @@ private fun mixHandler(player: Player, used: Int, with: Int, product: Int, level override fun getAll(index: Int): Int { return min( - amountInInventory(player, used), - amountInInventory(player, with) + amountInInventory(player, used.id)/used.amount, + amountInInventory(player, with.id)/with.amount ) } } diff --git a/Server/src/main/content/global/skill/cooking/recipe/MixScript.kt b/Server/src/main/content/global/skill/cooking/recipe/MixScript.kt index 07e7eba5a..711fd2d2f 100644 --- a/Server/src/main/content/global/skill/cooking/recipe/MixScript.kt +++ b/Server/src/main/content/global/skill/cooking/recipe/MixScript.kt @@ -3,12 +3,13 @@ package content.global.skill.cooking.recipe import core.api.* import core.game.node.entity.player.Player import core.game.node.entity.skill.Skills +import core.game.node.item.Item import org.rs09.consts.Items class MixScript( private val player: Player, - private val used: Int, - private val with: Int, + private val used: Item, + private val with: Item, private val product: Int, private val sets: Int, private val level: Int, @@ -26,14 +27,14 @@ class MixScript( return@queueScript stopExecuting(player) } - if (inInventory(player, used) && inInventory(player, with)) { + if (inInventory(player, used.id, used.amount) && inInventory(player, with.id, with.amount)) { removeItem(player, used) removeItem(player, with) sendMessage(player, message) rewardXP(player, Skills.COOKING, experience) addItem(player, product) - containerIngredient(player, used) - containerIngredient(player, with) + containerIngredient(player, used.id) + containerIngredient(player, with.id) } else { return@queueScript stopExecuting(player) } diff --git a/Server/src/main/content/global/skill/cooking/recipe/OomlieWrapListener.kt b/Server/src/main/content/global/skill/cooking/recipe/OomlieWrapListener.kt index 43ea4b81c..79024be71 100644 --- a/Server/src/main/content/global/skill/cooking/recipe/OomlieWrapListener.kt +++ b/Server/src/main/content/global/skill/cooking/recipe/OomlieWrapListener.kt @@ -16,8 +16,8 @@ class OomlieWrapListener : InteractionListener { return@onUseWith standardMix( player, - used.id, - with.id, + used.asItem(), + with.asItem(), product, level, experience, diff --git a/Server/src/main/content/global/skill/cooking/recipe/cake/ChocolateCakeListener.kt b/Server/src/main/content/global/skill/cooking/recipe/cake/ChocolateCakeListener.kt index 1fd3a2185..623c2b3cc 100644 --- a/Server/src/main/content/global/skill/cooking/recipe/cake/ChocolateCakeListener.kt +++ b/Server/src/main/content/global/skill/cooking/recipe/cake/ChocolateCakeListener.kt @@ -19,8 +19,8 @@ class ChocolateCakeListener : InteractionListener { return@onUseWith standardMix( player, - used.id, - with.id, + used.asItem(), + with.asItem(), product, level, experience, diff --git a/Server/src/main/content/global/skill/cooking/recipe/pie/PieListener.kt b/Server/src/main/content/global/skill/cooking/recipe/pie/PieListener.kt index e7dfd4ae5..2d28081f5 100644 --- a/Server/src/main/content/global/skill/cooking/recipe/pie/PieListener.kt +++ b/Server/src/main/content/global/skill/cooking/recipe/pie/PieListener.kt @@ -26,8 +26,8 @@ class PieListener : InteractionListener { return@onUseWith standardMix( player, - used.id, - with.id, + used.asItem(), + with.asItem(), product, level, experience, diff --git a/Server/src/main/content/global/skill/cooking/recipe/pie/PieShellListener.kt b/Server/src/main/content/global/skill/cooking/recipe/pie/PieShellListener.kt index 713b5c499..d91cd9580 100644 --- a/Server/src/main/content/global/skill/cooking/recipe/pie/PieShellListener.kt +++ b/Server/src/main/content/global/skill/cooking/recipe/pie/PieShellListener.kt @@ -17,8 +17,8 @@ class PieShellListener : InteractionListener { return@onUseWith standardMix( player, - used.id, - with.id, + used.asItem(), + with.asItem(), product, level, experience, diff --git a/Server/src/main/content/global/skill/cooking/recipe/pizza/PizzaListener.kt b/Server/src/main/content/global/skill/cooking/recipe/pizza/PizzaListener.kt index 3ace9e567..86a7c16e1 100644 --- a/Server/src/main/content/global/skill/cooking/recipe/pizza/PizzaListener.kt +++ b/Server/src/main/content/global/skill/cooking/recipe/pizza/PizzaListener.kt @@ -26,8 +26,8 @@ class PizzaListener : InteractionListener { return@onUseWith standardMix( player, - used.id, - with.id, + used.asItem(), + with.asItem(), product, level, experience, diff --git a/Server/src/main/content/global/skill/cooking/recipe/stew/CurryListener.kt b/Server/src/main/content/global/skill/cooking/recipe/stew/CurryListener.kt index 5a0d0ef0a..e88f7a807 100644 --- a/Server/src/main/content/global/skill/cooking/recipe/stew/CurryListener.kt +++ b/Server/src/main/content/global/skill/cooking/recipe/stew/CurryListener.kt @@ -1,12 +1,10 @@ package content.global.skill.cooking.recipe.stew -import core.api.* +import content.global.skill.cooking.recipe.standardMix import core.game.interaction.IntType import core.game.interaction.InteractionListener -import core.game.node.entity.skill.Skills import core.game.node.item.Item import org.rs09.consts.Items -import kotlin.math.min class CurryListener : InteractionListener { @@ -20,52 +18,21 @@ class CurryListener : InteractionListener { Items.SPICE_2007 -> 1 else -> 0 } - val amountAvailable = when (with.id) { - Items.CURRY_LEAF_5970 -> amountInInventory(player, with.id)/3 - Items.SPICE_2007 -> amountInInventory(player, with.id) - else -> 0 - } + val level = 60 + val experience = 0.0 + val message = "You mix the spice with the stew." + val failMessage = "You need a Cooking level of at least $level in order to do this." - if (!hasLevelDyn(player, Skills.COOKING, 60)) { - sendMessage(player, "You need a Cooking level of at least 60 in order to do this.") - return@onUseWith true - } - - if (amountAvailable == 0) { - sendMessage(player, "You do not have three curry leaves.") //inauthentic dialogue - return@onUseWith true - } - - // Avoids sending dialogue if only one can be created - if (amountInInventory(player, used.id) == 1 || amountAvailable == 1) { - if (removeItem(player, used.id) && removeItem(player, Item(with.id, amountAdded))) { - addItem(player, product) - sendMessage(player, "You mix the spice with the stew.") - } - return@onUseWith true - } - - sendSkillDialogue(player) { - withItems(product) - create { _, amount -> - - runTask(player, 2, amount) { - if (amount < 1) return@runTask - - if (removeItem(player, used.id) && removeItem(player, Item(with.id, amountAdded))) { - addItem(player, product) - sendMessage(player, "You mix the spice with the stew.") - } - return@runTask - } - } - - calculateMaxAmount { _ -> - min(amountInInventory(player, used.id), amountAvailable) - } - } - - return@onUseWith true + return@onUseWith standardMix( + player, + used.asItem(), + Item(with.id, amountAdded), + product, + level, + experience, + message, + failMessage + ) } } } \ No newline at end of file diff --git a/Server/src/main/content/global/skill/cooking/recipe/stew/StewListener.kt b/Server/src/main/content/global/skill/cooking/recipe/stew/StewListener.kt index 9601ba556..4fb799266 100644 --- a/Server/src/main/content/global/skill/cooking/recipe/stew/StewListener.kt +++ b/Server/src/main/content/global/skill/cooking/recipe/stew/StewListener.kt @@ -1,11 +1,9 @@ package content.global.skill.cooking.recipe.stew -import core.api.* +import content.global.skill.cooking.recipe.standardMix import core.game.interaction.IntType import core.game.interaction.InteractionListener -import core.game.node.entity.skill.Skills import org.rs09.consts.Items -import kotlin.math.min class StewListener : InteractionListener { @@ -20,41 +18,22 @@ class StewListener : InteractionListener { return@onUseWith false } - if (!hasLevelDyn(player, Skills.COOKING, stew.minimumLevel)) { - sendMessage(player, "You need a Cooking level of at least ${stew.minimumLevel} in order to do this.") - return@onUseWith true - } + val product = stew.product + val level = stew.minimumLevel + val experience = 0.0 + val message = "You cut up the ${stew.message} and put it into the stew." + val failMessage = "You need a Cooking level of at least ${stew.minimumLevel} in order to do this." - // Avoids sending dialogue if only one can be created - if (amountInInventory(player, used.id) == 1 || amountInInventory(player, with.id) == 1) { - if (removeItem(player, used.id) && removeItem(player, with.id)) { - addItem(player, stew.product) - sendMessage(player, "You cut up the ${stew.message} and put it into the stew.") - } - return@onUseWith true - } - - sendSkillDialogue(player) { - withItems(stew.product) - create { _, amount -> - - runTask(player, 2, amount) { - if (amount < 1) return@runTask - - if (removeItem(player, used.id) && removeItem(player, with.id)) { - addItem(player, stew.product) - sendMessage(player, "You cut up the ${stew.message} and put it into the stew.") - } - return@runTask - } - } - - calculateMaxAmount { _ -> - min(amountInInventory(player, with.id), amountInInventory(player, used.id)) - } - } - - return@onUseWith true + return@onUseWith standardMix( + player, + used.asItem(), + with.asItem(), + product, + level, + experience, + message, + failMessage + ) } } From 8b375fc319d394646a0042bf0e3e4547835b9c9b Mon Sep 17 00:00:00 2001 From: Syndromeramo Date: Tue, 29 Jul 2025 16:36:40 -0500 Subject: [PATCH 19/24] Refactored Potato Toppings. --- .../global/skill/cooking/recipe/MixScript.kt | 1 + .../global/skill/cooking/recipe/Recipe.java | 2 - .../cooking/recipe/topping/ToppingListener.kt | 85 +++++++++++++++++++ .../cooking/recipe/topping/ToppingRecipe.java | 58 ------------- .../recipe/topping/impl/ChilliConCarne.java | 81 ------------------ .../recipe/topping/impl/ChoppedOnion.java | 69 --------------- .../recipe/topping/impl/ChoppedTuna.java | 69 --------------- .../recipe/topping/impl/EggAndTomato.java | 72 ---------------- .../recipe/topping/impl/MushroomAndOnion.java | 72 ---------------- .../recipe/topping/impl/SlicedMushroom.java | 69 --------------- .../recipe/topping/impl/SpicySauce.java | 84 ------------------ .../recipe/topping/impl/TunaAndCorn.java | 72 ---------------- .../recipe/topping/impl/UncookedEgg.java | 54 ------------ 13 files changed, 86 insertions(+), 702 deletions(-) create mode 100644 Server/src/main/content/global/skill/cooking/recipe/topping/ToppingListener.kt delete mode 100644 Server/src/main/content/global/skill/cooking/recipe/topping/ToppingRecipe.java delete mode 100644 Server/src/main/content/global/skill/cooking/recipe/topping/impl/ChilliConCarne.java delete mode 100644 Server/src/main/content/global/skill/cooking/recipe/topping/impl/ChoppedOnion.java delete mode 100644 Server/src/main/content/global/skill/cooking/recipe/topping/impl/ChoppedTuna.java delete mode 100644 Server/src/main/content/global/skill/cooking/recipe/topping/impl/EggAndTomato.java delete mode 100644 Server/src/main/content/global/skill/cooking/recipe/topping/impl/MushroomAndOnion.java delete mode 100644 Server/src/main/content/global/skill/cooking/recipe/topping/impl/SlicedMushroom.java delete mode 100644 Server/src/main/content/global/skill/cooking/recipe/topping/impl/SpicySauce.java delete mode 100644 Server/src/main/content/global/skill/cooking/recipe/topping/impl/TunaAndCorn.java delete mode 100644 Server/src/main/content/global/skill/cooking/recipe/topping/impl/UncookedEgg.java diff --git a/Server/src/main/content/global/skill/cooking/recipe/MixScript.kt b/Server/src/main/content/global/skill/cooking/recipe/MixScript.kt index 711fd2d2f..8d8dda982 100644 --- a/Server/src/main/content/global/skill/cooking/recipe/MixScript.kt +++ b/Server/src/main/content/global/skill/cooking/recipe/MixScript.kt @@ -51,6 +51,7 @@ class MixScript( fun containerIngredient(player: Player, ingredient: Int): Boolean{ return when (ingredient) { Items.BUCKET_OF_WATER_1929, Items.COMPOST_6032 -> addItem(player, Items.BUCKET_1925) + Items.FRIED_MUSHROOMS_7082 -> addItem(player, Items.BOWL_1923) else -> false } } \ No newline at end of file diff --git a/Server/src/main/content/global/skill/cooking/recipe/Recipe.java b/Server/src/main/content/global/skill/cooking/recipe/Recipe.java index f9a3ad2be..588d25faa 100644 --- a/Server/src/main/content/global/skill/cooking/recipe/Recipe.java +++ b/Server/src/main/content/global/skill/cooking/recipe/Recipe.java @@ -1,7 +1,6 @@ package content.global.skill.cooking.recipe; import content.global.skill.cooking.recipe.potato.impl.*; -import content.global.skill.cooking.recipe.topping.impl.*; import core.game.interaction.NodeUsageEvent; import core.game.node.entity.player.Player; import core.game.node.item.Item; @@ -23,7 +22,6 @@ public abstract class Recipe { // - Making pineapple cutting a recipe would probably fix their make-x making all with any option public static final Recipe[] RECIPES = new Recipe[] { new ButterPotato(), new ChilliPotato(), new CheesePotato(), new EggPotato(), new MushroomPotato(), new TunaPotato(), - new SpicySauce(), new ChilliConCarne(), new UncookedEgg(), new EggAndTomato(), new MushroomAndOnion(), new ChoppedOnion(), new SlicedMushroom(), new ChoppedTuna(), new TunaAndCorn() }; /** diff --git a/Server/src/main/content/global/skill/cooking/recipe/topping/ToppingListener.kt b/Server/src/main/content/global/skill/cooking/recipe/topping/ToppingListener.kt new file mode 100644 index 000000000..049dbebc6 --- /dev/null +++ b/Server/src/main/content/global/skill/cooking/recipe/topping/ToppingListener.kt @@ -0,0 +1,85 @@ +package content.global.skill.cooking.recipe.topping + +import content.global.skill.cooking.recipe.standardMix +import core.api.inInventory +import core.api.sendDialogue +import core.game.interaction.IntType +import core.game.interaction.InteractionListener +import org.rs09.consts.Items + +class ToppingListener : InteractionListener { + + val base = ToppingProduct.values().map { it.base }.toIntArray() + val added = ToppingProduct.values().map { it.added }.toIntArray() + + override fun defineListeners() { + onUseWith(IntType.ITEM, base, *added) { player, used, with -> + val topping = ToppingProduct.productMap[used.id] ?: return@onUseWith true + val verb = if (with.id == Items.COOKED_MEAT_2142) "cut" else "slice" + + if (topping.added != with.id) { + return@onUseWith false + } + + if (topping.cut_name != "" && !inInventory(player, Items.KNIFE_946)) { + sendDialogue(player, "You need a knife in order to $verb up the ${topping.cut_name}.") + return@onUseWith true + } + + val product = topping.product + val level = topping.minimumLevel + val experience = topping.experience + val message = topping.message + val failMessage = "You need a Cooking level of at least ${topping.minimumLevel} in order to do this." + + return@onUseWith standardMix( + player, + used.asItem(), + with.asItem(), + product, + level, + experience, + message, + failMessage + ) + } + } + + enum class ToppingProduct( + val base: Int, + val added: Int, + val product: Int, + val minimumLevel: Int, + val experience: Double, + val message: String, + val cut_name: String + ) { + //Tuna and Corn: https://www.youtube.com/watch?v=wAavERc9p2c + //Uncooked Egg: https://www.youtube.com/watch?v=LiLq6PhCc2M + //Bowl of sweetcorn (OSRS source is only I could find) https://www.youtube.com/watch?v=pz8epXjkKYE + + UNCOOKED_EGG(Items.EGG_1944, Items.BOWL_1923, Items.UNCOOKED_EGG_7076, 1, 0.0, "You carefully break the egg into the bowl.", ""), + BOWL_OF_SWEETCORN(Items.COOKED_SWEETCORN_5988, Items.BOWL_1923, Items.SWEETCORN_7088, 1, 0.0, "You put the cooked sweetcorn into the bowl.", ""), + SLICED_MUSHROOM(Items.MUSHROOM_6004, Items.BOWL_1923, Items.SLICED_MUSHROOMS_7080, 1, 0.0, "You chop the mushrooms into the bowl.", "mushrooms"), + CHOPPED_TUNA(Items.TUNA_361, Items.BOWL_1923, Items.CHOPPED_TUNA_7086, 1, 0.0, "You chop the tuna into the bowl.", "tuna"), + CHOPPED_ONION(Items.ONION_1957, Items.BOWL_1923, Items.CHOPPED_ONION_1871, 1, 0.0, "You chop the onion into the bowl.", "onion"), + CHOPPED_GARLIC(Items.GARLIC_1550, Items.BOWL_1923, Items.CHOPPED_GARLIC_7074, 1, 0.0, "You chop the garlic into the bowl.", "garlic"), + SPICY_SAUCE(Items.CHOPPED_GARLIC_7074, Items.GNOME_SPICE_2169, Items.SPICY_SAUCE_7072, 9, 25.0, "You mix the ingredients to make the topping.", ""), //inauthentic, used generic mixing message + CHILLI_CON_CARNE(Items.SPICY_SAUCE_7072, Items.COOKED_MEAT_2142, Items.CHILLI_CON_CARNE_7062, 9, 0.0, "You mix the ingredients to make the topping.", "meat"), //inauthentic, used generic mixing message + EGG_AND_TOMATO(Items.TOMATO_1982, Items.SCRAMBLED_EGG_7078, Items.EGG_AND_TOMATO_7064, 23, 50.0, "You mix the ingredients to make the topping.", ""), + MUSHROOM_AND_ONION(Items.FRIED_MUSHROOMS_7082, Items.FRIED_ONIONS_7084, Items.MUSHROOM_AND_ONION_7066, 57, 120.0, "You mix the ingredients to make the topping.", ""), + TUNA_AND_CORN_1(Items.CHOPPED_TUNA_7086, Items.COOKED_SWEETCORN_5988, Items.TUNA_AND_CORN_7068, 67, 204.0, "You mix the ingredients to make the topping.", ""), + TUNA_AND_CORN_2(Items.SWEETCORN_7088, Items.TUNA_361, Items.TUNA_AND_CORN_7068, 67, 204.0, "You mix the ingredients to make the topping.", "tuna"), + ; + + companion object { + val productMap = HashMap() + + init { + for (topping in ToppingProduct.values()) { + productMap[topping.base] = topping + } + } + } + } +} \ No newline at end of file diff --git a/Server/src/main/content/global/skill/cooking/recipe/topping/ToppingRecipe.java b/Server/src/main/content/global/skill/cooking/recipe/topping/ToppingRecipe.java deleted file mode 100644 index 5c2cacb15..000000000 --- a/Server/src/main/content/global/skill/cooking/recipe/topping/ToppingRecipe.java +++ /dev/null @@ -1,58 +0,0 @@ -package content.global.skill.cooking.recipe.topping; - -import core.game.node.entity.skill.Skills; -import content.global.skill.cooking.recipe.Recipe; -import core.game.interaction.NodeUsageEvent; -import core.game.node.entity.player.Player; -import core.game.node.item.Item; - -/** - * Represents a generic topping recipe. - * @author 'Vexia - * @date 22/12/2013 - */ -public abstract class ToppingRecipe extends Recipe { - - /** - * Represents the bowl item. - */ - protected static final Item BOWL = new Item(1923); - - @Override - public void mix(final Player player, final NodeUsageEvent event) { - if (player.getSkills().getLevel(Skills.COOKING) < getLevel()) { - player.getDialogueInterpreter().sendDialogue("You need a Cooking level of at least " + getLevel() + " in order to do this."); - return; - } - super.mix(player, event); - player.getSkills().addExperience(Skills.COOKING, getExperience(), true); - } - - @Override - public Item getBase() { - return BOWL; - } - - @Override - public String getMixMessage(NodeUsageEvent event) { - return null; - } - - @Override - public boolean isSingular() { - return true; - } - - /** - * Method used to get the level required. - * @return the level. - */ - public abstract int getLevel(); - - /** - * Method used to get the experience gained. - * @return the experience. - */ - public abstract double getExperience(); - -} diff --git a/Server/src/main/content/global/skill/cooking/recipe/topping/impl/ChilliConCarne.java b/Server/src/main/content/global/skill/cooking/recipe/topping/impl/ChilliConCarne.java deleted file mode 100644 index 4085d149b..000000000 --- a/Server/src/main/content/global/skill/cooking/recipe/topping/impl/ChilliConCarne.java +++ /dev/null @@ -1,81 +0,0 @@ -package content.global.skill.cooking.recipe.topping.impl; - -import core.game.node.entity.skill.Skills; -import content.global.skill.cooking.recipe.Recipe; -import core.game.interaction.NodeUsageEvent; -import core.game.node.entity.player.Player; -import core.game.node.item.Item; - -/** - * Represents the chilli con carne recipe. This recipe consists of using spicy - * sauce with cooked meat. - * @author 'Vexia - * @date 22/12/2013 - */ -public class ChilliConCarne extends Recipe { - - /** - * Represents the bowl item. - */ - private static final Item SPICY_SAUCE = new Item(7072); - - /** - * Represents the chilli con carne item. - */ - private static final Item CHILLI_CON_CARNE = new Item(7062); - - /** - * Represents the cooked meat item. - */ - private static final Item COOKED_MEAT = new Item(2142); - - /** - * Represents the knife item. - */ - private static final Item KNIFE = new Item(946); - - @Override - public void mix(final Player player, final NodeUsageEvent event) { - if (player.getSkills().getLevel(Skills.COOKING) < 9) { - player.getDialogueInterpreter().sendDialogue("You need a Cooking level of at least " + 9 + " in order to do this."); - return; - } - if (!player.getInventory().containsItem(KNIFE)) { - player.getDialogueInterpreter().sendDialogue("You need a knife in order to cut up the meat."); - return; - } - super.mix(player, event); - player.getSkills().addExperience(Skills.COOKING, 25, true); - } - - @Override - public Item getBase() { - return SPICY_SAUCE; - } - - @Override - public Item getProduct() { - return CHILLI_CON_CARNE; - } - - @Override - public Item[] getIngredients() { - return new Item[] { COOKED_MEAT }; - } - - @Override - public Item[] getParts() { - return new Item[] {}; - } - - @Override - public String getMixMessage(NodeUsageEvent event) { - return "You put the cut up meat into the bowl."; - } - - @Override - public boolean isSingular() { - return true; - } - -} diff --git a/Server/src/main/content/global/skill/cooking/recipe/topping/impl/ChoppedOnion.java b/Server/src/main/content/global/skill/cooking/recipe/topping/impl/ChoppedOnion.java deleted file mode 100644 index 5a30107c1..000000000 --- a/Server/src/main/content/global/skill/cooking/recipe/topping/impl/ChoppedOnion.java +++ /dev/null @@ -1,69 +0,0 @@ -package content.global.skill.cooking.recipe.topping.impl; - -import content.global.skill.cooking.recipe.topping.ToppingRecipe; -import core.game.interaction.NodeUsageEvent; -import core.game.node.entity.player.Player; -import core.game.node.item.Item; - -/** - * Represents the chopped onion recipe. This recipe consists of using an onion - * on a bowl with a knife. - * @author 'Vexia - * @date 22/12/2013 - */ -public class ChoppedOnion extends ToppingRecipe { - - /** - * Represents the chopped onion product item. - */ - private static final Item CHOPPED_ONION = new Item(1871); - - /** - * Represents the knife used to cut the onion. - */ - private static final Item KNIFE = new Item(946); - - /** - * Represents the onion item. - */ - private static final Item ONION = new Item(1957); - - @Override - public void mix(final Player player, final NodeUsageEvent event) { - if (!player.getInventory().containsItem(KNIFE)) { - player.getDialogueInterpreter().sendDialogue("You need a knife in order to slice up the onion."); - return; - } - super.mix(player, event); - } - - @Override - public int getLevel() { - return 1; - } - - @Override - public double getExperience() { - return 0; - } - - @Override - public Item getProduct() { - return CHOPPED_ONION; - } - - @Override - public Item[] getIngredients() { - return new Item[] { ONION }; - } - - @Override - public Item[] getParts() { - return new Item[] {}; - } - - @Override - public boolean isSingular() { - return true; - } -} diff --git a/Server/src/main/content/global/skill/cooking/recipe/topping/impl/ChoppedTuna.java b/Server/src/main/content/global/skill/cooking/recipe/topping/impl/ChoppedTuna.java deleted file mode 100644 index 4723c61ff..000000000 --- a/Server/src/main/content/global/skill/cooking/recipe/topping/impl/ChoppedTuna.java +++ /dev/null @@ -1,69 +0,0 @@ -package content.global.skill.cooking.recipe.topping.impl; - -import content.global.skill.cooking.recipe.topping.ToppingRecipe; -import core.game.interaction.NodeUsageEvent; -import core.game.node.entity.player.Player; -import core.game.node.item.Item; - -/** - * Represents the chopped tuna recipe. This recipe consists of adding tuna to a - * bowl with a knife. - * @author 'Vexia - * @date 22/12/2013 - */ -public class ChoppedTuna extends ToppingRecipe { - - /** - * Represents the chopped tuna item. - */ - private static final Item CHOPPED_TUNA = new Item(7086); - - /** - * Represents the tuna item. - */ - private static final Item TUNA = new Item(361); - - /** - * Represents the knife item. - */ - private static final Item KNIFE = new Item(946); - - @Override - public void mix(final Player player, final NodeUsageEvent event) { - if (!player.getInventory().containsItem(KNIFE)) { - player.getDialogueInterpreter().sendDialogue("You need a knife in order to slice up the tuna."); - return; - } - super.mix(player, event); - } - - @Override - public int getLevel() { - return 1; - } - - @Override - public double getExperience() { - return 1; - } - - @Override - public Item getProduct() { - return CHOPPED_TUNA; - } - - @Override - public Item[] getIngredients() { - return new Item[] { TUNA }; - } - - @Override - public Item[] getParts() { - return new Item[] {}; - } - - @Override - public boolean isSingular() { - return true; - } -} diff --git a/Server/src/main/content/global/skill/cooking/recipe/topping/impl/EggAndTomato.java b/Server/src/main/content/global/skill/cooking/recipe/topping/impl/EggAndTomato.java deleted file mode 100644 index dabf2db2b..000000000 --- a/Server/src/main/content/global/skill/cooking/recipe/topping/impl/EggAndTomato.java +++ /dev/null @@ -1,72 +0,0 @@ -package content.global.skill.cooking.recipe.topping.impl; - -import content.global.skill.cooking.recipe.Recipe; -import core.game.node.entity.skill.Skills; -import core.game.interaction.NodeUsageEvent; -import core.game.node.entity.player.Player; -import core.game.node.item.Item; - -/** - * Represents the egg and tomato recipe. This recipe consists of mixing a tomato - * with a scrambled egg. - * @author 'Vexia - * @date 22/12/2013 - */ -public class EggAndTomato extends Recipe { - - /** - * Represents the egg and tomato. - */ - private static final Item EGG_AND_TOMATO = new Item(7064); - - /** - * Represents the scrambled egg item. - */ - private static final Item SCRAMBLED_EGG = new Item(7078); - - /** - * epresents the tomato item. - */ - private static final Item TOMATO = new Item(1982); - - @Override - public void mix(final Player player, final NodeUsageEvent event) { - if (player.getSkills().getLevel(Skills.COOKING) < 23) { - player.getDialogueInterpreter().sendDialogue("You need a Cooking level of at least " + 23 + " in order to do this."); - return; - } - super.mix(player, event); - player.getSkills().addExperience(Skills.COOKING, 50, true); - } - - @Override - public Item getBase() { - return SCRAMBLED_EGG; - } - - @Override - public Item getProduct() { - return EGG_AND_TOMATO; - } - - @Override - public Item[] getIngredients() { - return new Item[] { TOMATO }; - } - - @Override - public Item[] getParts() { - return new Item[] {}; - } - - @Override - public String getMixMessage(NodeUsageEvent event) { - return null; - } - - @Override - public boolean isSingular() { - return true; - } - -} diff --git a/Server/src/main/content/global/skill/cooking/recipe/topping/impl/MushroomAndOnion.java b/Server/src/main/content/global/skill/cooking/recipe/topping/impl/MushroomAndOnion.java deleted file mode 100644 index 3b99200f7..000000000 --- a/Server/src/main/content/global/skill/cooking/recipe/topping/impl/MushroomAndOnion.java +++ /dev/null @@ -1,72 +0,0 @@ -package content.global.skill.cooking.recipe.topping.impl; - -import core.game.node.entity.skill.Skills; -import content.global.skill.cooking.recipe.Recipe; -import core.game.interaction.NodeUsageEvent; -import core.game.node.entity.player.Player; -import core.game.node.item.Item; - -/** - * Represents the mushroom and onion recipe. This recipe consists of using a - * fried mushroom with a friend onion. - * @author 'Vexia - * @date 22/12/2013 - */ -public class MushroomAndOnion extends Recipe { - - /** - * Represents the mushroom and onion item. - */ - private static final Item MUSHROOM_AND_ONION = new Item(7066); - - /** - * Represents the fried onions item. - */ - private static final Item FRIED_ONIONS = new Item(7084); - - /** - * Represents the fried mushrooms item. - */ - private static final Item FRIED_MUSHROOMS = new Item(7082); - - @Override - public void mix(final Player player, final NodeUsageEvent event) { - if (player.getSkills().getLevel(Skills.COOKING) < 57) { - player.getDialogueInterpreter().sendDialogue("You need a Cooking level of at least " + 57 + " in order to do this."); - return; - } - super.mix(player, event); - player.getSkills().addExperience(Skills.COOKING, 120, true); - } - - @Override - public Item getBase() { - return FRIED_MUSHROOMS; - } - - @Override - public Item getProduct() { - return MUSHROOM_AND_ONION; - } - - @Override - public Item[] getIngredients() { - return new Item[] { FRIED_ONIONS }; - } - - @Override - public Item[] getParts() { - return new Item[] {}; - } - - @Override - public String getMixMessage(NodeUsageEvent event) { - return null; - } - - @Override - public boolean isSingular() { - return true; - } - -} diff --git a/Server/src/main/content/global/skill/cooking/recipe/topping/impl/SlicedMushroom.java b/Server/src/main/content/global/skill/cooking/recipe/topping/impl/SlicedMushroom.java deleted file mode 100644 index 46f9d09f8..000000000 --- a/Server/src/main/content/global/skill/cooking/recipe/topping/impl/SlicedMushroom.java +++ /dev/null @@ -1,69 +0,0 @@ -package content.global.skill.cooking.recipe.topping.impl; - -import content.global.skill.cooking.recipe.topping.ToppingRecipe; -import core.game.interaction.NodeUsageEvent; -import core.game.node.entity.player.Player; -import core.game.node.item.Item; - -/** - * Represents the fried mushroom recipe. This recipe consists of using a - * mushroom on a bowl. - * @author 'Vexia - * @date 22/12/2013 - */ -public final class SlicedMushroom extends ToppingRecipe { - - /** - * Represents the sliced mushrooms item. - */ - private static final Item SLICED_MUSHROOMS = new Item(7080); - - /** - * Represents the mushroom item. - */ - private static final Item MUSHROOM = new Item(6004); - - /** - * Represents the knife item. - */ - private static final Item KNIFE = new Item(946); - - @Override - public void mix(final Player player, final NodeUsageEvent event) { - if (!player.getInventory().containsItem(KNIFE)) { - player.getDialogueInterpreter().sendDialogue("You need a knife in order to slice up the mushrooms."); - return; - } - super.mix(player, event); - } - - @Override - public int getLevel() { - return 1; - } - - @Override - public double getExperience() { - return 0; - } - - @Override - public Item getProduct() { - return SLICED_MUSHROOMS; - } - - @Override - public Item[] getIngredients() { - return new Item[] { MUSHROOM }; - } - - @Override - public Item[] getParts() { - return new Item[] {}; - } - - @Override - public boolean isSingular() { - return true; - } -} diff --git a/Server/src/main/content/global/skill/cooking/recipe/topping/impl/SpicySauce.java b/Server/src/main/content/global/skill/cooking/recipe/topping/impl/SpicySauce.java deleted file mode 100644 index 2b0a7e103..000000000 --- a/Server/src/main/content/global/skill/cooking/recipe/topping/impl/SpicySauce.java +++ /dev/null @@ -1,84 +0,0 @@ -package content.global.skill.cooking.recipe.topping.impl; - -import core.game.node.entity.skill.Skills; -import content.global.skill.cooking.recipe.Recipe; -import core.game.interaction.NodeUsageEvent; -import core.game.node.entity.player.Player; -import core.game.node.item.Item; - -/** - * Represents the spicy sauce recipe. This recipe consists of mixing gnome spice - * and garlic together. - * @author 'Vexia - * @date 22/12/2013 - */ -public class SpicySauce extends Recipe { - - /** - * Represents the spicy sauce item. - */ - private static final Item SPICY_SAUCE = new Item(7072); - - /** - * Represents the bowl item. - */ - private static final Item BOWL = new Item(1923); - - /** - * Represents the garlic item. - */ - private static final Item GARLIC = new Item(1550); - - /** - * Represents the chopped garlic item. - */ - private static final Item CHOPPED_GARLIC = new Item(7074); - - /** - * Represents the gnome spice item. - */ - private static final Item GNOME_SPICE = new Item(2169); - - @Override - public void mix(final Player player, final NodeUsageEvent event) { - if (player.getSkills().getLevel(Skills.COOKING) < 9) { - player.getDialogueInterpreter().sendDialogue("You need a Cooking level of at least " + 9 + " in order to do this."); - return; - } - super.mix(player, event); - if (event.getBaseItem().getId() == GNOME_SPICE.getId() || event.getUsedItem().getId() == GNOME_SPICE.getId()) { - player.getSkills().addExperience(Skills.COOKING, 25, true); - } - } - - @Override - public Item getBase() { - return BOWL; - } - - @Override - public Item getProduct() { - return SPICY_SAUCE; - } - - @Override - public Item[] getIngredients() { - return new Item[] { GARLIC, GNOME_SPICE }; - } - - @Override - public Item[] getParts() { - return new Item[] { BOWL, CHOPPED_GARLIC, SPICY_SAUCE }; - } - - @Override - public String getMixMessage(NodeUsageEvent event) { - return null; - } - - @Override - public boolean isSingular() { - return false; - } - -} diff --git a/Server/src/main/content/global/skill/cooking/recipe/topping/impl/TunaAndCorn.java b/Server/src/main/content/global/skill/cooking/recipe/topping/impl/TunaAndCorn.java deleted file mode 100644 index 1e2c92a6f..000000000 --- a/Server/src/main/content/global/skill/cooking/recipe/topping/impl/TunaAndCorn.java +++ /dev/null @@ -1,72 +0,0 @@ -package content.global.skill.cooking.recipe.topping.impl; - -import core.game.node.entity.skill.Skills; -import content.global.skill.cooking.recipe.Recipe; -import core.game.interaction.NodeUsageEvent; -import core.game.node.entity.player.Player; -import core.game.node.item.Item; - -/** - * Represents the tuna and corn recipe. This recipe consists of adding cooked - * sweetcorn to a bowl of chopped tuna. - * @author 'Vexia - * @date 22/12/2013 - */ -public final class TunaAndCorn extends Recipe { - - /** - * Represents the chopped tuna item. - */ - private static final Item CHOPPED_TUNA = new Item(7086); - - /** - * Represents the cooked corn item. - */ - private static final Item COOKED_CORN = new Item(5988); - - /** - * Represents the tuna and corn item. - */ - private static final Item TUNA_AND_CORN = new Item(7068); - - @Override - public void mix(final Player player, final NodeUsageEvent event) { - if (player.getSkills().getLevel(Skills.COOKING) < 67) { - player.getDialogueInterpreter().sendDialogue("You need a Cooking level of at least " + 57 + " in order to do this."); - return; - } - super.mix(player, event); - player.getSkills().addExperience(Skills.COOKING, 204, true); - } - - @Override - public Item getBase() { - return CHOPPED_TUNA; - } - - @Override - public Item getProduct() { - return TUNA_AND_CORN; - } - - @Override - public Item[] getIngredients() { - return new Item[] { COOKED_CORN }; - } - - @Override - public Item[] getParts() { - return new Item[] {}; - } - - @Override - public String getMixMessage(NodeUsageEvent event) { - return null; - } - - @Override - public boolean isSingular() { - return true; - } - -} diff --git a/Server/src/main/content/global/skill/cooking/recipe/topping/impl/UncookedEgg.java b/Server/src/main/content/global/skill/cooking/recipe/topping/impl/UncookedEgg.java deleted file mode 100644 index 61ce50394..000000000 --- a/Server/src/main/content/global/skill/cooking/recipe/topping/impl/UncookedEgg.java +++ /dev/null @@ -1,54 +0,0 @@ -package content.global.skill.cooking.recipe.topping.impl; - -import content.global.skill.cooking.recipe.topping.ToppingRecipe; -import core.game.node.item.Item; - -/** - * Represents the uncooked egg recipe. This recipe consists of adding an - * uncooked egg into a bowl. - * @author 'Vexia - * @date 22/12/2013 - */ -public final class UncookedEgg extends ToppingRecipe { - - /** - * Represents the egg item. - */ - private static final Item EGG = new Item(1944); - - /** - * Represents the uncooked egg product. - */ - private static final Item UNCOOKED_EGG = new Item(7076); - - @Override - public int getLevel() { - return 1; - } - - @Override - public double getExperience() { - return 1; - } - - @Override - public Item getProduct() { - return UNCOOKED_EGG; - } - - @Override - public Item[] getIngredients() { - return new Item[] { EGG }; - } - - @Override - public boolean isSingular() { - return true; - } - - @Override - public Item[] getParts() { - return new Item[] {}; - } - -} From c1fbdcdd287ce5fcccacad3e63619471eca2718b Mon Sep 17 00:00:00 2001 From: Syndromeramo Date: Tue, 29 Jul 2025 17:56:05 -0500 Subject: [PATCH 20/24] Refactored Baked Potatoes. Final removal of Recipe.java, reorganization of recipes. --- .../skill/cooking/CookingRecipePlugin.java | 134 ------------------ .../{cake => }/ChocolateCakeListener.kt | 3 +- .../recipe/{stew => }/CurryListener.kt | 3 +- .../cooking/recipe/{pie => }/PieListener.kt | 3 +- .../recipe/{pie => }/PieShellListener.kt | 3 +- .../recipe/{pizza => }/PizzaListener.kt | 3 +- .../skill/cooking/recipe/PotatoListener.kt | 81 +++++++++++ .../global/skill/cooking/recipe/Recipe.java | 120 ---------------- .../cooking/recipe/{stew => }/StewListener.kt | 3 +- .../recipe/{topping => }/ToppingListener.kt | 3 +- .../cooking/recipe/potato/PotatoRecipe.java | 76 ---------- .../recipe/potato/impl/ButterPotato.java | 72 ---------- .../recipe/potato/impl/CheesePotato.java | 49 ------- .../recipe/potato/impl/ChilliPotato.java | 49 ------- .../cooking/recipe/potato/impl/EggPotato.java | 49 ------- .../recipe/potato/impl/MushroomPotato.java | 49 ------- .../recipe/potato/impl/TunaPotato.java | 49 ------- 17 files changed, 88 insertions(+), 661 deletions(-) delete mode 100644 Server/src/main/content/global/skill/cooking/CookingRecipePlugin.java rename Server/src/main/content/global/skill/cooking/recipe/{cake => }/ChocolateCakeListener.kt (89%) rename Server/src/main/content/global/skill/cooking/recipe/{stew => }/CurryListener.kt (91%) rename Server/src/main/content/global/skill/cooking/recipe/{pie => }/PieListener.kt (97%) rename Server/src/main/content/global/skill/cooking/recipe/{pie => }/PieShellListener.kt (88%) rename Server/src/main/content/global/skill/cooking/recipe/{pizza => }/PizzaListener.kt (95%) create mode 100644 Server/src/main/content/global/skill/cooking/recipe/PotatoListener.kt delete mode 100644 Server/src/main/content/global/skill/cooking/recipe/Recipe.java rename Server/src/main/content/global/skill/cooking/recipe/{stew => }/StewListener.kt (95%) rename Server/src/main/content/global/skill/cooking/recipe/{topping => }/ToppingListener.kt (97%) delete mode 100644 Server/src/main/content/global/skill/cooking/recipe/potato/PotatoRecipe.java delete mode 100644 Server/src/main/content/global/skill/cooking/recipe/potato/impl/ButterPotato.java delete mode 100644 Server/src/main/content/global/skill/cooking/recipe/potato/impl/CheesePotato.java delete mode 100644 Server/src/main/content/global/skill/cooking/recipe/potato/impl/ChilliPotato.java delete mode 100644 Server/src/main/content/global/skill/cooking/recipe/potato/impl/EggPotato.java delete mode 100644 Server/src/main/content/global/skill/cooking/recipe/potato/impl/MushroomPotato.java delete mode 100644 Server/src/main/content/global/skill/cooking/recipe/potato/impl/TunaPotato.java diff --git a/Server/src/main/content/global/skill/cooking/CookingRecipePlugin.java b/Server/src/main/content/global/skill/cooking/CookingRecipePlugin.java deleted file mode 100644 index 067217358..000000000 --- a/Server/src/main/content/global/skill/cooking/CookingRecipePlugin.java +++ /dev/null @@ -1,134 +0,0 @@ -package content.global.skill.cooking; - -import content.global.skill.cooking.recipe.Recipe; -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.game.system.task.Pulse; -import core.plugin.Initializable; -import core.plugin.Plugin; -import core.game.dialogue.SkillDialogueHandler.SkillDialogue; -import core.game.dialogue.SkillDialogueHandler; - -import java.util.ArrayList; -import java.util.List; - -/** - * Represents a cooking recipe plugin. This is used to handle the multiple - * recipes used in cooking these recipes can range from making a pizza or making - * a pie. - * @author 'Vexia - * @version 1.9 - */ -@Initializable -public final class CookingRecipePlugin extends UseWithHandler { - - /** - * Constructs a new {@code CookingRecipePlugin} {@code Object}. - */ - public CookingRecipePlugin() { - super(getAllowedNodes()); - } - - @Override - public Plugin newInstance(Object arg) throws Throwable { - for (Recipe recipe : Recipe.RECIPES) { - for (Item ingredient : recipe.getIngredients()) { - addHandler(ingredient.getId(), ITEM_TYPE, this); - } - } - return this; - } - - @Override - public boolean handle(NodeUsageEvent event) { - Recipe recipe = null; - Item part = null; - // TODO: Transitioning to a Listener would save an O(n) pass through the recipes list on every use-with - recipeloop: - for (Recipe temp : Recipe.RECIPES) { - if (temp.isSingular()) { - if (temp.getBase().getId() == event.getUsedItem().getId() || temp.getBase().getId() == event.getBaseItem().getId()) { - for (Item ingredient : temp.getIngredients()) { - if (ingredient.getId() == event.getBaseItem().getId() || ingredient.getId() == event.getUsedItem().getId()) { - recipe = temp; - break recipeloop; - } - } - } - } else { - for (int k = 0; k < temp.getParts().length; k++) { - for (int i = 0; i < temp.getIngredients().length; i++) { - Item tempPart = temp.getParts()[k]; - Item ingredient = temp.getIngredients()[i]; - if (tempPart.getId() == event.getUsedItem().getId() && ingredient.getId() == event.getBaseItem().getId() || tempPart.getId() == event.getBaseItem().getId() && ingredient.getId() == event.getUsedItem().getId()) { - if (k == i) {// represents that this ingredient can - // mix with the other. - recipe = temp; - part = tempPart; - break recipeloop; - } - } - } - } - } - } - if (recipe != null) { - final Player player = event.getPlayer(); - final Recipe recipe_ = recipe; - final Item part_ = part; - SkillDialogueHandler handler = new SkillDialogueHandler(player, SkillDialogue.ONE_OPTION, recipe.getProduct()) { - @Override - public void create(final int amount, int index) { - player.getPulseManager().run(new Pulse(2) { - int count = 0; - @Override - public boolean pulse() { - recipe_.mix(player, event); - return ++count >= amount; - } - }); - } - - @Override - public int getAll(int index) { - return player.getInventory().getAmount(part_ != null ? part_ : recipe_.getBase()); - } - }; - if (player.getInventory().getAmount(recipe.getBase()) == 1) { - recipe_.mix(player, event); - } else { - handler.open(); - } - return true; - } - return false; - } - - /** - * Method used to get the allowed nodes for this plugin. - * @return the allowed nodes. - */ - private final static int[] getAllowedNodes() { - List bases = new ArrayList<>(10); - for (Recipe recipe : Recipe.RECIPES) { - for (Item base : recipe.getParts()) { - if (bases.contains(base.getId())) { - continue; - } - bases.add(base.getId()); - } - if (bases.contains(recipe.getBase().getId())) { - continue; - } - bases.add(recipe.getBase().getId()); - } - int[] baseArray = new int[bases.size()]; - for (int i = 0; i < bases.size(); i++) { - baseArray[i] = bases.get(i); - } - return baseArray; - } - -} diff --git a/Server/src/main/content/global/skill/cooking/recipe/cake/ChocolateCakeListener.kt b/Server/src/main/content/global/skill/cooking/recipe/ChocolateCakeListener.kt similarity index 89% rename from Server/src/main/content/global/skill/cooking/recipe/cake/ChocolateCakeListener.kt rename to Server/src/main/content/global/skill/cooking/recipe/ChocolateCakeListener.kt index 623c2b3cc..0661c9417 100644 --- a/Server/src/main/content/global/skill/cooking/recipe/cake/ChocolateCakeListener.kt +++ b/Server/src/main/content/global/skill/cooking/recipe/ChocolateCakeListener.kt @@ -1,6 +1,5 @@ -package content.global.skill.cooking.recipe.cake +package content.global.skill.cooking.recipe -import content.global.skill.cooking.recipe.standardMix import core.game.interaction.IntType import core.game.interaction.InteractionListener import org.rs09.consts.Items diff --git a/Server/src/main/content/global/skill/cooking/recipe/stew/CurryListener.kt b/Server/src/main/content/global/skill/cooking/recipe/CurryListener.kt similarity index 91% rename from Server/src/main/content/global/skill/cooking/recipe/stew/CurryListener.kt rename to Server/src/main/content/global/skill/cooking/recipe/CurryListener.kt index e88f7a807..b6be43bb4 100644 --- a/Server/src/main/content/global/skill/cooking/recipe/stew/CurryListener.kt +++ b/Server/src/main/content/global/skill/cooking/recipe/CurryListener.kt @@ -1,6 +1,5 @@ -package content.global.skill.cooking.recipe.stew +package content.global.skill.cooking.recipe -import content.global.skill.cooking.recipe.standardMix import core.game.interaction.IntType import core.game.interaction.InteractionListener import core.game.node.item.Item diff --git a/Server/src/main/content/global/skill/cooking/recipe/pie/PieListener.kt b/Server/src/main/content/global/skill/cooking/recipe/PieListener.kt similarity index 97% rename from Server/src/main/content/global/skill/cooking/recipe/pie/PieListener.kt rename to Server/src/main/content/global/skill/cooking/recipe/PieListener.kt index 2d28081f5..20ddd1fe6 100644 --- a/Server/src/main/content/global/skill/cooking/recipe/pie/PieListener.kt +++ b/Server/src/main/content/global/skill/cooking/recipe/PieListener.kt @@ -1,6 +1,5 @@ -package content.global.skill.cooking.recipe.pie +package content.global.skill.cooking.recipe -import content.global.skill.cooking.recipe.standardMix import core.game.interaction.IntType import core.game.interaction.InteractionListener import org.rs09.consts.Items diff --git a/Server/src/main/content/global/skill/cooking/recipe/pie/PieShellListener.kt b/Server/src/main/content/global/skill/cooking/recipe/PieShellListener.kt similarity index 88% rename from Server/src/main/content/global/skill/cooking/recipe/pie/PieShellListener.kt rename to Server/src/main/content/global/skill/cooking/recipe/PieShellListener.kt index d91cd9580..b0e075575 100644 --- a/Server/src/main/content/global/skill/cooking/recipe/pie/PieShellListener.kt +++ b/Server/src/main/content/global/skill/cooking/recipe/PieShellListener.kt @@ -1,6 +1,5 @@ -package content.global.skill.cooking.recipe.pie +package content.global.skill.cooking.recipe -import content.global.skill.cooking.recipe.standardMix import core.game.interaction.IntType import core.game.interaction.InteractionListener import org.rs09.consts.Items diff --git a/Server/src/main/content/global/skill/cooking/recipe/pizza/PizzaListener.kt b/Server/src/main/content/global/skill/cooking/recipe/PizzaListener.kt similarity index 95% rename from Server/src/main/content/global/skill/cooking/recipe/pizza/PizzaListener.kt rename to Server/src/main/content/global/skill/cooking/recipe/PizzaListener.kt index 86a7c16e1..f70c32f35 100644 --- a/Server/src/main/content/global/skill/cooking/recipe/pizza/PizzaListener.kt +++ b/Server/src/main/content/global/skill/cooking/recipe/PizzaListener.kt @@ -1,6 +1,5 @@ -package content.global.skill.cooking.recipe.pizza +package content.global.skill.cooking.recipe -import content.global.skill.cooking.recipe.standardMix import core.game.interaction.IntType import core.game.interaction.InteractionListener import org.rs09.consts.Items diff --git a/Server/src/main/content/global/skill/cooking/recipe/PotatoListener.kt b/Server/src/main/content/global/skill/cooking/recipe/PotatoListener.kt new file mode 100644 index 000000000..14e631bb0 --- /dev/null +++ b/Server/src/main/content/global/skill/cooking/recipe/PotatoListener.kt @@ -0,0 +1,81 @@ +package content.global.skill.cooking.recipe + +import core.game.interaction.IntType +import core.game.interaction.InteractionListener +import org.rs09.consts.Items + +class PotatoListener : InteractionListener { + + val added = PotatoProduct.values().map { it.added }.toIntArray() + + override fun defineListeners() { + onUseWith(IntType.ITEM, Items.BAKED_POTATO_6701, Items.PAT_OF_BUTTER_6697) { player, used, with -> + val product = Items.POTATO_WITH_BUTTER_6703 + val level = 39 + val experience = 40.5 + val message = "You add a pat of butter to the potato." + val failMessage = "You need a Cooking level of at least $level in order to do this." + + return@onUseWith standardMix( + player, + used.asItem(), + with.asItem(), + product, + level, + experience, + message, + failMessage + ) + } + + onUseWith(IntType.ITEM, added, Items.POTATO_WITH_BUTTER_6703) { player, used, with -> + val topping = PotatoProduct.productMap[used.id] ?: return@onUseWith true + + val product = topping.product + val level = topping.minimumLevel + val experience = topping.experience + val message = "" + val failMessage = "You need a Cooking level of at least $level in order to do this." + + return@onUseWith standardMix( + player, + used.asItem(), + with.asItem(), + product, + level, + experience, + message, + failMessage + ) + } + } + + enum class PotatoProduct( + val added: Int, + val product: Int, + val minimumLevel: Int, + val experience: Double, + val message: String + ) { + //Tuna and Corn: https://www.youtube.com/watch?v=wAavERc9p2c + //Uncooked Egg: https://www.youtube.com/watch?v=LiLq6PhCc2M + //Bowl of sweetcorn (OSRS source is only I could find) https://www.youtube.com/watch?v=pz8epXjkKYE + + CHEESE_POTATO(Items.CHEESE_1985, Items.POTATO_WITH_CHEESE_6705, 47, 10.0, ""), + CHILLI_POTATO(Items.CHILLI_CON_CARNE_7062, Items.CHILLI_POTATO_7054, 41, 15.0, ""), + EGG_POTATO(Items.EGG_AND_TOMATO_7064, Items.EGG_POTATO_7056, 51, 50.0, ""), + TUNA_POTATO(Items.TUNA_AND_CORN_7068, Items.TUNA_POTATO_7060, 68, 10.0, ""), + MUSHROOM_POTATO(Items.MUSHROOM_AND_ONION_7066, Items.MUSHROOM_POTATO_7058, 64, 55.0, ""), + ; + + companion object { + val productMap = HashMap() + + init { + for (topping in PotatoProduct.values()) { + productMap[topping.added] = topping + } + } + } + } +} \ No newline at end of file diff --git a/Server/src/main/content/global/skill/cooking/recipe/Recipe.java b/Server/src/main/content/global/skill/cooking/recipe/Recipe.java deleted file mode 100644 index 588d25faa..000000000 --- a/Server/src/main/content/global/skill/cooking/recipe/Recipe.java +++ /dev/null @@ -1,120 +0,0 @@ -package content.global.skill.cooking.recipe; - -import content.global.skill.cooking.recipe.potato.impl.*; -import core.game.interaction.NodeUsageEvent; -import core.game.node.entity.player.Player; -import core.game.node.item.Item; - -/** - * Represents a cooking recipe, this is dynamic that can range from a pie to a - * pizza. - * @author 'Vexia - * @date 21/12/2013 - */ -public abstract class Recipe { - - /** - * Represents the array of active recipes in 2009Scape. - */ - // TODO: - // - Making this an enum would drastically save on file/line count, since the recipes seem to mostly be plain-old-data classes - // - Making pie shells a recipe would make make-x for them just work - // - Making pineapple cutting a recipe would probably fix their make-x making all with any option - public static final Recipe[] RECIPES = new Recipe[] { - new ButterPotato(), new ChilliPotato(), new CheesePotato(), new EggPotato(), new MushroomPotato(), new TunaPotato(), - }; - - /** - * Method used to get the base item. - * @return the item. - */ - public abstract Item getBase(); - - /** - * Method used to get the product item. - * @return the product item. - */ - public abstract Item getProduct(); - - /** - * Method used to get the ingredients in this recipe. - * @return the ingredients. - */ - public abstract Item[] getIngredients(); - - /** - * Method used to get the part items made from ingredients. - * @return the part items. - */ - public abstract Item[] getParts(); - - /** - * Method used to get the mixing message. - * @param event the node usage event. - * @return the message used to mix. - */ - public abstract String getMixMessage(final NodeUsageEvent event); - - /** - * Method used to check if this is a singular one step recipe. - * @return True if so. - */ - public abstract boolean isSingular(); - - /** - * Method used to mix this recipes ingredients. - * @param player the player. - * @param event the event. - */ - public void mix(final Player player, final NodeUsageEvent event) { - if (getIngredients().length == 1) { - singleMix(player, event); - } else { - multipleMix(player, event); - } - } - - /** - * Method used to handle a single mixing. - * @param player the player. - * @param event the event. - */ - public void singleMix(final Player player, final NodeUsageEvent event) { - if (player.getInventory().remove(event.getBaseItem()) && player.getInventory().remove(event.getUsedItem())) { - player.getInventory().add(getProduct()); - String message = getMixMessage(event); - if (message != null) { - player.getPacketDispatch().sendMessage(message); - } - } - } - - /** - * Method used to handle mixing multiple item recipes. - * @param player the player. - * @param event the event. - */ - public void multipleMix(final Player player, final NodeUsageEvent event) { - Item item = null; - int index = -1; - for (int counter = 0; counter < getIngredients().length; counter++) { - item = getIngredients()[counter]; - if (item.getId() == event.getUsedItem().getId() || item.getId() == event.getBaseItem().getId()) { - index = counter; - break; - } - } - if (index != -1) { - if (!player.getInventory().containItems(event.getBaseItem().getId(), event.getUsedItem().getId())) { - return; - } - if (player.getInventory().remove(event.getBaseItem()) && player.getInventory().remove(event.getUsedItem())) { - player.getInventory().add(getParts()[index + 1]); - String message = getMixMessage(event); - if (message != null) { - player.getPacketDispatch().sendMessage(message); - } - } - } - } -} diff --git a/Server/src/main/content/global/skill/cooking/recipe/stew/StewListener.kt b/Server/src/main/content/global/skill/cooking/recipe/StewListener.kt similarity index 95% rename from Server/src/main/content/global/skill/cooking/recipe/stew/StewListener.kt rename to Server/src/main/content/global/skill/cooking/recipe/StewListener.kt index 4fb799266..312aedcf0 100644 --- a/Server/src/main/content/global/skill/cooking/recipe/stew/StewListener.kt +++ b/Server/src/main/content/global/skill/cooking/recipe/StewListener.kt @@ -1,6 +1,5 @@ -package content.global.skill.cooking.recipe.stew +package content.global.skill.cooking.recipe -import content.global.skill.cooking.recipe.standardMix import core.game.interaction.IntType import core.game.interaction.InteractionListener import org.rs09.consts.Items diff --git a/Server/src/main/content/global/skill/cooking/recipe/topping/ToppingListener.kt b/Server/src/main/content/global/skill/cooking/recipe/ToppingListener.kt similarity index 97% rename from Server/src/main/content/global/skill/cooking/recipe/topping/ToppingListener.kt rename to Server/src/main/content/global/skill/cooking/recipe/ToppingListener.kt index 049dbebc6..68e5c55bb 100644 --- a/Server/src/main/content/global/skill/cooking/recipe/topping/ToppingListener.kt +++ b/Server/src/main/content/global/skill/cooking/recipe/ToppingListener.kt @@ -1,6 +1,5 @@ -package content.global.skill.cooking.recipe.topping +package content.global.skill.cooking.recipe -import content.global.skill.cooking.recipe.standardMix import core.api.inInventory import core.api.sendDialogue import core.game.interaction.IntType diff --git a/Server/src/main/content/global/skill/cooking/recipe/potato/PotatoRecipe.java b/Server/src/main/content/global/skill/cooking/recipe/potato/PotatoRecipe.java deleted file mode 100644 index c2640a8bc..000000000 --- a/Server/src/main/content/global/skill/cooking/recipe/potato/PotatoRecipe.java +++ /dev/null @@ -1,76 +0,0 @@ -package content.global.skill.cooking.recipe.potato; - -import core.game.node.entity.skill.Skills; -import content.global.skill.cooking.recipe.Recipe; -import core.game.interaction.NodeUsageEvent; -import core.game.node.entity.player.Player; -import core.game.node.item.Item; - -/** - * Represents a generic potato topping recipe. - * @author 'Vexia - * @date 22/12/2013 - */ -public abstract class PotatoRecipe extends Recipe { - - /** - * Represents the potato with butter. - */ - private static final Item POTATO_WITH_BUTTER = new Item(6703); - - /** - * Represents the bowl item. - */ - protected static final Item BOWL = new Item(1923); - - @Override - public void mix(final Player player, final NodeUsageEvent event) { - if (player.getSkills().getLevel(Skills.COOKING) < getLevel()) { - player.getDialogueInterpreter().sendDialogue("You need a Cooking level of at least " + getLevel() + " in order to do this."); - return; - } - super.singleMix(player, event); - if (isTopping()) { - player.getInventory().add(BOWL); - } - player.getSkills().addExperience(Skills.COOKING, getExperience(), true); - } - - @Override - public Item getBase() { - return POTATO_WITH_BUTTER; - } - - @Override - public Item[] getParts() { - return new Item[] {}; - } - - @Override - public String getMixMessage(NodeUsageEvent event) { - return null; - } - - @Override - public boolean isSingular() { - return true; - } - - /** - * Method used to check if it is a topping recipe. - * @return True if it is a topping. - */ - public abstract boolean isTopping(); - - /** - * Method used to get the level required. - * @return the level. - */ - public abstract int getLevel(); - - /** - * Method used to get the experience gained. - * @return the experience. - */ - public abstract double getExperience(); -} diff --git a/Server/src/main/content/global/skill/cooking/recipe/potato/impl/ButterPotato.java b/Server/src/main/content/global/skill/cooking/recipe/potato/impl/ButterPotato.java deleted file mode 100644 index b382a5029..000000000 --- a/Server/src/main/content/global/skill/cooking/recipe/potato/impl/ButterPotato.java +++ /dev/null @@ -1,72 +0,0 @@ -package content.global.skill.cooking.recipe.potato.impl; - -import content.global.skill.cooking.recipe.Recipe; -import core.game.node.entity.skill.Skills; -import core.game.interaction.NodeUsageEvent; -import core.game.node.entity.player.Player; -import core.game.node.item.Item; - -/** - * Represents the butter potato recipe. This recipe consists of adding a pat of - * butter to a potato. - * @author 'Vexia - * @date 22/12/2013 - */ -public class ButterPotato extends Recipe { - - /** - * Represents the baked potato. - */ - private static final Item BAKED_POTATO = new Item(6701); - - /** - * Represents the potato with butter. - */ - private static final Item POTATO_WITH_BUTTER = new Item(6703); - - /** - * Represents the pat of butter. - */ - private static final Item PAT_OF_BUTTER = new Item(6697); - - @Override - public void mix(final Player player, final NodeUsageEvent event) { - if (player.getSkills().getLevel(Skills.COOKING) < 39) { - player.getDialogueInterpreter().sendDialogue("You need a Cooking level of at least " + 39 + " in order to do this."); - return; - } - super.singleMix(player, event); - player.getSkills().addExperience(Skills.COOKING, 40.5, true); - } - - @Override - public Item getBase() { - return BAKED_POTATO; - } - - @Override - public Item getProduct() { - return POTATO_WITH_BUTTER; - } - - @Override - public Item[] getIngredients() { - return new Item[] { PAT_OF_BUTTER }; - } - - @Override - public Item[] getParts() { - return new Item[] {}; - } - - @Override - public String getMixMessage(NodeUsageEvent event) { - return "You add a pat of butter to the potato."; - } - - @Override - public boolean isSingular() { - return true; - } - -} diff --git a/Server/src/main/content/global/skill/cooking/recipe/potato/impl/CheesePotato.java b/Server/src/main/content/global/skill/cooking/recipe/potato/impl/CheesePotato.java deleted file mode 100644 index f111ed950..000000000 --- a/Server/src/main/content/global/skill/cooking/recipe/potato/impl/CheesePotato.java +++ /dev/null @@ -1,49 +0,0 @@ -package content.global.skill.cooking.recipe.potato.impl; - -import content.global.skill.cooking.recipe.potato.PotatoRecipe; -import core.game.node.item.Item; - -/** - * Represents the cheese potato. This recipe consists of mixing cheese witha - * baked potato. - * @author 'Vexia - * @date 22/12/2013 - */ -public class CheesePotato extends PotatoRecipe { - - /** - * Represents the cheese potato. - */ - private static final Item CHEESE_POTATO = new Item(6705); - - /** - * Represents the cheese item. - */ - private static final Item CHEESE = new Item(1985); - - @Override - public Item getProduct() { - return CHEESE_POTATO; - } - - @Override - public Item[] getIngredients() { - return new Item[] { CHEESE }; - } - - @Override - public boolean isTopping() { - return false; - } - - @Override - public int getLevel() { - return 47; - } - - @Override - public double getExperience() { - return 10; - } - -} diff --git a/Server/src/main/content/global/skill/cooking/recipe/potato/impl/ChilliPotato.java b/Server/src/main/content/global/skill/cooking/recipe/potato/impl/ChilliPotato.java deleted file mode 100644 index 88c5ed146..000000000 --- a/Server/src/main/content/global/skill/cooking/recipe/potato/impl/ChilliPotato.java +++ /dev/null @@ -1,49 +0,0 @@ -package content.global.skill.cooking.recipe.potato.impl; - -import content.global.skill.cooking.recipe.potato.PotatoRecipe; -import core.game.node.item.Item; - -/** - * Represents the chilli potato recipe. This recipe consists of adding chilli - * con carne to a baked butter potato. - * @author 'Vexia - * @date 22/12/2013 - */ -public class ChilliPotato extends PotatoRecipe { - - /** - * Represents the chilli potato item. - */ - private static final Item CHILLI_POTATO = new Item(7054); - - /** - * Represents the chilli con carne item/ - */ - private static final Item CHILLI_CON_CARNE = new Item(7062); - - @Override - public Item getProduct() { - return CHILLI_POTATO; - } - - @Override - public Item[] getIngredients() { - return new Item[] { CHILLI_CON_CARNE }; - } - - @Override - public boolean isTopping() { - return true; - } - - @Override - public int getLevel() { - return 41; - } - - @Override - public double getExperience() { - return 10; - } - -} diff --git a/Server/src/main/content/global/skill/cooking/recipe/potato/impl/EggPotato.java b/Server/src/main/content/global/skill/cooking/recipe/potato/impl/EggPotato.java deleted file mode 100644 index c616591fd..000000000 --- a/Server/src/main/content/global/skill/cooking/recipe/potato/impl/EggPotato.java +++ /dev/null @@ -1,49 +0,0 @@ -package content.global.skill.cooking.recipe.potato.impl; - -import content.global.skill.cooking.recipe.potato.PotatoRecipe; -import core.game.node.item.Item; - -/** - * Represents the egg potato recipe. This recipe consists of mixing a egg and a - * tomato. - * @author 'Vexia - * @date 22/12/2013 - */ -public class EggPotato extends PotatoRecipe { - - /** - * Represents the egg potato. - */ - private static final Item EGG_POTATO = new Item(7056); - - /** - * Represents the topping item. - */ - private static final Item TOPPING = new Item(7064); - - @Override - public Item getProduct() { - return EGG_POTATO; - } - - @Override - public Item[] getIngredients() { - return new Item[] { TOPPING }; - } - - @Override - public boolean isTopping() { - return true; - } - - @Override - public int getLevel() { - return 51; - } - - @Override - public double getExperience() { - return 10; - } - -} diff --git a/Server/src/main/content/global/skill/cooking/recipe/potato/impl/MushroomPotato.java b/Server/src/main/content/global/skill/cooking/recipe/potato/impl/MushroomPotato.java deleted file mode 100644 index d7bfa1c2c..000000000 --- a/Server/src/main/content/global/skill/cooking/recipe/potato/impl/MushroomPotato.java +++ /dev/null @@ -1,49 +0,0 @@ -package content.global.skill.cooking.recipe.potato.impl; - -import content.global.skill.cooking.recipe.potato.PotatoRecipe; -import core.game.node.item.Item; - -/** - * Represents the mushrrom potato. This recipe consists of mixing a baked potato - * with mushroom and onion toppings. - * @author 'Vexia - * @date 22/12/2013 - */ -public class MushroomPotato extends PotatoRecipe { - - /** - * Represents the egg potato. - */ - private static final Item MUSHROOM_POTATO = new Item(7058); - - /** - * Represents the topping item. - */ - private static final Item TOPPING = new Item(7066); - - @Override - public Item getProduct() { - return MUSHROOM_POTATO; - } - - @Override - public Item[] getIngredients() { - return new Item[] { TOPPING }; - } - - @Override - public boolean isTopping() { - return true; - } - - @Override - public int getLevel() { - return 64; - } - - @Override - public double getExperience() { - return 10; - } - -} diff --git a/Server/src/main/content/global/skill/cooking/recipe/potato/impl/TunaPotato.java b/Server/src/main/content/global/skill/cooking/recipe/potato/impl/TunaPotato.java deleted file mode 100644 index 645d5ed2e..000000000 --- a/Server/src/main/content/global/skill/cooking/recipe/potato/impl/TunaPotato.java +++ /dev/null @@ -1,49 +0,0 @@ -package content.global.skill.cooking.recipe.potato.impl; - -import content.global.skill.cooking.recipe.potato.PotatoRecipe; -import core.game.node.item.Item; - -/** - * Represents the tuna potato recipe. This recipe consists of mixing tuna and - * corn toppings. - * @author 'Vexia - * @date 22/12/2013 - */ -public class TunaPotato extends PotatoRecipe { - - /** - * Represents the tuna potato. - */ - private static final Item TUNA_POTATO = new Item(7060); - - /** - * Represents the topping item. - */ - private static final Item TOPPING = new Item(7068); - - @Override - public Item getProduct() { - return TUNA_POTATO; - } - - @Override - public Item[] getIngredients() { - return new Item[] { TOPPING }; - } - - @Override - public boolean isTopping() { - return true; - } - - @Override - public int getLevel() { - return 68; - } - - @Override - public double getExperience() { - return 10; - } - -} From 27fb60264de8e0ec9821994e9a0a82f895e4dae9 Mon Sep 17 00:00:00 2001 From: Syndromeramo Date: Tue, 29 Jul 2025 21:06:18 -0500 Subject: [PATCH 21/24] Chopped Tuna and Onion are now consumable. --- Server/src/main/content/data/consumables/Consumables.java | 2 ++ .../content/global/skill/cooking/recipe/PotatoListener.kt | 4 ---- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/Server/src/main/content/data/consumables/Consumables.java b/Server/src/main/content/data/consumables/Consumables.java index 58143afc0..92c71fe18 100644 --- a/Server/src/main/content/data/consumables/Consumables.java +++ b/Server/src/main/content/data/consumables/Consumables.java @@ -118,6 +118,8 @@ public enum Consumables { EGG_AND_TOMATO(new Food(new int[] {7064, 1923}, new HealingEffect(8))), SWEET_CORN(new Food(new int[] {5988}, new MultiEffect(new HealingEffect(1), new PercentageHealthEffect(10)))), SWEETCORN_BOWL(new Food(new int[] {7088, 1923}, new MultiEffect(new HealingEffect(1), new PercentageHealthEffect(10)))), + CHOPPED_TUNA(new Food(new int[] {7086, 1923}, new HealingEffect(10))), + CHOPPED_ONION(new Food(new int[] {1871, 1923}, new HealingEffect(1))), POTATO_WITH_BUTTER(new Food(new int[] {6703}, new HealingEffect(7))), CHILLI_POTATO(new Food(new int[] {7054}, new HealingEffect(14))), FRIED_ONIONS(new Food(new int[] {7084, 1923}, new HealingEffect(5))), diff --git a/Server/src/main/content/global/skill/cooking/recipe/PotatoListener.kt b/Server/src/main/content/global/skill/cooking/recipe/PotatoListener.kt index 14e631bb0..6e2cd5b5c 100644 --- a/Server/src/main/content/global/skill/cooking/recipe/PotatoListener.kt +++ b/Server/src/main/content/global/skill/cooking/recipe/PotatoListener.kt @@ -57,10 +57,6 @@ class PotatoListener : InteractionListener { val experience: Double, val message: String ) { - //Tuna and Corn: https://www.youtube.com/watch?v=wAavERc9p2c - //Uncooked Egg: https://www.youtube.com/watch?v=LiLq6PhCc2M - //Bowl of sweetcorn (OSRS source is only I could find) https://www.youtube.com/watch?v=pz8epXjkKYE - CHEESE_POTATO(Items.CHEESE_1985, Items.POTATO_WITH_CHEESE_6705, 47, 10.0, ""), CHILLI_POTATO(Items.CHILLI_CON_CARNE_7062, Items.CHILLI_POTATO_7054, 41, 15.0, ""), EGG_POTATO(Items.EGG_AND_TOMATO_7064, Items.EGG_POTATO_7056, 51, 50.0, ""), From b0cf16fd189c4fd57fe3e2a2fc5cefcfa30c64f1 Mon Sep 17 00:00:00 2001 From: Syndromeramo Date: Tue, 29 Jul 2025 21:17:50 -0500 Subject: [PATCH 22/24] Removed firemaking requirement to skewered foods, added cooking requirement. --- .../global/skill/cooking/SkeweredFoodListener.kt | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/Server/src/main/content/global/skill/cooking/SkeweredFoodListener.kt b/Server/src/main/content/global/skill/cooking/SkeweredFoodListener.kt index 16bcebbdb..f170eb421 100644 --- a/Server/src/main/content/global/skill/cooking/SkeweredFoodListener.kt +++ b/Server/src/main/content/global/skill/cooking/SkeweredFoodListener.kt @@ -16,8 +16,16 @@ class SkeweredFoodListener : InteractionListener { override fun defineListeners() { onUseWith(IntType.ITEM, skewerMap.keys.toIntArray(), Items.IRON_SPIT_7225) { player, used, with -> - if (getDynLevel(player, Skills.FIREMAKING) < 20) { - sendMessage(player, "You need a Firemaking level of at least 20 in order to do this.") + val level = when (used.id) { + Items.RAW_BIRD_MEAT_9978 -> 11 + Items.RAW_RABBIT_3226 -> 16 + Items.RAW_BEAST_MEAT_9986 -> 21 + Items.RAW_CHOMPY_2876 -> 30 + else -> 0 + } + + if (getDynLevel(player, Skills.COOKING) < level) { + sendMessage(player, "You need a Cooking level of at least $level in order to do this.") return@onUseWith true } if(removeItem(player, used.id) && removeItem(player, with.id)) { From c6824277294fa90b8a381b78aa5cb1bd0bb02b68 Mon Sep 17 00:00:00 2001 From: Syndromeramo Date: Thu, 14 Aug 2025 10:36:36 -0500 Subject: [PATCH 23/24] Updated examine texts. --- Server/data/configs/item_configs.json | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/Server/data/configs/item_configs.json b/Server/data/configs/item_configs.json index 34d0d7b90..e528501e1 100644 --- a/Server/data/configs/item_configs.json +++ b/Server/data/configs/item_configs.json @@ -20859,8 +20859,10 @@ { "ge_buy_limit": "200", "grand_exchange_price": "177", + "examine": "I need to add some meat too.", "durability": null, "name": "Incomplete stew", + "tradeable": "true", "archery_ticket_price": "0", "id": "1997" }, @@ -20876,8 +20878,10 @@ { "ge_buy_limit": "200", "grand_exchange_price": "210", + "examine": "I need to add some potato too.", "durability": null, "name": "Incomplete stew", + "tradeable": "true", "archery_ticket_price": "0", "id": "1999" }, @@ -64497,7 +64501,7 @@ }, { "ge_buy_limit": "10000", - "examine": "Raw sweetcorn.", + "examine": "A bowl of cooked sweetcorn.", "grand_exchange_price": "110", "durability": null, "name": "Sweetcorn", From 9db92bc99c659832a3ff3d50a2d4b7ba8936f3cc Mon Sep 17 00:00:00 2001 From: Syndromeramo Date: Thu, 14 Aug 2025 10:54:49 -0500 Subject: [PATCH 24/24] Cooking level required for making cake mix. --- .../main/content/global/skill/cooking/CakeListener.kt | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/Server/src/main/content/global/skill/cooking/CakeListener.kt b/Server/src/main/content/global/skill/cooking/CakeListener.kt index 3cf0e7a0f..f5538371f 100644 --- a/Server/src/main/content/global/skill/cooking/CakeListener.kt +++ b/Server/src/main/content/global/skill/cooking/CakeListener.kt @@ -1,11 +1,9 @@ package content.global.skill.cooking -import core.api.addItem -import core.api.inInventory -import core.api.removeItem -import core.api.sendMessage +import core.api.* import core.game.interaction.IntType import core.game.interaction.InteractionListener +import core.game.node.entity.skill.Skills import org.rs09.consts.Items class CakeListener : InteractionListener { @@ -17,6 +15,11 @@ class CakeListener : InteractionListener { override fun defineListeners() { onUseWith(IntType.ITEM, cakeArr, Items.CAKE_TIN_1887) { player, _, _ -> + if (getDynLevel(player, Skills.COOKING) < 40) { + sendMessage(player, "You need a Cooking level of at least 40 in order to do this.") + return@onUseWith true + } + if(inInventory(player, Items.EGG_1944) && inInventory(player, Items.BUCKET_OF_MILK_1927) && inInventory(player, Items.POT_OF_FLOUR_1933) && inInventory(player, Items.CAKE_TIN_1887)) { removeItem(player, Items.EGG_1944) removeItem(player, Items.BUCKET_OF_MILK_1927)