Skip to content

Commit

Permalink
Fix logic in Attribute to ignore periods (.) in brackets.
Browse files Browse the repository at this point in the history
  • Loading branch information
aufdemrand committed Apr 8, 2013
1 parent 84ba8cf commit 62c99de
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions src/main/java/net/aufdemrand/denizen/tags/Attribute.java
Expand Up @@ -4,6 +4,7 @@
import net.aufdemrand.denizen.scripts.ScriptEntry;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
Expand All @@ -20,21 +21,27 @@ public class Attribute {

ScriptEntry scriptEntry;

String raw_tag;

public ScriptEntry getScriptEntry() {
return scriptEntry;
}

public Attribute(String attributes, ScriptEntry scriptEntry) {

raw_tag = attributes;
this.scriptEntry = scriptEntry;

if (attributes == null) {
this.attributes = Collections.emptyList();
return;
}

Pattern attributer = Pattern.compile("[^\\[\\]\\.]+(\\[.*?\\])?");
List<String> matches = new ArrayList<String>();
Matcher matcher = attributer.matcher(attributes);

while (matcher.find()) {
while (matcher.find())
matches.add(matcher.group());
}

this.attributes = matches;
}
Expand Down Expand Up @@ -80,7 +87,7 @@ public int getIntContext(int attribute) {
return 0;
}

private String getAttribute(int num) {
public String getAttribute(int num) {
if (attributes.size() < num) return "";
else return attributes.get(num - 1);
}
Expand Down

0 comments on commit 62c99de

Please sign in to comment.