Skip to content

Commit

Permalink
Formatting.
Browse files Browse the repository at this point in the history
  • Loading branch information
aufdemrand committed Nov 7, 2013
1 parent a1f938c commit 0d046e8
Show file tree
Hide file tree
Showing 4 changed files with 146 additions and 158 deletions.
1 change: 0 additions & 1 deletion src/main/java/net/aufdemrand/denizen/tags/TagManager.java
Expand Up @@ -42,7 +42,6 @@ public void registerCoreTags() {
new UtilTags(denizen);
new ProcedureScriptTag(denizen);
new ContextTags(denizen);
new SpecialCharacterTags(denizen);
new TextTags(denizen);

// For compatibility
Expand Down
15 changes: 8 additions & 7 deletions src/main/java/net/aufdemrand/denizen/tags/core/ContextTags.java
Expand Up @@ -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);
Expand All @@ -88,8 +89,8 @@ public void contextTags(ReplaceableTagEvent event) {
Map<String, String> context = (HashMap<String, String>) entry.getObject("CONTEXT");
// Build IDs
Map<String, Integer> 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()))));
}
}

Expand Down

This file was deleted.

138 changes: 138 additions & 0 deletions src/main/java/net/aufdemrand/denizen/tags/core/TextTags.java
Expand Up @@ -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());
Expand Down Expand Up @@ -77,6 +78,7 @@ else if (event.getName().equals("&Uuml"))

}


// 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"};
Expand Down Expand Up @@ -389,6 +391,7 @@ else if (event.getName().equals("&Uuml"))
// Returns the ChatColor that resets the following characters to normal.
// -->


@EventHandler
public void colorTags(ReplaceableTagEvent event) {
Attribute attribute =
Expand All @@ -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 <&lt>
// @returns Element
// @description
// Returns a less than symbol: <
// -->
else if (event.getName().equalsIgnoreCase("&lt"))
event.setReplaced(new Element(String.valueOf((char)0x01)).getAttribute(attribute.fulfill(1)));

// <--[tag]
// @attribute <&gt>
// @returns Element
// @description
// Returns a greater than symbol: >
// -->
else if (event.getName().equalsIgnoreCase("&gt"))
event.setReplaced(new Element(String.valueOf((char)0x02)).getAttribute(attribute.fulfill(1)));

}

}

0 comments on commit 0d046e8

Please sign in to comment.