mirror of
https://github.com/EngineHub/WorldGuard.git
synced 2024-11-24 03:25:24 +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,7 +164,13 @@ private boolean internalGetState(StateFlag flag, LocalPlayer player,
|
||||
|
||||
// The global region has this flag set
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -168,7 +168,6 @@ public void setOwners(DefaultDomain owners) {
|
||||
* @return the members
|
||||
*/
|
||||
public DefaultDomain getMembers() {
|
||||
|
||||
return members;
|
||||
}
|
||||
|
||||
@ -178,12 +177,21 @@ public DefaultDomain getMembers() {
|
||||
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)) {
|
||||
@ -226,6 +234,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