diff --git a/src/main/java/com/bgsoftware/superiorskyblock/utils/logic/PlayersLogic.java b/src/main/java/com/bgsoftware/superiorskyblock/utils/logic/PlayersLogic.java index 2df55aff0..af7786ba4 100644 --- a/src/main/java/com/bgsoftware/superiorskyblock/utils/logic/PlayersLogic.java +++ b/src/main/java/com/bgsoftware/superiorskyblock/utils/logic/PlayersLogic.java @@ -97,16 +97,16 @@ public static boolean handlePlayerLeaveIsland(SuperiorPlayer superiorPlayer, Loc fromIsland.setPlayerInside(superiorPlayer, false); Player player = superiorPlayer.asPlayer(); - assert player != null; - - player.resetPlayerTime(); - player.resetPlayerWeather(); - fromIsland.removeEffects(superiorPlayer); - - if (superiorPlayer.hasIslandFlyEnabled() && (toIsland == null || toIsland.isSpawn()) && !superiorPlayer.hasFlyGamemode()) { - player.setAllowFlight(false); - player.setFlying(false); - Message.ISLAND_FLY_DISABLED.send(player); + if (player != null) { + player.resetPlayerTime(); + player.resetPlayerWeather(); + fromIsland.removeEffects(superiorPlayer); + + if (superiorPlayer.hasIslandFlyEnabled() && (toIsland == null || toIsland.isSpawn()) && !superiorPlayer.hasFlyGamemode()) { + player.setAllowFlight(false); + player.setFlying(false); + Message.ISLAND_FLY_DISABLED.send(player); + } } if (toIsland == null) @@ -152,8 +152,6 @@ public static void handlePlayerEnterIsland(SuperiorPlayer superiorPlayer, Locati boolean toInsideRange = toIsland.isInsideRange(toLocation); boolean fromInsideRange = fromLocation != null && fromIsland != null && fromIsland.isInsideRange(fromLocation); boolean equalWorlds = fromLocation != null && toLocation.getWorld().equals(fromLocation.getWorld()); - Player player = superiorPlayer.asPlayer(); - assert player != null; if (toInsideRange && (!equalIslands || !fromInsideRange)) { if (!EventsCaller.callIslandEnterProtectedEvent(superiorPlayer, toIsland, enterCause)) { @@ -193,7 +191,8 @@ public static void handlePlayerEnterIsland(SuperiorPlayer superiorPlayer, Locati superiorPlayer.setImmunedToPortals(true); Executor.sync(() -> superiorPlayer.setImmunedToPortals(false), 100L); - if (plugin.getSettings().getSpawn().isProtected() || !toIsland.isSpawn()) { + Player player = superiorPlayer.asPlayer(); + if (player != null && (plugin.getSettings().getSpawn().isProtected() || !toIsland.isSpawn())) { if (toIsland.hasSettingsEnabled(IslandFlags.ALWAYS_DAY)) { player.setPlayerTime(0, false); } else if (toIsland.hasSettingsEnabled(IslandFlags.ALWAYS_MIDDLE_DAY)) { @@ -215,7 +214,7 @@ public static void handlePlayerEnterIsland(SuperiorPlayer superiorPlayer, Locati if (superiorPlayer.hasIslandFlyEnabled() && !superiorPlayer.hasFlyGamemode()) { Executor.sync(() -> { - if (player.isOnline()) + if (player != null) toIsland.updateIslandFly(superiorPlayer); }, 5L); }