Skip to content

Commit

Permalink
Improve flag handling
Browse files Browse the repository at this point in the history
Don't return weirdly for non-existent flags.
  • Loading branch information
mcmonkey4eva committed Oct 6, 2014
1 parent a6a0311 commit a41e51c
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 12 deletions.
12 changes: 6 additions & 6 deletions src/main/java/net/aufdemrand/denizen/objects/dNPC.java
Expand Up @@ -527,17 +527,17 @@ && getCitizen().getTrait(Anchors.class).getAnchor(attribute.getContext(1)) != nu
String flag_name;
if (attribute.hasContext(1)) flag_name = attribute.getContext(1);
else return Element.NULL.getAttribute(attribute.fulfill(1));
attribute.fulfill(1);
if (attribute.startsWith("is_expired")
if (attribute.getAttribute(2).equalsIgnoreCase("is_expired")
|| attribute.startsWith("isexpired"))
return new Element(!FlagManager.npcHasFlag(this, flag_name))
.getAttribute(attribute.fulfill(1));
if (attribute.startsWith("size") && !FlagManager.npcHasFlag(this, flag_name))
return new Element(0).getAttribute(attribute.fulfill(1));
.getAttribute(attribute.fulfill(2));
if (attribute.getAttribute(2).equalsIgnoreCase("size") && !FlagManager.npcHasFlag(this, flag_name))
return new Element(0).getAttribute(attribute.fulfill(2));
if (FlagManager.npcHasFlag(this, flag_name))
return new dList(DenizenAPI.getCurrentInstance().flagManager()
.getNPCFlag(getId(), flag_name))
.getAttribute(attribute);
.getAttribute(attribute.fulfill(1));
return new Element(identify()).getAttribute(attribute);
}

// <--[tag]
Expand Down
12 changes: 6 additions & 6 deletions src/main/java/net/aufdemrand/denizen/objects/dPlayer.java
Expand Up @@ -552,17 +552,17 @@ public String getAttribute(Attribute attribute) {
String flag_name;
if (attribute.hasContext(1)) flag_name = attribute.getContext(1);
else return Element.NULL.getAttribute(attribute.fulfill(1));
attribute.fulfill(1);
if (attribute.startsWith("is_expired")
if (attribute.getAttribute(2).equalsIgnoreCase("is_expired")
|| attribute.startsWith("isexpired"))
return new Element(!FlagManager.playerHasFlag(this, flag_name))
.getAttribute(attribute.fulfill(1));
if (attribute.startsWith("size") && !FlagManager.playerHasFlag(this, flag_name))
return new Element(0).getAttribute(attribute.fulfill(1));
.getAttribute(attribute.fulfill(2));
if (attribute.getAttribute(2).equalsIgnoreCase("size") && !FlagManager.playerHasFlag(this, flag_name))
return new Element(0).getAttribute(attribute.fulfill(2));
if (FlagManager.playerHasFlag(this, flag_name))
return new dList(DenizenAPI.getCurrentInstance().flagManager()
.getPlayerFlag(this, flag_name))
.getAttribute(attribute);
.getAttribute(attribute.fulfill(1));
return new Element(identify()).getAttribute(attribute);
}

// <--[tag]
Expand Down

0 comments on commit a41e51c

Please sign in to comment.