diff --git a/src/main/java/world/bentobox/bentobox/listeners/JoinLeaveListener.java b/src/main/java/world/bentobox/bentobox/listeners/JoinLeaveListener.java index 23b8bd2ed..601d847c4 100644 --- a/src/main/java/world/bentobox/bentobox/listeners/JoinLeaveListener.java +++ b/src/main/java/world/bentobox/bentobox/listeners/JoinLeaveListener.java @@ -55,7 +55,7 @@ public class JoinLeaveListener implements Listener { if (!players.isKnown(playerUUID)) { firstTime(user); } - + // Make sure the player is loaded into the cache or create the player if they don't exist players.addPlayer(playerUUID); @@ -121,7 +121,7 @@ public class JoinLeaveListener implements Listener { } } }); - + } /** @@ -142,10 +142,11 @@ public class JoinLeaveListener implements Listener { * @param user Targeted user. */ private void clearPlayersInventory(World world, @NonNull User user) { + if (user.getUniqueId() == null) return; // Clear inventory if required Players playerData = players.getPlayer(user.getUniqueId()); - if (playerData.getPendingKicks().contains(world.getName())) { + if (playerData != null && playerData.getPendingKicks().contains(world.getName())) { if (plugin.getIWM().isOnLeaveResetEnderChest(world)) { user.getPlayer().getEnderChest().clear(); } @@ -214,13 +215,13 @@ public class JoinLeaveListener implements Listener { // Call Protection Range Change event. Does not support cancelling. IslandEvent.builder() - .island(island) - .location(island.getCenter()) - .reason(IslandEvent.Reason.RANGE_CHANGE) - .involvedPlayer(user.getUniqueId()) - .admin(true) - .protectionRange(range, oldRange) - .build(); + .island(island) + .location(island.getCenter()) + .reason(IslandEvent.Reason.RANGE_CHANGE) + .involvedPlayer(user.getUniqueId()) + .admin(true) + .protectionRange(range, oldRange) + .build(); } } }); diff --git a/src/main/java/world/bentobox/bentobox/managers/PlayersManager.java b/src/main/java/world/bentobox/bentobox/managers/PlayersManager.java index 3c56fb6c9..cbca30594 100644 --- a/src/main/java/world/bentobox/bentobox/managers/PlayersManager.java +++ b/src/main/java/world/bentobox/bentobox/managers/PlayersManager.java @@ -103,8 +103,9 @@ public class PlayersManager { /** * Get player by UUID. Adds player to cache if not in there already * @param uuid of player - * @return player object or null if it does not exist + * @return player object or null if it does not exist, for example the UUID is null */ + @Nullable public Players getPlayer(UUID uuid){ if (!playerCache.containsKey(uuid)) { addPlayer(uuid);