From 095f53114e0af47f9756ea8f91c2cead0bc5c6ed Mon Sep 17 00:00:00 2001 From: Player Name Date: Sun, 19 Apr 2026 10:12:29 +0000 Subject: [PATCH] Added ::items command Added missing 6th colour variant of kitten/cat Fixed duplicated interaction implementations --- .../handlers/item/EmptyOptionListener.kt | 11 +++---- .../handlers/item/LightSourceListeners.kt | 32 +++++++++++++++++++ .../handlers/item/MiningHelmetListener.kt | 17 ---------- .../skill/cooking/NettleWaterListener.kt | 18 ----------- .../templeofikov/TempleOfIkovListeners.kt | 14 -------- .../varrock/dialogue/GertrudeDialogue.java | 2 +- .../system/command/sets/SpawnCommandSet.kt | 27 ++++++++++++++++ 7 files changed, 65 insertions(+), 56 deletions(-) create mode 100644 Server/src/main/content/global/handlers/item/LightSourceListeners.kt delete mode 100644 Server/src/main/content/global/handlers/item/MiningHelmetListener.kt delete mode 100644 Server/src/main/content/global/skill/cooking/NettleWaterListener.kt diff --git a/Server/src/main/content/global/handlers/item/EmptyOptionListener.kt b/Server/src/main/content/global/handlers/item/EmptyOptionListener.kt index c58bf62ed..71239cc7c 100644 --- a/Server/src/main/content/global/handlers/item/EmptyOptionListener.kt +++ b/Server/src/main/content/global/handlers/item/EmptyOptionListener.kt @@ -50,15 +50,14 @@ class EmptyOptionListener : InteractionListener { POTION(Items.POTION_195, Items.VIAL_229, "You empty the vial.", Sounds.LIQUID_2401), BURNT_STEW(Items.BURNT_STEW_2005, Items.BOWL_1923, "You empty the contents of the bowl onto the floor.", Sounds.LIQUID_2401), NETTLE_TEA(Items.NETTLE_TEA_4239, Items.BOWL_1923, "You empty the contents of the bowl onto the floor.", Sounds.LIQUID_2401), - CUP_OF_TEA(Items.CUP_OF_TEA_4242, Items.EMPTY_CUP_1980, "You empty the cup of tea.", Sounds.LIQUID_2401), - NETTLE_WATER(Items.NETTLE_WATER_4237, Items.BOWL_1923, "You empty the contents of the bowl onto the floor.", Sounds.LIQUID_2401), - NETTLE_TEA_MILKY(Items.NETTLE_TEA_4240, Items.BOWL_1923, "You empty the contents of the bowl onto the floor.", Sounds.LIQUID_2401), - NETTLE_TEA_CUP(Items.CUP_OF_TEA_4242, Items.EMPTY_CUP_1980, "You empty the contents of the cup onto the floor.", Sounds.LIQUID_2401), + NETTLE_TEA_CUP(Items.CUP_OF_TEA_4242, Items.EMPTY_CUP_1980, "You empty the cup of tea.", Sounds.LIQUID_2401), NETTLE_TEA_CUP_MILKY(Items.CUP_OF_TEA_4243, Items.EMPTY_CUP_1980, "You empty the contents of the cup onto the floor.", Sounds.LIQUID_2401), - TEA_CUP_WATER(Items.CUP_OF_WATER_4458, Items.EMPTY_CUP_1980, "You empty the contents of the cup onto the floor.", Sounds.LIQUID_2401), - TEA_CUP_HOT_WATER(Items.CUP_OF_HOT_WATER_4460, Items.EMPTY_CUP_1980, "You empty the contents of the cup onto the floor.", Sounds.LIQUID_2401), NETTLE_TEA_PORCELAIN(Items.CUP_OF_TEA_4245, Items.PORCELAIN_CUP_4244, "You empty the contents of the cup onto the floor.", Sounds.LIQUID_2401), NETTLE_TEA_PORCELAIN_MILKY(Items.CUP_OF_TEA_4246, Items.PORCELAIN_CUP_4244, "You empty the contents of the cup onto the floor.", Sounds.LIQUID_2401), + NETTLE_WATER(Items.NETTLE_WATER_4237, Items.BOWL_1923, "You empty the contents of the bowl onto the floor.", Sounds.LIQUID_2401), + NETTLE_TEA_MILKY(Items.NETTLE_TEA_4240, Items.BOWL_1923, "You empty the contents of the bowl onto the floor.", Sounds.LIQUID_2401), + TEA_CUP_WATER(Items.CUP_OF_WATER_4458, Items.EMPTY_CUP_1980, "You empty the contents of the cup onto the floor.", Sounds.LIQUID_2401), + TEA_CUP_HOT_WATER(Items.CUP_OF_HOT_WATER_4460, Items.EMPTY_CUP_1980, "You empty the contents of the cup onto the floor.", Sounds.LIQUID_2401), BUILDERS_TEA1(Items.CUP_OF_TEA_7730, Items.EMPTY_CUP_7728, "You empty the contents of the cup onto the floor.", Sounds.LIQUID_2401), BUILDERS_TEA1_MILKY(Items.CUP_OF_TEA_7731, Items.EMPTY_CUP_7728, "You empty the contents of the cup onto the floor.", Sounds.LIQUID_2401), BUILDERS_TEA2(Items.CUP_OF_TEA_7733, Items.PORCELAIN_CUP_7732, "You empty the contents of the cup onto the floor.", Sounds.LIQUID_2401), diff --git a/Server/src/main/content/global/handlers/item/LightSourceListeners.kt b/Server/src/main/content/global/handlers/item/LightSourceListeners.kt new file mode 100644 index 000000000..989746869 --- /dev/null +++ b/Server/src/main/content/global/handlers/item/LightSourceListeners.kt @@ -0,0 +1,32 @@ +package content.global.handlers.item + +import content.data.LightSource +import core.api.* +import core.game.interaction.InteractionListener +import core.game.interaction.IntType +import org.rs09.consts.Items +import kotlin.collections.toIntArray + +class LightSourceListeners : InteractionListener { + override fun defineListeners() { + val lightSourceProducts = LightSource.values().map { it.product.id }.toIntArray() + + on(lightSourceProducts, ITEM, "drop") { player, light -> + val active = LightSource.getActiveLightSource(player).product.id + if (player.location.isInRegion(10648) && light.id == active) { //Temple of Ikov dungeon + sendMessage(player, "Dropping the " + LightSource.getActiveLightSource(player).product.name.lowercase() + " would leave you without a light source.") + return@on false + } + val removed = removeItem(player, light.id) + if (removed) { + var droppedId = light.id + if (light.id == Items.MINING_HELMET_5013) { + droppedId = Items.MINING_HELMET_5014 + sendMessage(player, "The helmet goes out as you drop it.") + } + produceGroundItem(player, droppedId) + } + return@on true + } + } +} \ No newline at end of file diff --git a/Server/src/main/content/global/handlers/item/MiningHelmetListener.kt b/Server/src/main/content/global/handlers/item/MiningHelmetListener.kt deleted file mode 100644 index 755a1cbde..000000000 --- a/Server/src/main/content/global/handlers/item/MiningHelmetListener.kt +++ /dev/null @@ -1,17 +0,0 @@ -package content.global.handlers.item - -import core.api.* -import core.game.interaction.InteractionListener -import core.game.interaction.IntType -import org.rs09.consts.Items - -class MiningHelmetListener : InteractionListener { - override fun defineListeners() { - on(Items.MINING_HELMET_5013, IntType.ITEM, "drop") { player, _ -> - val removed = removeItem(player, Items.MINING_HELMET_5013) - if (removed) produceGroundItem(player, Items.MINING_HELMET_5014) - sendMessage(player, "The helmet goes out as you drop it.") - return@on true - } - } -} \ No newline at end of file diff --git a/Server/src/main/content/global/skill/cooking/NettleWaterListener.kt b/Server/src/main/content/global/skill/cooking/NettleWaterListener.kt deleted file mode 100644 index bf52e8067..000000000 --- a/Server/src/main/content/global/skill/cooking/NettleWaterListener.kt +++ /dev/null @@ -1,18 +0,0 @@ -package content.global.skill.cooking - -import org.rs09.consts.Items -import core.api.replaceSlot -import core.api.removeItem -import core.game.interaction.IntType -import core.game.interaction.InteractionListener -import core.game.node.item.Item - -class NettleWaterListener : InteractionListener { - override fun defineListeners() { - onUseWith(IntType.ITEM, Items.BOWL_OF_WATER_1921, Items.NETTLES_4241) { player, used, with -> - replaceSlot(player, used.asItem().slot, Item(Items.NETTLE_WATER_4237), used.asItem()) - removeItem(player, with.asItem()) - return@onUseWith true - } - } -} \ No newline at end of file diff --git a/Server/src/main/content/region/kandarin/quest/templeofikov/TempleOfIkovListeners.kt b/Server/src/main/content/region/kandarin/quest/templeofikov/TempleOfIkovListeners.kt index 135e3dc92..7f4c3d09c 100644 --- a/Server/src/main/content/region/kandarin/quest/templeofikov/TempleOfIkovListeners.kt +++ b/Server/src/main/content/region/kandarin/quest/templeofikov/TempleOfIkovListeners.kt @@ -137,20 +137,6 @@ class TempleOfIkovListeners : InteractionListener { teleport(player, Location.create(2649, 9804, 0)) } - // don't let light extinguish or cape take off - val lightSourceProducts = LightSource.values().map { it.product.id }.toIntArray() - - on(lightSourceProducts, ITEM, "drop") { player, light -> - val active = LightSource.getActiveLightSource(player).product.id - if (player.location.isInRegion(10648) && light.id == active) { - sendMessage(player, "Dropping the " + LightSource.getActiveLightSource(player).product.name.lowercase() + " would leave you without a light source.") - return@on false - } - val removed = removeItem(player, light.id) - if (removed) produceGroundItem(player, light.id) - return@on true - } - // B: Attach lever, authentic if you log out, the lever is lost, and you have to do that bridge again onUseWith(SCENERY, Items.LEVER_83, Scenery.LEVER_BRACKET_86) { player, used, with -> removeItem(player, used) diff --git a/Server/src/main/content/region/misthalin/varrock/dialogue/GertrudeDialogue.java b/Server/src/main/content/region/misthalin/varrock/dialogue/GertrudeDialogue.java index 9fcbd6bb2..e9a4ea493 100644 --- a/Server/src/main/content/region/misthalin/varrock/dialogue/GertrudeDialogue.java +++ b/Server/src/main/content/region/misthalin/varrock/dialogue/GertrudeDialogue.java @@ -420,7 +420,7 @@ public final class GertrudeDialogue extends DialoguePlugin { * @return the item. */ public Item getKitten() { - return new Item(RandomFunction.random(1555, 1560)); + return new Item(RandomFunction.random(1555, 1561)); } @Override diff --git a/Server/src/main/core/game/system/command/sets/SpawnCommandSet.kt b/Server/src/main/core/game/system/command/sets/SpawnCommandSet.kt index de41b11a8..468bdaf96 100644 --- a/Server/src/main/core/game/system/command/sets/SpawnCommandSet.kt +++ b/Server/src/main/core/game/system/command/sets/SpawnCommandSet.kt @@ -81,6 +81,33 @@ class SpawnCommandSet : CommandSet(Privilege.ADMIN){ player.inventory.add(item) } + + /** + * Spawns multiple items with the given ID + */ + define("items", usage = "::items start-id end-id [amount]", description = "Loops through item ids from 'start-id' to 'end-id' and spawns 'amount' of them in your inventory."){player,args -> + if (args.size < 3) { + reject(player,"You must specify start and end item ids.") + return@define + } + val start = args[1].toIntOrNull() ?: return@define + val end = args[2].toIntOrNull() ?: return@define + var amount = (args.getOrNull(3) ?: "1").toInt() + for (id in start..end) { + if (id > Cache.getItemDefinitionsSize()) { + reject(player,"Item ID '$id' out of range.") + return@define + } + val item = Item(id, amount) + val max = player.inventory.getMaximumAdd(item) + if (amount > max) { + amount = max + } + item.setAmount(amount) + player.inventory.add(item) + } + } + /** * Spawn object with given ID at the player's location */