Skip to content

Commit

Permalink
(Automated Change): mass debug report pre-check
Browse files Browse the repository at this point in the history
+ some auto reformats
  • Loading branch information
mcmonkey4eva committed Oct 5, 2018
1 parent c497b69 commit afe8d48
Show file tree
Hide file tree
Showing 117 changed files with 902 additions and 536 deletions.
Expand Up @@ -245,7 +245,7 @@ public void onEntityDeath(EntityDeathEvent event) {
}
}
else if (livingEntity.getKiller() != null) {
damager = new dEntity(livingEntity.getKiller()).getDenizenObject();
damager = new dEntity(livingEntity.getKiller()).getDenizenObject();
}

}
Expand Down
Expand Up @@ -99,7 +99,7 @@ else if (dScript.matches(determination)) {
bookMeta = (BookMeta) dBook.getItemStack().getItemMeta();
// TODO: 1.13 - better method?
if (NMSHandler.getVersion().isAtLeast(NMSVersion.v1_13_R2) ? dBook.getMaterial().getMaterial() == Material.WRITABLE_BOOK
: dBook.getMaterial().getMaterial() == Material.valueOf("BOOK_AND_QUILL")) {
: dBook.getMaterial().getMaterial() == Material.valueOf("BOOK_AND_QUILL")) {
signing = Element.FALSE;
}
}
Expand Down
Expand Up @@ -144,45 +144,45 @@ private static Material[] combine(Material[] first, Material... second) {
static {
if (NMSHandler.getVersion().isAtLeast(NMSVersion.v1_13_R2)) {
COBWEB = Material.COBWEB;
WATER = new Material[] { Material.WATER };
LAVA = new Material[] { Material.LAVA };
REPEATER = new Material[] { Material.REPEATER };
FENCE_GATE = new Material[] { Material.ACACIA_FENCE_GATE, Material.BIRCH_FENCE_GATE,
WATER = new Material[]{Material.WATER};
LAVA = new Material[]{Material.LAVA};
REPEATER = new Material[]{Material.REPEATER};
FENCE_GATE = new Material[]{Material.ACACIA_FENCE_GATE, Material.BIRCH_FENCE_GATE,
Material.DARK_OAK_FENCE_GATE, Material.JUNGLE_FENCE_GATE,
Material.OAK_FENCE_GATE, Material.SPRUCE_FENCE_GATE };
Material.OAK_FENCE_GATE, Material.SPRUCE_FENCE_GATE};
TALL_GRASS = Material.TALL_GRASS;
REDSTONE_TORCH = new Material[] { Material.REDSTONE_TORCH };
CARPET = new Material[] { Material.BLACK_CARPET, Material.BLUE_CARPET, Material.BROWN_CARPET,
REDSTONE_TORCH = new Material[]{Material.REDSTONE_TORCH};
CARPET = new Material[]{Material.BLACK_CARPET, Material.BLUE_CARPET, Material.BROWN_CARPET,
Material.CYAN_CARPET, Material.GRAY_CARPET, Material.GREEN_CARPET, Material.LIME_CARPET,
Material.LIGHT_BLUE_CARPET, Material.LIGHT_GRAY_CARPET, Material.MAGENTA_CARPET,
Material.ORANGE_CARPET, Material.PINK_CARPET, Material.PURPLE_CARPET, Material.RED_CARPET,
Material.WHITE_CARPET, Material.YELLOW_CARPET };
Material.WHITE_CARPET, Material.YELLOW_CARPET};
ROSE_RED = Material.ROSE_RED;
RAIL = Material.RAIL;
WOOD_BUTTON = new Material[] { Material.ACACIA_BUTTON, Material.BIRCH_BUTTON,
WOOD_BUTTON = new Material[]{Material.ACACIA_BUTTON, Material.BIRCH_BUTTON,
Material.DARK_OAK_BUTTON, Material.JUNGLE_BUTTON,
Material.OAK_BUTTON, Material.SPRUCE_BUTTON };
WOODEN_DOOR = new Material[] { Material.ACACIA_DOOR, Material.BIRCH_DOOR,
Material.OAK_BUTTON, Material.SPRUCE_BUTTON};
WOODEN_DOOR = new Material[]{Material.ACACIA_DOOR, Material.BIRCH_DOOR,
Material.DARK_OAK_DOOR, Material.JUNGLE_DOOR,
Material.OAK_DOOR, Material.SPRUCE_DOOR };
Material.OAK_DOOR, Material.SPRUCE_DOOR};
SUGAR_CANE = Material.SUGAR_CANE;
SIGN = new Material[] { Material.SIGN, Material.WALL_SIGN };
SIGN = new Material[]{Material.SIGN, Material.WALL_SIGN};
}
else {
COBWEB = Material.valueOf("WEB");
WATER = new Material[] { Material.valueOf("WATER"), Material.valueOf("STATIONARY_WATER") };
LAVA = new Material[] { Material.valueOf("LAVA"), Material.valueOf("STATIONARY_LAVA") };
REPEATER = new Material[] { Material.valueOf("DIODE"), Material.valueOf("DIODE_BLOCK_OFF"), Material.valueOf("DIODE_BLOCK_ON") };
FENCE_GATE = new Material[] { Material.valueOf("FENCE_GATE") };
WATER = new Material[]{Material.valueOf("WATER"), Material.valueOf("STATIONARY_WATER")};
LAVA = new Material[]{Material.valueOf("LAVA"), Material.valueOf("STATIONARY_LAVA")};
REPEATER = new Material[]{Material.valueOf("DIODE"), Material.valueOf("DIODE_BLOCK_OFF"), Material.valueOf("DIODE_BLOCK_ON")};
FENCE_GATE = new Material[]{Material.valueOf("FENCE_GATE")};
TALL_GRASS = Material.valueOf("LONG_GRASS");
REDSTONE_TORCH = new Material[] { Material.valueOf("REDSTONE_TORCH_ON"), Material.valueOf("REDSTONE_TORCH_OFF") };
CARPET = new Material[] { Material.valueOf("CARPET") };
REDSTONE_TORCH = new Material[]{Material.valueOf("REDSTONE_TORCH_ON"), Material.valueOf("REDSTONE_TORCH_OFF")};
CARPET = new Material[]{Material.valueOf("CARPET")};
ROSE_RED = Material.valueOf("RED_ROSE");
RAIL = Material.valueOf("RAILS");
WOOD_BUTTON = new Material[] { Material.valueOf("WOOD_BUTTON") };
WOODEN_DOOR = new Material[] { Material.valueOf("WOODEN_DOOR") };
WOOD_BUTTON = new Material[]{Material.valueOf("WOOD_BUTTON")};
WOODEN_DOOR = new Material[]{Material.valueOf("WOODEN_DOOR")};
SUGAR_CANE = Material.valueOf("SUGAR_CANE_BLOCK");
SIGN = new Material[] { Material.valueOf("SIGN_POST"), Material.valueOf("WALL_SIGN") };
SIGN = new Material[]{Material.valueOf("SIGN_POST"), Material.valueOf("WALL_SIGN")};
}
}

Expand Down
Expand Up @@ -33,11 +33,11 @@ private BukkitElementProperties(Element element) {
this.element = element;
}

public static final String[] handledAttribs = new String[] {
public static final String[] handledAttribs = new String[]{
"aschunk", "as_chunk", "ascolor", "as_color", "ascuboid", "as_cuboid", "asentity", "as_entity",
"asinventory", "as_inventory", "asitem", "as_item", "aslocation", "as_location", "asmaterial",
"as_material", "asnpc", "as_npc", "asplayer", "as_player", "asworld", "as_world", "asplugin",
"as_plugin", "last_color", "format", "strip_color", "parse_color", "to_itemscript_hash" };
"as_plugin", "last_color", "format", "strip_color", "parse_color", "to_itemscript_hash"};

Element element;

Expand Down
Expand Up @@ -23,9 +23,9 @@ public static boolean describes(dObject item) {
|| ((dItem) item).getItemStack().getType() == Material.LEATHER_HELMET
|| ((dItem) item).getItemStack().getType() == Material.LEATHER_LEGGINGS
|| (NMSHandler.getVersion().isAtLeast(NMSVersion.v1_9_R2)
&& (((dItem) item).getItemStack().getType() == Material.POTION
|| ((dItem) item).getItemStack().getType() == Material.SPLASH_POTION
|| ((dItem) item).getItemStack().getType() == Material.LINGERING_POTION)));
&& (((dItem) item).getItemStack().getType() == Material.POTION
|| ((dItem) item).getItemStack().getType() == Material.SPLASH_POTION
|| ((dItem) item).getItemStack().getType() == Material.LINGERING_POTION)));
}

