Fixed some flag algorithm issues, added the possibility of owners and members on the global region in order to affect build.

This commit is contained in:
sk89q 2011-06-27 11:01:53 -07:00
parent a31476251e
commit df8fdd086b

View File

@ -81,7 +81,6 @@ public boolean canUse(LocalPlayer player) {
/**
* Gets the state of a state flag. This cannot be used for the build flag.
*
* @see #allows(com.sk89q.worldguard.protection.flags.StateFlag, com.sk89q.worldguard.LocalPlayer)
* @param flag flag to check
* @return whether it is allowed
* @throws IllegalArgumentException if the build flag is given
@ -161,16 +160,20 @@ private boolean internalGetState(StateFlag flag, LocalPlayer player,
// Handle defaults
if (globalRegion != null) {
State globalState = globalRegion.getFlag(flag);
// The global region has this flag set
if (globalState != null) {
// Special case for the build flag
// Build flag is very special
if (player != null && globalRegion.hasMembersOrOwners()) {
def = globalRegion.isMember(player)
? (globalState == State.ALLOW) : false;
def = globalRegion.isMember(player) && (globalState == State.ALLOW);
} else {
def = (globalState == State.ALLOW);
}
} else {
// Build flag is very special
if (player != null && globalRegion.hasMembersOrOwners()) {
def = globalRegion.isMember(player);
}
}
}
@ -252,6 +255,8 @@ private boolean internalGetState(StateFlag flag, LocalPlayer player,
// on membership, so we have to check for parent-child
// relationships
if (player != null) {
hasFlagDefined = true;
if (hasCleared.contains(region)) {
// Already cleared, so do nothing
} else {