From 4a3c9ad8ae63f2f29a8e83f0a0901511589b6647 Mon Sep 17 00:00:00 2001 From: tastybento Date: Sat, 2 May 2020 17:53:35 -0700 Subject: [PATCH] Added null checking for world when changing worlds https://github.com/BentoBoxWorld/BentoBox/issues/1336 --- .../world/bentobox/bentobox/listeners/JoinLeaveListener.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/main/java/world/bentobox/bentobox/listeners/JoinLeaveListener.java b/src/main/java/world/bentobox/bentobox/listeners/JoinLeaveListener.java index 601d847c4..ed2bc2196 100644 --- a/src/main/java/world/bentobox/bentobox/listeners/JoinLeaveListener.java +++ b/src/main/java/world/bentobox/bentobox/listeners/JoinLeaveListener.java @@ -130,8 +130,11 @@ public class JoinLeaveListener implements Listener { */ @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) public void onPlayerSwitchWorld(final PlayerChangedWorldEvent event) { + World world = Util.getWorld(event.getPlayer().getWorld()); // Clear inventory if required - clearPlayersInventory(Util.getWorld(event.getPlayer().getWorld()), User.getInstance(event.getPlayer())); + if (world != null) { + clearPlayersInventory(world, User.getInstance(event.getPlayer())); + } }