mirror of
https://github.com/BentoBoxWorld/BentoBox.git
synced 2024-11-28 13:45:14 +01:00
Fixed bugs
Fixed issues where Settings were used instead of WorldSettings. Added getWorld to the Admin team commands.
This commit is contained in:
parent
66d9ef857d
commit
60eac8e54e
@ -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();
|
||||
|
||||
|
@ -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<List<String>> tabComplete(User user, String alias, List<String> args) {
|
||||
List<String> options = getPlugin().getIWM().getOverWorldNames().stream().collect(Collectors.toList());
|
||||
String lastArg = !args.isEmpty() ? args.get(args.size()-1) : "";
|
||||
return Optional.of(Util.tabLimit(options, lastArg));
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -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;
|
||||
|
@ -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<String> 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;
|
||||
|
||||
|
@ -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<String> 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");
|
||||
|
@ -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<String> 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;
|
||||
|
||||
|
@ -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<String> 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;
|
||||
}
|
||||
|
@ -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());
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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));
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
@ -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"));
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user