Added the ability to add owners/members to the global region for handling guest groups.

This commit is contained in:
sk89q 2011-06-27 10:11:23 -07:00
parent 3b871b9c00
commit 360a655627
2 changed files with 46 additions and 8 deletions

View File

@ -164,7 +164,13 @@ private boolean internalGetState(StateFlag flag, LocalPlayer player,
// The global region has this flag set // The global region has this flag set
if (globalState != null) { if (globalState != null) {
def = (globalState == State.ALLOW); // Special case for the build flag
if (player != null && globalRegion.hasMembersOrOwners()) {
def = globalRegion.isMember(player)
? (globalState == State.ALLOW) : false;
} else {
def = (globalState == State.ALLOW);
}
} }
} }

View File

@ -168,7 +168,6 @@ public void setOwners(DefaultDomain owners) {
* @return the members * @return the members
*/ */
public DefaultDomain getMembers() { public DefaultDomain getMembers() {
return members; return members;
} }
@ -179,11 +178,20 @@ public void setMembers(DefaultDomain members) {
this.members = members; this.members = members;
} }
/**
* Checks whether a region has members or owners.
*
* @return whether there are members or owners
*/
public boolean hasMembersOrOwners() {
return owners.size() > 0 || members.size() > 0;
}
/** /**
* Checks whether a player is an owner of region or any of its parents. * Checks whether a player is an owner of region or any of its parents.
* *
* @param player * @param player player to check
* @return * @return whether an owner
*/ */
public boolean isOwner(LocalPlayer player) { public boolean isOwner(LocalPlayer player) {
if (owners.contains(player)) { if (owners.contains(player)) {
@ -202,12 +210,12 @@ public boolean isOwner(LocalPlayer player) {
return false; return false;
} }
/** /**
* Checks whether a player is a member of the region or any of its parents. * Checks whether a player is a member OR OWNER of the region
* or any of its parents.
* *
* @param player * @param player player to check
* @return * @return whether an owner or member
*/ */
public boolean isMember(LocalPlayer player) { public boolean isMember(LocalPlayer player) {
if (owners.contains(player) || members.contains(player)) { if (owners.contains(player) || members.contains(player)) {
@ -227,6 +235,30 @@ public boolean isMember(LocalPlayer player) {
return false; return false;
} }
/**
* Checks whether a player is a member of the region
* or any of its parents.
*
* @param player player to check
* @return whether an member
*/
public boolean isMemberOnly(LocalPlayer player) {
if (members.contains(player)) {
return true;
}
ProtectedRegion curParent = getParent();
while (curParent != null) {
if (curParent.getMembers().contains(player)) {
return true;
}
curParent = curParent.getParent();
}
return false;
}
/** /**
* Get a flag's value. * Get a flag's value.
* *