mirror of
https://github.com/EngineHub/WorldGuard.git
synced 2024-12-25 18:47:44 +01:00
yet another fix for state flag fallback
This commit is contained in:
parent
83c6c9c743
commit
79b937e8d2
@ -27,7 +27,6 @@
|
||||
import com.sk89q.worldguard.protection.regions.flags.RegionFlag.State;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
/**
|
||||
* Represents a setFlag of regions and their rules as applied to one point.
|
||||
*
|
||||
@ -60,7 +59,12 @@ public ApplicableRegionSet(List<ProtectedRegion> applicable, GlobalFlags global
|
||||
* @return
|
||||
*/
|
||||
public boolean canBuild(LocalPlayer player) {
|
||||
return isStateFlagAllowed(FlagType.BUILD, global.canBuild, player);
|
||||
|
||||
if (!this.isAnyRegionAffected()) {
|
||||
return global.canBuild;
|
||||
}
|
||||
|
||||
return getStateFlag(FlagType.BUILD, true).getValue(State.DENY) == State.ALLOW || isMember(player);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -70,35 +74,41 @@ public boolean canBuild(LocalPlayer player) {
|
||||
* @return
|
||||
*/
|
||||
public boolean isStateFlagAllowed(FlagType type) {
|
||||
|
||||
return isStateFlagAllowed(type, global.getDefaultValue(type));
|
||||
}
|
||||
|
||||
public boolean isStateFlagAllowed(FlagType type, boolean def) {
|
||||
|
||||
if(!this.isAnyRegionAffected())
|
||||
{
|
||||
if (!this.isAnyRegionAffected()) {
|
||||
return def;
|
||||
}
|
||||
|
||||
return getStateFlag(type, true).getValue(State.DENY) == State.ALLOW;
|
||||
State defState = def ? State.ALLOW : State.DENY;
|
||||
return getStateFlag(type, true).getValue(defState) == State.ALLOW;
|
||||
}
|
||||
|
||||
public boolean isStateFlagAllowed(FlagType type, LocalPlayer player) {
|
||||
|
||||
if (type == FlagType.BUILD) {
|
||||
return canBuild(player);
|
||||
}
|
||||
return isStateFlagAllowed(type, global.getDefaultValue(type), player);
|
||||
}
|
||||
|
||||
public boolean isStateFlagAllowed(FlagType type, boolean def, LocalPlayer player) {
|
||||
|
||||
if(!this.isAnyRegionAffected())
|
||||
{
|
||||
if (type == FlagType.BUILD) {
|
||||
return canBuild(player);
|
||||
}
|
||||
|
||||
if (!this.isAnyRegionAffected()) {
|
||||
return def;
|
||||
}
|
||||
|
||||
return getStateFlag(type, true).getValue(State.DENY) == State.ALLOW || this.isMember(player);
|
||||
State defState = def ? State.ALLOW : State.DENY;
|
||||
return getStateFlag(type, true).getValue(defState) == State.ALLOW || this.isMember(player);
|
||||
}
|
||||
|
||||
|
||||
private RegionFlag getFlag(FlagType type, Boolean inherit) {
|
||||
|
||||
ProtectedRegion region = affectedRegion;
|
||||
@ -199,12 +209,10 @@ public LocationRegionFlag getLocationFlag(FlagType type, boolean inherit) {
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isAnyRegionAffected()
|
||||
{
|
||||
public boolean isAnyRegionAffected() {
|
||||
return this.applicable.size() > 0;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Determines the region with the hightest priority that is not a parent.
|
||||
*
|
||||
@ -223,8 +231,6 @@ private void determineAffectedRegion() {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
public boolean isOwner(LocalPlayer player) {
|
||||
return affectedRegion != null ? affectedRegion.isOwner(player) : false;
|
||||
}
|
||||
@ -246,9 +252,6 @@ public String getAffectedRegionId() {
|
||||
public int getAffectedRegionPriority() {
|
||||
return affectedRegion != null ? affectedRegion.getPriority() : 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Checks to see if a flag is permitted.
|
||||
*
|
||||
@ -333,8 +336,6 @@ private boolean isStateFlagAllowed(String flag, boolean def, LocalPlayer player)
|
||||
|| (player != null && needsClear.size() == 0);
|
||||
}
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* Clear a region's parents for isStateFlagAllowed().
|
||||
*
|
||||
|
Loading…
Reference in New Issue
Block a user