Skip to content

Commit

Permalink
more general command db report cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
mcmonkey4eva committed Nov 7, 2021
1 parent dfd3d99 commit a92f314
Show file tree
Hide file tree
Showing 49 changed files with 63 additions and 195 deletions.
Expand Up @@ -95,7 +95,7 @@ public void execute(final ScriptEntry scriptEntry) {
boolean lock = scriptEntry.hasObject("lock");

if (scriptEntry.dbCallShouldDebug()) {
Debug.report(scriptEntry, getName(), (lock ? db("lock", true) : ""), (ageType != null ? db("agetype", ageType) : db("age", age)), db("entities", entities.toString()));
Debug.report(scriptEntry, getName(), (lock ? db("lock", true) : ""), (ageType != null ? db("agetype", ageType) : db("age", age)), db("entities", entities));
}
for (EntityTag entity : entities) {
if (entity.isSpawned()) {
Expand Down
Expand Up @@ -74,7 +74,7 @@ public void execute(final ScriptEntry scriptEntry) {
List<EntityTag> entities = (List<EntityTag>) scriptEntry.getObject("entities");
DurationTag duration = scriptEntry.getObjectTag("duration");
if (scriptEntry.dbCallShouldDebug()) {
Debug.report(scriptEntry, getName(), duration, db("entities", entities.toString()));
Debug.report(scriptEntry, getName(), duration, db("entities", entities));
}
for (EntityTag entity : entities) {
if (entity.isSpawned()) {
Expand Down
Expand Up @@ -126,7 +126,7 @@ public void execute(ScriptEntry scriptEntry) {
Map<String, ItemTag> equipment = (Map<String, ItemTag>) scriptEntry.getObject("equipment");
List<EntityTag> entities = (List<EntityTag>) scriptEntry.getObject("entities");
if (scriptEntry.dbCallShouldDebug()) {
Debug.report(scriptEntry, getName(), db("entities", entities.toString()), db("equipment", equipment.toString()));
Debug.report(scriptEntry, getName(), db("entities", entities), db("equipment", equipment));
}
for (EntityTag entity : entities) {
if (entity.isGeneric()) {
Expand Down
Expand Up @@ -170,7 +170,7 @@ public void execute(ScriptEntry scriptEntry) {
ElementTag reset = scriptEntry.getElement("reset");
DurationTag duration = scriptEntry.getObjectTag("duration");
if (scriptEntry.dbCallShouldDebug()) {
Debug.report(scriptEntry, getName(), db("entities", entities.toString()), db("equipment", equipment.toString()), reset, duration, db("for", playersFor));
Debug.report(scriptEntry, getName(), db("entities", entities), db("equipment", equipment), reset, duration, db("for", playersFor));
}
boolean isReset = reset != null && reset.asBoolean();
for (PlayerTag player : playersFor) {
Expand Down
Expand Up @@ -135,7 +135,7 @@ public void execute(final ScriptEntry scriptEntry) {
if (entities.get(entities.size() - 1) != entity) {
controller = entity;
if (scriptEntry.dbCallShouldDebug()) {
Debug.report(scriptEntry, getName(), "Flight control defaulting to " + controller);
Debug.echoDebug(scriptEntry, "Flight control defaulting to " + controller);
}
break;
}
Expand All @@ -144,7 +144,7 @@ public void execute(final ScriptEntry scriptEntry) {
// If the controller is still null, we cannot continue
if (controller == null) {
if (scriptEntry.dbCallShouldDebug()) {
Debug.report(scriptEntry, getName(), "There is no one to control the flight's path!");
Debug.echoDebug(scriptEntry, "There is no one to control the flight's path!");
}
return;
}
Expand All @@ -162,7 +162,7 @@ public void execute(final ScriptEntry scriptEntry) {
// Add the controller to the entity list
if (!found) {
if (scriptEntry.dbCallShouldDebug()) {
Debug.report(scriptEntry, getName(), "Adding controller " + controller + " to flying entities.");
Debug.echoDebug(scriptEntry, "Adding controller " + controller + " to flying entities.");
}
entities.add(0, controller);
}
Expand All @@ -172,13 +172,8 @@ public void execute(final ScriptEntry scriptEntry) {
final float rotationThreshold = ((ElementTag) scriptEntry.getObject("rotation_threshold")).asFloat();
boolean cancel = scriptEntry.hasObject("cancel");
if (scriptEntry.dbCallShouldDebug()) {
Debug.report(scriptEntry, getName(), (cancel ? db("cancel", cancel) : "") +
db("origin", origin) +
db("entities", entities.toString()) +
db("speed", speed) +
db("rotation threshold degrees", rotationThreshold) +
(freeflight ? db("controller", controller)
: db("destinations", destinations.toString())));
Debug.report(scriptEntry, getName(), (cancel ? db("cancel", true) : ""), origin, db("entities", entities),
db("speed", speed), db("rotation threshold degrees", rotationThreshold), (freeflight ? controller : db("destinations", destinations)));
}
if (!cancel) {
for (EntityTag entity : entities) {
Expand Down
Expand Up @@ -67,7 +67,7 @@ public void execute(ScriptEntry scriptEntry) {
ElementTag skin = scriptEntry.getElement("skin");
MaterialTag material = scriptEntry.getObjectTag("material");
if (scriptEntry.dbCallShouldDebug()) {
Debug.report(scriptEntry, getName(), db("entities", entities.toString()), skin, material);
Debug.report(scriptEntry, getName(), db("entities", entities), skin, material);
}
ItemStack item = null;
if (skin != null) {
Expand Down
Expand Up @@ -117,7 +117,7 @@ public void execute(ScriptEntry scriptEntry) {
ElementTag heal = scriptEntry.getElement("heal");
List<EntityTag> targets = (List<EntityTag>) scriptEntry.getObject("target");
if (scriptEntry.dbCallShouldDebug()) {
Debug.report(scriptEntry, getName(), quantity, action, heal, db("target", targets.toString()));
Debug.report(scriptEntry, getName(), quantity, action, heal, db("target", targets));
}
if (quantity == null && action == null) {
Debug.echoError(scriptEntry.getResidingQueue(), "Null quantity!");
Expand Down
Expand Up @@ -114,7 +114,7 @@ else if (holderObject instanceof LocationTag) {
}
boolean cancel = scriptEntry.hasObject("cancel");
if (scriptEntry.dbCallShouldDebug()) {
Debug.report(scriptEntry, getName(), (cancel ? db("cancel", "true") : ""), db("entities", entities.toString()), (holder != null ? db("holder", holder) : db("holder", holderLoc)));
Debug.report(scriptEntry, getName(), (cancel ? db("cancel", "true") : ""), db("entities", entities), db("holder", holder), db("holder", holderLoc));
}
for (EntityTag entity : entities) {
if (entity.isSpawned() && entity.isLivingEntity()) {
Expand Down
Expand Up @@ -119,7 +119,7 @@ public void execute(ScriptEntry scriptEntry) {
ElementTag pitch = scriptEntry.getElement("pitch");
ElementTag cancel = scriptEntry.getElement("cancel");
if (scriptEntry.dbCallShouldDebug()) {
Debug.report(scriptEntry, getName(), cancel, loc, duration, yaw, pitch, db("entities", entities.toString()));
Debug.report(scriptEntry, getName(), cancel, loc, duration, yaw, pitch, db("entities", entities));
}
for (EntityTag entity : entities) {
if (entity.isSpawned()) {
Expand Down
Expand Up @@ -183,9 +183,7 @@ public void execute(final ScriptEntry scriptEntry) {
: null);
// TODO: Should this be checked in argument parsing?
if (destination == null) {
if (scriptEntry.dbCallShouldDebug()) {
Debug.report(scriptEntry, getName(), "No destination specified!");
}
Debug.echoError("No destination specified!");
scriptEntry.setFinished(true);
return;
}
Expand All @@ -198,7 +196,7 @@ public void execute(final ScriptEntry scriptEntry) {
ElementTag precision = scriptEntry.getElement("precision");
ElementTag ignore_collision = scriptEntry.getElement("ignore_collision");
if (scriptEntry.dbCallShouldDebug()) {
Debug.report(scriptEntry, getName(), db("origin", originEntity != null ? originEntity : originLocation), db("entities", entities.toString()),
Debug.report(scriptEntry, getName(), db("origin", originEntity != null ? originEntity : originLocation), db("entities", entities),
destination, speedElement, duration, script, force_along, precision, (no_rotate ? db("no_rotate", "true") : ""), (no_damage ? db("no_damage", "true") : ""),
ignore_collision, definitions);
}
Expand Down
Expand Up @@ -214,9 +214,7 @@ public void execute(final ScriptEntry scriptEntry) {
originLocation.getDirection().multiply(30))) : null));
// TODO: Same as PUSH -- is this the place to do this?
if (destination == null) {
if (scriptEntry.dbCallShouldDebug()) {
Debug.report(scriptEntry, getName(), "No destination specified!");
}
Debug.echoError("No destination specified!");
return;
}
final List<EntityTag> entities = (List<EntityTag>) scriptEntry.getObject("entities");
Expand Down
Expand Up @@ -117,7 +117,7 @@ public void execute(final ScriptEntry scriptEntry) {
ElementTag spread = scriptEntry.getElement("spread");
boolean persistent = scriptEntry.hasObject("persistent");
if (scriptEntry.dbCallShouldDebug()) {
Debug.report(scriptEntry, getName(), db("entities", entities.toString()), location, spread, target, (persistent ? db("persistent", "true") : ""));
Debug.report(scriptEntry, getName(), db("entities", entities), location, spread, target, (persistent ? db("persistent", "true") : ""));
}
// Keep a ListTag of entities that can be called using <entry[name].spawned_entities> later in the script queue
ListTag entityList = new ListTag();
Expand Down
Expand Up @@ -102,7 +102,7 @@ public void execute(final ScriptEntry scriptEntry) {
LocationTag location = scriptEntry.getObjectTag("location");
List<EntityTag> entities = (List<EntityTag>) scriptEntry.getObject("entities");
if (scriptEntry.dbCallShouldDebug()) {
Debug.report(scriptEntry, getName(), location, db("entities", entities.toString()));
Debug.report(scriptEntry, getName(), location, db("entities", entities));
}
for (EntityTag entity : entities) {
if (entity.isFake && entity.getWorld().equals(location.getWorld())) {
Expand Down
Expand Up @@ -166,7 +166,7 @@ public void execute(ScriptEntry scriptEntry) {
items = (List<ItemTag>) items_object;
}
if (scriptEntry.dbCallShouldDebug()) {
Debug.report(scriptEntry, getName(), db("Type", type.name()), inventory, quantity, unlimit_stack_size, (items != null ? db("Items", items) : ""), slot);
Debug.report(scriptEntry, getName(), db("Type", type.name()), inventory, quantity, unlimit_stack_size, db("Items", items), slot);
}
switch (type) {
case MONEY:
Expand Down
Expand Up @@ -265,7 +265,7 @@ public void execute(final ScriptEntry scriptEntry) {
DataAction flagAction = (DataAction) scriptEntry.getObject("flag_action");
TimeTag expiration = scriptEntry.getObjectTag("expiration");
if (scriptEntry.dbCallShouldDebug()) {
Debug.report(scriptEntry, getName(), db("actions", actions.toString()), destination, origin, mechanism, mechanismValue, flagAction, expiration, slot);
Debug.report(scriptEntry, getName(), db("actions", actions), destination, origin, mechanism, mechanismValue, flagAction, expiration, slot);
}
int slotId = SlotHelper.nameToIndexFor(slot.asString(), destination.getInventory().getHolder());
if (slotId < 0) {
Expand Down
Expand Up @@ -74,8 +74,7 @@ public void parseArgs(ScriptEntry scriptEntry) throws InvalidArgumentsException
public void execute(final ScriptEntry scriptEntry) {
List<NPCTag> npcs = (List<NPCTag>) scriptEntry.getObject("npcs");
if (scriptEntry.dbCallShouldDebug()) {
Debug.report(scriptEntry, getName(),
db("NPCs", npcs.toString()));
Debug.report(scriptEntry, getName(), db("NPCs", npcs));
}
for (NPCTag npc : npcs) {
if (npc.getCitizen().hasTrait(Spawned.class)) {
Expand Down
Expand Up @@ -102,8 +102,7 @@ public void execute(ScriptEntry scriptEntry) {
ElementTag idElement = scriptEntry.getElement("pose_id");
LocationTag pose_loc = scriptEntry.getObjectTag("pose_loc");
if (scriptEntry.dbCallShouldDebug()) {
Debug.report(scriptEntry, getName(), db("Target", target.toString()), (target == TargetType.PLAYER ? Utilities.getEntryPlayer(scriptEntry) : ""), npc,
db("Action", action.toString()), idElement, pose_loc);
Debug.report(scriptEntry, getName(), db("Target", target), (target == TargetType.PLAYER ? Utilities.getEntryPlayer(scriptEntry) : ""), npc, db("Action", action), idElement, pose_loc);
}
if (!npc.getCitizen().hasTrait(Poses.class)) {
npc.getCitizen().addTrait(Poses.class);
Expand Down
Expand Up @@ -121,11 +121,7 @@ public void execute(ScriptEntry scriptEntry) {
text = TagManager.tag(text, context);
}
if (scriptEntry.dbCallShouldDebug()) {
Debug.report(scriptEntry, getName(),
db("Message", text)
+ db("Targets", targets)
+ (formatObj != null ? formatObj.debug() : "")
+ (perPlayerObj != null ? perPlayerObj.debug() : ""));
Debug.report(scriptEntry, getName(), db("message", text), db("targets", targets), formatObj, perPlayerObj);
}
FormatScriptContainer format = formatObj == null ? null : (FormatScriptContainer) formatObj.getContainer();
for (PlayerTag player : targets) {
Expand Down
Expand Up @@ -205,13 +205,7 @@ public void execute(ScriptEntry scriptEntry) {
ElementTag y = scriptEntry.getElement("y");
ElementTag progressLength = scriptEntry.getElement("progress_length");
if (scriptEntry.dbCallShouldDebug()) {
Debug.report(scriptEntry, name, id.debug() + (parent != null ? parent.debug() : "")
+ (delete != null ? delete.debug() : "") + (grant != null ? grant.debug() : "")
+ (revoke != null ? revoke.debug() : "")
+ icon.debug() + title.debug() + description.debug()
+ (background != null ? background.debug() : "")
+ (progressLength != null ? progressLength.debug() : "")
+ frame.debug() + toast.debug() + announce.debug() + hidden.debug() + x.debug() + y.debug());
Debug.report(scriptEntry, name, id, parent, delete, grant, revoke, icon, title, description, background, progressLength, frame, toast, announce, hidden, x, y);
}
final AdvancementHelper advancementHelper = NMSHandler.getAdvancementHelper();
NamespacedKey key = new NamespacedKey(Denizen.getInstance(), id.asString());
Expand Down
Expand Up @@ -124,7 +124,7 @@ public void execute(ScriptEntry scriptEntry) {
ElementTag message = scriptEntry.getElement("message");
ElementTag chatRange = scriptEntry.getElement("range");
if (scriptEntry.dbCallShouldDebug()) {
Debug.report(scriptEntry, getName(), talkers.debug() + targets.debug() + message.debug() + chatRange.debug());
Debug.report(scriptEntry, getName(), talkers, targets, message, chatRange);
}
DenizenSpeechContext context = new DenizenSpeechContext(message.asString(), scriptEntry, chatRange.asDouble());
if (!targets.isEmpty()) {
Expand Down
Expand Up @@ -67,9 +67,7 @@ public void addCustomTabCompletions(String arg, Consumer<String> addOne) {

@Override
public void parseArgs(ScriptEntry scriptEntry) throws InvalidArgumentsException {

for (Argument arg : scriptEntry) {

if (!scriptEntry.hasObject("location")
&& arg.matchesArgumentType(LocationTag.class)) {
scriptEntry.addObject("location", arg.asType(LocationTag.class));
Expand All @@ -82,7 +80,6 @@ else if (!scriptEntry.hasObject("reset")
arg.reportUnhandled();
}
}

if (!scriptEntry.hasObject("location") && !scriptEntry.hasObject("reset")) {
throw new InvalidArgumentsException("Missing location argument!");
}
Expand All @@ -92,23 +89,19 @@ else if (!scriptEntry.hasObject("reset")

@Override
public void execute(ScriptEntry scriptEntry) {

LocationTag location = scriptEntry.getObjectTag("location");
ElementTag reset = scriptEntry.getElement("reset");
Player player = Utilities.getEntryPlayer(scriptEntry).getPlayerEntity();

if (scriptEntry.dbCallShouldDebug()) {
Debug.report(scriptEntry, getName(), (location != null ? location.debug() : "") + reset.debug());
Debug.report(scriptEntry, getName(), location, reset);
}

if (reset.asBoolean()) {
Location bed = player.getBedSpawnLocation();
player.setCompassTarget(bed != null ? bed : player.getWorld().getSpawnLocation());
}
else {
player.setCompassTarget(location);
}

}
}

Expand Up @@ -314,10 +314,7 @@ public void execute(ScriptEntry scriptEntry) {
ElementTag global = scriptEntry.getElement("global");
List<PlayerTag> players = (List<PlayerTag>) scriptEntry.getObject("players");
if (scriptEntry.dbCallShouldDebug()) {
Debug.report(scriptEntry, getName(), entity.debug()
+ (cancel != null ? cancel.debug() : as.debug())
+ (global != null ? global.debug() : "")
+ db("players", players));
Debug.report(scriptEntry, getName(), entity, cancel, as, global, db("players", players));
}
boolean isGlobal = global != null && global.asBoolean();
HashMap<UUID, TrackedDisguise> playerMap = disguises.get(entity.getUUID());
Expand Down
Expand Up @@ -115,9 +115,7 @@ public void execute(ScriptEntry scriptEntry) {
Boolean level = (Boolean) scriptEntry.getObject("level");
//Boolean silent = (Boolean) scriptEntry.getObject("silent");
if (scriptEntry.dbCallShouldDebug()) {
Debug.report(scriptEntry, name, db("Type", type.toString())
+ db("Quantity", level ? quantity + " levels" : quantity)
+ db("Player", Utilities.getEntryPlayer(scriptEntry).getName()));
Debug.report(scriptEntry, name, db("type", type.toString()), db("quantity", level ? quantity + " levels" : quantity), db("player", Utilities.getEntryPlayer(scriptEntry)));
}
Player player = Utilities.getEntryPlayer(scriptEntry).getPlayerEntity();
switch (type) {
Expand Down
Expand Up @@ -114,9 +114,7 @@ public void execute(ScriptEntry scriptEntry) {
DurationTag duration = scriptEntry.getObjectTag("duration");
ElementTag cancel = scriptEntry.getElement("cancel");
if (scriptEntry.dbCallShouldDebug()) {
Debug.report(scriptEntry, getName(), entity.debug()
+ (cancel != null ? cancel.debug() : location.debug() + duration.debug())
+ db("players", players));
Debug.report(scriptEntry, getName(), entity, cancel, location, duration, db("players", players));
}
if (cancel != null && cancel.asBoolean()) {
if (entity.isFake) {
Expand Down

0 comments on commit a92f314

Please sign in to comment.