use of com.sk89q.worldguard.protection.flags.StateFlag.State in project CombatLogX by SirBlobman.
the class ProtectionStonesRegionHandler method isSafeZone.
@Override
public boolean isSafeZone(Player player, Location location, TagType tagType) {
if (tagType != TagType.PLAYER)
return false;
PSRegion region = PSRegion.fromLocation(location);
if (region == null)
return false;
ProtectedRegion wgRegion = region.getWGRegion();
if (wgRegion == null)
return false;
State pvpState = wgRegion.getFlag(Flags.PVP);
return (pvpState == State.DENY);
}
use of com.sk89q.worldguard.protection.flags.StateFlag.State in project WorldGuard by EngineHub.
the class FlagValueCalculator method getEffectiveFlagOf.
@SuppressWarnings("unchecked")
@Nullable
public static <V> V getEffectiveFlagOf(final ProtectedRegion region, Flag<V> flag, @Nullable RegionAssociable subject) {
if (region.getId().equals(ProtectedRegion.GLOBAL_REGION)) {
if (flag == Flags.PASSTHROUGH) {
// Has members/owners -> the global region acts like
// a regular region without PASSTHROUGH
State passthrough = region.getFlag(Flags.PASSTHROUGH);
if (passthrough == State.DENY || passthrough != State.ALLOW && region.hasMembersOrOwners()) {
return null;
} else {
return (V) State.ALLOW;
}
} else if (flag instanceof StateFlag && ((StateFlag) flag).preventsAllowOnGlobal()) {
// Legacy behavior -> we can't let people change BUILD on
// the global region
State value = region.getFlag((StateFlag) flag);
return value != State.ALLOW ? (V) value : null;
}
}
ProtectedRegion current = region;
List<ProtectedRegion> seen = new ArrayList<>();
while (current != null) {
seen.add(current);
V value = current.getFlag(flag);
if (value != null) {
boolean use = true;
if (flag.getRegionGroupFlag() != null) {
RegionGroup group = current.getFlag(flag.getRegionGroupFlag());
if (group == null) {
group = flag.getRegionGroupFlag().getDefault();
}
if (group == null) {
use = false;
} else if (subject == null) {
use = group.contains(Association.NON_MEMBER);
} else if (!group.contains(subject.getAssociation(seen))) {
use = false;
}
}
if (use) {
return value;
}
}
current = current.getParent();
}
return null;
}
Aggregations