Skip to content

Commit

Permalink
add helpful error message for objecttag usage
Browse files Browse the repository at this point in the history
  • Loading branch information
mcmonkey4eva committed Aug 19, 2019
1 parent 025be1b commit 8f1098a
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions src/main/java/com/denizenscript/denizencore/tags/TagManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import com.denizenscript.denizencore.objects.core.ElementTag;
import com.denizenscript.denizencore.objects.core.ListTag;
import com.denizenscript.denizencore.scripts.ScriptEntry;
import com.denizenscript.denizencore.scripts.queues.ScriptQueue;
import com.denizenscript.denizencore.tags.core.*;
import com.denizenscript.denizencore.utilities.CoreUtilities;
import com.denizenscript.denizencore.utilities.debugging.Debug;
Expand All @@ -22,6 +23,7 @@
import java.util.HashMap;
import java.util.List;
import java.util.concurrent.*;
import java.util.regex.Pattern;

public class TagManager {

Expand Down Expand Up @@ -388,13 +390,20 @@ public static ObjectTag readSingleTagObject(TagContext context, ReplaceableTagEv
DenizenCore.getImplementation().debugTagFill(context, event.toString(), event.getReplacedObj().debuggable());
}
if (!event.replaced()) {
Debug.echoError(context.entry != null ? context.entry.getResidingQueue() : null,
"Tag <" + event.toString() + "> is invalid!");
ScriptQueue queue = context.entry != null ? context.entry.getResidingQueue() : null;
String tagStr = "<" + event.toString() + ">";
Debug.echoError(queue, "Tag " + tagStr + " is invalid!");
if (OBJECTTAG_CONFUSION_PATTERN.matcher(tagStr).matches()) {
Debug.echoError(queue, "'ObjectTag' notation is for documentation purposes, and not to be used literally."
+ " An actual object must be inserted instead. If confused, join our Discord at https://discord.gg/Q6pZGSR to ask for help!");
}
return new ElementTag(event.raw_tag);
}
return event.getReplacedObj();
}

public static Pattern OBJECTTAG_CONFUSION_PATTERN = Pattern.compile("<\\w+tag[\\[.>].*", Pattern.CASE_INSENSITIVE);

static HashMap<String, List<ParseableTagPiece>> preCalced = new HashMap<>();

public static class ParseableTagPiece {
Expand Down

0 comments on commit 8f1098a

Please sign in to comment.