From 2dc3ddfa2cadfa2ca2f55483a15ac913e2b29931 Mon Sep 17 00:00:00 2001 From: ceikry Date: Sat, 10 Jul 2021 14:00:55 -0500 Subject: [PATCH] Add kermit-friendly dig command --- .../game/system/command/sets/FunCommandSet.kt | 44 +++++++++++++++++++ .../system/command/sets/MiscCommandSet.kt | 23 ---------- 2 files changed, 44 insertions(+), 23 deletions(-) diff --git a/Server/src/main/kotlin/rs09/game/system/command/sets/FunCommandSet.kt b/Server/src/main/kotlin/rs09/game/system/command/sets/FunCommandSet.kt index 1878789e2..c6e6cf2bf 100644 --- a/Server/src/main/kotlin/rs09/game/system/command/sets/FunCommandSet.kt +++ b/Server/src/main/kotlin/rs09/game/system/command/sets/FunCommandSet.kt @@ -1,13 +1,20 @@ package rs09.game.system.command.sets +import api.ContentAPI import core.game.content.quest.tutorials.tutorialisland.CharacterDesign import core.game.node.entity.npc.NPC +import core.game.node.entity.player.Player import core.game.system.task.Pulse +import core.game.world.map.Location import core.game.world.map.RegionManager import core.game.world.update.flag.context.Animation import core.plugin.Initializable +import rs09.game.content.dialogue.DialogueFile +import rs09.game.interaction.InteractionListeners +import rs09.game.interaction.SpadeDigListener import rs09.game.system.command.Command import rs09.game.world.GameWorld +import rs09.tools.END_DIALOGUE import java.util.* @Initializable @@ -116,5 +123,42 @@ class FunCommandSet : CommandSet(Command.Privilege.ADMIN) { define("makeover", Command.Privilege.MODERATOR){ player, _ -> CharacterDesign.open(player) } + + /** + * Bury inventory at current location + */ + define("bury"){player, _ -> + if(player.inventory.isEmpty){ + reject(player, "You have no items to bury.") + } + + player.dialogueInterpreter.open(object : DialogueFile(){ + override fun handle(componentID: Int, buttonID: Int) { + when(stage){ + 0 -> dialogue("This will bury your whole inventory in this spot.","Are you sure?").also { stage++ } + 1 -> options("Yes","No").also { stage++ } + 2 -> when(buttonID){ + 1 -> bury(player).also { end() } + 2 -> stage = END_DIALOGUE + } + } + } + }) + + } + } + + fun bury(player: Player){ + val loc = Location.create(player.location) + val inv = player.inventory.toArray().filterNotNull() + SpadeDigListener.registerListener(player.location){p -> + for(item in inv){ + ContentAPI.addItemOrDrop(p, item.id, item.amount) + ContentAPI.sendMessage(p, "You dig and find ${if(item.amount > 1) "some" else "a"} ${item.name}") + } + SpadeDigListener.listeners.remove(loc) + } + player.inventory.clear() + notify(player, "You have buried your loot at ${loc.toString()}") } } diff --git a/Server/src/main/kotlin/rs09/game/system/command/sets/MiscCommandSet.kt b/Server/src/main/kotlin/rs09/game/system/command/sets/MiscCommandSet.kt index f9142922b..85be2c318 100644 --- a/Server/src/main/kotlin/rs09/game/system/command/sets/MiscCommandSet.kt +++ b/Server/src/main/kotlin/rs09/game/system/command/sets/MiscCommandSet.kt @@ -479,28 +479,5 @@ class MiscCommandSet : CommandSet(Command.Privilege.ADMIN){ notify(player,"No parent NPC found.") } } - - - define("bury"){player,args -> - if(args.size < 2){ - reject(player,"Usage: ::bury itemid") - } - - val itemId = args[1].toInt() - val def = ItemDefinition.forId(itemId) - - SpadeDigListener.registerListener(player.location){pl -> - if(player.getAttribute("${player.location.toString()}:$itemId",false)){ - pl.sendMessage("You dig and find nothing.") - return@registerListener - } - pl.dialogueInterpreter.sendDialogue("You dig and find a ${def.name}!") - player.inventory.add(Item(itemId)) - player.setExpirableAttribute("/save:${player.location.toString()}:$itemId",true,TimeUnit.SECONDS.toMillis(10)) - } - - notify(player,"You buried a ${def.name} at ${player.location}") - } - } } \ No newline at end of file