From a748a41313bb1c9ee7ffb13415137934b1ebf444 Mon Sep 17 00:00:00 2001 From: Christian Koop Date: Fri, 28 May 2021 08:40:49 +0200 Subject: [PATCH] Fix NPE console spam --- .../skyblock/listeners/MoveListeners.java | 16 ++++++++++------ .../permissions/listening/PortalPermission.java | 16 ++++++++++------ 2 files changed, 20 insertions(+), 12 deletions(-) diff --git a/src/main/java/com/songoda/skyblock/listeners/MoveListeners.java b/src/main/java/com/songoda/skyblock/listeners/MoveListeners.java index cc142c06..7f374c14 100644 --- a/src/main/java/com/songoda/skyblock/listeners/MoveListeners.java +++ b/src/main/java/com/songoda/skyblock/listeners/MoveListeners.java @@ -100,7 +100,7 @@ public class MoveListeners implements Listener { boolean keepItemsOnDeath; if (configLoad.getBoolean("Island.Settings.KeepItemsOnDeath.Enable")) { - keepItemsOnDeath = permissionManager.hasPermission(island,"KeepItemsOnDeath", IslandRole.Owner); + keepItemsOnDeath = permissionManager.hasPermission(island, "KeepItemsOnDeath", IslandRole.Owner); } else { keepItemsOnDeath = configLoad.getBoolean("Island.KeepItemsOnDeath.Enable"); } @@ -206,17 +206,21 @@ public class MoveListeners implements Listener { } } else { loc = island.getLocation(world, IslandEnvironment.Main); - + if(plugin.getConfiguration().getBoolean("Island.Teleport.RemoveWater", false)) { LocationUtil.removeWaterFromLoc(loc); } } } else { if (!player.getGameMode().equals(GameMode.CREATIVE) && !player.getGameMode().equals(GameMode.SPECTATOR)) { - if(plugin.getConfiguration().getBoolean("Island.Teleport.SafetyCheck", true)) { - Location safeLoc = LocationUtil.getSafeLocation(island.getLocation(world, IslandEnvironment.Visitor)); - if (safeLoc != null) { - loc = safeLoc; + if (plugin.getConfiguration().getBoolean("Island.Teleport.SafetyCheck", true)) { + Location isLoc = island.getLocation(world, IslandEnvironment.Visitor); + + if (isLoc != null) { + Location safeLoc = LocationUtil.getSafeLocation(isLoc); + if (safeLoc != null) { + loc = safeLoc; + } } } } else { diff --git a/src/main/java/com/songoda/skyblock/permission/permissions/listening/PortalPermission.java b/src/main/java/com/songoda/skyblock/permission/permissions/listening/PortalPermission.java index 231a2c50..3c19e7d5 100644 --- a/src/main/java/com/songoda/skyblock/permission/permissions/listening/PortalPermission.java +++ b/src/main/java/com/songoda/skyblock/permission/permissions/listening/PortalPermission.java @@ -72,15 +72,19 @@ public class PortalPermission extends ListeningPermission { IslandManager islandManager = plugin.getIslandManager(); Island island = islandManager.getIslandAtLocation(from); Location to = island.getLocation(IslandWorld.Normal, IslandEnvironment.Main); - if(island.hasRole(IslandRole.Visitor, player.getUniqueId())){ - if(plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "config.yml")) + if (island.hasRole(IslandRole.Visitor, player.getUniqueId())) { + if (plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "config.yml")) .getFileConfiguration().getBoolean("Island.Teleport.SafetyCheck", true)) { - Location safeLoc = LocationUtil.getSafeLocation(island.getLocation(IslandWorld.Normal, IslandEnvironment.Visitor)); - if (safeLoc != null) { - to = safeLoc; + Location isLoc = island.getLocation(IslandWorld.Normal, IslandEnvironment.Visitor); + + if (isLoc != null) { + Location safeLoc = LocationUtil.getSafeLocation(isLoc); + if (safeLoc != null) { + to = safeLoc; + } } } - if(to == null){ + if (to == null) { to = LocationUtil.getSpawnLocation(); } }