From 9e6c91bec1b6afd263d01d8173a21fc6b3f422ed Mon Sep 17 00:00:00 2001 From: DroppingAnvil Date: Fri, 1 Nov 2019 16:37:38 -0500 Subject: [PATCH] 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 --- .../java/com/massivecraft/factions/cmd/CmdFly.java | 12 ++++++------ .../factions/listeners/FactionsPlayerListener.java | 2 +- .../massivecraft/factions/struct/Permission.java | 7 +++++++ .../factions/zcore/persist/MemoryFPlayer.java | 14 +++++++------- 4 files changed, 21 insertions(+), 14 deletions(-) diff --git a/src/main/java/com/massivecraft/factions/cmd/CmdFly.java b/src/main/java/com/massivecraft/factions/cmd/CmdFly.java index c7a60caa..bce3e2b7 100644 --- a/src/main/java/com/massivecraft/factions/cmd/CmdFly.java +++ b/src/main/java/com/massivecraft/factions/cmd/CmdFly.java @@ -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; } diff --git a/src/main/java/com/massivecraft/factions/listeners/FactionsPlayerListener.java b/src/main/java/com/massivecraft/factions/listeners/FactionsPlayerListener.java index 07ada5f1..142c32a4 100644 --- a/src/main/java/com/massivecraft/factions/listeners/FactionsPlayerListener.java +++ b/src/main/java/com/massivecraft/factions/listeners/FactionsPlayerListener.java @@ -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")) { diff --git a/src/main/java/com/massivecraft/factions/struct/Permission.java b/src/main/java/com/massivecraft/factions/struct/Permission.java index 7a08c686..87d1dc59 100755 --- a/src/main/java/com/massivecraft/factions/struct/Permission.java +++ b/src/main/java/com/massivecraft/factions/struct/Permission.java @@ -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"), diff --git a/src/main/java/com/massivecraft/factions/zcore/persist/MemoryFPlayer.java b/src/main/java/com/massivecraft/factions/zcore/persist/MemoryFPlayer.java index 80dacc66..7724774e 100644 --- a/src/main/java/com/massivecraft/factions/zcore/persist/MemoryFPlayer.java +++ b/src/main/java/com/massivecraft/factions/zcore/persist/MemoryFPlayer.java @@ -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); }