From 111607d126f8dfee73218d23c9be419f4095ba98 Mon Sep 17 00:00:00 2001 From: Alex 'mcmonkey' Goodwin Date: Mon, 30 Nov 2020 18:07:43 -0800 Subject: [PATCH] patch up despawn command a bit --- .../denizenscript/denizen/objects/NPCTag.java | 10 +--------- .../scripts/commands/npc/DespawnCommand.java | 17 +++++------------ .../command/DenizenCommandHandler.java | 2 +- 3 files changed, 7 insertions(+), 22 deletions(-) diff --git a/plugin/src/main/java/com/denizenscript/denizen/objects/NPCTag.java b/plugin/src/main/java/com/denizenscript/denizen/objects/NPCTag.java index 795226835f..3b51e841ef 100644 --- a/plugin/src/main/java/com/denizenscript/denizen/objects/NPCTag.java +++ b/plugin/src/main/java/com/denizenscript/denizen/objects/NPCTag.java @@ -1473,16 +1473,8 @@ public void adjust(Mechanism mechanism) { getCitizen().getNavigator().getDefaultParameters().speedModifier(mechanism.getValue().asFloat()); } - // <--[mechanism] - // @object NPCTag - // @name despawn - // @input None - // @description - // Despawns the NPC. - // @tags - // - // --> if (mechanism.matches("despawn")) { + Deprecations.npcDespawnMech.warn(mechanism.context); getCitizen().despawn(DespawnReason.PLUGIN); } diff --git a/plugin/src/main/java/com/denizenscript/denizen/scripts/commands/npc/DespawnCommand.java b/plugin/src/main/java/com/denizenscript/denizen/scripts/commands/npc/DespawnCommand.java index 4ec36041d4..ee73f2604d 100644 --- a/plugin/src/main/java/com/denizenscript/denizen/scripts/commands/npc/DespawnCommand.java +++ b/plugin/src/main/java/com/denizenscript/denizen/scripts/commands/npc/DespawnCommand.java @@ -35,9 +35,8 @@ public DespawnCommand() { // @Group npc // // @Description - // This command will temporarily despawn either the linked NPC or - // a list of other NPCs. Despawning means they are no longer visible - // or interactable, but they still exist and can be respawned. + // This command will temporarily despawn either the linked NPC or a list of other NPCs. + // Despawning means they are no longer visible or interactable, but they still exist and can be respawned. // // @Tags // @@ -53,9 +52,7 @@ public DespawnCommand() { @Override public void parseArgs(ScriptEntry scriptEntry) throws InvalidArgumentsException { - for (Argument arg : scriptEntry.getProcessedArgs()) { - if (!scriptEntry.hasObject("npcs") && arg.matchesArgumentList(NPCTag.class)) { scriptEntry.addObject("npcs", arg.asType(ListTag.class).filter(NPCTag.class, scriptEntry)); @@ -64,7 +61,6 @@ public void parseArgs(ScriptEntry scriptEntry) throws InvalidArgumentsException arg.reportUnhandled(); } } - if (!scriptEntry.hasObject("npcs")) { if (Utilities.entryHasNPC(scriptEntry)) { scriptEntry.addObject("npcs", Arrays.asList(Utilities.getEntryNPC(scriptEntry))); @@ -73,24 +69,21 @@ public void parseArgs(ScriptEntry scriptEntry) throws InvalidArgumentsException throw new InvalidArgumentsException("Must specify a valid list of NPCs!"); } } - } @SuppressWarnings("unchecked") @Override public void execute(final ScriptEntry scriptEntry) { List npcs = (List) scriptEntry.getObject("npcs"); - if (scriptEntry.dbCallShouldDebug()) { Debug.report(scriptEntry, getName(), ArgumentHelper.debugObj("NPCs", npcs.toString())); } - for (NPCTag npc : npcs) { + if (npc.getCitizen().hasTrait(Spawned.class)) { + npc.getCitizen().getOrAddTrait(Spawned.class).setSpawned(false); + } if (npc.isSpawned()) { - if (npc.getCitizen().hasTrait(Spawned.class)) { - npc.getCitizen().getOrAddTrait(Spawned.class).setSpawned(false); - } npc.getCitizen().despawn(DespawnReason.PLUGIN); } } diff --git a/plugin/src/main/java/com/denizenscript/denizen/utilities/command/DenizenCommandHandler.java b/plugin/src/main/java/com/denizenscript/denizen/utilities/command/DenizenCommandHandler.java index 2add1708f0..c8a1267b7f 100644 --- a/plugin/src/main/java/com/denizenscript/denizen/utilities/command/DenizenCommandHandler.java +++ b/plugin/src/main/java/com/denizenscript/denizen/utilities/command/DenizenCommandHandler.java @@ -116,7 +116,7 @@ public void submit(CommandContext args, final CommandSender sender) throws Comma // '-s' enables/disables stacktraces generated by Denizen. We might ask you to enable this when problems arise. // '-b' enables/disables the ScriptBuilder debug. When enabled, Denizen will show info on script and argument creation. // Warning: Can be spammy. - // '-n' enables/disables debug trimming. When enabled, messages longer than 512 characters will be 'snipped'. + // '-n' enables/disables debug trimming. When enabled, messages longer than 1024 characters will be 'snipped'. // '-i' enables/disables source information. When enabled, debug will show where it came from (when possible). // '-p' enables/disables packet debug logging. When enabled, all packets sent to players (from anywhere) will be logged to console. // '-f' enables/disables showing of future warnings. When enabled, future warnings (such as upcoming deprecations) will be displayed in console logs.