All /f fly permissions converted to Permission Enum. Why were they just strings? I didnt even know all these perms were a thing until now bc they were not in the enum.

Signed-off-by: DroppingAnvil <dr0pping.4nvi1@gmail.com>
This commit is contained in:
DroppingAnvil 2019-11-01 16:37:38 -05:00
parent 07db3fd015
commit 9e6c91bec1
4 changed files with 21 additions and 14 deletions

View File

@ -99,29 +99,29 @@ public class CmdFly extends FCommand {
public static boolean checkBypassPerms(FPlayer fme, Player me, Faction toFac) {
if (toFac != fme.getFaction()) {
if (!me.hasPermission("factions.fly.wilderness") && toFac.isWilderness() || !me.hasPermission("factions.fly.safezone") && toFac.isSafeZone() || !me.hasPermission("factions.fly.warzone") && toFac.isWarZone()) {
if (!me.hasPermission(Permission.FLY_WILD.node) && toFac.isWilderness() || !me.hasPermission(Permission.FLY_SAFEZONE.node) && toFac.isSafeZone() || !me.hasPermission(Permission.FLY_WARZONE.node) && toFac.isWarZone()) {
fme.msg(TL.COMMAND_FLY_NO_ACCESS, toFac.getTag(fme));
return false;
}
Access access = toFac.getAccess(fme, PermissableAction.FLY);
if ((!(me.hasPermission("factions.fly.enemy") || access == Access.ALLOW)) && toFac.getRelationTo(fme.getFaction()) == Relation.ENEMY) {
if ((!(me.hasPermission(Permission.FLY_ENEMY.node) || access == Access.ALLOW)) && toFac.getRelationTo(fme.getFaction()) == Relation.ENEMY) {
fme.msg(TL.COMMAND_FLY_NO_ACCESS, toFac.getTag(fme));
return false;
}
if (!(me.hasPermission("factions.fly.ally") || access == Access.ALLOW) && toFac.getRelationTo(fme.getFaction()) == Relation.ALLY) {
if (!(me.hasPermission(Permission.FLY_ALLY.node) || access == Access.ALLOW) && toFac.getRelationTo(fme.getFaction()) == Relation.ALLY) {
fme.msg(TL.COMMAND_FLY_NO_ACCESS, toFac.getTag(fme));
return false;
}
if (!(me.hasPermission("factions.fly.truce") || access == Access.ALLOW) && toFac.getRelationTo(fme.getFaction()) == Relation.TRUCE) {
if (!(me.hasPermission(Permission.FLY_TRUCE.node) || access == Access.ALLOW) && toFac.getRelationTo(fme.getFaction()) == Relation.TRUCE) {
fme.msg(TL.COMMAND_FLY_NO_ACCESS, toFac.getTag(fme));
return false;
}
if (!(me.hasPermission("factions.fly.neutral") || access == Access.ALLOW) && toFac.getRelationTo(fme.getFaction()) == Relation.NEUTRAL && !isSystemFaction(toFac)) {
if (!(me.hasPermission(Permission.FLY_NEUTRAL.node) || access == Access.ALLOW) && toFac.getRelationTo(fme.getFaction()) == Relation.NEUTRAL && !isSystemFaction(toFac)) {
fme.msg(TL.COMMAND_FLY_NO_ACCESS, toFac.getTag(fme));
return false;
}
return me.hasPermission("factions.fly") && (access != Access.DENY || toFac.isSystemFaction());
return me.hasPermission(Permission.FLY.node) && (access != Access.DENY || toFac.isSystemFaction());
}
return true;
}

View File

@ -575,7 +575,7 @@ public class FactionsPlayerListener implements Listener {
}
public void enableFly(FPlayer me) {
if (!me.getPlayer().hasPermission("factions.fly")) return;
if (!me.getPlayer().hasPermission(Permission.FLY.node)) return;
me.setFFlying(true, false);
if (FactionsPlugin.getInstance().getConfig().getBoolean("ffly.AutoEnable")) {

View File

@ -36,6 +36,13 @@ public enum Permission {
DISBAND_ANY("disband.any"),
DISCORD("discord"),
FLY("fly"),
FLY_WILD("factions.fly.wilderness"),
FLY_SAFEZONE("factions.fly.safezone"),
FLY_WARZONE("factions.fly.warzone"),
FLY_ENEMY("factions.fly.enemy"),
FLY_ALLY("factions.fly.ally"),
FLY_TRUCE("factions.fly.truce"),
FLY_NEUTRAL("factions.fly.neutral"),
FOCUS("focus"),
GLOBALCHAT("globalchat"),
GRACE("grace"),

View File

@ -1158,42 +1158,42 @@ public abstract class MemoryFPlayer implements FPlayer {
@Override
public Boolean canflyinWilderness() {
return getPlayer().hasPermission("factions.fly.wilderness");
return getPlayer().hasPermission(Permission.FLY_WILD.node);
}
@Override
public Boolean canflyinWarzone() {
return getPlayer().hasPermission("factions.fly.warzone");
return getPlayer().hasPermission(Permission.FLY_WARZONE.node);
}
@Override
public Boolean canflyinSafezone() {
return getPlayer().hasPermission("factions.fly.safezone");
return getPlayer().hasPermission(Permission.FLY_SAFEZONE.node);
}
@Override
public Boolean canflyinEnemy() {
return getPlayer().hasPermission("factions.fly.enemy");
return getPlayer().hasPermission(Permission.FLY_ENEMY.node);
}
@Override
public Boolean canflyinAlly() {
return getPlayer().hasPermission("factions.fly.ally");
return getPlayer().hasPermission(Permission.FLY_ALLY.node);
}
@Override
public Boolean canflyinTruce() {
return getPlayer().hasPermission("factions.fly.truce");
return getPlayer().hasPermission(Permission.FLY_TRUCE.node);
}
@Override
public Boolean canflyinNeutral() {
return getPlayer().hasPermission("factions.fly.neutral");
return getPlayer().hasPermission(Permission.FLY_NEUTRAL.node);
}