Skip to content

Commit

Permalink
Fix permission.global and group.global, add has_permission and in_gro…
Browse files Browse the repository at this point in the history
…up aliases. Add dPlayer tag 'selected_npc' to return the NPC currently selected with /npc sel.
  • Loading branch information
aufdemrand committed Jul 2, 2013
1 parent b375d7c commit 352dc76
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions src/main/java/net/aufdemrand/denizen/objects/dPlayer.java
Expand Up @@ -317,7 +317,8 @@ else if ((float) getPlayerEntity().getFoodLevel() / maxHunger < 1)
return new Element(String.valueOf(getPlayerEntity().getFoodLevel()))
.getAttribute(attribute.fulfill(1));

if (attribute.startsWith("permission")) {
if (attribute.startsWith("permission")
|| attribute.startsWith("has_permission")) {
if (Depends.permissions == null) {
dB.echoError("No permission system loaded! Have you installed Vault and a compatible permissions plugin?");
return null;
Expand All @@ -326,7 +327,7 @@ else if ((float) getPlayerEntity().getFoodLevel() / maxHunger < 1)
String permission = attribute.getContext(1);

// Non-world specific permission
if (attribute.startsWith("permission.global"))
if (attribute.getAttribute(2).startsWith("global"))
return new Element(String.valueOf(Depends.permissions.has((World) null, player_name, permission)))
.getAttribute(attribute.fulfill(2));

Expand All @@ -346,7 +347,8 @@ else if ((float) getPlayerEntity().getFoodLevel() / maxHunger < 1)
else return null;
}

if (attribute.startsWith("group")) {
if (attribute.startsWith("group")
|| attribute.startsWith("in_group")) {
if (Depends.permissions == null) {
dB.echoError("No permission system loaded! Have you installed Vault and a compatible permissions plugin?");
return "null";
Expand All @@ -355,7 +357,7 @@ else if ((float) getPlayerEntity().getFoodLevel() / maxHunger < 1)
String group = attribute.getContext(1);

// Non-world specific permission
if (attribute.startsWith("group.global"))
if (attribute.getAttribute(2).startsWith("global"))
return new Element(String.valueOf(Depends.permissions.playerInGroup((World) null, player_name, group)))
.getAttribute(attribute.fulfill(2));

Expand Down Expand Up @@ -398,7 +400,7 @@ else if ((float) getPlayerEntity().getFoodLevel() / maxHunger < 1)

if (attribute.startsWith("selected_npc")) {
if (getPlayerEntity().hasMetadata("selected"))
return dNPC.valueOf(String.valueOf(getPlayerEntity().getMetadata("selected").get(0)))
return dNPC.valueOf(getPlayerEntity().getMetadata("selected").get(0).asString())
.getAttribute(attribute.fulfill(1));
else return "null";
}
Expand Down

0 comments on commit 352dc76

Please sign in to comment.