If f perm is not set or undefined, allow server owners to define default f fly access in the conf.json. Adds #1100

This commit is contained in:
Trent Hensler 2018-03-20 19:19:24 -07:00
parent 20cd874026
commit 1567df7311
2 changed files with 32 additions and 4 deletions

View File

@ -160,6 +160,12 @@ public class Conf {
public static Set<String> warzoneDenyCommands = new LinkedHashSet<>();
public static Set<String> wildernessDenyCommands = new LinkedHashSet<>();
public static boolean defaultFlyPermEnemy = false;
public static boolean defaultFlyPermNeutral = false;
public static boolean defaultFlyPermTruce = false;
public static boolean defaultFlyPermAlly = true;
public static boolean defaultFlyPermMember = true;
public static boolean territoryDenyBuild = true;
public static boolean territoryDenyBuildWhenOffline = true;
public static boolean territoryPainBuild = false;

View File

@ -951,14 +951,36 @@ public abstract class MemoryFPlayer implements FPlayer {
if (faction.isWilderness() || faction.isSafeZone() || faction.isWarZone()) {
return false;
}
if (faction == getFaction() && getRole() == Role.ADMIN) {
// Admins can always fly in their territory.
// admin bypass (ops) can fly as well.
if (isAdminBypassing || (faction == getFaction() && getRole() == Role.ADMIN)) {
return true;
}
Access access = faction.getAccess(this, PermissableAction.FLY);
// True if access is somehow null (should never happen), true if access is undefinied (let everyone fly by default)
// or if access is set (allow or deny), true if allow.
return access == null || access == Access.UNDEFINED || access == Access.ALLOW;
if (access == null || access == Access.UNDEFINED) {
// If access is null or undefined, we'll default to the conf.json
switch (faction.getRelationTo(getFaction())) {
case ENEMY:
return Conf.defaultFlyPermEnemy;
case ALLY:
return Conf.defaultFlyPermAlly;
case NEUTRAL:
return Conf.defaultFlyPermNeutral;
case TRUCE:
return Conf.defaultFlyPermTruce;
case MEMBER:
return Conf.defaultFlyPermMember;
default:
return false; // should never reach.
}
}
return access == Access.ALLOW;
}
public boolean shouldTakeFallDamage() {