Skip to content

Commit

Permalink
debugging cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
mcmonkey4eva committed Nov 28, 2021
1 parent 051f7c0 commit 269c916
Show file tree
Hide file tree
Showing 11 changed files with 20 additions and 63 deletions.
Expand Up @@ -191,7 +191,6 @@ public void execute(ScriptEntry scriptEntry) {
ListTag value = null;
ElementTag increment = null;
ElementTag start = null;
String debug;
if (per_player) {
if (elTitle != null) {
perTitle = elTitle.asString();
Expand All @@ -208,11 +207,9 @@ public void execute(ScriptEntry scriptEntry) {
if (elStart != null) {
perStart = elStart.asString();
}
debug = scriptEntry.dbCallShouldDebug() ? ((elTitle != null ? elTitle.debug() : "") +
(elScores != null ? elScores.debug() : "") +
(elValue != null ? elValue.debug() : "") +
(elIncrement != null ? elIncrement.debug() : "") +
(elStart != null ? elStart.debug() : "")) : null;
if (scriptEntry.dbCallShouldDebug()) {
Debug.report(scriptEntry, getName(), action, elTitle, elScores, elValue, elIncrement, elStart, db("players", players));
}
}
else {
BukkitTagContext context = (BukkitTagContext) scriptEntry.getContext();
Expand All @@ -231,14 +228,9 @@ public void execute(ScriptEntry scriptEntry) {
if (elStart != null) {
start = new ElementTag(TagManager.tag(elStart.asString(), context));
}
debug = scriptEntry.dbCallShouldDebug() ? ((title != null ? title.debug() : "") +
(scores != null ? db("scores", scores) : "") +
(value != null ? db("value", value) : "") +
(increment != null ? increment.debug() : "") +
(start != null ? start.debug() : "")) : null;
}
if (scriptEntry.dbCallShouldDebug()) {
Debug.report(scriptEntry, getName(), action, debug, db("players", players));
if (scriptEntry.dbCallShouldDebug()) {
Debug.report(scriptEntry, getName(), action, title, scores, value, increment, start, db("players", players));
}
}
switch (Action.valueOf(action.asString())) {
case ADD:
Expand Down
Expand Up @@ -122,10 +122,7 @@ public void execute(ScriptEntry scriptEntry) {
ListTag chunklocs = scriptEntry.getObjectTag("location");
DurationTag length = scriptEntry.getObjectTag("duration");
if (scriptEntry.dbCallShouldDebug()) {
Debug.report(scriptEntry, getName(),
action.debug()
+ chunklocs.debug()
+ length.debug());
Debug.report(scriptEntry, getName(), action, chunklocs, length);
}
for (String chunkText : chunklocs) {
Chunk chunk;
Expand Down
Expand Up @@ -86,8 +86,7 @@ public void execute(ScriptEntry scriptEntry) {
LocationTag destination = scriptEntry.getObjectTag("destination");
ElementTag remove_original = scriptEntry.getElement("remove");
if (scriptEntry.dbCallShouldDebug()) {
Debug.report(scriptEntry, getName(), (copy_location != null ? copy_location.debug() : "")
+ destination.debug() + remove_original.debug());
Debug.report(scriptEntry, getName(), copy_location, destination, remove_original);
}
List<Location> locations = new ArrayList<>();
if (copy_location != null) {
Expand Down
Expand Up @@ -120,12 +120,7 @@ public void execute(ScriptEntry scriptEntry) {
ElementTag fire = scriptEntry.getElement("fire");
EntityTag source = scriptEntry.getObjectTag("source");
if (scriptEntry.dbCallShouldDebug()) {
Debug.report(scriptEntry, getName(),
location.debug() +
(source == null ? "" : source.debug()) +
power.debug() +
breakblocks.debug() +
fire.debug());
Debug.report(scriptEntry, getName(), location, source, power, breakblocks, fire);
}
location.getWorld().createExplosion(location, power.asFloat(), fire.asBoolean(), breakblocks.asBoolean(), source == null ? null : source.getBukkitEntity());
}
Expand Down
Expand Up @@ -75,7 +75,7 @@ public void execute(ScriptEntry scriptEntry) {
ElementTag gamerule = scriptEntry.getElement("gamerule");
ElementTag value = scriptEntry.getElement("value");
if (scriptEntry.dbCallShouldDebug()) {
Debug.report(scriptEntry, getName(), world.debug() + gamerule.debug() + value.debug());
Debug.report(scriptEntry, getName(), world, gamerule, value);
}
if (!world.getWorld().setGameRuleValue(gamerule.asString(), value.asString())) {
Debug.echoError(scriptEntry.getResidingQueue(), "Invalid gamerule!");
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 @@ -87,32 +85,23 @@ else if (!scriptEntry.hasObject("duration")
&& arg.matchesArgumentType(DurationTag.class)) {
scriptEntry.addObject("duration", arg.asType(DurationTag.class));
}

}

if (!scriptEntry.hasObject("location") ||
(!scriptEntry.hasObject("light") && !scriptEntry.hasObject("reset"))) {
throw new InvalidArgumentsException("Must specify a valid location and light level.");
}

scriptEntry.defaultObject("reset", new ElementTag(false));
}

@Override
public void execute(ScriptEntry scriptEntry) {

LocationTag location = scriptEntry.getObjectTag("location");
ElementTag light = scriptEntry.getElement("light");
ElementTag reset = scriptEntry.getElement("reset");
DurationTag duration = scriptEntry.getObjectTag("duration");

if (scriptEntry.dbCallShouldDebug()) {

Debug.report(scriptEntry, getName(), location.debug() + reset.debug()
+ (light != null ? light.debug() : "") + (duration != null ? duration.debug() : ""));

Debug.report(scriptEntry, getName(), location, reset, light, duration);
}

if (!Utilities.isLocationYSafe(location)) {
Debug.echoError(scriptEntry.getResidingQueue(), "Invalid light location!");
return;
Expand Down
Expand Up @@ -240,18 +240,8 @@ public void execute(final ScriptEntry scriptEntry) {
}
final List<MaterialTag> materialList = materials.filter(MaterialTag.class, scriptEntry);
if (scriptEntry.dbCallShouldDebug()) {
Debug.report(scriptEntry, getName(), materials.debug()
+ physics.debug()
+ radiusElement.debug()
+ heightElement.debug()
+ depthElement.debug()
+ (natural == null ? "" : natural.debug())
+ delayed.debug()
+ maxDelayMs.debug()
+ (script != null ? script.debug() : "")
+ (percents != null ? percents.debug() : "")
+ (source != null ? source.debug() : "")
+ (locations == null ? location_list.debug() : db("locations", locations)));
Debug.report(scriptEntry, getName(), materials, physics, radiusElement, heightElement, depthElement, natural,
delayed, maxDelayMs, script, percents, source, (locations == null ? location_list : db("locations", locations)));
}
Player sourcePlayer = source == null ? null : source.getPlayerEntity();
final boolean doPhysics = physics.asBoolean();
Expand Down
Expand Up @@ -224,7 +224,7 @@ public void execute(ScriptEntry scriptEntry) {
ElementTag special_data = scriptEntry.getElement("special_data");
LocationTag velocity = scriptEntry.getObjectTag("velocity");
if (scriptEntry.dbCallShouldDebug()) {
Debug.report(scriptEntry, getName(), (effect != null ? db("effect", effect.name()) : particleEffect != null ? db("special effect", particleEffect.getName()) : (iconcrack != null ? iconcrack.debug() : "")),
Debug.report(scriptEntry, getName(), (effect != null ? db("effect", effect.name()) : particleEffect != null ? db("special effect", particleEffect.getName()) : iconcrack),
db("locations", locations), db("targets", targets), radius, data, quantity, offset, special_data, velocity, (should_offset ? db("note", "Location will be offset 1 block-height upward (see documentation)") : ""));
}
for (LocationTag location : locations) {
Expand Down
Expand Up @@ -78,11 +78,9 @@ else if (arg.matches("no_damage") || arg.matches("nodamage")) {
@Override
public void execute(ScriptEntry scriptEntry) {
LocationTag location = scriptEntry.getObjectTag("location");
Boolean damage = scriptEntry.getElement("damage").asBoolean();
boolean damage = scriptEntry.getElement("damage").asBoolean();
if (scriptEntry.dbCallShouldDebug()) {
Debug.report(scriptEntry, getName(),
location.debug()
+ db("Damageable", String.valueOf(damage)));
Debug.report(scriptEntry, getName(), location, db("damage", damage));
}
if (damage) {
location.getWorld().strikeLightning(location);
Expand Down
Expand Up @@ -134,11 +134,7 @@ public void execute(ScriptEntry scriptEntry) {
ElementTag freeze = scriptEntry.getElement("freeze");
Type type = Type.valueOf(type_element.asString().toUpperCase());
if (scriptEntry.dbCallShouldDebug()) {
Debug.report(scriptEntry, getName(), type_element.debug()
+ (reset != null ? reset.debug() : value.debug())
+ (freeze != null ? freeze.debug() : "")
+ (resetAfter != null ? resetAfter.debug() : "")
+ world.debug());
Debug.report(scriptEntry, getName(), type_element, reset, value, freeze, resetAfter, world);
}
if (type.equals(Type.GLOBAL)) {
world.getWorld().setTime(value.getTicks());
Expand Down
Expand Up @@ -79,10 +79,11 @@ public static void report(Debuggable caller, String name, Object... values) {
continue;
}
if (obj instanceof ObjectTag) {
output.append(((ObjectTag) obj).debug());
ObjectTag objTag = (ObjectTag) obj;
output.append("<G>").append(objTag.getPrefix()).append("='<Y>").append(objTag.debuggable()).append("<G>' ");
}
else {
output.append(obj.toString());
output.append(obj);
}
}
echo("<Y>+> <G>Executing '<Y>" + name + "<G>': " + trimMessage(output.toString()), caller);
Expand Down

0 comments on commit 269c916

Please sign in to comment.