From 103c69fecf8e47c71d831c4fe6ef073d3dedc674 Mon Sep 17 00:00:00 2001 From: DroppingAnvil Date: Tue, 7 Apr 2020 16:02:18 -0500 Subject: [PATCH] Changed every fly check to the same one instead of having multiple, FactionsPlayerListener.checkCanFly will be removed soon. --- .../com/massivecraft/factions/cmd/CmdFly.java | 3 ++- .../listeners/FactionsPlayerListener.java | 21 +++++++++++++------ 2 files changed, 17 insertions(+), 7 deletions(-) diff --git a/src/main/java/com/massivecraft/factions/cmd/CmdFly.java b/src/main/java/com/massivecraft/factions/cmd/CmdFly.java index b7099af1..c605080a 100644 --- a/src/main/java/com/massivecraft/factions/cmd/CmdFly.java +++ b/src/main/java/com/massivecraft/factions/cmd/CmdFly.java @@ -27,6 +27,7 @@ public class CmdFly extends FCommand { public static ConcurrentHashMap flyMap = new ConcurrentHashMap<>(); public static BukkitTask particleTask = null; public static BukkitTask flyTask = null; + public static boolean autoenable = FactionsPlugin.instance.getConfig().getBoolean("ffly.AutoEnable"); public CmdFly() { @@ -97,7 +98,7 @@ public class CmdFly extends FCommand { } public static boolean checkFly(FPlayer fme, Player me, Faction toFac) { - if (Conf.denyFlightIfInNoClaimingWorld && !Conf.worldsNoClaiming.isEmpty() && Conf.worldsNoClaiming.stream().anyMatch(me.getWorld().getName()::equalsIgnoreCase)) + if ((Conf.denyFlightIfInNoClaimingWorld && !Conf.worldsNoClaiming.isEmpty() && Conf.worldsNoClaiming.stream().anyMatch(me.getWorld().getName()::equalsIgnoreCase)) || me.hasPermission(Permission.FLY_FLY.node)) return false; if (toFac.getAccess(fme, PermissableAction.FLY) == Access.ALLOW) return true; if (fme.getFaction().isWilderness()) return false; diff --git a/src/main/java/com/massivecraft/factions/listeners/FactionsPlayerListener.java b/src/main/java/com/massivecraft/factions/listeners/FactionsPlayerListener.java index b917507b..a9963a0a 100644 --- a/src/main/java/com/massivecraft/factions/listeners/FactionsPlayerListener.java +++ b/src/main/java/com/massivecraft/factions/listeners/FactionsPlayerListener.java @@ -4,6 +4,7 @@ import com.massivecraft.factions.*; import com.massivecraft.factions.cmd.CmdFGlobal; import com.massivecraft.factions.cmd.CmdFly; import com.massivecraft.factions.cmd.CmdSeeChunk; +import com.massivecraft.factions.cmd.FCmdRoot; import com.massivecraft.factions.cmd.audit.FLogType; import com.massivecraft.factions.cmd.logout.LogoutHandler; import com.massivecraft.factions.cmd.wild.CmdWild; @@ -569,15 +570,17 @@ public class FactionsPlayerListener implements Listener { .replace("{leader}", faction.getFPlayerAdmin() + ""); return string; } - + @Deprecated public void checkCanFly(FPlayer me) { if (!FactionsPlugin.getInstance().getConfig().getBoolean("enable-faction-flight") || !FactionsPlugin.instance.getConfig().getBoolean("ffly.AutoEnable")) return; if (me.isFlying()) return; - me.setFFlying(true, false); - CmdFly.flyMap.put(me.getName(), true); - if (CmdFly.particleTask == null) - CmdFly.startParticles(); + if (me.getPlayer().hasPermission(Permission.FLY_FLY.node)) { + me.setFFlying(true, false); + CmdFly.flyMap.put(me.getName(), true); + if (CmdFly.particleTask == null) + CmdFly.startParticles(); + } } //inspect @@ -716,7 +719,13 @@ public class FactionsPlayerListener implements Listener { }, 5); } } - this.checkCanFly(me); + if (FCmdRoot.instance.fFlyEnabled && CmdFly.autoenable && CmdFly.checkFly(me, me.getPlayer(), factionTo)) { + me.setFFlying(true, false); + CmdFly.flyMap.put(me.getName(), true); + if (CmdFly.particleTask == null) + CmdFly.startParticles(); + } + if (me.getAutoClaimFor() != null) { me.attemptClaim(me.getAutoClaimFor(), newLocation, true);