diff --git a/src/main/java/net/aufdemrand/denizen/tags/TagManager.java b/src/main/java/net/aufdemrand/denizen/tags/TagManager.java index d2c46359da..33fb3b6276 100644 --- a/src/main/java/net/aufdemrand/denizen/tags/TagManager.java +++ b/src/main/java/net/aufdemrand/denizen/tags/TagManager.java @@ -42,7 +42,6 @@ public void registerCoreTags() { new UtilTags(denizen); new ProcedureScriptTag(denizen); new ContextTags(denizen); - new SpecialCharacterTags(denizen); new TextTags(denizen); // For compatibility diff --git a/src/main/java/net/aufdemrand/denizen/tags/core/ContextTags.java b/src/main/java/net/aufdemrand/denizen/tags/core/ContextTags.java index 7b1f550b47..5fcc944c61 100644 --- a/src/main/java/net/aufdemrand/denizen/tags/core/ContextTags.java +++ b/src/main/java/net/aufdemrand/denizen/tags/core/ContextTags.java @@ -65,18 +65,19 @@ else if (type.equalsIgnoreCase("NAME")) { public void contextTags(ReplaceableTagEvent event) { if (!event.matches("context, c") || event.getScriptEntry() == null) return; - String type = event.getType(); + String object = event.getType(); // First, check queue object context. - if (event.getScriptEntry().getResidingQueue().hasContext(type)) { + if (event.getScriptEntry().getResidingQueue().hasContext(object)) { Attribute attribute = new Attribute(event.raw_tag, event.getScriptEntry()); - event.setReplaced(event.getScriptEntry().getResidingQueue().getContext(type).getAttribute(attribute.fulfill(2))); + event.setReplaced(event.getScriptEntry().getResidingQueue() + .getContext(object).getAttribute(attribute.fulfill(2))); } // Next, try to replace with task-script-defined context // NOTE: (DEPRECATED -- new RUN command uses definitions system instead) - if (!ScriptRegistry.containsScript(event.getScriptEntry().getScript().getName(), TaskScriptContainer.class)) - return; + if (!ScriptRegistry.containsScript(event.getScriptEntry().getScript().getName(), + TaskScriptContainer.class)) return; TaskScriptContainer script = ScriptRegistry.getScriptContainerAs( event.getScriptEntry().getScript().getName(), TaskScriptContainer.class); @@ -88,8 +89,8 @@ public void contextTags(ReplaceableTagEvent event) { Map context = (HashMap) entry.getObject("CONTEXT"); // Build IDs Map id = script.getContextMap(); - if (context.containsKey( String.valueOf(id.get(type.toUpperCase())))) { - event.setReplaced(context.get(String.valueOf(id.get(type.toUpperCase())))); + if (context.containsKey( String.valueOf(id.get(object.toUpperCase())))) { + event.setReplaced(context.get(String.valueOf(id.get(object.toUpperCase())))); } } diff --git a/src/main/java/net/aufdemrand/denizen/tags/core/SpecialCharacterTags.java b/src/main/java/net/aufdemrand/denizen/tags/core/SpecialCharacterTags.java deleted file mode 100644 index 1ce9fd38a1..0000000000 --- a/src/main/java/net/aufdemrand/denizen/tags/core/SpecialCharacterTags.java +++ /dev/null @@ -1,150 +0,0 @@ -package net.aufdemrand.denizen.tags.core; - -import net.aufdemrand.denizen.Denizen; -import net.aufdemrand.denizen.events.ReplaceableTagEvent; -import net.aufdemrand.denizen.objects.Element; -import net.aufdemrand.denizen.tags.Attribute; -import org.bukkit.event.EventHandler; -import org.bukkit.event.Listener; - -public class SpecialCharacterTags implements Listener { - - public SpecialCharacterTags(Denizen denizen) { - denizen.getServer().getPluginManager().registerEvents(this, denizen); - } - - @EventHandler - public void specialCharacterTags(ReplaceableTagEvent event) { - if (!event.getName().startsWith("&")) return; - Attribute attribute = - new Attribute(event.raw_tag, event.getScriptEntry()); - - // <--[tag] - // @attribute <&nl> - // @returns Element - // @description - // Returns a newline symbol. - // --> - if (event.getName().equalsIgnoreCase("&nl")) - event.setReplaced(new Element("\n").getAttribute(attribute.fulfill(1))); - - // <--[tag] - // @attribute <&cm> - // @returns Element - // @description - // Returns a comma symbol: , - // --> - else if (event.getName().equalsIgnoreCase("&cm")) - event.setReplaced(new Element(",").getAttribute(attribute.fulfill(1))); - - // <--[tag] - // @attribute <&ss> - // @returns Element - // @description - // Returns an internal coloring symbol: § - // --> - else if (event.getName().equalsIgnoreCase("&ss")) - event.setReplaced(new Element("§").getAttribute(attribute.fulfill(1))); - - // <--[tag] - // @attribute <&sq> - // @returns Element - // @description - // Returns a single-quote symbol: ' - // --> - else if (event.getName().equalsIgnoreCase("&sq")) - event.setReplaced(new Element("'").getAttribute(attribute.fulfill(1))); - - // <--[tag] - // @attribute <&dq> - // @returns Element - // @description - // Returns a double-quote symbol: " - // --> - else if (event.getName().equalsIgnoreCase("&dq")) - event.setReplaced(new Element("\"").getAttribute(attribute.fulfill(1))); - - // <--[tag] - // @attribute <&co> - // @returns Element - // @description - // Returns a colon symbol: : - // --> - else if (event.getName().equalsIgnoreCase("&co")) - event.setReplaced(new Element(":").getAttribute(attribute.fulfill(1))); - - // <--[tag] - // @attribute <&rb> - // @returns Element - // @description - // Returns a right-bracket symbol: ] - // --> - else if (event.getName().equalsIgnoreCase("&rb")) - event.setReplaced(new Element("]").getAttribute(attribute.fulfill(1))); - - // <--[tag] - // @attribute <&lb> - // @returns Element - // @description - // Returns a left-bracket symbol: [ - // --> - else if (event.getName().equalsIgnoreCase("&lb")) - event.setReplaced(new Element("[").getAttribute(attribute.fulfill(1))); - - // <--[tag] - // @attribute <&rc> - // @returns Element - // @description - // Returns a right-brace symbol: } - // --> - else if (event.getName().equalsIgnoreCase("&rc")) - event.setReplaced(new Element("}").getAttribute(attribute.fulfill(1))); - - // <--[tag] - // @attribute <&lc> - // @returns Element - // @description - // Returns a left-brace symbol: { - // --> - else if (event.getName().equalsIgnoreCase("&lc")) - event.setReplaced(new Element("{").getAttribute(attribute.fulfill(1))); - - // <--[tag] - // @attribute <&ns> - // @returns Element - // @description - // Returns a hash symbol: # - // --> - else if (event.getName().equalsIgnoreCase("&ns")) - event.setReplaced(new Element("#").getAttribute(attribute.fulfill(1))); - - // <--[tag] - // @attribute <&pc> - // @returns Element - // @description - // Returns a percent symbol: % - // --> - else if (event.getName().equalsIgnoreCase("&pc")) - event.setReplaced(new Element("%").getAttribute(attribute.fulfill(1))); - - // <--[tag] - // @attribute <<> - // @returns Element - // @description - // Returns a less than symbol: < - // --> - else if (event.getName().equalsIgnoreCase("<")) - event.setReplaced(new Element(String.valueOf((char)0x01)).getAttribute(attribute.fulfill(1))); - - // <--[tag] - // @attribute <>> - // @returns Element - // @description - // Returns a greater than symbol: > - // --> - else if (event.getName().equalsIgnoreCase(">")) - event.setReplaced(new Element(String.valueOf((char)0x02)).getAttribute(attribute.fulfill(1))); - - } - -} diff --git a/src/main/java/net/aufdemrand/denizen/tags/core/TextTags.java b/src/main/java/net/aufdemrand/denizen/tags/core/TextTags.java index 114eb09a47..8314bd8db2 100644 --- a/src/main/java/net/aufdemrand/denizen/tags/core/TextTags.java +++ b/src/main/java/net/aufdemrand/denizen/tags/core/TextTags.java @@ -17,6 +17,7 @@ public TextTags(Denizen denizen) { @EventHandler public void foreignCharacterTags(ReplaceableTagEvent event) { + if (!event.getName().startsWith("&")) return; Attribute attribute = new Attribute(event.raw_tag, event.getScriptEntry()); @@ -77,6 +78,7 @@ else if (event.getName().equals("Ü")) } + // Thanks geckon :) final String[] code = {"0","1","2","3","4","5","6","7","8","9" ,"a","b","c","d","e","f","k","l","m","n","o","r"}; @@ -389,6 +391,7 @@ else if (event.getName().equals("Ü")) // Returns the ChatColor that resets the following characters to normal. // --> + @EventHandler public void colorTags(ReplaceableTagEvent event) { Attribute attribute = @@ -404,4 +407,139 @@ else if (event.matches("&" + code[i])) } } + + @EventHandler + public void specialCharacterTags(ReplaceableTagEvent event) { + if (!event.getName().startsWith("&")) return; + Attribute attribute = + new Attribute(event.raw_tag, event.getScriptEntry()); + + // <--[tag] + // @attribute <&nl> + // @returns Element + // @description + // Returns a newline symbol. + // --> + if (event.getName().equalsIgnoreCase("&nl")) + event.setReplaced(new Element("\n").getAttribute(attribute.fulfill(1))); + + // <--[tag] + // @attribute <&cm> + // @returns Element + // @description + // Returns a comma symbol: , + // --> + else if (event.getName().equalsIgnoreCase("&cm")) + event.setReplaced(new Element(",").getAttribute(attribute.fulfill(1))); + + // <--[tag] + // @attribute <&ss> + // @returns Element + // @description + // Returns an internal coloring symbol: § + // --> + else if (event.getName().equalsIgnoreCase("&ss")) + event.setReplaced(new Element("§").getAttribute(attribute.fulfill(1))); + + // <--[tag] + // @attribute <&sq> + // @returns Element + // @description + // Returns a single-quote symbol: ' + // --> + else if (event.getName().equalsIgnoreCase("&sq")) + event.setReplaced(new Element("'").getAttribute(attribute.fulfill(1))); + + // <--[tag] + // @attribute <&dq> + // @returns Element + // @description + // Returns a double-quote symbol: " + // --> + else if (event.getName().equalsIgnoreCase("&dq")) + event.setReplaced(new Element("\"").getAttribute(attribute.fulfill(1))); + + // <--[tag] + // @attribute <&co> + // @returns Element + // @description + // Returns a colon symbol: : + // --> + else if (event.getName().equalsIgnoreCase("&co")) + event.setReplaced(new Element(":").getAttribute(attribute.fulfill(1))); + + // <--[tag] + // @attribute <&rb> + // @returns Element + // @description + // Returns a right-bracket symbol: ] + // --> + else if (event.getName().equalsIgnoreCase("&rb")) + event.setReplaced(new Element("]").getAttribute(attribute.fulfill(1))); + + // <--[tag] + // @attribute <&lb> + // @returns Element + // @description + // Returns a left-bracket symbol: [ + // --> + else if (event.getName().equalsIgnoreCase("&lb")) + event.setReplaced(new Element("[").getAttribute(attribute.fulfill(1))); + + // <--[tag] + // @attribute <&rc> + // @returns Element + // @description + // Returns a right-brace symbol: } + // --> + else if (event.getName().equalsIgnoreCase("&rc")) + event.setReplaced(new Element("}").getAttribute(attribute.fulfill(1))); + + // <--[tag] + // @attribute <&lc> + // @returns Element + // @description + // Returns a left-brace symbol: { + // --> + else if (event.getName().equalsIgnoreCase("&lc")) + event.setReplaced(new Element("{").getAttribute(attribute.fulfill(1))); + + // <--[tag] + // @attribute <&ns> + // @returns Element + // @description + // Returns a hash symbol: # + // --> + else if (event.getName().equalsIgnoreCase("&ns")) + event.setReplaced(new Element("#").getAttribute(attribute.fulfill(1))); + + // <--[tag] + // @attribute <&pc> + // @returns Element + // @description + // Returns a percent symbol: % + // --> + else if (event.getName().equalsIgnoreCase("&pc")) + event.setReplaced(new Element("%").getAttribute(attribute.fulfill(1))); + + // <--[tag] + // @attribute <<> + // @returns Element + // @description + // Returns a less than symbol: < + // --> + else if (event.getName().equalsIgnoreCase("<")) + event.setReplaced(new Element(String.valueOf((char)0x01)).getAttribute(attribute.fulfill(1))); + + // <--[tag] + // @attribute <>> + // @returns Element + // @description + // Returns a greater than symbol: > + // --> + else if (event.getName().equalsIgnoreCase(">")) + event.setReplaced(new Element(String.valueOf((char)0x02)).getAttribute(attribute.fulfill(1))); + + } + }