diff --git a/src/main/java/us/tastybento/bskyblock/api/commands/BSBCommand.java b/src/main/java/us/tastybento/bskyblock/api/commands/BSBCommand.java index ac67ceeab..870e8d81b 100644 --- a/src/main/java/us/tastybento/bskyblock/api/commands/BSBCommand.java +++ b/src/main/java/us/tastybento/bskyblock/api/commands/BSBCommand.java @@ -14,7 +14,7 @@ public interface BSBCommand { /** * Anything that needs to be set up for this command. - * Do not register subcommands in this section. Put them after the super in the constructor + * Register subcommands in this section. */ void setup(); diff --git a/src/main/java/us/tastybento/bskyblock/commands/IslandCommand.java b/src/main/java/us/tastybento/bskyblock/commands/IslandCommand.java index 8af8fba75..8c92ac151 100755 --- a/src/main/java/us/tastybento/bskyblock/commands/IslandCommand.java +++ b/src/main/java/us/tastybento/bskyblock/commands/IslandCommand.java @@ -2,8 +2,6 @@ package us.tastybento.bskyblock.commands; import java.util.ArrayList; import java.util.List; -import java.util.Optional; -import java.util.stream.Collectors; import us.tastybento.bskyblock.api.commands.CompositeCommand; import us.tastybento.bskyblock.api.user.User; @@ -20,7 +18,6 @@ import us.tastybento.bskyblock.commands.island.IslandSetnameCommand; import us.tastybento.bskyblock.commands.island.IslandSettingsCommand; import us.tastybento.bskyblock.commands.island.IslandUnbanCommand; import us.tastybento.bskyblock.commands.island.teams.IslandTeamCommand; -import us.tastybento.bskyblock.util.Util; public class IslandCommand extends CompositeCommand { @@ -65,8 +62,7 @@ public class IslandCommand extends CompositeCommand { return false; } if (args.isEmpty()) { - // If in world, go - + // If user has an island, go if (getPlugin().getIslands().getIsland(getWorld(), user.getUniqueId()) != null) { return getSubCommand("go").map(goCmd -> goCmd.execute(user, new ArrayList<>())).orElse(false); } @@ -78,11 +74,4 @@ public class IslandCommand extends CompositeCommand { } - @Override - public Optional> tabComplete(User user, String alias, List args) { - List options = getPlugin().getIWM().getOverWorldNames().stream().collect(Collectors.toList()); - String lastArg = !args.isEmpty() ? args.get(args.size()-1) : ""; - return Optional.of(Util.tabLimit(options, lastArg)); - } - } diff --git a/src/main/java/us/tastybento/bskyblock/commands/admin/AdminRegisterCommand.java b/src/main/java/us/tastybento/bskyblock/commands/admin/AdminRegisterCommand.java index c97ad5a68..288e6fa1c 100644 --- a/src/main/java/us/tastybento/bskyblock/commands/admin/AdminRegisterCommand.java +++ b/src/main/java/us/tastybento/bskyblock/commands/admin/AdminRegisterCommand.java @@ -53,7 +53,7 @@ public class AdminRegisterCommand extends CompositeCommand { // Register island if it exists return island.map(i -> { // Island exists - getIslands().makeLeader(user, targetUUID, i); + getIslands().makeLeader(user, targetUUID, i, getPermissionPrefix()); user.sendMessage("commands.admin.register.registered-island", "[xyz]", Util.xyz(i.getCenter().toVector())); user.sendMessage("general.success"); return true; diff --git a/src/main/java/us/tastybento/bskyblock/commands/admin/teams/AdminTeamAddCommand.java b/src/main/java/us/tastybento/bskyblock/commands/admin/teams/AdminTeamAddCommand.java index dd0ffbd07..deabb7254 100644 --- a/src/main/java/us/tastybento/bskyblock/commands/admin/teams/AdminTeamAddCommand.java +++ b/src/main/java/us/tastybento/bskyblock/commands/admin/teams/AdminTeamAddCommand.java @@ -3,8 +3,6 @@ package us.tastybento.bskyblock.commands.admin.teams; import java.util.List; import java.util.UUID; -import org.bukkit.World; - import us.tastybento.bskyblock.api.commands.CompositeCommand; import us.tastybento.bskyblock.api.user.User; @@ -24,8 +22,6 @@ public class AdminTeamAddCommand extends CompositeCommand { @Override public boolean execute(User user, List args) { - // TODO: fix world - World world = getPlugin().getIWM().getIslandWorld(); // If args are not right, show help if (args.size() != 2) { showHelp(this, user); @@ -42,20 +38,20 @@ public class AdminTeamAddCommand extends CompositeCommand { user.sendMessage("general.errors.unknown-player-name", "[name]", args.get(1)); return false; } - if (!getIslands().hasIsland(world, leaderUUID)) { + if (!getIslands().hasIsland(getWorld(), leaderUUID)) { user.sendMessage("general.errors.player-has-no-island"); return false; } - if (getIslands().inTeam(world, leaderUUID) && !getIslands().getTeamLeader(world, leaderUUID).equals(leaderUUID)) { + if (getIslands().inTeam(getWorld(), leaderUUID) && !getIslands().getTeamLeader(getWorld(), leaderUUID).equals(leaderUUID)) { user.sendMessage("commands.admin.team.add.name-not-leader", "[name]", args.get(0)); - getIslands().getIsland(world, leaderUUID).showMembers(getPlugin(), user); + getIslands().getIsland(getWorld(), leaderUUID).showMembers(getPlugin(), user); return false; } - if (getIslands().inTeam(world, targetUUID)) { + if (getIslands().inTeam(getWorld(), targetUUID)) { user.sendMessage("commands.island.team.invite.errors.already-on-team"); return false; } - if (getIslands().hasIsland(world, targetUUID)) { + if (getIslands().hasIsland(getWorld(), targetUUID)) { user.sendMessage("commands.admin.team.add.name-has-island", "[name]", args.get(1)); return false; } @@ -64,7 +60,7 @@ public class AdminTeamAddCommand extends CompositeCommand { User leader = User.getInstance(leaderUUID); leader.sendMessage("commands.island.team.invite.accept.name-joined-your-island", "[name]", getPlugin().getPlayers().getName(targetUUID)); target.sendMessage("commands.island.team.invite.accept.you-joined-island", "[label]", getTopLabel()); - getIslands().getIsland(world, leaderUUID).addMember(targetUUID); + getIslands().getIsland(getWorld(), leaderUUID).addMember(targetUUID); user.sendMessage("general.success"); return true; diff --git a/src/main/java/us/tastybento/bskyblock/commands/admin/teams/AdminTeamDisbandCommand.java b/src/main/java/us/tastybento/bskyblock/commands/admin/teams/AdminTeamDisbandCommand.java index b8217f881..5bea1c69d 100644 --- a/src/main/java/us/tastybento/bskyblock/commands/admin/teams/AdminTeamDisbandCommand.java +++ b/src/main/java/us/tastybento/bskyblock/commands/admin/teams/AdminTeamDisbandCommand.java @@ -3,8 +3,6 @@ package us.tastybento.bskyblock.commands.admin.teams; import java.util.List; import java.util.UUID; -import org.bukkit.World; - import us.tastybento.bskyblock.api.commands.CompositeCommand; import us.tastybento.bskyblock.api.user.User; @@ -23,9 +21,6 @@ public class AdminTeamDisbandCommand extends CompositeCommand { @Override public boolean execute(User user, List args) { - // TODO: fix world - World world = getPlugin().getIWM().getIslandWorld(); - // If args are not right, show help if (args.size() != 1) { showHelp(this, user); @@ -37,24 +32,24 @@ public class AdminTeamDisbandCommand extends CompositeCommand { user.sendMessage("general.errors.unknown-player"); return false; } - if (!getIslands().hasIsland(world, targetUUID)) { + if (!getIslands().hasIsland(getWorld(), targetUUID)) { user.sendMessage("general.errors.no-island"); return false; } - if (!getIslands().inTeam(world, targetUUID)) { + if (!getIslands().inTeam(getWorld(), targetUUID)) { user.sendMessage("general.errors.not-in-team"); return false; } - if (!getIslands().getTeamLeader(world, targetUUID).equals(targetUUID)) { - user.sendMessage("commands.admin.team.disband.use-disband-leader", "[leader]", getPlayers().getName(getIslands().getTeamLeader(world, targetUUID))); + if (!getIslands().getTeamLeader(getWorld(), targetUUID).equals(targetUUID)) { + user.sendMessage("commands.admin.team.disband.use-disband-leader", "[leader]", getPlayers().getName(getIslands().getTeamLeader(getWorld(), targetUUID))); return false; } // Disband team - getIslands().getMembers(world, targetUUID).forEach(m -> { + getIslands().getMembers(getWorld(), targetUUID).forEach(m -> { User.getInstance(m).sendMessage("commands.admin.team.disband.disbanded"); // The leader gets to keep the island if (!m.equals(targetUUID)) { - getIslands().setLeaveTeam(world, m); + getIslands().setLeaveTeam(getWorld(), m); } }); user.sendMessage("general.success"); diff --git a/src/main/java/us/tastybento/bskyblock/commands/admin/teams/AdminTeamKickCommand.java b/src/main/java/us/tastybento/bskyblock/commands/admin/teams/AdminTeamKickCommand.java index ec8c794c9..7848b56b7 100644 --- a/src/main/java/us/tastybento/bskyblock/commands/admin/teams/AdminTeamKickCommand.java +++ b/src/main/java/us/tastybento/bskyblock/commands/admin/teams/AdminTeamKickCommand.java @@ -3,8 +3,6 @@ package us.tastybento.bskyblock.commands.admin.teams; import java.util.List; import java.util.UUID; -import org.bukkit.World; - import us.tastybento.bskyblock.api.commands.CompositeCommand; import us.tastybento.bskyblock.api.user.User; @@ -24,9 +22,6 @@ public class AdminTeamKickCommand extends CompositeCommand { @Override public boolean execute(User user, List args) { - // TODO: fix world - World world = getPlugin().getIWM().getIslandWorld(); - // If args are not right, show help if (args.size() != 1) { showHelp(this, user); @@ -38,21 +33,21 @@ public class AdminTeamKickCommand extends CompositeCommand { user.sendMessage("general.errors.unknown-player"); return false; } - if (!getIslands().hasIsland(world, targetUUID)) { + if (!getIslands().hasIsland(getWorld(), targetUUID)) { user.sendMessage("general.errors.no-island"); return false; } - if (!getIslands().inTeam(world, targetUUID)) { + if (!getIslands().inTeam(getWorld(), targetUUID)) { user.sendMessage("general.errors.not-in-team"); return false; } - if (getIslands().getTeamLeader(world, targetUUID).equals(targetUUID)) { + if (getIslands().getTeamLeader(getWorld(), targetUUID).equals(targetUUID)) { user.sendMessage("commands.admin.team.kick.cannot-kick-leader"); - getIslands().getIsland(world, targetUUID).showMembers(getPlugin(), user); + getIslands().getIsland(getWorld(), targetUUID).showMembers(getPlugin(), user); return false; } User.getInstance(targetUUID).sendMessage("commands.admin.team.kick.admin-kicked"); - getIslands().removePlayer(world, targetUUID); + getIslands().removePlayer(getWorld(), targetUUID); user.sendMessage("general.success"); return true; diff --git a/src/main/java/us/tastybento/bskyblock/commands/admin/teams/AdminTeamMakeLeaderCommand.java b/src/main/java/us/tastybento/bskyblock/commands/admin/teams/AdminTeamMakeLeaderCommand.java index 6444332f4..70e016c44 100644 --- a/src/main/java/us/tastybento/bskyblock/commands/admin/teams/AdminTeamMakeLeaderCommand.java +++ b/src/main/java/us/tastybento/bskyblock/commands/admin/teams/AdminTeamMakeLeaderCommand.java @@ -3,8 +3,6 @@ package us.tastybento.bskyblock.commands.admin.teams; import java.util.List; import java.util.UUID; -import org.bukkit.World; - import us.tastybento.bskyblock.api.commands.CompositeCommand; import us.tastybento.bskyblock.api.user.User; @@ -23,9 +21,6 @@ public class AdminTeamMakeLeaderCommand extends CompositeCommand { @Override public boolean execute(User user, List args) { - // TODO: fix world - World world = getPlugin().getIWM().getIslandWorld(); - // If args are not right, show help if (args.size() != 1) { showHelp(this, user); @@ -37,20 +32,20 @@ public class AdminTeamMakeLeaderCommand extends CompositeCommand { user.sendMessage("general.errors.unknown-player"); return false; } - if (!getIslands().hasIsland(world, targetUUID)) { + if (!getIslands().hasIsland(getWorld(), targetUUID)) { user.sendMessage("general.errors.no-island"); return false; } - if (!getIslands().inTeam(world, targetUUID)) { + if (!getIslands().inTeam(getWorld(), targetUUID)) { user.sendMessage("general.errors.not-in-team"); return false; } - if (getIslands().getTeamLeader(world, targetUUID).equals(targetUUID)) { + if (getIslands().getTeamLeader(getWorld(), targetUUID).equals(targetUUID)) { user.sendMessage("commands.admin.team.makeleader.already-leader"); return false; } // Make new leader - getIslands().makeLeader(world, user, targetUUID); + getIslands().makeLeader(getWorld(), user, targetUUID, getPermissionPrefix()); user.sendMessage("general.success"); return true; } diff --git a/src/main/java/us/tastybento/bskyblock/commands/island/IslandGoCommand.java b/src/main/java/us/tastybento/bskyblock/commands/island/IslandGoCommand.java index 3f0d200ad..1e316695d 100644 --- a/src/main/java/us/tastybento/bskyblock/commands/island/IslandGoCommand.java +++ b/src/main/java/us/tastybento/bskyblock/commands/island/IslandGoCommand.java @@ -44,7 +44,7 @@ public class IslandGoCommand extends CompositeCommand { } if (!args.isEmpty() && NumberUtils.isDigits(args.get(0))) { int homeValue = Integer.valueOf(args.get(0)); - int maxHomes = Util.getPermValue(user.getPlayer(), "island.maxhomes", getSettings().getMaxHomes()); + int maxHomes = Util.getPermValue(user.getPlayer(), "island.maxhomes", getIWM().getMaxHomes(getWorld())); if (homeValue > 1 && homeValue <= maxHomes) { getIslands().homeTeleport(getWorld(), user.getPlayer(), homeValue); user.sendMessage("commands.island.go.tip", "[label]", getTopLabel()); diff --git a/src/main/java/us/tastybento/bskyblock/commands/island/teams/IslandTeamSetownerCommand.java b/src/main/java/us/tastybento/bskyblock/commands/island/teams/IslandTeamSetownerCommand.java index 109abcb44..7fd8bb870 100644 --- a/src/main/java/us/tastybento/bskyblock/commands/island/teams/IslandTeamSetownerCommand.java +++ b/src/main/java/us/tastybento/bskyblock/commands/island/teams/IslandTeamSetownerCommand.java @@ -68,7 +68,7 @@ public class IslandTeamSetownerCommand extends CompositeCommand { if (event.isCancelled()) { return false; } - getIslands().makeLeader(getWorld(), user, targetUUID); + getIslands().makeLeader(getWorld(), user, targetUUID, getPermissionPrefix()); getIslands().save(true); return true; } diff --git a/src/main/java/us/tastybento/bskyblock/managers/IslandsManager.java b/src/main/java/us/tastybento/bskyblock/managers/IslandsManager.java index 5aa383153..60adddd51 100644 --- a/src/main/java/us/tastybento/bskyblock/managers/IslandsManager.java +++ b/src/main/java/us/tastybento/bskyblock/managers/IslandsManager.java @@ -794,9 +794,6 @@ public class IslandsManager { return getMembers(world, playerUUID).size() > 1; } - private int getMaxRangeSize(User user) { - return Util.getPermValue(user.getPlayer(), "island.range.", plugin.getSettings().getIslandProtectionRange()); - } /** * Makes a new leader for an island @@ -804,8 +801,8 @@ public class IslandsManager { * @param user - the user who is issuing the command * @param targetUUID - the current island member who is going to become the leader */ - public void makeLeader(World world, User user, UUID targetUUID) { - makeLeader(user, targetUUID, getIsland(world, targetUUID)); + public void makeLeader(World world, User user, UUID targetUUID, String permPrefix) { + makeLeader(user, targetUUID, getIsland(world, targetUUID), permPrefix); } /** @@ -814,7 +811,7 @@ public class IslandsManager { * @param targetUUID - new leader * @param island - island to register */ - public void makeLeader(User user, UUID targetUUID, Island island) { + public void makeLeader(User user, UUID targetUUID, Island island, String permPrefix) { islandCache.setOwner(island, targetUUID); user.sendMessage("commands.island.team.setowner.name-is-the-owner", "[name]", plugin.getPlayers().getName(targetUUID)); @@ -824,7 +821,7 @@ public class IslandsManager { target.sendMessage("commands.island.team.setowner.you-are-the-owner"); if (target.isOnline()) { // Check if new leader has a different range permission than the island size - int range = getMaxRangeSize(target); + int range = Util.getPermValue(target.getPlayer(), permPrefix + "island.range.", plugin.getIWM().getIslandProtectionRange(Util.getWorld(island.getWorld()))); // Range can go up or down if (range != island.getProtectionRange()) { user.sendMessage("commands.admin.setrange.range-updated", "[number]", String.valueOf(range)); diff --git a/src/main/java/us/tastybento/bskyblock/util/DeleteIslandChunks.java b/src/main/java/us/tastybento/bskyblock/util/DeleteIslandChunks.java index d198e78dd..cc6e44c22 100644 --- a/src/main/java/us/tastybento/bskyblock/util/DeleteIslandChunks.java +++ b/src/main/java/us/tastybento/bskyblock/util/DeleteIslandChunks.java @@ -40,11 +40,11 @@ public class DeleteIslandChunks { for (int x = minXChunk; x <= maxXChunk; x++) { for (int z = minZChunk; z<=maxZChunk; z++) { world.regenerateChunk(x, z); - if (plugin.getSettings().isNetherGenerate() && plugin.getSettings().isNetherIslands()) { + if (plugin.getIWM().isNetherGenerate(world) && plugin.getIWM().isNetherIslands(world)) { plugin.getIWM().getNetherWorld().regenerateChunk(x, z); } - if (plugin.getSettings().isEndGenerate() && plugin.getSettings().isEndIslands()) { + if (plugin.getIWM().isEndGenerate(world) && plugin.getIWM().isEndIslands(world)) { plugin.getIWM().getEndWorld().regenerateChunk(x, z); } } diff --git a/src/test/java/us/tastybento/bskyblock/commands/admin/teams/AdminTeamMakeLeaderCommandTest.java b/src/test/java/us/tastybento/bskyblock/commands/admin/teams/AdminTeamMakeLeaderCommandTest.java index 0213654db..031819bb7 100644 --- a/src/test/java/us/tastybento/bskyblock/commands/admin/teams/AdminTeamMakeLeaderCommandTest.java +++ b/src/test/java/us/tastybento/bskyblock/commands/admin/teams/AdminTeamMakeLeaderCommandTest.java @@ -199,7 +199,7 @@ public class AdminTeamMakeLeaderCommandTest { AdminTeamMakeLeaderCommand itl = new AdminTeamMakeLeaderCommand(ac); assertTrue(itl.execute(user, Arrays.asList(name))); // Add other verifications - Mockito.verify(im).makeLeader(Mockito.any(), Mockito.eq(user), Mockito.eq(notUUID)); + Mockito.verify(im).makeLeader(Mockito.any(), Mockito.eq(user), Mockito.eq(notUUID), Mockito.any()); Mockito.verify(user).sendMessage(Mockito.eq("general.success")); }