Skip to content

Commit

Permalink
warn on some of the weirder tag shorthands
Browse files Browse the repository at this point in the history
  • Loading branch information
mcmonkey4eva committed Feb 3, 2019
1 parent ba9bb68 commit 47c9560
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 0 deletions.
Expand Up @@ -2,6 +2,7 @@

import net.aufdemrand.denizen.Denizen;
import net.aufdemrand.denizen.objects.dLocation;
import net.aufdemrand.denizen.utilities.debugging.dB;
import net.aufdemrand.denizencore.objects.TagRunnable;
import net.aufdemrand.denizencore.tags.Attribute;
import net.aufdemrand.denizencore.tags.ReplaceableTagEvent;
Expand All @@ -25,6 +26,11 @@ public void locationTags(ReplaceableTagEvent event) {
return;
}

if (event.matches("l")) {
dB.echoError(event.getScriptEntry() == null ? null : event.getScriptEntry().getResidingQueue(),
"Short-named tags are hard to read. Please use 'location' instead of 'l' as a root tag.");
}

// Stage the location
dLocation loc = null;

Expand Down
Expand Up @@ -76,6 +76,11 @@ public void playerTags(ReplaceableTagEvent event) {
return;
}

if (event.matches("pl")) {
dB.echoError(event.getScriptEntry() == null ? null : event.getScriptEntry().getResidingQueue(),
"Short-named tags are hard to read. Please use 'player' instead of 'pl' as a root tag.");
}

// Build a new attribute out of the raw_tag supplied in the script to be fulfilled
Attribute attribute = event.getAttributes();

Expand Down
Expand Up @@ -86,6 +86,10 @@ public void mathTag(ReplaceableTagEvent event) { // TODO: Core
if (!event.matches("math", "m")) {
return;
}
if (event.matches("l")) {
dB.echoError(event.getScriptEntry() == null ? null : event.getScriptEntry().getResidingQueue(),
"Short-named tags are hard to read. Please use 'math' instead of 'm' as a root tag.");
}
try {
Double evaluation = new DoubleEvaluator().evaluate(event.getValue());
event.setReplaced(new Element(String.valueOf(evaluation)).getAttribute(event.getAttributes().fulfill(1)));
Expand All @@ -110,6 +114,10 @@ public void ternaryTag(ReplaceableTagEvent event) { // TODO: Core
if (!event.matches("ternary", "tern", "t")) {
return;
}
if (event.matches("t")) {
dB.echoError(event.getScriptEntry() == null ? null : event.getScriptEntry().getResidingQueue(),
"Short-named tags are hard to read. Please use 'tern' instead of 't' as a root tag.");
}

// Fallback if nothing to evaluate
if (!event.hasNameContext()) {
Expand All @@ -129,6 +137,14 @@ public void serverTag(ReplaceableTagEvent event) {
if (!event.matches("server", "svr", "global") || event.replaced()) {
return;
}
if (event.matches("l")) {
dB.echoError(event.getScriptEntry() == null ? null : event.getScriptEntry().getResidingQueue(),
"Short-named tags are hard to read. Please use 'server' instead of 'svr' as a root tag.");
}
if (event.matches("global")) {
dB.echoError(event.getScriptEntry() == null ? null : event.getScriptEntry().getResidingQueue(),
"Using 'global' as a base tag is a deprecated alternate name. Please use 'server' instead.");
}
Attribute attribute = event.getAttributes().fulfill(1);

// <--[tag]
Expand Down

0 comments on commit 47c9560

Please sign in to comment.