Fixed NPE with Start flight method
This commit is contained in:
parent
2cb2068825
commit
c5445e2d17
@ -58,7 +58,8 @@ public class SavageFactions extends MPlugin {
|
|||||||
// a green light to use the api.
|
// a green light to use the api.
|
||||||
public static boolean startupFinished = false;
|
public static boolean startupFinished = false;
|
||||||
|
|
||||||
|
// Persistence related
|
||||||
|
public static ArrayList<FPlayer> playersFlying = new ArrayList();
|
||||||
|
|
||||||
public boolean PlaceholderApi;
|
public boolean PlaceholderApi;
|
||||||
// Commands
|
// Commands
|
||||||
@ -185,6 +186,11 @@ public class SavageFactions extends MPlugin {
|
|||||||
faction.addFPlayer(fPlayer);
|
faction.addFPlayer(fPlayer);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
playersFlying.clear();
|
||||||
|
for (FPlayer fPlayer : FPlayers.getInstance().getAllFPlayers()) {
|
||||||
|
playersFlying.add(fPlayer);
|
||||||
|
}
|
||||||
UtilFly.run();
|
UtilFly.run();
|
||||||
|
|
||||||
Board.getInstance().load();
|
Board.getInstance().load();
|
||||||
|
@ -14,14 +14,18 @@ import java.util.Iterator;
|
|||||||
public class UtilFly {
|
public class UtilFly {
|
||||||
|
|
||||||
|
|
||||||
|
public static ArrayList<FPlayer> playersFlying = SavageFactions.playersFlying;
|
||||||
|
|
||||||
public static void run() {
|
public static void run() {
|
||||||
if (!SavageFactions.plugin.getConfig().getBoolean("enable-faction-flight"))
|
if (!SavageFactions.plugin.getConfig().getBoolean("enable-faction-flight"))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
playersFlying.clear();
|
||||||
|
|
||||||
Bukkit.getScheduler().scheduleSyncRepeatingTask(SavageFactions.plugin, () -> {
|
Bukkit.getScheduler().scheduleSyncRepeatingTask(SavageFactions.plugin, () -> {
|
||||||
for (FPlayer fp : FPlayers.getInstance().getAllFPlayers()) {
|
for (FPlayer fp : playersFlying) {
|
||||||
if (fp.isFlying()) fp.checkIfNearbyEnemies();
|
if (fp != null)
|
||||||
|
fp.checkIfNearbyEnemies();
|
||||||
}
|
}
|
||||||
}, 0, SavageFactions.plugin.getConfig().getInt("fly-task-interval", 10));
|
}, 0, SavageFactions.plugin.getConfig().getInt("fly-task-interval", 10));
|
||||||
}
|
}
|
||||||
@ -34,6 +38,11 @@ public class UtilFly {
|
|||||||
fp.getPlayer().setFlying(fly);
|
fp.getPlayer().setFlying(fly);
|
||||||
fp.setFlying(fly);
|
fp.setFlying(fly);
|
||||||
|
|
||||||
|
if (fly) {
|
||||||
|
playersFlying.add(fp);
|
||||||
|
} else {
|
||||||
|
playersFlying.remove(fp);
|
||||||
|
}
|
||||||
|
|
||||||
if (!silent) {
|
if (!silent) {
|
||||||
if (!damage) {
|
if (!damage) {
|
||||||
@ -98,3 +107,4 @@ public class UtilFly {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -1070,6 +1070,7 @@ public abstract class MemoryFPlayer implements FPlayer {
|
|||||||
if (e == null) {
|
if (e == null) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (e instanceof Player) {
|
if (e instanceof Player) {
|
||||||
Player eplayer = (((Player) e).getPlayer());
|
Player eplayer = (((Player) e).getPlayer());
|
||||||
if (eplayer == null) {
|
if (eplayer == null) {
|
||||||
|
Loading…
Reference in New Issue
Block a user