Skip to content

Commit

Permalink
Add region.members, .owners
Browse files Browse the repository at this point in the history
Also fix the region object in general
  • Loading branch information
mcmonkey4eva committed Oct 18, 2014
1 parent 4f3f415 commit a329265
Showing 1 changed file with 34 additions and 1 deletion.
Expand Up @@ -47,6 +47,7 @@ public static WorldGuardRegion valueOf(String string) {
+ "' for world '" + worldName + "'");
return null;
}
return new WorldGuardRegion(manager.getRegion(regionName), world);
}

return null;
Expand Down Expand Up @@ -151,6 +152,38 @@ public String getAttribute(Attribute attribute) {
return new Element(region.getId()).getAttribute(attribute.fulfill(1));
}

// <--[tag]
// @attribute <region@region.members>
// @returns dList(dPlayer)
// @description
// Gets a list of all members of a region. (Members are permitted to build, etc.)
// -->
if (attribute.startsWith("members")) {
dList list = new dList();
for (String str: region.getMembers().getPlayers()) {
dPlayer player = dPlayer.valueOf(str);
if (player != null)
list.add(player.identify());
}
return list.getAttribute(attribute.fulfill(1));
}

// <--[tag]
// @attribute <region@region.owners>
// @returns dList(dPlayer)
// @description
// Gets a list of all owners of a region. (Owners are permitted to build, edit settings, etc.)
// -->
if (attribute.startsWith("owners")) {
dList list = new dList();
for (String str: region.getOwners().getPlayers()) {
dPlayer player = dPlayer.valueOf(str);
if (player != null)
list.add(player.identify());
}
return list.getAttribute(attribute.fulfill(1));
}

// <--[tag]
// @attribute <region@region.world>
// @returns dWorld
Expand All @@ -161,7 +194,7 @@ public String getAttribute(Attribute attribute) {
return new dWorld(world).getAttribute(attribute.fulfill(1));
}

return new Element(identify()).getAttribute(attribute.fulfill(1));
return new Element(identify()).getAttribute(attribute);

}
}

0 comments on commit a329265

Please sign in to comment.