Skip to content

Commit

Permalink
move debugOverride to core and more refreshState usage
Browse files Browse the repository at this point in the history
  • Loading branch information
mcmonkey4eva committed Jun 23, 2022
1 parent 2b7419c commit 4729903
Show file tree
Hide file tree
Showing 9 changed files with 23 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -656,11 +656,12 @@ public String debuggable() {

@Override
public String identify() {
if (isUnique()) {
return "cu@" + noteName;
CuboidTag self = refreshState();
if (self.isUnique()) {
return "cu@" + self.noteName;
}
else {
return identifyFull();
return self.identifyFull();
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -346,11 +346,12 @@ public String getObjectType() {

@Override
public String identify() {
if (isUnique()) {
return "ellipsoid@" + noteName;
EllipsoidTag self = refreshState();
if (self.isUnique()) {
return "ellipsoid@" + self.noteName;
}
else {
return identifyFull();
return self.identifyFull();
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import com.denizenscript.denizencore.tags.Attribute;
import com.denizenscript.denizencore.tags.ObjectTagProcessor;
import com.denizenscript.denizencore.tags.TagContext;
import com.denizenscript.denizencore.utilities.CoreConfiguration;
import com.denizenscript.denizencore.utilities.CoreUtilities;
import org.bukkit.NamespacedKey;
import org.bukkit.enchantments.Enchantment;
Expand Down Expand Up @@ -77,7 +78,7 @@ public static EnchantmentTag valueOf(String string, TagContext context) {
ench = ScriptRegistry.getScriptContainerAs(string, EnchantmentScriptContainer.class).enchantment;
}
if (ench == null) {
if (context == null || context.debug) {
if (context == null || context.debug || CoreConfiguration.debugOverride) {
Debug.echoError("Unknown enchantment '" + string + "'");
}
return null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,7 @@ else if (context == null || context.showErrors()) {
}
}
else {
if (context == null || context.debug) {
if (context == null || context.debug || CoreConfiguration.debugOverride) {
Debug.echoError("NPC '" + string + "' does not exist!");
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -475,11 +475,12 @@ public String debuggable() {

@Override
public String identify() {
if (isUnique()) {
return "polygon@" + noteName;
PolygonTag self = refreshState();
if (self.isUnique()) {
return "polygon@" + self.noteName;
}
else {
return identifyFull();
return self.identifyFull();
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import com.denizenscript.denizencore.objects.core.MapTag;
import com.denizenscript.denizencore.scripts.ScriptEntry;
import com.denizenscript.denizencore.tags.TagContext;
import com.denizenscript.denizencore.utilities.CoreConfiguration;
import com.denizenscript.denizencore.utilities.text.StringHolder;
import org.bukkit.Color;
import org.bukkit.entity.Entity;
Expand Down Expand Up @@ -75,7 +76,7 @@ else if (arg.object instanceof MapTag || (isElement && arg.getValue().startsWith
int slot = new ElementTag(entry.getKey().str).asInt();
ItemTag item = ItemTag.getItemFor(entry.getValue(), context);
if (item == null) {
if (context == null || context.debug) {
if (context == null || context.debug || CoreConfiguration.debugOverride) {
Debug.echoError("Not a valid item: '" + entry.getValue() + "'");
}
continue;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -151,8 +151,8 @@ public void debug(CommandContext args, CommandSender sender) throws CommandExcep
if (!Debug.showDebug) {
Debug.toggle();
}
Debug.debugOverride = !Debug.debugOverride;
Messaging.sendInfo(sender, (Debug.debugOverride ? "Denizen debugger is now overriding 'debug: false'."
CoreConfiguration.debugOverride = !CoreConfiguration.debugOverride;
Messaging.sendInfo(sender, (CoreConfiguration.debugOverride ? "Denizen debugger is now overriding 'debug: false'."
: "Denizen debugger override has been disabled."));
}
if (args.hasFlag('b')) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ public class Debug {
public static boolean showDebug = true;
public static boolean showStackTraces = true;
public static boolean showColor = true;
public static boolean debugOverride = false;
public static boolean showSources = false;

public static boolean shouldTrim = true;
Expand Down Expand Up @@ -408,7 +407,7 @@ private static String trimMessage(String message) {
}

public static boolean shouldDebug(Debuggable caller) {
if (debugOverride) {
if (CoreConfiguration.debugOverride) {
return true;
}
if (!showDebug) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import com.denizenscript.denizen.Denizen;
import com.denizenscript.denizencore.scripts.ScriptRegistry;
import com.denizenscript.denizencore.utilities.CoreConfiguration;
import com.denizenscript.denizencore.utilities.CoreUtilities;
import com.denizenscript.denizencore.utilities.Deprecations;
import org.bukkit.Bukkit;
Expand Down Expand Up @@ -69,7 +70,7 @@ public void run() {
in.close();
}
catch (Exception e) {
if (Debug.debugOverride) {
if (CoreConfiguration.debugOverride) {
Debug.echoError(e);
}
}
Expand All @@ -80,7 +81,7 @@ public void run() {
}
}
catch (Exception e) {
if (Debug.debugOverride) {
if (CoreConfiguration.debugOverride) {
Debug.echoError(e);
}
}
Expand Down

0 comments on commit 4729903

Please sign in to comment.