public static ItemColor getFrom(dObject _item) {
Expand Down Expand Up @@ -119,10 +119,10 @@ public void adjust(Mechanism mechanism) {
&& (mat == Material.POTION
|| mat == Material.LINGERING_POTION
|| mat == Material.SPLASH_POTION)) {
PotionMeta meta = (PotionMeta) item.getItemStack().getItemMeta();
meta.setColor(color.getColor());
item.getItemStack().setItemMeta(meta);
return;
PotionMeta meta = (PotionMeta) item.getItemStack().getItemMeta();
meta.setColor(color.getColor());
item.getItemStack().setItemMeta(meta);
return;
}
LeatherArmorMeta meta = (LeatherArmorMeta) item.getItemStack().getItemMeta();
meta.setColor(color.getColor());
Expand Down
Expand Up @@ -52,10 +52,14 @@ public void execute(ScriptEntry scriptEntry) throws CommandExecutionException {

dList objects = scriptEntry.getdObject("object");

dB.report(scriptEntry, getName(),
objects.debug()
+ mechanism.debug()
+ (value == null ? "" : value.debug()));
if (scriptEntry.dbCallShouldDebug()) {

dB.report(scriptEntry, getName(),
objects.debug()
+ mechanism.debug()
+ (value == null ? "" : value.debug()));

}

dList result = new dList();

Expand Down
Expand Up @@ -74,10 +74,12 @@ public void execute(ScriptEntry scriptEntry) throws CommandExecutionException {
(Type) scriptEntry.getObject("type") : Type.PLAYER);

// Report to dB
dB.report(scriptEntry, getName(), aH.debugObj("Type", type.name())
+ script.debug()
+ (type.name().equalsIgnoreCase("player") ? ((BukkitScriptEntryData) scriptEntry.entryData).getPlayer().debug() : "")
+ duration.debug());
if (scriptEntry.dbCallShouldDebug()) {
dB.report(scriptEntry, getName(), aH.debugObj("Type", type.name())
+ script.debug()
+ (type.name().equalsIgnoreCase("player") ? ((BukkitScriptEntryData) scriptEntry.entryData).getPlayer().debug() : "")
+ duration.debug());
}

// Perform cooldown
switch (type) {
Expand Down
Expand Up @@ -49,7 +49,11 @@ public void execute(ScriptEntry scriptEntry) throws CommandExecutionException {
dList events = (dList) scriptEntry.getObject("events");
dList context = (dList) scriptEntry.getObject("context");

dB.report(scriptEntry, getName(), events.debug() + context.debug());
if (scriptEntry.dbCallShouldDebug()) {

dB.report(scriptEntry, getName(), events.debug() + context.debug());

}

if (context.size() % 2 == 1) { // Size is uneven!
context.add("null");
Expand Down
Expand Up @@ -64,8 +64,10 @@ public void execute(ScriptEntry scriptEntry) throws CommandExecutionException {
dPlayer player = (dPlayer) scriptEntry.getObject("player");

// Report to dB
dB.report(scriptEntry, getName(),
player.debug() + script.debug());
if (scriptEntry.dbCallShouldDebug()) {
dB.report(scriptEntry, getName(),
player.debug() + script.debug());
}

dB.echoError(scriptEntry.getResidingQueue(), "The Fail command is outdated, use flags intead!");

Expand Down
Expand Up @@ -56,7 +56,11 @@ public void execute(final ScriptEntry scriptEntry) throws CommandExecutionExcept
Element destination = scriptEntry.getElement("destination");
Element overwrite = scriptEntry.getElement("overwrite");

dB.report(scriptEntry, getName(), origin.debug() + destination.debug() + overwrite.debug());
if (scriptEntry.dbCallShouldDebug()) {

dB.report(scriptEntry, getName(), origin.debug() + destination.debug() + overwrite.debug());

}

if (!Settings.allowFilecopy()) {
dB.echoError(scriptEntry.getResidingQueue(), "File copy disabled by server administrator.");
Expand Down
Expand Up @@ -64,8 +64,10 @@ public void execute(ScriptEntry scriptEntry) throws CommandExecutionException {
dPlayer player = (dPlayer) scriptEntry.getObject("player");

// Report to dB
dB.report(scriptEntry, getName(),
player.debug() + script.debug());
if (scriptEntry.dbCallShouldDebug()) {
dB.report(scriptEntry, getName(),
player.debug() + script.debug());
}

dB.echoError(scriptEntry.getResidingQueue(), "Finish is outdated, use flags instead!");

Expand Down
Expand Up @@ -218,11 +218,13 @@ public void execute(ScriptEntry scriptEntry) throws CommandExecutionException {
}

// Send information to debugger
dB.report(scriptEntry, getName(),
name.debug() + (index > 0 ? aH.debugObj("Index", String.valueOf(index)) : "")
+ aH.debugUniqueObj("Action/Value", action.toString(), (value != null ? value.asString() : "null"))
+ (duration != null ? duration.debug() : "")
+ flag_target.debug());
if (scriptEntry.dbCallShouldDebug()) {
dB.report(scriptEntry, getName(),
name.debug() + (index > 0 ? aH.debugObj("Index", String.valueOf(index)) : "")
+ aH.debugUniqueObj("Action/Value", action.toString(), (value != null ? value.asString() : "null"))
+ (duration != null ? duration.debug() : "")
+ flag_target.debug());
}

Flag flag;

Expand Down
Expand Up @@ -142,11 +142,15 @@ else if (!scriptEntry.hasObject("path")) {
@Override
public void execute(ScriptEntry scriptEntry) throws CommandExecutionException {

dB.report(scriptEntry, getName(),
(scriptEntry.hasObject("script") ? scriptEntry.getdObject("script").debug() : scriptEntry.getScript().debug())
+ (scriptEntry.hasObject("instant") ? scriptEntry.getdObject("instant").debug() : "")
+ (scriptEntry.hasObject("path") ? scriptEntry.getElement("path").debug() : "")
+ (scriptEntry.hasObject("local") ? scriptEntry.getElement("local").debug() : ""));
if (scriptEntry.dbCallShouldDebug()) {

dB.report(scriptEntry, getName(),
(scriptEntry.hasObject("script") ? scriptEntry.getdObject("script").debug() : scriptEntry.getScript().debug())
+ (scriptEntry.hasObject("instant") ? scriptEntry.getdObject("instant").debug() : "")
+ (scriptEntry.hasObject("path") ? scriptEntry.getElement("path").debug() : "")
+ (scriptEntry.hasObject("local") ? scriptEntry.getElement("local").debug() : ""));

}

// Get the script
dScript script = scriptEntry.getdObject("script");
Expand Down
Expand Up @@ -65,8 +65,12 @@ public void execute(ScriptEntry scriptEntry) throws CommandExecutionException {
Element fileName = scriptEntry.getElement("file");
Element typeElement = scriptEntry.getElement("type");

dB.report(scriptEntry, getName(),
message.debug() + fileName.debug() + typeElement.debug());
if (scriptEntry.dbCallShouldDebug()) {

dB.report(scriptEntry, getName(),
message.debug() + fileName.debug() + typeElement.debug());

}

Type type = Type.valueOf(typeElement.asString().toUpperCase());

Expand Down
Expand Up @@ -54,7 +54,11 @@ public void execute(ScriptEntry scriptEntry) throws CommandExecutionException {
Element id = scriptEntry.getElement("id");
Element remove = scriptEntry.getElement("remove");

dB.report(scriptEntry, getName(), aH.debugObj("object", object) + id.debug() + remove.debug());
if (scriptEntry.dbCallShouldDebug()) {

dB.report(scriptEntry, getName(), aH.debugObj("object", object) + id.debug() + remove.debug());

}

if (remove.asBoolean()) {
if (NotableManager.isSaved(id.asString())) {
Expand Down
Expand Up @@ -65,9 +65,11 @@ public void execute(ScriptEntry scriptEntry) throws CommandExecutionException {
Duration delay = (Duration) scriptEntry.getObject("delay");

// Debugger
dB.report(scriptEntry, getName(), queue.debug()
+ aH.debugObj("Action", action.toString())
+ (action == Action.DELAY ? delay.debug() : ""));
if (scriptEntry.dbCallShouldDebug()) {
dB.report(scriptEntry, getName(), queue.debug()
+ aH.debugObj("Action", action.toString())
+ (action == Action.DELAY ? delay.debug() : ""));
}

switch (action) {

Expand Down
Expand Up @@ -90,7 +90,11 @@ public void execute(ScriptEntry scriptEntry) throws CommandExecutionException {
scriptEntry.addObject("possibilities", new Element(possibilities));
scriptEntry.addObject("selected", new Element(selected));

dB.report(scriptEntry, getName(), aH.debugObj("possibilities", possibilities) + aH.debugObj("choice", selected + 1));
if (scriptEntry.dbCallShouldDebug()) {

dB.report(scriptEntry, getName(), aH.debugObj("possibilities", possibilities) + aH.debugObj("choice", selected + 1));

}

scriptEntry.setInstant(true);

Expand Down
Expand Up @@ -75,7 +75,9 @@ public void execute(ScriptEntry scriptEntry) throws CommandExecutionException {

if (stop != null && stop.asBoolean()) {
// Report to dB
dB.report(scriptEntry, getName(), stop.debug());
if (scriptEntry.dbCallShouldDebug()) {
dB.report(scriptEntry, getName(), stop.debug());
}
boolean hasnext = false;
for (int i = 0; i < scriptEntry.getResidingQueue().getQueueSize(); i++) {
ScriptEntry entry = scriptEntry.getResidingQueue().getEntry(i);
Expand Down Expand Up @@ -103,7 +105,9 @@ public void execute(ScriptEntry scriptEntry) throws CommandExecutionException {
}
else if (next != null && next.asBoolean()) {
// Report to dB
dB.report(scriptEntry, getName(), next.debug());
if (scriptEntry.dbCallShouldDebug()) {
dB.report(scriptEntry, getName(), next.debug());
}
boolean hasnext = false;
for (int i = 0; i < scriptEntry.getResidingQueue().getQueueSize(); i++) {
ScriptEntry entry = scriptEntry.getResidingQueue().getEntry(i);
Expand Down Expand Up @@ -178,7 +182,9 @@ else if (callback != null && callback.asBoolean()) {
}

// Report to dB
dB.report(scriptEntry, getName(), quantity.debug());
if (scriptEntry.dbCallShouldDebug()) {
dB.report(scriptEntry, getName(), quantity.debug());
}

int target = quantity.asInt();
if (target <= 0) {
Expand Down
Expand Up @@ -78,10 +78,14 @@ public void execute(ScriptEntry scriptEntry) throws CommandExecutionException {
Type type = (Type) scriptEntry.getObject("type");
dScript script = scriptEntry.getdObject("script");

dB.report(scriptEntry, getName(),
(players != null ? players.debug() : "")
+ aH.debugObj("type", type)
+ (script != null ? script.debug() : ""));
if (scriptEntry.dbCallShouldDebug()) {

dB.report(scriptEntry, getName(),
(players != null ? players.debug() : "")
+ aH.debugObj("type", type)
+ (script != null ? script.debug() : ""));

}

// Deal with GLOBAL_COOLDOWN reset first, since there's no player/players involved
if (type == Type.GLOBAL_COOLDOWN) {
Expand Down

0 comments on commit afe8d48

Please sign in to comment.