Fix to avoid admins becoming subowners when registering an island.

This commit is contained in:
tastybento 2024-01-08 22:21:20 +09:00
parent 0e0c502e1d
commit 54a7b8b0f2
2 changed files with 10 additions and 7 deletions

View File

@ -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()),

View File

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