From 54a7b8b0f225cc4af226de9da1e3901816365fed Mon Sep 17 00:00:00 2001 From: tastybento Date: Mon, 8 Jan 2024 22:21:20 +0900 Subject: [PATCH] Fix to avoid admins becoming subowners when registering an island. --- .../api/commands/admin/AdminRegisterCommand.java | 4 ++-- .../bentobox/bentobox/managers/IslandsManager.java | 13 ++++++++----- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/src/main/java/world/bentobox/bentobox/api/commands/admin/AdminRegisterCommand.java b/src/main/java/world/bentobox/bentobox/api/commands/admin/AdminRegisterCommand.java index 575a1414f..5d9682c3c 100644 --- a/src/main/java/world/bentobox/bentobox/api/commands/admin/AdminRegisterCommand.java +++ b/src/main/java/world/bentobox/bentobox/api/commands/admin/AdminRegisterCommand.java @@ -79,7 +79,7 @@ public class AdminRegisterCommand extends ConfirmableCommand { // Register island if it exists if (!island.map(i -> { // Island exists - getIslands().setOwner(user, targetUUID, i); + getIslands().setOwner(user, targetUUID, i, RanksManager.VISITOR_RANK); if (i.isSpawn()) { getIslands().clearSpawn(i.getWorld()); } @@ -111,7 +111,7 @@ public class AdminRegisterCommand extends ConfirmableCommand { user.sendMessage("commands.admin.register.cannot-make-island"); return; } - getIslands().setOwner(user, targetUUID, i); + getIslands().setOwner(user, targetUUID, i, RanksManager.VISITOR_RANK); i.setReserved(true); i.getCenter().getBlock().setType(Material.BEDROCK); user.sendMessage("commands.admin.register.reserved-island", TextVariables.XYZ, Util.xyz(i.getCenter().toVector()), diff --git a/src/main/java/world/bentobox/bentobox/managers/IslandsManager.java b/src/main/java/world/bentobox/bentobox/managers/IslandsManager.java index 55ad2d68b..c46c8e51f 100644 --- a/src/main/java/world/bentobox/bentobox/managers/IslandsManager.java +++ b/src/main/java/world/bentobox/bentobox/managers/IslandsManager.java @@ -1515,9 +1515,9 @@ public class IslandsManager { Location sp = spawn.get(w).getSpawnPoint(w.getEnvironment()); if (sp != null) { PaperLib.teleportAsync(p, sp); - } else { + } else { plugin.logWarning("Spawn exists but its location is null!"); - } + } } } }); @@ -1630,7 +1630,7 @@ public class IslandsManager { * owner */ public void setOwner(World world, User user, UUID targetUUID) { - setOwner(user, targetUUID, getIsland(world, user.getUniqueId())); + setOwner(user, targetUUID, getIsland(world, user.getUniqueId()), RanksManager.SUB_OWNER_RANK); } /** @@ -1639,11 +1639,14 @@ public class IslandsManager { * @param user previous owner * @param targetUUID new owner * @param island island to register + * @param rank rank to which to set old owner. */ - public void setOwner(User user, UUID targetUUID, Island island) { + public void setOwner(User user, UUID targetUUID, Island island, int rank) { islandCache.setOwner(island, targetUUID); // Set old owner as sub-owner on island. - island.setRank(user, RanksManager.SUB_OWNER_RANK); + if (rank > RanksManager.VISITOR_RANK) { + island.setRank(user, rank); + } user.sendMessage("commands.island.team.setowner.name-is-the-owner", "[name]", plugin.getPlayers().getName(targetUUID));