Fixed NPE with Start flight method

This commit is contained in:
Driftay
2019-05-20 15:25:23 -04:00
parent 2cb2068825
commit c5445e2d17
3 changed files with 20 additions and 3 deletions

View File

@@ -14,14 +14,18 @@ import java.util.Iterator;
public class UtilFly {
public static ArrayList<FPlayer> playersFlying = SavageFactions.playersFlying;
public static void run() {
if (!SavageFactions.plugin.getConfig().getBoolean("enable-faction-flight"))
return;
playersFlying.clear();
Bukkit.getScheduler().scheduleSyncRepeatingTask(SavageFactions.plugin, () -> {
for (FPlayer fp : FPlayers.getInstance().getAllFPlayers()) {
if (fp.isFlying()) fp.checkIfNearbyEnemies();
for (FPlayer fp : playersFlying) {
if (fp != null)
fp.checkIfNearbyEnemies();
}
}, 0, SavageFactions.plugin.getConfig().getInt("fly-task-interval", 10));
}
@@ -34,6 +38,11 @@ public class UtilFly {
fp.getPlayer().setFlying(fly);
fp.setFlying(fly);
if (fly) {
playersFlying.add(fp);
} else {
playersFlying.remove(fp);
}
if (!silent) {
if (!damage) {
@@ -98,3 +107,4 @@ public class UtilFly {
}