mirror of
https://github.com/EngineHub/WorldGuard.git
synced 2024-12-24 18:19:03 +01:00
Added ProtectedRegion.isOwner/Member(String playerName).
This commit is contained in:
parent
690da2332b
commit
69119e6db7
@ -253,6 +253,29 @@ public boolean isOwner(LocalPlayer player) {
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks whether a player is an owner of region or any of its parents.
|
||||
*
|
||||
* @param playerName player name to check
|
||||
* @return whether an owner
|
||||
*/
|
||||
public boolean isOwner(String playerName) {
|
||||
if (owners.contains(playerName)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
ProtectedRegion curParent = getParent();
|
||||
while (curParent != null) {
|
||||
if (curParent.getOwners().contains(playerName)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
curParent = curParent.getParent();
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks whether a player is a member OR OWNER of the region
|
||||
* or any of its parents.
|
||||
@ -261,14 +284,45 @@ public boolean isOwner(LocalPlayer player) {
|
||||
* @return whether an owner or member
|
||||
*/
|
||||
public boolean isMember(LocalPlayer player) {
|
||||
if (owners.contains(player) || members.contains(player)) {
|
||||
if (isOwner(player)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (members.contains(player)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
ProtectedRegion curParent = getParent();
|
||||
while (curParent != null) {
|
||||
if (curParent.getOwners().contains(player)
|
||||
|| curParent.getMembers().contains(player)) {
|
||||
if (curParent.getMembers().contains(player)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
curParent = curParent.getParent();
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks whether a player is a member OR OWNER of the region
|
||||
* or any of its parents.
|
||||
*
|
||||
* @param playerName player name to check
|
||||
* @return whether an owner or member
|
||||
*/
|
||||
public boolean isMember(String playerName) {
|
||||
if (isOwner(playerName)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (members.contains(playerName)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
ProtectedRegion curParent = getParent();
|
||||
while (curParent != null) {
|
||||
if (curParent.getMembers().contains(playerName)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user