Fly improved
This commit is contained in:
parent
44cac68a15
commit
5cf21d479e
@ -77,18 +77,18 @@ public class CmdFly extends FCommand {
|
||||
continue;
|
||||
}
|
||||
FPlayer fPlayer = FPlayers.getInstance().getByPlayer(player);
|
||||
Faction myFaction = fPlayer.getFaction();
|
||||
if (!player.hasPermission("factions.fly.bypassnearbyenemycheck") && !fPlayer.isAdminBypassing()) {
|
||||
if (fPlayer.hasEnemiesNearby()) disableFlightSync(fPlayer);
|
||||
if (fPlayer.isAdminBypassing()) continue;
|
||||
if (!player.hasPermission("factions.fly.bypassnearbyenemycheck")) {
|
||||
checkEnemiesSync(fPlayer);
|
||||
continue;
|
||||
if (fPlayer.hasEnemiesNearby()) {
|
||||
disableFlightSync(fPlayer);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
FLocation myFloc = new FLocation(player.getLocation());
|
||||
if (Board.getInstance().getFactionAt(myFloc) != myFaction) {
|
||||
if (!checkFly(fPlayer, player, Board.getInstance().getFactionAt(myFloc))) {
|
||||
disableFlightSync(fPlayer);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@ -97,6 +97,7 @@ public class CmdFly extends FCommand {
|
||||
}
|
||||
|
||||
public static boolean checkFly(FPlayer fme, Player me, Faction toFac) {
|
||||
System.out.print("Checking user " + me.getName());
|
||||
if (Conf.denyFlightIfInNoClaimingWorld && !Conf.worldsNoClaiming.isEmpty() && Conf.worldsNoClaiming.stream().anyMatch(me.getWorld().getName()::equalsIgnoreCase))
|
||||
return false;
|
||||
if (toFac.getAccess(fme, PermissableAction.FLY) == Access.ALLOW) return true;
|
||||
|
@ -403,6 +403,8 @@ public class FCmdRoot extends FCommand implements CommandExecutor {
|
||||
if (FactionsPlugin.getInstance().getConfig().getBoolean("enable-faction-flight", false) && !fFlyEnabled) {
|
||||
this.addSubCommand(this.cmdFly);
|
||||
fFlyEnabled = true;
|
||||
CmdFly.startFlyCheck();
|
||||
CmdFly.startParticles();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -571,13 +571,8 @@ public class FactionsPlayerListener implements Listener {
|
||||
}
|
||||
|
||||
public void checkCanFly(FPlayer me) {
|
||||
if (!FactionsPlugin.getInstance().getConfig().getBoolean("enable-faction-flight")) return;
|
||||
if (me.isFlying() && !me.isVanished() && (!me.canFlyAtLocation() || me.checkIfNearbyEnemies())) {
|
||||
me.setFFlying(false, false);
|
||||
me.msg(TL.COMMAND_FLY_NO_ACCESS, Board.getInstance().getFactionAt(me.getLastStoodAt()).getTag());
|
||||
return;
|
||||
}
|
||||
if (me.isFlying() || !FactionsPlugin.instance.getConfig().getBoolean("ffly.AutoEnable")) return;
|
||||
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)
|
||||
@ -656,33 +651,6 @@ public class FactionsPlayerListener implements Listener {
|
||||
}
|
||||
refreshPosition(player, lastLocations.get(player.getUniqueId()), player.getLocation());
|
||||
lastLocations.put(player.getUniqueId(), player.getLocation());
|
||||
if (CmdFly.flyMap.containsKey(player.getName())) {
|
||||
String name = player.getName();
|
||||
if (!player.isFlying()
|
||||
|| player.getGameMode() == GameMode.CREATIVE
|
||||
|| !FactionsPlugin.instance.mc17 && player.getGameMode() == GameMode.SPECTATOR) {
|
||||
continue;
|
||||
}
|
||||
FPlayer fPlayer = FPlayers.getInstance().getByPlayer(player);
|
||||
Faction myFaction = fPlayer.getFaction();
|
||||
if (myFaction.isWilderness()) {
|
||||
Bukkit.getScheduler().runTask(FactionsPlugin.instance, () -> fPlayer.setFlying(false));
|
||||
CmdFly.flyMap.remove(player.getName());
|
||||
continue;
|
||||
}
|
||||
Bukkit.getScheduler().runTask(FactionsPlugin.instance, () -> {
|
||||
if (!fPlayer.checkIfNearbyEnemies()) {
|
||||
FLocation myFloc = new FLocation(player.getLocation());
|
||||
if (Board.getInstance().getFactionAt(myFloc) != myFaction) {
|
||||
if (!CmdFly.checkFly(fPlayer, player, Board.getInstance().getFactionAt(myFloc))) {
|
||||
fPlayer.setFFlying(false, false);
|
||||
CmdFly.flyMap.remove(name);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}, 5L, 10L);
|
||||
|
Loading…
Reference in New Issue
Block a user