Added null checking for world when changing worlds

https://github.com/BentoBoxWorld/BentoBox/issues/1336
This commit is contained in:
tastybento 2020-05-02 17:53:35 -07:00
parent 304867c1f8
commit 4a3c9ad8ae

View File

@ -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()));
}
}