diff --git a/src/main/java/world/bentobox/bentobox/api/user/User.java b/src/main/java/world/bentobox/bentobox/api/user/User.java index 95398f374..93c9b9413 100644 --- a/src/main/java/world/bentobox/bentobox/api/user/User.java +++ b/src/main/java/world/bentobox/bentobox/api/user/User.java @@ -228,7 +228,7 @@ public class User { if (!NumberUtils.isNumber(spl[1])) { plugin.logError("Player " + player.getName() + " has permission: '" + perms.getPermission() + "' <-- the last part MUST be a number! Ignoring..."); } else { - int v = Integer.valueOf(spl[1]); + int v = Integer.parseInt(spl[1]); if (v < 0) { return v; } diff --git a/src/main/java/world/bentobox/bentobox/managers/IslandsManager.java b/src/main/java/world/bentobox/bentobox/managers/IslandsManager.java index 8e0b70742..8d5fe5f31 100644 --- a/src/main/java/world/bentobox/bentobox/managers/IslandsManager.java +++ b/src/main/java/world/bentobox/bentobox/managers/IslandsManager.java @@ -737,6 +737,7 @@ public class IslandsManager { * Island coordinates should always be a multiple of the island distance x 2. If they are not, this method * realigns the grid coordinates. * @param island - island + * @since 1.3.0 */ public void fixIslandCenter(Island island) { World world = island.getWorld(); @@ -744,8 +745,8 @@ public class IslandsManager { return; } int distance = island.getRange() * 2; - long x = island.getCenter().getBlockX() - plugin.getIWM().getIslandXOffset(world); - long z = island.getCenter().getBlockZ() - plugin.getIWM().getIslandZOffset(world); + long x = ((long) island.getCenter().getBlockX()) - plugin.getIWM().getIslandXOffset(world); + long z = ((long) island.getCenter().getBlockZ()) - plugin.getIWM().getIslandZOffset(world); if (x % distance != 0 || z % distance != 0) { // Island is off grid x = Math.round((double) x / distance) * distance + plugin.getIWM().getIslandXOffset(world); @@ -975,6 +976,7 @@ public class IslandsManager { * @return optional island * @since 1.3.0 */ + @NonNull public Optional getIslandById(String uniqueId) { return Optional.ofNullable(islandCache.getIslandById(uniqueId)); } @@ -987,6 +989,7 @@ public class IslandsManager { * @return list of islands; may be empty * @since 1.3.0 */ + @NonNull public List getQuarantinedIslandByUser(@NonNull World world, @Nullable UUID uuid) { return quarantineCache.getOrDefault(uuid, Collections.emptyList()).stream() .filter(i -> i.getWorld().equals(world)).collect(Collectors.toList()); @@ -1011,6 +1014,7 @@ public class IslandsManager { * @return the quarantineCache * @since 1.3.0 */ + @NonNull public Map> getQuarantineCache() { return quarantineCache; } @@ -1019,15 +1023,13 @@ public class IslandsManager { * Remove a quarantined island and delete it from the database completely. * This is NOT recoverable unless you have database backups. * @param island island - * @return true if island is quarantined and removed + * @return {@code true} if island is quarantined and removed * @since 1.3.0 */ public boolean purgeQuarantinedIsland(Island island) { - if (quarantineCache.containsKey(island.getOwner())) { - if (quarantineCache.get(island.getOwner()).remove(island)) { - handler.deleteObject(island); - return true; - } + if (quarantineCache.containsKey(island.getOwner()) && quarantineCache.get(island.getOwner()).remove(island)) { + handler.deleteObject(island); + return true; } return false; } diff --git a/src/main/java/world/bentobox/bentobox/managers/island/IslandCache.java b/src/main/java/world/bentobox/bentobox/managers/island/IslandCache.java index 8d7d9856a..29b021fa0 100644 --- a/src/main/java/world/bentobox/bentobox/managers/island/IslandCache.java +++ b/src/main/java/world/bentobox/bentobox/managers/island/IslandCache.java @@ -257,7 +257,7 @@ public class IslandCache { /** * Get the island by unique id - * @param uniqueId + * @param uniqueId unique id of the Island. * @return island or null if none found * @since 1.3.0 */ @@ -289,6 +289,6 @@ public class IslandCache { */ public void resetAllFlags(World world) { World w = Util.getWorld(world); - islandsById.values().stream().filter(i -> i.getWorld().equals(w)).forEach(i -> i.setFlagsDefaults()); + islandsById.values().stream().filter(i -> i.getWorld().equals(w)).forEach(Island::setFlagsDefaults); } }