diff --git a/src/main/java/net/aufdemrand/denizen/objects/dEntity.java b/src/main/java/net/aufdemrand/denizen/objects/dEntity.java index 945e9df510..5b34e4d199 100644 --- a/src/main/java/net/aufdemrand/denizen/objects/dEntity.java +++ b/src/main/java/net/aufdemrand/denizen/objects/dEntity.java @@ -1184,7 +1184,7 @@ else if (attribute.startsWith("equipment")) { // @attribute // @returns dItem // @description - // returns the item the entity is holding, or null + // returns the item the entity is holding, or i@air // if none. // --> if (attribute.startsWith("item_in_hand") || diff --git a/src/main/java/net/aufdemrand/denizen/scripts/commands/core/_templateCommand.java b/src/main/java/net/aufdemrand/denizen/scripts/commands/core/_templateCommand.java index 18eb339a79..d1359b1653 100644 --- a/src/main/java/net/aufdemrand/denizen/scripts/commands/core/_templateCommand.java +++ b/src/main/java/net/aufdemrand/denizen/scripts/commands/core/_templateCommand.java @@ -64,7 +64,7 @@ public void execute(ScriptEntry scriptEntry) throws CommandExecutionException { // Debug the execution - // dB.report(getName(), required_integer.debug() + // dB.report(scriptEntry, getName(), required_integer.debug() // + required_location.debug()); diff --git a/src/main/java/net/aufdemrand/denizen/scripts/commands/npc/AssignmentCommand.java b/src/main/java/net/aufdemrand/denizen/scripts/commands/npc/AssignmentCommand.java index 6b1572f455..28c2f4f62e 100644 --- a/src/main/java/net/aufdemrand/denizen/scripts/commands/npc/AssignmentCommand.java +++ b/src/main/java/net/aufdemrand/denizen/scripts/commands/npc/AssignmentCommand.java @@ -8,7 +8,6 @@ import net.aufdemrand.denizen.scripts.commands.AbstractCommand; import net.aufdemrand.denizen.objects.aH; import net.aufdemrand.denizen.utilities.debugging.dB; -import net.aufdemrand.denizen.utilities.debugging.dB.Messages; /** * TODO: Document usage @@ -33,7 +32,7 @@ public void parseArgs(ScriptEntry scriptEntry) throws InvalidArgumentsException if (aH.matchesScript(arg)) { script = aH.getScriptFrom(arg); if (script != null && !script.getType().equalsIgnoreCase("assignment")) { - dB.echoError("Script type must be 'ASSIGNMENT'. Script specified is '%s'.", script.getType()); + dB.echoError("Script type must be 'ASSIGNMENT'. Script specified is '" + script.getType() + "'."); script = null; } } @@ -42,15 +41,16 @@ public void parseArgs(ScriptEntry scriptEntry) throws InvalidArgumentsException else if (aH.matchesArg("SET, REMOVE", arg)) action = Action.valueOf(arg.toUpperCase()); - else throw new InvalidArgumentsException(Messages.ERROR_UNKNOWN_ARGUMENT, arg); + else + dB.echoError("Unnknown argument '" + arg + "'"); } // If 'SET'ting with no 'script' throws an error. if (action == Action.SET && script == null) - throw new InvalidArgumentsException(Messages.ERROR_MISSING_OTHER, "SCRIPT"); + throw new InvalidArgumentsException("Missing 'script' argument!"); // If no NPC attached, throw an error if (scriptEntry.getNPC() == null) - throw new InvalidArgumentsException(Messages.ERROR_NO_NPCID); + throw new InvalidArgumentsException("This command requires a linked npc!"); // Add objects that need to be passed to execute() to the scriptEntry scriptEntry.addObject("script", script) @@ -64,7 +64,7 @@ public void execute(ScriptEntry scriptEntry) throws CommandExecutionException { dScript script = (dScript) scriptEntry.getObject("script"); // Report to dB - dB.report(getName(), + dB.report(scriptEntry, getName(), aH.debugObj("Action", action.toString()) + (script != null ? script.debug() : "") + aH.debugObj("NPC", scriptEntry.getNPC().toString())); diff --git a/src/main/java/net/aufdemrand/denizen/scripts/commands/npc/DisengageCommand.java b/src/main/java/net/aufdemrand/denizen/scripts/commands/npc/DisengageCommand.java index a1e30f1dae..515cd7d57f 100644 --- a/src/main/java/net/aufdemrand/denizen/scripts/commands/npc/DisengageCommand.java +++ b/src/main/java/net/aufdemrand/denizen/scripts/commands/npc/DisengageCommand.java @@ -5,9 +5,7 @@ import net.aufdemrand.denizen.scripts.ScriptEntry; import net.aufdemrand.denizen.scripts.commands.AbstractCommand; import net.aufdemrand.denizen.objects.aH; -import net.aufdemrand.denizen.scripts.commands.npc.EngageCommand; import net.aufdemrand.denizen.utilities.debugging.dB; -import net.aufdemrand.denizen.utilities.debugging.dB.Messages; /** * Unsets the Denizen from the Engage List. @@ -30,7 +28,7 @@ public void parseArgs(ScriptEntry scriptEntry) throws InvalidArgumentsException // Make sure NPC is available if (scriptEntry.getNPC() == null) - throw new InvalidArgumentsException(Messages.ERROR_NO_NPCID); + throw new InvalidArgumentsException("This command requires a linked NPC!"); } @@ -38,7 +36,7 @@ public void parseArgs(ScriptEntry scriptEntry) throws InvalidArgumentsException public void execute(ScriptEntry scriptEntry) throws CommandExecutionException { // Report to dB - dB.report(getName(), + dB.report(scriptEntry, getName(), aH.debugObj("NPC", scriptEntry.getNPC().toString())); // Set Disengaged diff --git a/src/main/java/net/aufdemrand/denizen/scripts/commands/npc/FishCommand.java b/src/main/java/net/aufdemrand/denizen/scripts/commands/npc/FishCommand.java index 6034fa9e48..f3fd57229e 100644 --- a/src/main/java/net/aufdemrand/denizen/scripts/commands/npc/FishCommand.java +++ b/src/main/java/net/aufdemrand/denizen/scripts/commands/npc/FishCommand.java @@ -8,7 +8,6 @@ import net.aufdemrand.denizen.objects.aH; import net.aufdemrand.denizen.objects.aH.ArgumentType; import net.aufdemrand.denizen.utilities.debugging.dB; -import net.aufdemrand.denizen.utilities.debugging.dB.Messages; import net.citizensnpcs.api.npc.NPC; import org.bukkit.Location; @@ -26,17 +25,17 @@ public void parseArgs(ScriptEntry scriptEntry) for (String arg : scriptEntry.getArguments()) { if (aH.matchesLocation(arg)) { location = aH.getLocationFrom(arg); - dB.echoDebug("...location set"); + dB.echoDebug(scriptEntry, "...location set"); } else if (aH.matchesArg("CATCHFISH", arg)) { catchFish = true; - dB.echoDebug("...npc will catch fish"); + dB.echoDebug(scriptEntry, "...npc will catch fish"); } else if (aH.matchesArg("STOP", arg)) { stopping = true; - dB.echoDebug("...stopping"); + dB.echoDebug(scriptEntry, "...stopping"); } else if (aH.matchesValueArg("CATCHPERCENT, PERCENT", arg, ArgumentType.Integer)) { catchPercent = aH.getIntegerFrom(arg); - dB.echoDebug("...set catch percent: " + catchPercent); - } else throw new InvalidArgumentsException(Messages.ERROR_UNKNOWN_ARGUMENT, arg); + dB.echoDebug(scriptEntry, "...set catch percent: " + catchPercent); + } else throw new InvalidArgumentsException("Unknown argument '" + arg + "'"); } scriptEntry.addObject("location", location) @@ -46,8 +45,7 @@ public void parseArgs(ScriptEntry scriptEntry) } @Override - public void execute(ScriptEntry scriptEntry) - throws CommandExecutionException { + public void execute(ScriptEntry scriptEntry) throws CommandExecutionException { Boolean stopping = (Boolean) scriptEntry.getObject("stopping"); Boolean catchFish = (Boolean) scriptEntry.getObject("catchFish"); int catchPercent = (Integer) scriptEntry.getObject("catchPercent"); diff --git a/src/main/java/net/aufdemrand/denizen/scripts/commands/npc/FollowCommand.java b/src/main/java/net/aufdemrand/denizen/scripts/commands/npc/FollowCommand.java index 9e01187947..f47da635ce 100644 --- a/src/main/java/net/aufdemrand/denizen/scripts/commands/npc/FollowCommand.java +++ b/src/main/java/net/aufdemrand/denizen/scripts/commands/npc/FollowCommand.java @@ -34,13 +34,14 @@ else if (!scriptEntry.hasObject("target") && arg.matchesArgumentType(dEntity.class)) scriptEntry.addObject("target", arg.asType(dEntity.class)); - else throw new InvalidArgumentsException(dB.Messages.ERROR_UNKNOWN_ARGUMENT, arg.raw_value); + else + arg.reportUnhandled(); } if (!scriptEntry.hasObject("target")) { if (scriptEntry.hasPlayer()) scriptEntry.addObject("target", scriptEntry.getPlayer().getDenizenEntity()); else - throw new InvalidArgumentsException(dB.Messages.ERROR_NO_PLAYER); + throw new InvalidArgumentsException("This command requires a linked player!"); } } @@ -52,7 +53,7 @@ public void execute(ScriptEntry scriptEntry) throws CommandExecutionException { dEntity target = (dEntity) scriptEntry.getObject("target"); // Report to dB - dB.report(getName(), + dB.report(scriptEntry, getName(), (scriptEntry.getPlayer() != null ? scriptEntry.getPlayer().debug() : "") + (stop == null ? aH.debugObj("Action", "FOLLOW") : aH.debugObj("Action", "STOP")) diff --git a/src/main/java/net/aufdemrand/denizen/scripts/commands/npc/LookcloseCommand.java b/src/main/java/net/aufdemrand/denizen/scripts/commands/npc/LookcloseCommand.java index 489ba0ff3b..8f1d3abb9a 100644 --- a/src/main/java/net/aufdemrand/denizen/scripts/commands/npc/LookcloseCommand.java +++ b/src/main/java/net/aufdemrand/denizen/scripts/commands/npc/LookcloseCommand.java @@ -7,7 +7,6 @@ import net.aufdemrand.denizen.objects.aH; import net.aufdemrand.denizen.objects.aH.ArgumentType; import net.aufdemrand.denizen.utilities.debugging.dB; -import net.aufdemrand.denizen.utilities.debugging.dB.Messages; import net.citizensnpcs.api.npc.NPC; import net.citizensnpcs.trait.LookClose; @@ -46,21 +45,21 @@ public void parseArgs(ScriptEntry scriptEntry) throws InvalidArgumentsException if (aH.matchesArg("REALISTIC", arg)) { realistic = true; - dB.echoDebug(Messages.DEBUG_SET_TYPE, arg); - } else if (aH.matchesValueArg("RANGE", arg, ArgumentType.Double)) { + } + else if (aH.matchesValueArg("RANGE", arg, ArgumentType.Double)) { range = aH.getDoubleFrom(arg); - dB.echoDebug(Messages.DEBUG_SET_RANGE, String.valueOf(range)); - } else if (aH.matchesState(arg)) { + } + else if (aH.matchesState(arg)) { toggle = aH.getBooleanFrom(arg); - dB.echoDebug(Messages.DEBUG_TOGGLE, String.valueOf(toggle)); - } else throw new InvalidArgumentsException(Messages.ERROR_UNKNOWN_ARGUMENT, arg); + } + else dB.echoError("Unknown argument '" + arg + "'"); } if (scriptEntry.getNPC() == null) - throw new InvalidArgumentsException(Messages.ERROR_NO_NPCID); + throw new InvalidArgumentsException("This command requires a linked NPC!"); scriptEntry.addObject("realistic", realistic) diff --git a/src/main/java/net/aufdemrand/denizen/scripts/commands/npc/PauseCommand.java b/src/main/java/net/aufdemrand/denizen/scripts/commands/npc/PauseCommand.java index 9c5bb56290..f7d1a57536 100644 --- a/src/main/java/net/aufdemrand/denizen/scripts/commands/npc/PauseCommand.java +++ b/src/main/java/net/aufdemrand/denizen/scripts/commands/npc/PauseCommand.java @@ -7,7 +7,6 @@ import net.aufdemrand.denizen.scripts.commands.AbstractCommand; import net.aufdemrand.denizen.objects.aH; import net.aufdemrand.denizen.utilities.debugging.dB; -import net.aufdemrand.denizen.utilities.debugging.dB.Messages; import net.citizensnpcs.trait.waypoint.Waypoints; import org.bukkit.entity.Player; @@ -53,15 +52,16 @@ public void parseArgs(ScriptEntry scriptEntry) throws InvalidArgumentsException if (aH.matchesDuration(arg)) { duration = aH.getIntegerFrom(arg); - dB.echoDebug(Messages.DEBUG_SET_DURATION, arg); - } else if (aH.matchesArg("WAYPOINTS", arg) || aH.matchesArg("NAVIGATION", arg) + } + else if (aH.matchesArg("WAYPOINTS", arg) || aH.matchesArg("NAVIGATION", arg) || aH.matchesArg("ACTIVITY", arg) || aH.matchesArg("WAYPOINTS", arg)) { // Could also maybe do for( ... : PauseType.values()) ... not sure which is faster. pauseType = PauseType.valueOf(arg.toUpperCase()); - dB.echoDebug(Messages.DEBUG_SET_TYPE, arg); - } else throw new InvalidArgumentsException(Messages.ERROR_UNKNOWN_ARGUMENT, arg); + } + else + dB.echoError("Unknown argument '" + arg + "'"); } } @@ -74,14 +74,16 @@ public void execute(ScriptEntry scriptEntry) throws CommandExecutionException { if (duration > 0) { if (durations.containsKey(dNPC.getCitizen().getId() + pauseType.name())) { try { denizen.getServer().getScheduler().cancelTask(durations.get(dNPC.getCitizen().getId() + pauseType.name())); } - catch (Exception e) { dB.echoError(Messages.ERROR_CANCELLING_DELAYED_TASK); } + catch (Exception e) { dB.echoError("There was an error pausing that!"); e.printStackTrace(); } - } dB.echoDebug(Messages.DEBUG_SETTING_DELAYED_TASK, "UNPAUSE " + pauseType); + } + dB.echoDebug(scriptEntry, "Running delayed task: Unpause " + pauseType.toString()); + final ScriptEntry se = scriptEntry; durations.put(dNPC.getId() + pauseType.name(), denizen.getServer().getScheduler().scheduleSyncDelayedTask(denizen, new Runnable() { @Override public void run() { - dB.echoDebug(Messages.DEBUG_RUNNING_DELAYED_TASK, "UNPAUSING " + pauseType); + dB.echoDebug(se, "Running delayed task: Pausing " + pauseType.toString()); pause(dNPC, pauseType, false); } diff --git a/src/main/java/net/aufdemrand/denizen/scripts/commands/npc/PoseCommand.java b/src/main/java/net/aufdemrand/denizen/scripts/commands/npc/PoseCommand.java index f2d5af8637..6956e2e865 100644 --- a/src/main/java/net/aufdemrand/denizen/scripts/commands/npc/PoseCommand.java +++ b/src/main/java/net/aufdemrand/denizen/scripts/commands/npc/PoseCommand.java @@ -10,7 +10,6 @@ import net.aufdemrand.denizen.scripts.commands.AbstractCommand; import net.aufdemrand.denizen.objects.aH; import net.aufdemrand.denizen.utilities.debugging.dB; -import net.aufdemrand.denizen.utilities.debugging.dB.Messages; import net.citizensnpcs.trait.Poses; /** @@ -44,15 +43,18 @@ public void parseArgs(ScriptEntry scriptEntry) throws InvalidArgumentsException } else if (aH.matchesArg("PLAYER", arg)) { targetType = TargetType.PLAYER; - dB.echoDebug("Setting pose on PLAYER!"); + dB.echoDebug(scriptEntry, "Setting pose on PLAYER!"); - } else throw new InvalidArgumentsException(dB.Messages.ERROR_UNKNOWN_ARGUMENT); + } else + dB.echoError("Unknown argument '" + arg + "'"); } // If TARGET is NPC/PLAYER and no NPC/PLAYER available, throw exception. - if (targetType == TargetType.PLAYER && scriptEntry.getPlayer() == null) throw new InvalidArgumentsException(Messages.ERROR_NO_PLAYER); - else if (targetType == TargetType.NPC && scriptEntry.getNPC() == null) throw new InvalidArgumentsException(Messages.ERROR_NO_NPCID); + if (targetType == TargetType.PLAYER && scriptEntry.getPlayer() == null) + throw new InvalidArgumentsException("This command requires a linked player!"); + else if (targetType == TargetType.NPC && scriptEntry.getNPC() == null) + throw new InvalidArgumentsException("This command requires a linked NPC!"); scriptEntry.addObject("target", targetType) .addObject("action", action).addObject("id", id); } @@ -68,7 +70,7 @@ public void execute(ScriptEntry scriptEntry) throws CommandExecutionException { String id = (String) scriptEntry.getObject("id"); // Report to dB - dB.report(getName(), + dB.report(scriptEntry, getName(), aH.debugObj(target.toString(), npc.toString()) + aH.debugObj("Action", action.toString()) + aH.debugObj("Id", id)); diff --git a/src/main/java/net/aufdemrand/denizen/scripts/commands/npc/RenameCommand.java b/src/main/java/net/aufdemrand/denizen/scripts/commands/npc/RenameCommand.java index df89e31a5a..b85281bdf8 100644 --- a/src/main/java/net/aufdemrand/denizen/scripts/commands/npc/RenameCommand.java +++ b/src/main/java/net/aufdemrand/denizen/scripts/commands/npc/RenameCommand.java @@ -41,7 +41,7 @@ public void execute(final ScriptEntry scriptEntry) throws CommandExecutionExcept Element name = (Element) scriptEntry.getObject("name"); - dB.report(getName(), name.debug()); + dB.report(scriptEntry, getName(), name.debug()); NPC npc = scriptEntry.getNPC().getCitizen(); diff --git a/src/main/java/net/aufdemrand/denizen/scripts/commands/npc/SitCommand.java b/src/main/java/net/aufdemrand/denizen/scripts/commands/npc/SitCommand.java index d6c7115df4..328836dec3 100644 --- a/src/main/java/net/aufdemrand/denizen/scripts/commands/npc/SitCommand.java +++ b/src/main/java/net/aufdemrand/denizen/scripts/commands/npc/SitCommand.java @@ -10,7 +10,6 @@ import net.aufdemrand.denizen.scripts.commands.AbstractCommand; import net.aufdemrand.denizen.objects.aH; import net.aufdemrand.denizen.utilities.debugging.dB; -import net.aufdemrand.denizen.utilities.debugging.dB.Messages; import net.citizensnpcs.api.npc.NPC; import org.bukkit.entity.Ocelot; import org.bukkit.entity.Wolf; @@ -26,7 +25,8 @@ public void parseArgs(ScriptEntry scriptEntry) throws InvalidArgumentsException && !scriptEntry.hasObject("location")) { scriptEntry.addObject("location", arg.asType(dLocation.class)); } - else throw new InvalidArgumentsException(Messages.ERROR_UNKNOWN_ARGUMENT, arg.raw_value); + else + arg.reportUnhandled(); } } @@ -53,7 +53,7 @@ else if (scriptEntry.getNPC().getEntityType() == EntityType.WOLF) { SittingTrait trait = scriptEntry.getNPC().getCitizen().getTrait(SittingTrait.class); if (!scriptEntry.getNPC().getCitizen().hasTrait(SittingTrait.class)) { scriptEntry.getNPC().getCitizen().addTrait(SittingTrait.class); - dB.echoDebug("...added sitting trait"); + dB.echoDebug(scriptEntry, "...added sitting trait"); } if (trait.isSitting()) { diff --git a/src/main/java/net/aufdemrand/denizen/scripts/commands/npc/StandCommand.java b/src/main/java/net/aufdemrand/denizen/scripts/commands/npc/StandCommand.java index a619fa4f9c..7660e08542 100644 --- a/src/main/java/net/aufdemrand/denizen/scripts/commands/npc/StandCommand.java +++ b/src/main/java/net/aufdemrand/denizen/scripts/commands/npc/StandCommand.java @@ -3,10 +3,10 @@ import net.aufdemrand.denizen.exceptions.CommandExecutionException; import net.aufdemrand.denizen.exceptions.InvalidArgumentsException; import net.aufdemrand.denizen.npc.traits.SittingTrait; +import net.aufdemrand.denizen.objects.aH; import net.aufdemrand.denizen.scripts.ScriptEntry; import net.aufdemrand.denizen.scripts.commands.AbstractCommand; import net.aufdemrand.denizen.utilities.debugging.dB; -import net.aufdemrand.denizen.utilities.debugging.dB.Messages; import net.citizensnpcs.api.npc.NPC; public class StandCommand extends AbstractCommand{ @@ -15,21 +15,21 @@ public class StandCommand extends AbstractCommand{ public void parseArgs(ScriptEntry scriptEntry) throws InvalidArgumentsException { //stand should have no additional arguments - for (String arg: scriptEntry.getArguments()) - throw new InvalidArgumentsException(Messages.ERROR_UNKNOWN_ARGUMENT, arg); + for (aH.Argument arg : aH.interpret(scriptEntry.getArguments())) { + arg.reportUnhandled(); + } } @Override - public void execute(ScriptEntry scriptEntry) - throws CommandExecutionException { + public void execute(ScriptEntry scriptEntry) throws CommandExecutionException { NPC npc = scriptEntry.getNPC().getCitizen(); SittingTrait trait = npc.getTrait(SittingTrait.class); if (!npc.hasTrait(SittingTrait.class)){ npc.addTrait(SittingTrait.class); - dB.echoDebug("...added sitting trait"); + dB.echoDebug(scriptEntry, "...added sitting trait"); } if (!trait.isSitting()) { diff --git a/src/main/java/net/aufdemrand/denizen/scripts/commands/npc/TraitCommand.java b/src/main/java/net/aufdemrand/denizen/scripts/commands/npc/TraitCommand.java index d1f41b9009..d761f9d5c9 100644 --- a/src/main/java/net/aufdemrand/denizen/scripts/commands/npc/TraitCommand.java +++ b/src/main/java/net/aufdemrand/denizen/scripts/commands/npc/TraitCommand.java @@ -7,7 +7,6 @@ import net.aufdemrand.denizen.scripts.ScriptEntry; import net.aufdemrand.denizen.scripts.commands.AbstractCommand; import net.aufdemrand.denizen.utilities.debugging.dB; -import net.aufdemrand.denizen.utilities.debugging.dB.Messages; import net.citizensnpcs.api.CitizensAPI; import net.citizensnpcs.api.npc.NPC; import net.citizensnpcs.api.trait.Trait; @@ -32,10 +31,10 @@ else if (!scriptEntry.hasObject("trait")) } if (!scriptEntry.hasObject("trait")) - throw new InvalidArgumentsException(Messages.ERROR_MISSING_OTHER, "TRAIT"); + throw new InvalidArgumentsException("Missing trait argument!"); if (!scriptEntry.hasNPC()) - throw new InvalidArgumentsException(Messages.ERROR_NO_NPCID); + throw new InvalidArgumentsException("This command requires a linked NPC!"); scriptEntry.defaultObject("state", new Element("TOGGLE")); @@ -48,7 +47,7 @@ public void execute(ScriptEntry scriptEntry) throws CommandExecutionException { Element traitName = scriptEntry.getElement("trait"); NPC npc = scriptEntry.getNPC().getCitizen(); - dB.report(getName(), + dB.report(scriptEntry, getName(), traitName.debug() + toggle.debug() + scriptEntry.getNPC().debug()); diff --git a/src/main/java/net/aufdemrand/denizen/scripts/commands/npc/TriggerCommand.java b/src/main/java/net/aufdemrand/denizen/scripts/commands/npc/TriggerCommand.java index 1d02a6dae9..6fb58b8c41 100644 --- a/src/main/java/net/aufdemrand/denizen/scripts/commands/npc/TriggerCommand.java +++ b/src/main/java/net/aufdemrand/denizen/scripts/commands/npc/TriggerCommand.java @@ -9,7 +9,6 @@ import net.aufdemrand.denizen.objects.aH; import net.aufdemrand.denizen.objects.aH.ArgumentType; import net.aufdemrand.denizen.utilities.debugging.dB; -import net.aufdemrand.denizen.utilities.debugging.dB.Messages; import net.citizensnpcs.api.npc.NPC; /** @@ -51,11 +50,12 @@ else if (aH.matchesValueArg("NAME", arg, ArgumentType.String)) else if (denizen.getTriggerRegistry().get(arg) != null) trigger = aH.getStringFrom(arg); - else throw new InvalidArgumentsException(Messages.ERROR_UNKNOWN_ARGUMENT, arg); + else + dB.echoError("Unknown argument '" + arg + "'"); } // Check required arguments - if (trigger == null) throw new InvalidArgumentsException(Messages.ERROR_MISSING_OTHER, "NAME"); + if (trigger == null) throw new InvalidArgumentsException("Missing name argument!"); // Store objects in ScriptEntry for execute() scriptEntry.addObject("trigger", trigger); diff --git a/src/main/java/net/aufdemrand/denizen/scripts/commands/npc/VulnerableCommand.java b/src/main/java/net/aufdemrand/denizen/scripts/commands/npc/VulnerableCommand.java index 6fa304570a..cc9976d50a 100644 --- a/src/main/java/net/aufdemrand/denizen/scripts/commands/npc/VulnerableCommand.java +++ b/src/main/java/net/aufdemrand/denizen/scripts/commands/npc/VulnerableCommand.java @@ -6,7 +6,6 @@ import net.aufdemrand.denizen.scripts.commands.AbstractCommand; import net.aufdemrand.denizen.objects.aH; import net.aufdemrand.denizen.utilities.debugging.dB; -import net.aufdemrand.denizen.utilities.debugging.dB.Messages; import net.citizensnpcs.api.npc.NPC; /** @@ -30,7 +29,7 @@ public void parseArgs(ScriptEntry scriptEntry) throws InvalidArgumentsException vulnerable = Toggle.valueOf(aH.getStringFrom(arg).toUpperCase()); if (scriptEntry.getNPC() == null) - throw new InvalidArgumentsException(Messages.ERROR_NO_NPCID); + throw new InvalidArgumentsException("This command requires a linked NPC!"); // Add objects that need to be passed to execute() to the scriptEntry scriptEntry.addObject("vulnerable", vulnerable); @@ -42,7 +41,7 @@ public void execute(ScriptEntry scriptEntry) throws CommandExecutionException { Toggle toggle = (Toggle) scriptEntry.getObject("vulnerable"); // Report to dB - dB.report(getName(), + dB.report(scriptEntry, getName(), aH.debugObj("NPC", scriptEntry.getNPC().toString()) + aH.debugObj("Toggle", toggle.toString())); diff --git a/src/main/java/net/aufdemrand/denizen/scripts/commands/npc/WalkCommand.java b/src/main/java/net/aufdemrand/denizen/scripts/commands/npc/WalkCommand.java index 295842921d..8439067e47 100644 --- a/src/main/java/net/aufdemrand/denizen/scripts/commands/npc/WalkCommand.java +++ b/src/main/java/net/aufdemrand/denizen/scripts/commands/npc/WalkCommand.java @@ -40,7 +40,8 @@ else if (!scriptEntry.hasObject("auto_range") && arg.matches("auto_range")) scriptEntry.addObject("auto_range", Element.TRUE); - else dB.echoError(dB.Messages.ERROR_UNKNOWN_ARGUMENT, arg.raw_value); + else + arg.reportUnhandled(); } @@ -68,7 +69,7 @@ public void execute(ScriptEntry scriptEntry) throws CommandExecutionException { // Debug the execution - dB.report(getName(), loc.debug() + dB.report(scriptEntry, getName(), loc.debug() + (speed != null ? speed.debug() : "") + (auto_range != null ? auto_range.debug() : "")); diff --git a/src/main/java/net/aufdemrand/denizen/scripts/commands/player/ChatCommand.java b/src/main/java/net/aufdemrand/denizen/scripts/commands/player/ChatCommand.java index af3eeac9f9..f886fc06af 100644 --- a/src/main/java/net/aufdemrand/denizen/scripts/commands/player/ChatCommand.java +++ b/src/main/java/net/aufdemrand/denizen/scripts/commands/player/ChatCommand.java @@ -104,7 +104,7 @@ public void execute(ScriptEntry scriptEntry) throws CommandExecutionException { dObject targets = scriptEntry.getdObject("targets"); Element message = scriptEntry.getElement("message"); - dB.report(getName(), talkers.debug() + targets.debug() + message.debug()); + dB.report(scriptEntry, getName(), talkers.debug() + targets.debug() + message.debug()); // Create new speech context SpeechContext context = new SpeechContext(message.asString()); diff --git a/src/main/java/net/aufdemrand/denizen/scripts/commands/player/CompassCommand.java b/src/main/java/net/aufdemrand/denizen/scripts/commands/player/CompassCommand.java index 8cc5651e80..1b52d80aa7 100644 --- a/src/main/java/net/aufdemrand/denizen/scripts/commands/player/CompassCommand.java +++ b/src/main/java/net/aufdemrand/denizen/scripts/commands/player/CompassCommand.java @@ -23,12 +23,13 @@ public void parseArgs(ScriptEntry scriptEntry) throws InvalidArgumentsException && arg.matchesArgumentType(dLocation.class)) scriptEntry.addObject("location", arg.asType(dLocation.class)); - else dB.echoError(dB.Messages.ERROR_UNKNOWN_ARGUMENT, arg.raw_value); + else + arg.reportUnhandled(); } // Check for required information if (!scriptEntry.hasObject("location")) - throw new InvalidArgumentsException(dB.Messages.ERROR_MISSING_OTHER, "LOCATION"); + throw new InvalidArgumentsException("Missing location argument!"); } @@ -43,7 +44,7 @@ public void execute(ScriptEntry scriptEntry) throws CommandExecutionException { // Debug the execution - dB.report(getName(), location.debug()); + dB.report(scriptEntry, getName(), location.debug()); player.setCompassTarget(location); diff --git a/src/main/java/net/aufdemrand/denizen/scripts/commands/player/ExperienceCommand.java b/src/main/java/net/aufdemrand/denizen/scripts/commands/player/ExperienceCommand.java index cf87911eaf..5814fe192f 100644 --- a/src/main/java/net/aufdemrand/denizen/scripts/commands/player/ExperienceCommand.java +++ b/src/main/java/net/aufdemrand/denizen/scripts/commands/player/ExperienceCommand.java @@ -8,7 +8,6 @@ import net.aufdemrand.denizen.scripts.commands.AbstractCommand; import net.aufdemrand.denizen.objects.aH; import net.aufdemrand.denizen.utilities.debugging.dB; -import net.aufdemrand.denizen.utilities.debugging.dB.Messages; public class ExperienceCommand extends AbstractCommand { @@ -46,7 +45,7 @@ else if (aH.matchesArg("SET, GIVE, TAKE", arg)) else if(aH.matchesArg("LEVEL", arg)) level = true; - else throw new InvalidArgumentsException(Messages.ERROR_UNKNOWN_ARGUMENT, arg); + else throw new InvalidArgumentsException("Unknown argument '" + arg + "'"); } scriptEntry.addObject("quantity", amount) @@ -63,7 +62,7 @@ public void execute(ScriptEntry scriptEntry) throws CommandExecutionException { Integer quantity = (Integer) scriptEntry.getObject("quantity"); Boolean level = (Boolean) scriptEntry.getObject("level"); - dB.report(name, aH.debugObj("Type", type.toString()) + dB.report(scriptEntry, name, aH.debugObj("Type", type.toString()) + aH.debugObj("Quantity", level ? quantity.toString() + " levels" : quantity.toString()) + aH.debugObj("Player", scriptEntry.getPlayer().getName())); diff --git a/src/main/java/net/aufdemrand/denizen/scripts/commands/player/GroupCommand.java b/src/main/java/net/aufdemrand/denizen/scripts/commands/player/GroupCommand.java index b6113c3b3f..bffcb9b13b 100644 --- a/src/main/java/net/aufdemrand/denizen/scripts/commands/player/GroupCommand.java +++ b/src/main/java/net/aufdemrand/denizen/scripts/commands/player/GroupCommand.java @@ -45,7 +45,7 @@ public void execute(ScriptEntry scriptEntry) throws CommandExecutionException { Player player = scriptEntry.getPlayer().getPlayerEntity(); // Report to dB - dB.report(getName(), + dB.report(scriptEntry, getName(), aH.debugObj("Action", action.toString()) + aH.debugObj("Player", player.getName()) + aH.debugObj("Group", group) @@ -54,20 +54,20 @@ public void execute(ScriptEntry scriptEntry) throws CommandExecutionException { switch (action) { case ADD: if(Depends.permissions.playerInGroup(world, player.getName(), group)) { - dB.echoDebug("Player " + player.getName() + " is already in group " + group); + dB.echoDebug(scriptEntry, "Player " + player.getName() + " is already in group " + group); } else { Depends.permissions.playerAddGroup(world, player.getName(), group); - dB.echoDebug("Added " + player.getName() + " to group " + group); + dB.echoDebug(scriptEntry, "Added " + player.getName() + " to group " + group); } return; case REMOVE: if(!Depends.permissions.playerInGroup(world, player.getName(), group)) { - dB.echoDebug("Player " + player.getName() + " is not in group " + group); + dB.echoDebug(scriptEntry, "Player " + player.getName() + " is not in group " + group); } else { Depends.permissions.playerRemoveGroup(world, player.getName(), group); - dB.echoDebug("Removed " + player.getName() + " from group " + group); + dB.echoDebug(scriptEntry, "Removed " + player.getName() + " from group " + group); } } } diff --git a/src/main/java/net/aufdemrand/denizen/scripts/commands/player/ListenCommand.java b/src/main/java/net/aufdemrand/denizen/scripts/commands/player/ListenCommand.java index 2d466dc397..02382ea263 100644 --- a/src/main/java/net/aufdemrand/denizen/scripts/commands/player/ListenCommand.java +++ b/src/main/java/net/aufdemrand/denizen/scripts/commands/player/ListenCommand.java @@ -80,7 +80,7 @@ public void execute(ScriptEntry scriptEntry) throws CommandExecutionException { Element id = scriptEntry.getElement("id"); dScript finish_script = (dScript) scriptEntry.getObject("finish_script"); - dB.report(getName(), action.debug() + (type != null ? type.debug() : "") + dB.report(scriptEntry, getName(), action.debug() + (type != null ? type.debug() : "") + id.debug() + (finish_script != null ? finish_script.debug() : "")); List arguments = (ArrayList) scriptEntry.getObject("args"); @@ -108,7 +108,7 @@ public void execute(ScriptEntry scriptEntry) throws CommandExecutionException { scriptEntry.getNPC()); } catch (Exception e) { - dB.echoDebug("Cancelled creation of NEW listener!"); + dB.echoDebug(scriptEntry, "Cancelled creation of NEW listener!"); // Why? Maybe a wrong listener type... if (denizen.getListenerRegistry().get(type.asString()) == null) diff --git a/src/main/java/net/aufdemrand/denizen/scripts/commands/player/NarrateCommand.java b/src/main/java/net/aufdemrand/denizen/scripts/commands/player/NarrateCommand.java index b2b823c088..21863bd29d 100644 --- a/src/main/java/net/aufdemrand/denizen/scripts/commands/player/NarrateCommand.java +++ b/src/main/java/net/aufdemrand/denizen/scripts/commands/player/NarrateCommand.java @@ -12,7 +12,6 @@ import net.aufdemrand.denizen.scripts.commands.AbstractCommand; import net.aufdemrand.denizen.scripts.containers.core.FormatScriptContainer; import net.aufdemrand.denizen.utilities.debugging.dB; -import net.aufdemrand.denizen.utilities.debugging.dB.Messages; /** * Sends a message to Players. @@ -31,7 +30,7 @@ public void parseArgs(ScriptEntry scriptEntry) throws InvalidArgumentsException if (scriptEntry.getArguments().size() > 4) - throw new InvalidArgumentsException(Messages.ERROR_LOTS_OF_ARGUMENTS); + throw new InvalidArgumentsException("Too many arguments! Did you forget a 'quote'?"); // Iterate through arguments for (aH.Argument arg : aH.interpret(scriptEntry.getArguments())) { @@ -62,7 +61,7 @@ else if ((arg.matchesPrefix("target") || arg.matchesPrefix(TARGET_ARG))) { (scriptEntry.hasPlayer() ? Arrays.asList(scriptEntry.getPlayer()) : null)); if (!scriptEntry.hasObject("text")) - throw new InvalidArgumentsException(Messages.ERROR_NO_TEXT); + throw new InvalidArgumentsException("Missing any text!"); } @@ -75,7 +74,7 @@ public void execute(ScriptEntry scriptEntry) throws CommandExecutionException { FormatScriptContainer format = (FormatScriptContainer) scriptEntry.getObject("format"); // Report to dB - dB.report(getName(), + dB.report(scriptEntry, getName(), aH.debugObj("Narrating", text) + aH.debugObj("Targets", targets) + (format != null ? aH.debugObj("Format", format.getName()) : "")); diff --git a/src/main/java/net/aufdemrand/denizen/scripts/commands/player/OxygenCommand.java b/src/main/java/net/aufdemrand/denizen/scripts/commands/player/OxygenCommand.java index 3d1e30e291..8405309a39 100644 --- a/src/main/java/net/aufdemrand/denizen/scripts/commands/player/OxygenCommand.java +++ b/src/main/java/net/aufdemrand/denizen/scripts/commands/player/OxygenCommand.java @@ -21,7 +21,6 @@ public void parseArgs(ScriptEntry scriptEntry) throws InvalidArgumentsException throw new InvalidArgumentsException("Must specify amount/quantity."); } - Player player = scriptEntry.getPlayer().getPlayerEntity(); Mode mode = Mode.SET; Type type = Type.REMAINING; int amount = 0; @@ -30,30 +29,26 @@ public void parseArgs(ScriptEntry scriptEntry) throws InvalidArgumentsException if(aH.matchesValueArg("type", arg, aH.ArgumentType.String)) { try { type = Type.valueOf(aH.getStringFrom(arg)); - dB.echoDebug("Set type to " + type.name()); + dB.echoDebug(scriptEntry, "Set type to " + type.name()); } catch(Exception e) { dB.echoError("Invalid type: " + e.getMessage()); } - } else if(aH.matchesValueArg("mode", arg, aH.ArgumentType.String)) { + } + else if(aH.matchesValueArg("mode", arg, aH.ArgumentType.String)) { try { mode = Mode.valueOf(aH.getStringFrom(arg)); - dB.echoDebug("Set mode to " + mode.name()); + dB.echoDebug(scriptEntry, "Set mode to " + mode.name()); } catch(Exception e) { dB.echoError("Invalid mode: " + e.getMessage()); } - } else if(aH.matchesValueArg("player", arg, aH.ArgumentType.String)) { - player = Bukkit.getPlayer(aH.getStringFrom(arg)); - if(player == null) throw new InvalidArgumentsException(dB.Messages.ERROR_NO_PLAYER); - - dB.echoDebug("Set player target to " + player.getName()); - } else if(aH.matchesQuantity(arg) || aH.matchesQuantity("amt")) { + } + else if(aH.matchesQuantity(arg) || aH.matchesQuantity("amt")) { amount = aH.getIntegerFrom(arg); - dB.echoDebug("Amount set to " + amount); + dB.echoDebug(scriptEntry, "Amount set to " + amount); } } - scriptEntry.addObject("player", player); scriptEntry.addObject("mode", mode); scriptEntry.addObject("type", type); scriptEntry.addObject("amount", amount); @@ -61,13 +56,13 @@ public void parseArgs(ScriptEntry scriptEntry) throws InvalidArgumentsException @Override public void execute(ScriptEntry scriptEntry) throws CommandExecutionException { - Player player = (Player) scriptEntry.getObject("player"); + Player player = scriptEntry.getPlayer().getPlayerEntity(); Mode mode = (Mode) scriptEntry.getObject("mode"); Type type = (Type) scriptEntry.getObject("type"); int amount = (Integer) scriptEntry.getObject("amount"); - dB.report(getName(), - aH.debugObj("Player", player) + aH.debugObj("Type", type.name()) + aH.debugObj("Mode", mode.name()) + dB.report(scriptEntry, getName(), + aH.debugObj("Type", type.name()) + aH.debugObj("Mode", mode.name()) + aH.debugObj("Amount", amount)); if(type == Type.MAXIMUM) { diff --git a/src/main/java/net/aufdemrand/denizen/scripts/commands/player/PermissionCommand.java b/src/main/java/net/aufdemrand/denizen/scripts/commands/player/PermissionCommand.java index 3655a2f7ab..c46bb17740 100644 --- a/src/main/java/net/aufdemrand/denizen/scripts/commands/player/PermissionCommand.java +++ b/src/main/java/net/aufdemrand/denizen/scripts/commands/player/PermissionCommand.java @@ -59,7 +59,7 @@ public void execute(ScriptEntry scriptEntry) throws CommandExecutionException { world = null; // Report to dB - dB.report(getName(), + dB.report(scriptEntry, getName(), aH.debugObj("Action", action.toString()) + aH.debugObj("Player", player.getName()) + aH.debugObj("Permission", permission) @@ -71,38 +71,38 @@ public void execute(ScriptEntry scriptEntry) throws CommandExecutionException { case ADD: if(group != null) { if(Depends.permissions.groupHas(world, group, permission)) { - dB.echoDebug("Group " + group + " already has permission " + permission); + dB.echoDebug(scriptEntry, "Group " + group + " already has permission " + permission); } else { Depends.permissions.groupAdd(world, group, permission); - dB.echoDebug("Added permission " + permission + " for group " + group); + dB.echoDebug(scriptEntry, "Added permission " + permission + " for group " + group); } } else { if(Depends.permissions.has(player, permission)) { - dB.echoDebug("Player " + player.getName() + " already has permission " + permission); + dB.echoDebug(scriptEntry, "Player " + player.getName() + " already has permission " + permission); } else { Depends.permissions.playerAdd(player, permission); - dB.echoDebug("Added permission " + permission + " for player " + player.getName()); + dB.echoDebug(scriptEntry, "Added permission " + permission + " for player " + player.getName()); } } return; case REMOVE: if(group != null) { if(!Depends.permissions.groupHas(world, group, permission)) { - dB.echoDebug("Group " + group + " does not have access to permission " + permission); + dB.echoDebug(scriptEntry, "Group " + group + " does not have access to permission " + permission); } else { Depends.permissions.groupRemove(world, group, permission); - dB.echoDebug("Removed permission " + permission + " for group " + group); + dB.echoDebug(scriptEntry, "Removed permission " + permission + " for group " + group); } } else { if(!Depends.permissions.has(player, permission)) { - dB.echoDebug("Player " + player.getName() + " does not have access to permission " + permission); + dB.echoDebug(scriptEntry, "Player " + player.getName() + " does not have access to permission " + permission); } else { Depends.permissions.playerRemove(world, player.getName(), permission); - dB.echoDebug("Removed permission " + permission + " for player " + player.getName()); + dB.echoDebug(scriptEntry, "Removed permission " + permission + " for player " + player.getName()); } } } diff --git a/src/main/java/net/aufdemrand/denizen/scripts/commands/player/ShowFakeCommand.java b/src/main/java/net/aufdemrand/denizen/scripts/commands/player/ShowFakeCommand.java index 86c6e3da2a..6828d95c8a 100644 --- a/src/main/java/net/aufdemrand/denizen/scripts/commands/player/ShowFakeCommand.java +++ b/src/main/java/net/aufdemrand/denizen/scripts/commands/player/ShowFakeCommand.java @@ -38,7 +38,8 @@ else if (arg.matchesPrefix("d, duration") else if (arg.matchesArgumentType(dMaterial.class)) scriptEntry.addObject("material", arg.asType(dMaterial.class)); - else dB.echoError(dB.Messages.ERROR_UNKNOWN_ARGUMENT, arg.raw_value); + else + arg.reportUnhandled(); } if (locations.isEmpty()) @@ -59,7 +60,7 @@ public void execute(ScriptEntry scriptEntry) throws CommandExecutionException { dMaterial material = (dMaterial) scriptEntry.getObject("material"); dList list = (dList) scriptEntry.getObject("locations"); - dB.report(getName(), material.debug() + dB.report(scriptEntry, getName(), material.debug() + list.debug() + scriptEntry.getPlayer().debug() + duration.debug()); for (dObject obj : list.filter(dLocation.class)) { diff --git a/src/main/java/net/aufdemrand/denizen/scripts/commands/server/AnnounceCommand.java b/src/main/java/net/aufdemrand/denizen/scripts/commands/server/AnnounceCommand.java index fd7563bb9b..1fab9d84f7 100644 --- a/src/main/java/net/aufdemrand/denizen/scripts/commands/server/AnnounceCommand.java +++ b/src/main/java/net/aufdemrand/denizen/scripts/commands/server/AnnounceCommand.java @@ -11,7 +11,6 @@ import net.aufdemrand.denizen.scripts.containers.core.FormatScriptContainer; import net.aufdemrand.denizen.objects.aH; import net.aufdemrand.denizen.utilities.debugging.dB; -import net.aufdemrand.denizen.utilities.debugging.dB.Messages; import org.bukkit.Bukkit; import org.bukkit.entity.Player; @@ -47,7 +46,7 @@ public void parseArgs(ScriptEntry scriptEntry) throws InvalidArgumentsException // Users tend to forget quotes sometimes on commands like this, so // let's check if there are more argument than usual. if (scriptEntry.getArguments().size() > 3) - throw new InvalidArgumentsException(Messages.ERROR_LOTS_OF_ARGUMENTS); + throw new InvalidArgumentsException("Too many arguments! Did you forget a 'quote'?"); for (aH.Argument arg : aH.interpret(scriptEntry.getArguments())) { @@ -76,7 +75,7 @@ else if (!scriptEntry.hasObject("text")) // If text is missing, alert the console. if (!scriptEntry.hasObject("text")) - throw new InvalidArgumentsException(Messages.ERROR_NO_TEXT); + throw new InvalidArgumentsException("Missing text argument!"); scriptEntry.defaultObject("type", AnnounceType.ALL); @@ -91,7 +90,7 @@ public void execute(ScriptEntry scriptEntry) throws CommandExecutionException { Element flag = scriptEntry.getElement("flag"); // Report to dB - dB.report(getName(), + dB.report(scriptEntry, getName(), aH.debugObj("Message", text) + (format != null ? aH.debugObj("Format", format.getName()) : "") + aH.debugObj("Type", type.name()) diff --git a/src/main/java/net/aufdemrand/denizen/scripts/commands/server/ExecuteCommand.java b/src/main/java/net/aufdemrand/denizen/scripts/commands/server/ExecuteCommand.java index 182c31a600..0e1bcfd929 100644 --- a/src/main/java/net/aufdemrand/denizen/scripts/commands/server/ExecuteCommand.java +++ b/src/main/java/net/aufdemrand/denizen/scripts/commands/server/ExecuteCommand.java @@ -12,7 +12,6 @@ import net.aufdemrand.denizen.scripts.commands.AbstractCommand; import net.aufdemrand.denizen.objects.aH; import net.aufdemrand.denizen.utilities.debugging.dB; -import net.aufdemrand.denizen.utilities.debugging.dB.Messages; public class ExecuteCommand extends AbstractCommand { @@ -53,14 +52,14 @@ else if (!scriptEntry.hasObject("command")) scriptEntry.addObject("command", new Element(arg.raw_value)); else - throw new InvalidArgumentsException(Messages.ERROR_UNKNOWN_ARGUMENT, arg.raw_value); + arg.reportUnhandled(); } if (!scriptEntry.hasObject("type")) - throw new InvalidArgumentsException(Messages.ERROR_MISSING_OTHER, "EXECUTE_TYPE"); + throw new InvalidArgumentsException("Missing execution type!"); if (!scriptEntry.hasObject("command")) - throw new InvalidArgumentsException(Messages.ERROR_MISSING_OTHER, "COMMAND_TEXT"); + throw new InvalidArgumentsException("Missing command text!"); } @@ -71,7 +70,7 @@ public void execute(ScriptEntry scriptEntry) throws CommandExecutionException { Element type = scriptEntry.getElement("type"); // Report to dB - dB.report(getName(), + dB.report(scriptEntry, getName(), type.debug() + cmd.debug()); diff --git a/src/main/java/net/aufdemrand/denizen/scripts/commands/server/ScoreboardCommand.java b/src/main/java/net/aufdemrand/denizen/scripts/commands/server/ScoreboardCommand.java index ed59edd575..e957b8900b 100644 --- a/src/main/java/net/aufdemrand/denizen/scripts/commands/server/ScoreboardCommand.java +++ b/src/main/java/net/aufdemrand/denizen/scripts/commands/server/ScoreboardCommand.java @@ -76,7 +76,8 @@ else if (!scriptEntry.hasObject("viewers") scriptEntry.addObject("viewers", ((dList) arg.asType(dList.class)).filter(dPlayer.class)); } - else dB.echoError(dB.Messages.ERROR_UNKNOWN_ARGUMENT, arg.raw_value); + else + arg.reportUnhandled(); } scriptEntry.defaultObject("action", new Element("add")); @@ -104,7 +105,7 @@ public void execute(final ScriptEntry scriptEntry) throws CommandExecutionExcept Action act = Action.valueOf(action.asString().toUpperCase()); // Report to dB - dB.report(getName(), action.debug() + + dB.report(scriptEntry, getName(), action.debug() + id.debug() + (viewers != null ? aH.debugObj("viewers", viewers.toString()) : "") + (objective != null ? objective.debug() : "") + @@ -187,7 +188,7 @@ else if (criteria != null && !obj.getCriteria().equals(criteria.asString())) { // If there is no objective and no viewers, but there are some lines, // the command cannot do anything at all, so print a message about that else if (viewers == null && !lines.isEmpty()) { - dB.echoDebug("Cannot add lines without specifying an objective!"); + dB.echoDebug(scriptEntry, "Cannot add lines without specifying an objective!"); } } else if (act.equals(Action.REMOVE)) { @@ -198,7 +199,7 @@ else if (act.equals(Action.REMOVE)) { if (obj != null) { // Remove the entire objective if no lines have been specified if (lines.isEmpty()) { - dB.echoDebug("Removing objective " + obj.getName() + + dB.echoDebug(scriptEntry, "Removing objective " + obj.getName() + " from scoreboard " + id.asString()); obj.unregister(); } @@ -217,7 +218,7 @@ else if (act.equals(Action.REMOVE)) { // If lines were specified, but an objective was not, remove the // lines from every objective else if (!lines.isEmpty()) { - dB.echoDebug("Removing lines " + lines.identify() + + dB.echoDebug(scriptEntry, "Removing lines " + lines.identify() + " from all objectives in scoreboard " + id.asString()); for (String line : lines) { @@ -229,7 +230,7 @@ else if (!lines.isEmpty()) { // argument was not specified (because if it was, a list // of viewers should be removed instead) else if (viewers == null) { - dB.echoDebug("Removing scoreboard " + id.asString()); + dB.echoDebug(scriptEntry, "Removing scoreboard " + id.asString()); ScoreboardHelper.deleteScoreboard(id.asString()); } } diff --git a/src/main/java/net/aufdemrand/denizen/scripts/commands/world/AnimateChestCommand.java b/src/main/java/net/aufdemrand/denizen/scripts/commands/world/AnimateChestCommand.java index 4da77a8e0d..b954a6fde3 100644 --- a/src/main/java/net/aufdemrand/denizen/scripts/commands/world/AnimateChestCommand.java +++ b/src/main/java/net/aufdemrand/denizen/scripts/commands/world/AnimateChestCommand.java @@ -25,15 +25,15 @@ public void parseArgs(ScriptEntry scriptEntry) for (String arg : scriptEntry.getArguments()) { if (aH.matchesArg("OPEN, CLOSE", arg)) { chestAction = aH.getStringFrom(arg); - dB.echoDebug("...chest action set: " + chestAction); + dB.echoDebug(scriptEntry, "...chest action set: " + chestAction); } else if (aH.matchesLocation(arg)) { location = aH.getLocationFrom(arg); - dB.echoDebug("...location set"); + dB.echoDebug(scriptEntry, "...location set"); } else if (aH.matchesValueArg("SOUND", arg, ArgumentType.Custom)) { sound = aH.getBooleanFrom(arg); - if (sound) dB.echoDebug("...sound enabled"); - else dB.echoDebug("...sound disabled"); - } else throw new InvalidArgumentsException(dB.Messages.ERROR_UNKNOWN_ARGUMENT, arg); + if (sound) dB.echoDebug(scriptEntry, "...sound enabled"); + else dB.echoDebug(scriptEntry, "...sound disabled"); + } else dB.echoError("Unknown argument '" + arg + "'"); } @@ -55,13 +55,13 @@ public void execute(ScriptEntry scriptEntry) case OPEN: if (sound) scriptEntry.getPlayer().getPlayerEntity().playSound(location, Sound.CHEST_OPEN, 1, 1); scriptEntry.getPlayer().getPlayerEntity().playNote(location, (byte)1, (byte)1); - dB.echoDebug("...opening chest"); + dB.echoDebug(scriptEntry, "...opening chest"); break; case CLOSE: if (sound) scriptEntry.getPlayer().getPlayerEntity().getWorld().playSound(location, Sound.CHEST_CLOSE, 1, 1); scriptEntry.getPlayer().getPlayerEntity().playNote(location, (byte)1, (byte)0); - dB.echoDebug("...closing chest"); + dB.echoDebug(scriptEntry, "...closing chest"); break; default: diff --git a/src/main/java/net/aufdemrand/denizen/scripts/commands/world/BreakCommand.java b/src/main/java/net/aufdemrand/denizen/scripts/commands/world/BreakCommand.java index 8bfebc9dc1..1e57c1a400 100644 --- a/src/main/java/net/aufdemrand/denizen/scripts/commands/world/BreakCommand.java +++ b/src/main/java/net/aufdemrand/denizen/scripts/commands/world/BreakCommand.java @@ -11,7 +11,6 @@ import net.aufdemrand.denizen.scripts.ScriptEntry; import net.aufdemrand.denizen.scripts.commands.AbstractCommand; import net.aufdemrand.denizen.utilities.debugging.dB; -import net.aufdemrand.denizen.utilities.debugging.dB.Messages; import net.citizensnpcs.npc.ai.BlockBreaker; /** @@ -39,7 +38,8 @@ else if (!scriptEntry.hasObject("radius") && arg.matchesPrimitive(aH.PrimitiveType.Double)) scriptEntry.addObject("radius", arg.asElement()); - else throw new InvalidArgumentsException(Messages.ERROR_UNKNOWN_ARGUMENT, arg.raw_value); + else + arg.reportUnhandled(); } // Make sure location and entity were fulfilled @@ -62,15 +62,16 @@ public void execute(ScriptEntry scriptEntry) throws CommandExecutionException { final dEntity entity = (dEntity) scriptEntry.getObject("entity"); Element radius = scriptEntry.getElement("radius"); - dB.report(getName(), location.debug() + entity.debug() + radius.debug()); + dB.report(scriptEntry, getName(), location.debug() + entity.debug() + radius.debug()); + final ScriptEntry se = scriptEntry; BlockBreaker.Configuration config = new BlockBreaker.Configuration() .item(entity.getLivingEntity().getEquipment().getItemInHand()) .radius(radius.asDouble()) .callback(new Runnable() { @Override public void run() { - dB.echoDebug(entity.debug() + " dug " + location.debug()); + dB.echoDebug(se, entity.debug() + " dug " + location.debug()); } }); diff --git a/src/main/java/net/aufdemrand/denizen/scripts/commands/world/ChunkLoadCommand.java b/src/main/java/net/aufdemrand/denizen/scripts/commands/world/ChunkLoadCommand.java index 37637f1dc4..8cc8d3df03 100644 --- a/src/main/java/net/aufdemrand/denizen/scripts/commands/world/ChunkLoadCommand.java +++ b/src/main/java/net/aufdemrand/denizen/scripts/commands/world/ChunkLoadCommand.java @@ -12,7 +12,6 @@ import net.aufdemrand.denizen.objects.Duration; import net.aufdemrand.denizen.objects.aH; import net.aufdemrand.denizen.utilities.debugging.dB; -import net.aufdemrand.denizen.utilities.debugging.dB.Messages; import net.citizensnpcs.api.event.NPCDespawnEvent; import org.bukkit.Chunk; @@ -52,11 +51,12 @@ else if (arg.matchesArgumentType(Duration.class) && !scriptEntry.hasObject("duration")) scriptEntry.addObject("duration", arg.asType(Duration.class)); - else throw new InvalidArgumentsException(Messages.ERROR_UNKNOWN_ARGUMENT, arg.raw_value); + else + arg.reportUnhandled(); } if (!scriptEntry.hasObject("location")) - throw new InvalidArgumentsException(Messages.DEBUG_SET_LOCATION); + throw new InvalidArgumentsException("Missing location argument!"); if (!scriptEntry.hasObject("action")) scriptEntry.addObject("action", new Element("ADD")); @@ -72,7 +72,7 @@ public void execute(ScriptEntry scriptEntry) throws CommandExecutionException { dLocation chunkloc = (dLocation) scriptEntry.getObject("location"); Duration length = (Duration) scriptEntry.getObject("duration"); - dB.report(getName(), + dB.report(scriptEntry, getName(), action.debug() + chunkloc.debug() + length.debug()); @@ -86,20 +86,20 @@ public void execute(ScriptEntry scriptEntry) throws CommandExecutionException { chunkDelays.put(chunkString, System.currentTimeMillis() + length.getMillis()); else chunkDelays.put(chunkString, (long) 0); - dB.echoDebug("...added chunk "+chunk.getX() + ", "+ chunk.getZ() + " with a delay of " + length.getSeconds() + " seconds."); + dB.echoDebug(scriptEntry, "...added chunk "+chunk.getX() + ", "+ chunk.getZ() + " with a delay of " + length.getSeconds() + " seconds."); if(!chunk.isLoaded()) chunk.load(); break; case REMOVE: if(chunkDelays.containsKey(chunkString)) { chunkDelays.remove(chunkString); - dB.echoDebug("...allowing unloading of chunk "+chunk.getX() + ", "+ chunk.getZ()); + dB.echoDebug(scriptEntry, "...allowing unloading of chunk "+chunk.getX() + ", "+ chunk.getZ()); } else dB.echoError("Chunk was not on the load list!"); break; case REMOVEALL: - dB.echoDebug("...allowing unloading of all stored chunks"); + dB.echoDebug(scriptEntry, "...allowing unloading of all stored chunks"); chunkDelays.clear(); break; } diff --git a/src/main/java/net/aufdemrand/denizen/scripts/commands/world/CopyBlockCommand.java b/src/main/java/net/aufdemrand/denizen/scripts/commands/world/CopyBlockCommand.java index 0ec6dfe7c4..d27f52acc9 100644 --- a/src/main/java/net/aufdemrand/denizen/scripts/commands/world/CopyBlockCommand.java +++ b/src/main/java/net/aufdemrand/denizen/scripts/commands/world/CopyBlockCommand.java @@ -7,7 +7,7 @@ import net.aufdemrand.denizen.objects.dLocation; import net.aufdemrand.denizen.objects.aH; import net.aufdemrand.denizen.objects.aH.ArgumentType; -import net.aufdemrand.denizen.utilities.debugging.dB.Messages; +import net.aufdemrand.denizen.utilities.debugging.dB; import org.bukkit.block.Block; import org.bukkit.block.BlockState; import org.bukkit.block.Sign; @@ -40,11 +40,12 @@ else if (aH.matchesValueArg("to", arg, ArgumentType.Location)) else if (aH.matchesArg("and_remove", arg)) remove_original = true; - else throw new InvalidArgumentsException(Messages.ERROR_UNKNOWN_ARGUMENT, arg); + else + dB.echoError("Unknown argument '" + arg + "'"); } if (copy_location == null || destination == null) - throw new InvalidArgumentsException(Messages.ERROR_MISSING_LOCATION); + throw new InvalidArgumentsException("Missing location argument!"); scriptEntry.addObject("copy_location", copy_location) .addObject("destination", destination) diff --git a/src/main/java/net/aufdemrand/denizen/scripts/commands/world/CreateWorldCommand.java b/src/main/java/net/aufdemrand/denizen/scripts/commands/world/CreateWorldCommand.java index f3267fa09e..8704377659 100644 --- a/src/main/java/net/aufdemrand/denizen/scripts/commands/world/CreateWorldCommand.java +++ b/src/main/java/net/aufdemrand/denizen/scripts/commands/world/CreateWorldCommand.java @@ -6,7 +6,6 @@ import net.aufdemrand.denizen.scripts.ScriptEntry; import net.aufdemrand.denizen.scripts.commands.AbstractCommand; import net.aufdemrand.denizen.utilities.debugging.dB; -import net.aufdemrand.denizen.utilities.debugging.dB.Messages; import org.bukkit.Bukkit; import org.bukkit.World; @@ -41,6 +40,8 @@ else if (!scriptEntry.hasObject("world_name")) // TODO: Rewrite this entire everything, make it make sense. // TODO: At time of writing this todo, commandfile was full of Template stuff 0.o + + // TODO: also, save worlds through restart! @Override public void execute(ScriptEntry scriptEntry) throws CommandExecutionException { @@ -59,7 +60,7 @@ public void execute(ScriptEntry scriptEntry) throws CommandExecutionException { .name(scriptEntry.getElement("world_name").asString())); if (world == null) - dB.echoDebug("World is null! :("); + dB.echoDebug(scriptEntry, "World is null! :("); } diff --git a/src/main/java/net/aufdemrand/denizen/scripts/commands/world/DropCommand.java b/src/main/java/net/aufdemrand/denizen/scripts/commands/world/DropCommand.java index f6d04b8b85..fabfbff116 100644 --- a/src/main/java/net/aufdemrand/denizen/scripts/commands/world/DropCommand.java +++ b/src/main/java/net/aufdemrand/denizen/scripts/commands/world/DropCommand.java @@ -6,7 +6,6 @@ import net.aufdemrand.denizen.scripts.ScriptEntry; import net.aufdemrand.denizen.scripts.commands.AbstractCommand; import net.aufdemrand.denizen.utilities.debugging.dB; -import net.aufdemrand.denizen.utilities.debugging.dB.Messages; import org.bukkit.entity.Entity; import org.bukkit.entity.EntityType; @@ -82,7 +81,8 @@ else if (!scriptEntry.hasObject("qty") // Quantity arg scriptEntry.addObject("qty", arg.asElement().setPrefix("qty")); - else throw new InvalidArgumentsException(Messages.ERROR_UNKNOWN_ARGUMENT, arg.raw_value); + else + arg.reportUnhandled(); } // Make sure all required arguments are met @@ -93,7 +93,7 @@ else if (!scriptEntry.hasObject("qty") if (!scriptEntry.hasObject("location")) if (scriptEntry.getPlayer() != null && scriptEntry.getPlayer().isOnline()) { scriptEntry.addObject("location", scriptEntry.getPlayer().getLocation().setPrefix("location")); - dB.echoDebug("Did not specify a location, assuming Player's location."); + dB.echoDebug(scriptEntry, "Did not specify a location, assuming Player's location."); } else throw new InvalidArgumentsException("Must specify a location!"); @@ -117,7 +117,7 @@ public void execute(ScriptEntry scriptEntry) throws CommandExecutionException { // Report to dB - dB.report(getName(), + dB.report(scriptEntry, getName(), action.debug() + location.debug() + qty.debug() + (item != null ? item.debug() : "") + (entity != null ? entity.debug() : "") @@ -134,7 +134,7 @@ public void execute(ScriptEntry scriptEntry) throws CommandExecutionException { case DROP_ITEM: if (qty.asInt() > 1 && item.isUnique()) - dB.echoDebug("Cannot drop multiples of this item because it is Unique!"); + dB.echoDebug(scriptEntry, "Cannot drop multiples of this item because it is Unique!"); // TODO: Make a dItem specific 'drop/give' to better keep track of it, like dEntity. for (int x = 0; x < qty.asInt(); x++) { Entity e = location.getWorld().dropItemNaturally(location, item.getItemStack()); @@ -144,7 +144,7 @@ public void execute(ScriptEntry scriptEntry) throws CommandExecutionException { case DROP_ENTITY: if (qty.asInt() > 1 && entity.isUnique()) - dB.echoDebug("Cannot drop multiples of this entity because it is Unique!"); + dB.echoDebug(scriptEntry, "Cannot drop multiples of this entity because it is Unique!"); for (int x = 0; x < qty.asInt(); x++) entity.spawnAt(location); break; diff --git a/src/main/java/net/aufdemrand/denizen/scripts/commands/world/ExplodeCommand.java b/src/main/java/net/aufdemrand/denizen/scripts/commands/world/ExplodeCommand.java index f7355883ac..327af04150 100644 --- a/src/main/java/net/aufdemrand/denizen/scripts/commands/world/ExplodeCommand.java +++ b/src/main/java/net/aufdemrand/denizen/scripts/commands/world/ExplodeCommand.java @@ -8,7 +8,6 @@ import net.aufdemrand.denizen.scripts.ScriptEntry; import net.aufdemrand.denizen.scripts.commands.AbstractCommand; import net.aufdemrand.denizen.utilities.debugging.dB; -import net.aufdemrand.denizen.utilities.debugging.dB.Messages; /** * Create an explosion at a location. @@ -50,7 +49,8 @@ else if (!scriptEntry.hasObject("fire") scriptEntry.addObject("fire", ""); } - else throw new InvalidArgumentsException(Messages.ERROR_UNKNOWN_ARGUMENT, arg.raw_value); + else + arg.reportUnhandled(); } // Use default values if necessary @@ -60,7 +60,7 @@ else if (!scriptEntry.hasObject("fire") scriptEntry.hasPlayer() ? scriptEntry.getPlayer().getLocation() : null); if (!scriptEntry.hasObject("location")) { - throw new InvalidArgumentsException(Messages.ERROR_MISSING_OTHER, "LOCATION"); + throw new InvalidArgumentsException("Missing location argument!"); } } @@ -74,7 +74,7 @@ public void execute(final ScriptEntry scriptEntry) throws CommandExecutionExcept Boolean fire = scriptEntry.hasObject("fire"); // Report to dB - dB.report(getName(), + dB.report(scriptEntry, getName(), (aH.debugObj("location", location.toString()) + aH.debugObj("power", power) + aH.debugObj("breakblocks", breakblocks) + diff --git a/src/main/java/net/aufdemrand/denizen/scripts/commands/world/FireworkCommand.java b/src/main/java/net/aufdemrand/denizen/scripts/commands/world/FireworkCommand.java index 1c4eac3046..0ac2ccb3a8 100644 --- a/src/main/java/net/aufdemrand/denizen/scripts/commands/world/FireworkCommand.java +++ b/src/main/java/net/aufdemrand/denizen/scripts/commands/world/FireworkCommand.java @@ -79,7 +79,8 @@ else if (!scriptEntry.hasObject("fade") scriptEntry.addObject("fade", ((dList) arg.asType(dList.class)).filter(dColor.class)); } - else dB.echoError(dB.Messages.ERROR_UNKNOWN_ARGUMENT, arg.raw_value); + else + arg.reportUnhandled(); } // Use the NPC or player's locations as the location if one is not specified @@ -109,7 +110,7 @@ public void execute(final ScriptEntry scriptEntry) throws CommandExecutionExcept List fade = (List) scriptEntry.getObject("fade"); // Report to dB - dB.report(getName(), location.debug() + + dB.report(scriptEntry, getName(), location.debug() + type.debug() + power.debug() + (flicker ? aH.debugObj("flicker", flicker) : "") + diff --git a/src/main/java/net/aufdemrand/denizen/scripts/commands/world/MidiCommand.java b/src/main/java/net/aufdemrand/denizen/scripts/commands/world/MidiCommand.java index 879bf0a597..45779d81b0 100644 --- a/src/main/java/net/aufdemrand/denizen/scripts/commands/world/MidiCommand.java +++ b/src/main/java/net/aufdemrand/denizen/scripts/commands/world/MidiCommand.java @@ -11,7 +11,6 @@ import net.aufdemrand.denizen.scripts.commands.AbstractCommand; import net.aufdemrand.denizen.utilities.midi.MidiUtil; import net.aufdemrand.denizen.utilities.debugging.dB; -import net.aufdemrand.denizen.utilities.debugging.dB.Messages; /** @@ -70,14 +69,15 @@ else if (!scriptEntry.hasObject("file")) { scriptEntry.addObject("file", new Element(path)); } - else throw new InvalidArgumentsException(Messages.ERROR_UNKNOWN_ARGUMENT, arg.raw_value); + else + arg.reportUnhandled(); } // Produce error if there is no file and the "cancel" argument was // not used if (!scriptEntry.hasObject("file") && !scriptEntry.hasObject("cancel")) - throw new InvalidArgumentsException(Messages.ERROR_MISSING_OTHER, "FILE"); + throw new InvalidArgumentsException("Missing file (Midi name) argument!"); if (!scriptEntry.hasObject("location")) { scriptEntry.defaultObject("entities", (scriptEntry.hasPlayer() ? Arrays.asList(scriptEntry.getPlayer().getDenizenEntity()) : null), @@ -104,14 +104,14 @@ public void execute(ScriptEntry scriptEntry) throws CommandExecutionException { float tempo = (float) scriptEntry.getElement("tempo").asDouble(); // Report to dB - dB.report(getName(), (cancel == true ? aH.debugObj("cancel", cancel) : "") + + dB.report(scriptEntry, getName(), (cancel ? aH.debugObj("cancel", cancel) : "") + (file != null ? aH.debugObj("file", file.getPath()) : "") + (entities != null ? aH.debugObj("entities", entities.toString()) : "") + (location != null ? location.debug() : "") + aH.debugObj("tempo", tempo)); // Play the midi - if (cancel == false) { + if (!cancel) { if (location != null) { MidiUtil.playMidi(file, tempo, location); } diff --git a/src/main/java/net/aufdemrand/denizen/scripts/commands/world/ModifyBlockCommand.java b/src/main/java/net/aufdemrand/denizen/scripts/commands/world/ModifyBlockCommand.java index 874fef9fd4..ae19987bf0 100644 --- a/src/main/java/net/aufdemrand/denizen/scripts/commands/world/ModifyBlockCommand.java +++ b/src/main/java/net/aufdemrand/denizen/scripts/commands/world/ModifyBlockCommand.java @@ -8,8 +8,6 @@ import net.aufdemrand.denizen.objects.dMaterial; import net.aufdemrand.denizen.scripts.ScriptEntry; import net.aufdemrand.denizen.scripts.commands.AbstractCommand; -import net.aufdemrand.denizen.utilities.debugging.dB; -import net.aufdemrand.denizen.utilities.debugging.dB.Messages; import org.bukkit.World; import org.bukkit.block.Block; @@ -76,13 +74,14 @@ else if (!scriptEntry.hasObject("depth") scriptEntry.addObject("depth", new Element(arg.getValue())); } - else throw new InvalidArgumentsException(Messages.ERROR_UNKNOWN_ARGUMENT, arg.raw_value); + else + arg.reportUnhandled(); } if (!scriptEntry.hasObject("material")) - throw new InvalidArgumentsException(Messages.ERROR_MISSING_OTHER, "MATERIAL"); + throw new InvalidArgumentsException("Missing material argument!"); if (!scriptEntry.hasObject("location")) - throw new InvalidArgumentsException(Messages.ERROR_MISSING_LOCATION); + throw new InvalidArgumentsException("Missing location argument!"); scriptEntry.defaultObject("radius", new Element(0)); scriptEntry.defaultObject("height", new Element(0)); scriptEntry.defaultObject("depth", new Element(0)); diff --git a/src/main/java/net/aufdemrand/denizen/scripts/commands/world/PlayEffectCommand.java b/src/main/java/net/aufdemrand/denizen/scripts/commands/world/PlayEffectCommand.java index 1925fbb706..46cd24847a 100644 --- a/src/main/java/net/aufdemrand/denizen/scripts/commands/world/PlayEffectCommand.java +++ b/src/main/java/net/aufdemrand/denizen/scripts/commands/world/PlayEffectCommand.java @@ -10,7 +10,6 @@ import net.aufdemrand.denizen.scripts.ScriptEntry; import net.aufdemrand.denizen.scripts.commands.AbstractCommand; import net.aufdemrand.denizen.utilities.debugging.dB; -import net.aufdemrand.denizen.utilities.debugging.dB.Messages; import net.aufdemrand.denizen.utilities.ParticleEffect; /** @@ -87,7 +86,8 @@ else if (!scriptEntry.hasObject("offset") scriptEntry.addObject("offset", arg.asElement()); } - else throw new InvalidArgumentsException(Messages.ERROR_UNKNOWN_ARGUMENT, arg.raw_value); + else + arg.reportUnhandled(); } // Use default values if necessary @@ -103,10 +103,10 @@ else if (!scriptEntry.hasObject("offset") if (!scriptEntry.hasObject("effect") && !scriptEntry.hasObject("particleeffect")) - throw new InvalidArgumentsException(Messages.ERROR_MISSING_OTHER, "EFFECT"); + throw new InvalidArgumentsException("Missing effect argument!"); if (!scriptEntry.hasObject("location")) - throw new InvalidArgumentsException(Messages.ERROR_MISSING_OTHER, "LOCATION"); + throw new InvalidArgumentsException("Missing location argument!"); } @Override @@ -126,7 +126,7 @@ public void execute(ScriptEntry scriptEntry) throws CommandExecutionException { location.add(0, 1, 0); // Report to dB - dB.report(getName(), (effect != null ? aH.debugObj("effect", effect.name()) : + dB.report(scriptEntry, getName(), (effect != null ? aH.debugObj("effect", effect.name()) : aH.debugObj("special effect", particleEffect.name())) + aH.debugObj("location", location.toString()) + aH.debugObj("radius", visibility) + diff --git a/src/main/java/net/aufdemrand/denizen/scripts/commands/world/PlaySoundCommand.java b/src/main/java/net/aufdemrand/denizen/scripts/commands/world/PlaySoundCommand.java index a1d69d41bd..72171efbc4 100644 --- a/src/main/java/net/aufdemrand/denizen/scripts/commands/world/PlaySoundCommand.java +++ b/src/main/java/net/aufdemrand/denizen/scripts/commands/world/PlaySoundCommand.java @@ -1,6 +1,5 @@ package net.aufdemrand.denizen.scripts.commands.world; -import org.bukkit.Location; import org.bukkit.Sound; import net.aufdemrand.denizen.exceptions.CommandExecutionException; @@ -11,7 +10,6 @@ import net.aufdemrand.denizen.objects.aH; import net.aufdemrand.denizen.objects.dLocation; import net.aufdemrand.denizen.utilities.debugging.dB; -import net.aufdemrand.denizen.utilities.debugging.dB.Messages; /* PLAYSOUND [LOCATION:x,y,z,world] [SOUND:NAME] (VOLUME:#) (PITCH:#)*/ @@ -55,14 +53,15 @@ else if (!scriptEntry.hasObject("sound") scriptEntry.addObject("sound", arg.asElement()); } - else throw new InvalidArgumentsException(Messages.ERROR_UNKNOWN_ARGUMENT, arg.raw_value); + else + arg.reportUnhandled(); } if (!scriptEntry.hasObject("sound")) - throw new InvalidArgumentsException(Messages.ERROR_MISSING_OTHER, "SOUND"); + throw new InvalidArgumentsException("Missing sound argument!"); if (!scriptEntry.hasObject("location")) - throw new InvalidArgumentsException(Messages.ERROR_MISSING_OTHER, "LOCATION"); + throw new InvalidArgumentsException("Missing location argument!"); scriptEntry.defaultObject("volume", new Element(1)); scriptEntry.defaultObject("pitch", new Element(1)); @@ -77,7 +76,7 @@ public void execute(ScriptEntry scriptEntry) throws CommandExecutionException { Element volume = scriptEntry.getElement("volume"); Element pitch = scriptEntry.getElement("pitch"); - dB.report(getName(), + dB.report(scriptEntry, getName(), location.debug() + sound.debug() + volume.debug() + diff --git a/src/main/java/net/aufdemrand/denizen/scripts/commands/world/SchematicCommand.java b/src/main/java/net/aufdemrand/denizen/scripts/commands/world/SchematicCommand.java index 259112409c..879545cf09 100644 --- a/src/main/java/net/aufdemrand/denizen/scripts/commands/world/SchematicCommand.java +++ b/src/main/java/net/aufdemrand/denizen/scripts/commands/world/SchematicCommand.java @@ -73,14 +73,14 @@ else if (!scriptEntry.hasObject("noair") scriptEntry.addObject("noair", Element.TRUE); else - dB.echoError(dB.Messages.ERROR_UNKNOWN_ARGUMENT, arg.raw_value); + arg.reportUnhandled(); } if (!scriptEntry.hasObject("type")) - throw new InvalidArgumentsException(dB.Messages.ERROR_MISSING_OTHER, "type"); + throw new InvalidArgumentsException("Missing type argument!"); if (!scriptEntry.hasObject("name")) - throw new InvalidArgumentsException(dB.Messages.ERROR_MISSING_OTHER, "name"); + throw new InvalidArgumentsException("Missing name argument!"); } @@ -94,7 +94,7 @@ public void execute(ScriptEntry scriptEntry) throws CommandExecutionException { Element noair = scriptEntry.getElement("noair"); dLocation location = (dLocation) scriptEntry.getObject("location"); - dB.report(getName(), type.debug() + dB.report(scriptEntry, getName(), type.debug() + name.debug() + (location != null ? location.debug(): "") + (angle != null ? angle.debug(): "") @@ -135,7 +135,7 @@ public void execute(ScriptEntry scriptEntry) throws CommandExecutionException { return; } if (angle == null) { - dB.echoError(dB.Messages.ERROR_MISSING_OTHER, "ANGLE"); + dB.echoError("Missing angle argument!"); return; } schematics.get(name.asString().toUpperCase()).rotate2D(angle.asInt()); @@ -146,7 +146,7 @@ public void execute(ScriptEntry scriptEntry) throws CommandExecutionException { return; } if (location == null) { - dB.echoError(dB.Messages.ERROR_MISSING_OTHER, "LOCATION"); + dB.echoError("Missing location argument!"); return; } try { diff --git a/src/main/java/net/aufdemrand/denizen/scripts/commands/world/SignCommand.java b/src/main/java/net/aufdemrand/denizen/scripts/commands/world/SignCommand.java index c486b72c3f..b1f2e524b0 100644 --- a/src/main/java/net/aufdemrand/denizen/scripts/commands/world/SignCommand.java +++ b/src/main/java/net/aufdemrand/denizen/scripts/commands/world/SignCommand.java @@ -10,7 +10,6 @@ import net.aufdemrand.denizen.scripts.commands.AbstractCommand; import net.aufdemrand.denizen.utilities.Utilities; import net.aufdemrand.denizen.utilities.debugging.dB; -import net.aufdemrand.denizen.utilities.debugging.dB.Messages; import org.bukkit.Material; import org.bukkit.block.Block; @@ -51,7 +50,8 @@ else if (!scriptEntry.hasObject("direction") && arg.matchesPrefix("direction, dir")) scriptEntry.addObject("direction", arg.asElement()); - else throw new InvalidArgumentsException(Messages.ERROR_UNKNOWN_ARGUMENT, arg.raw_value); + else + arg.reportUnhandled(); } // Check to make sure required arguments have been filled @@ -74,7 +74,7 @@ public void execute(final ScriptEntry scriptEntry) throws CommandExecutionExcept dLocation location = (dLocation) scriptEntry.getObject("location"); // Report to dB - dB.report(getName(), type.name() + ", " + dB.report(scriptEntry, getName(), type.name() + ", " + aH.debugObj("location", location) + aH.debugObj("text", text)); diff --git a/src/main/java/net/aufdemrand/denizen/scripts/commands/world/StrikeCommand.java b/src/main/java/net/aufdemrand/denizen/scripts/commands/world/StrikeCommand.java index 77a106011e..dc95b60b58 100644 --- a/src/main/java/net/aufdemrand/denizen/scripts/commands/world/StrikeCommand.java +++ b/src/main/java/net/aufdemrand/denizen/scripts/commands/world/StrikeCommand.java @@ -8,7 +8,6 @@ import net.aufdemrand.denizen.objects.dLocation; import net.aufdemrand.denizen.objects.aH; import net.aufdemrand.denizen.utilities.debugging.dB; -import net.aufdemrand.denizen.utilities.debugging.dB.Messages; public class StrikeCommand extends AbstractCommand { @@ -26,13 +25,14 @@ public void parseArgs(ScriptEntry scriptEntry) throws InvalidArgumentsException else if (arg.matches("no_damage") || arg.matches("nodamage")) scriptEntry.addObject("damage", Element.FALSE); - else throw new InvalidArgumentsException(Messages.ERROR_UNKNOWN_ARGUMENT, arg.raw_value); + else + arg.reportUnhandled(); } // Check required args if (!scriptEntry.hasObject("location")) - throw new InvalidArgumentsException(Messages.ERROR_MISSING_OTHER, "LOCATION"); + throw new InvalidArgumentsException("Missing location argument!"); scriptEntry.defaultObject("damage", Element.TRUE); } @@ -45,7 +45,7 @@ public void execute(ScriptEntry scriptEntry) throws CommandExecutionException { Boolean damage = scriptEntry.getElement("damage").asBoolean(); // Debugger - dB.report(getName(), + dB.report(scriptEntry, getName(), location.debug() + aH.debugObj("Damageable", String.valueOf(damage))); diff --git a/src/main/java/net/aufdemrand/denizen/scripts/requirements/core/InGroupRequirement.java b/src/main/java/net/aufdemrand/denizen/scripts/requirements/core/InGroupRequirement.java index c7ef712133..e4efdda00c 100644 --- a/src/main/java/net/aufdemrand/denizen/scripts/requirements/core/InGroupRequirement.java +++ b/src/main/java/net/aufdemrand/denizen/scripts/requirements/core/InGroupRequirement.java @@ -38,22 +38,22 @@ public boolean check(RequirementsContext context, List args) throws Requ { if (Depends.permissions.playerInGroup((World) null, context.getPlayer().getName(), arg)) { - dB.echoDebug("...player is in global group: " + arg); + dB.echoDebug(context.getScriptContainer(), "...player is in global group: " + arg); outcome = true; } else - dB.echoDebug("...player is not in global group: " + arg + "!"); + dB.echoDebug(context.getScriptContainer(), "...player is not in global group: " + arg + "!"); } else { if (Depends.permissions.playerInGroup(context.getPlayer().getPlayerEntity(), arg)) { - dB.echoDebug("...player is in group: " + arg); + dB.echoDebug(context.getScriptContainer(), "...player is in group: " + arg); outcome = true; } else { - dB.echoDebug("...player is not in group: " + arg + "!"); + dB.echoDebug(context.getScriptContainer(), "...player is not in group: " + arg + "!"); } } @@ -63,7 +63,7 @@ public boolean check(RequirementsContext context, List args) throws Requ return outcome; } - dB.echoDebug("...no permission plugin found, assume as FALSE!"); + dB.echoDebug(context.getScriptContainer(), "...no permission plugin found, assume as FALSE!"); } return false; diff --git a/src/main/java/net/aufdemrand/denizen/scripts/requirements/core/OxygenRequirement.java b/src/main/java/net/aufdemrand/denizen/scripts/requirements/core/OxygenRequirement.java index ae500720d8..b59fb2616f 100644 --- a/src/main/java/net/aufdemrand/denizen/scripts/requirements/core/OxygenRequirement.java +++ b/src/main/java/net/aufdemrand/denizen/scripts/requirements/core/OxygenRequirement.java @@ -26,13 +26,13 @@ public boolean check(RequirementsContext context, List args) throws Requ if(aH.matchesValueArg("range", arg, aH.ArgumentType.String)) { try { range = Range.valueOf(aH.getStringFrom(arg)); - dB.echoDebug("Set range to " + range.name() + "!"); + dB.echoDebug(context.getScriptContainer(), "Set range to " + range.name() + "!"); } catch(Exception e) { dB.echoError("Invalid range: " + e.getMessage()); } } else if(aH.matchesQuantity(arg) || aH.matchesArg("amt", arg)) { val = aH.getIntegerFrom(arg); - dB.echoDebug("Amount set to " + val); + dB.echoDebug(context.getScriptContainer(), "Amount set to " + val); } } diff --git a/src/main/java/net/aufdemrand/denizen/scripts/requirements/core/WorldGuardRegionRequirement.java b/src/main/java/net/aufdemrand/denizen/scripts/requirements/core/WorldGuardRegionRequirement.java index ea218754ce..c6783400fa 100644 --- a/src/main/java/net/aufdemrand/denizen/scripts/requirements/core/WorldGuardRegionRequirement.java +++ b/src/main/java/net/aufdemrand/denizen/scripts/requirements/core/WorldGuardRegionRequirement.java @@ -49,7 +49,7 @@ public boolean check(RequirementsContext context, List args) throws Requ for (String arg : args) { if (aH.matchesValueArg("NAME, N", arg, ArgumentType.String)) { region = aH.getStringFrom(arg); - dB.echoDebug("...region set as: " + region); + dB.echoDebug(context.getScriptContainer(), "...region set as: " + region); } else throw new RequirementCheckException("Invalid argument specified!"); } @@ -61,9 +61,9 @@ public boolean check(RequirementsContext context, List args) throws Requ /* * Display proper debug output */ - if (outcome) dB.echoDebug("...player in region!"); - else dB.echoDebug("...player is not in region!"); + if (outcome) dB.echoDebug(context.getScriptContainer(), "...player in region!"); + else dB.echoDebug(context.getScriptContainer(), "...player is not in region!"); return outcome; } -} +} diff --git a/src/main/java/net/aufdemrand/denizen/tags/core/_templateTag.java b/src/main/java/net/aufdemrand/denizen/tags/core/_templateTag.java index 9ea07b1bad..4d3ca541ca 100644 --- a/src/main/java/net/aufdemrand/denizen/tags/core/_templateTag.java +++ b/src/main/java/net/aufdemrand/denizen/tags/core/_templateTag.java @@ -75,7 +75,7 @@ public void constantTags(ReplaceableTagEvent event) { if (type.equalsIgnoreCase("for")) { // Check if type_context is a valid player... if (aH.getPlayerFrom(type_context) == null) { - dB.echoDebug("This tag requires a player! Has this player logged off? Aborting replacement..."); + dB.echoDebug(event.getScriptEntry(), "This tag requires a player! Has this player logged off? Aborting replacement..."); return; } @@ -111,4 +111,4 @@ public void constantTags(ReplaceableTagEvent event) { dB.echoError("Example skills tag '" + event.raw_tag + "' was unable to match an attribute. Replacement has been cancelled..."); } -} +}