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,9 +164,15 @@ private boolean internalGetState(StateFlag flag, LocalPlayer player,
// The global region has this flag set
if (globalState != null) {
// Special case for the build flag
if (player != null && globalRegion.hasMembersOrOwners()) {
def = globalRegion.isMember(player)
? (globalState == State.ALLOW) : false;
} else {
def = (globalState == State.ALLOW);
}
}
}
// The player argument is used if and only if the flag is the build
// flag -- in which case, if there are any regions in this area, we

View File

@ -168,7 +168,6 @@ public void setOwners(DefaultDomain owners) {
* @return the members
*/
public DefaultDomain getMembers() {
return members;
}
@ -179,11 +178,20 @@ public void setMembers(DefaultDomain 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.
*
* @param player
* @return
* @param player player to check
* @return whether an owner
*/
public boolean isOwner(LocalPlayer player) {
if (owners.contains(player)) {
@ -202,12 +210,12 @@ public boolean isOwner(LocalPlayer player) {
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
* @return
* @param player player to check
* @return whether an owner or member
*/
public boolean isMember(LocalPlayer player) {
if (owners.contains(player) || members.contains(player)) {
@ -227,6 +235,30 @@ public boolean isMember(LocalPlayer player) {
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.
*