mirror of
https://github.com/EngineHub/WorldGuard.git
synced 2024-11-24 11:36:11 +01:00
Added the ability to add owners/members to the global region for handling guest groups.
This commit is contained in:
parent
3b871b9c00
commit
360a655627
@ -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
|
||||
|
@ -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.
|
||||
*
|
||||
|
Loading…
Reference in New Issue
Block a user