Skip to content

Commit

Permalink
Add <&bs> - backslash tag
Browse files Browse the repository at this point in the history
I had to rewrite a bitttt of the character escaping to allow this to
work, but it seems to all be fine. Also fixed a tiny mislabeled tag
meta.
  • Loading branch information
mcmonkey4eva committed Nov 26, 2013
1 parent 3281494 commit 54064e4
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 6 deletions.
4 changes: 2 additions & 2 deletions src/main/java/net/aufdemrand/denizen/objects/dLocation.java
Expand Up @@ -400,9 +400,9 @@ public String getAttribute(Attribute attribute) {

// <--[tag]
// @attribute <l@location.material>
// @returns Element
// @returns dMaterial
// @description
// Returns the Bukkit material name of the block at the location.
// Returns the material of the block at the location.
// -->
if (attribute.startsWith("material"))
return dMaterial.getMaterialFrom(getBlock().getType(), getBlock().getData()).getAttribute(attribute.fulfill(1));
Expand Down
7 changes: 3 additions & 4 deletions src/main/java/net/aufdemrand/denizen/tags/TagManager.java
Expand Up @@ -106,11 +106,12 @@ public static String tag(dPlayer player, dNPC npc, String arg, boolean instant,
// confirm there are/is a replaceable TAG(s), if not, return the arg.
if (arg.indexOf('>') == -1 || arg.length() < 3) return arg;

if (!instant) arg = arg.replace("\\<", String.valueOf((char)0x01)).replace("\\>", String.valueOf((char)0x02));

// Find location of the first tag
int[] positions = locateTag(arg);
if (positions == null) {
// Un-escape \<, \>
if (!instant) arg = arg.replace("\\<", "<").replace("\\>", ">");
arg = arg.replace((char)0x01, '<').replace((char)0x02, '>').replace(dList.internal_escape, "|");
return arg;
}

Expand Down Expand Up @@ -142,8 +143,6 @@ public static String tag(dPlayer player, dNPC npc, String arg, boolean instant,
// Return argument with replacements
arg = arg.replace((char)0x01, '<').replace((char)0x02, '>').replace(dList.internal_escape, "|");

// Un-escape \< \>'s
if (!instant) arg = arg.replace("\\<", "<").replace("\\>", ">");
return arg;
}

Expand Down
9 changes: 9 additions & 0 deletions src/main/java/net/aufdemrand/denizen/tags/core/TextTags.java
Expand Up @@ -540,6 +540,15 @@ else if (event.getName().equalsIgnoreCase("&lt"))
else if (event.getName().equalsIgnoreCase("&gt"))
event.setReplaced(new Element(String.valueOf((char)0x02)).getAttribute(attribute.fulfill(1)));

// <--[tag]
// @attribute <&bs>
// @returns Element
// @description
// Returns a backslash symbol: \
// -->
else if (event.getName().equalsIgnoreCase("&bs"))
event.setReplaced(new Element("\\").getAttribute(attribute.fulfill(1)));

}

}

0 comments on commit 54064e4

Please sign in to comment.