mirror of
https://github.com/BentoBoxWorld/BentoBox.git
synced 2024-11-23 19:25:12 +01:00
Improved success messages for admin commands and fixed failing tests
#630
This commit is contained in:
parent
6ecc021401
commit
64d89f9ca9
@ -65,8 +65,6 @@ public class AdminDeleteCommand extends ConfirmableCommand {
|
||||
|
||||
private void deletePlayer(User user, UUID targetUUID) {
|
||||
// Delete player and island
|
||||
user.sendMessage("commands.admin.delete.deleted-island", "[xyz]", Util.xyz(getIslands().getIsland(getWorld(), targetUUID).getCenter().toVector()));
|
||||
|
||||
// Get the target's island
|
||||
Island oldIsland = getIslands().getIsland(getWorld(), targetUUID);
|
||||
if (oldIsland != null) {
|
||||
@ -89,7 +87,7 @@ public class AdminDeleteCommand extends ConfirmableCommand {
|
||||
getIslands().deleteIsland(oldIsland, true, targetUUID);
|
||||
}
|
||||
getPlayers().clearHomeLocations(getWorld(), targetUUID);
|
||||
user.sendMessage("general.success");
|
||||
user.sendMessage("commands.admin.delete.deleted-island", "[xyz]", Util.xyz(getIslands().getIsland(getWorld(), targetUUID).getCenter().toVector()));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -53,7 +53,7 @@ public class AdminEmptyTrashCommand extends ConfirmableCommand {
|
||||
} else {
|
||||
this.askConfirmation(user, () -> {
|
||||
getIslands().deleteQuarantinedIslandByUser(getWorld(), targetUUID);
|
||||
user.sendMessage("general.success");
|
||||
user.sendMessage("commands.admin.emptytrash.success");
|
||||
});
|
||||
return true;
|
||||
}
|
||||
|
@ -94,7 +94,6 @@ public class AdminRegisterCommand extends ConfirmableCommand {
|
||||
getIslands().setOwner(user, targetUUID, i);
|
||||
getWorld().getBlockAt(i.getCenter()).setType(Material.BEDROCK);
|
||||
user.sendMessage("commands.admin.register.registered-island", "[xyz]", Util.xyz(i.getCenter().toVector()));
|
||||
user.sendMessage("general.success");
|
||||
IslandBaseEvent event = IslandEvent.builder()
|
||||
.island(i)
|
||||
.location(i.getCenter())
|
||||
|
@ -29,7 +29,7 @@ public class AdminResetFlagsCommand extends ConfirmableCommand {
|
||||
// Everything's fine, we can set the island as spawn :)
|
||||
askConfirmation(user, () -> {
|
||||
getIslands().resetAllFlags(getWorld());
|
||||
user.sendMessage("general.success");
|
||||
user.sendMessage("commands.admin.resetflags.success");
|
||||
});
|
||||
return true;
|
||||
}
|
||||
|
@ -75,7 +75,6 @@ public class AdminSetspawnCommand extends ConfirmableCommand {
|
||||
}
|
||||
getIslands().setSpawn(i);
|
||||
i.setSpawnPoint(World.Environment.NORMAL, user.getLocation());
|
||||
user.sendMessage("general.success");
|
||||
|
||||
user.sendMessage("commands.admin.setspawn.success");
|
||||
}
|
||||
}
|
||||
|
@ -67,7 +67,7 @@ public class AdminSwitchtoCommand extends ConfirmableCommand {
|
||||
}
|
||||
this.askConfirmation(user, () -> {
|
||||
if (getIslands().switchIsland(getWorld(), targetUUID, islands.get(n -1))) {
|
||||
user.sendMessage("general.success");
|
||||
user.sendMessage("commands.admin.switchto.success");
|
||||
} else {
|
||||
user.sendMessage("commands.admin.switchto.cannot-switch");
|
||||
}
|
||||
|
@ -63,7 +63,6 @@ public class AdminUnregisterCommand extends ConfirmableCommand {
|
||||
private void unregisterPlayer(User user, UUID targetUUID) {
|
||||
// Unregister island
|
||||
Island oldIsland = getIslands().getIsland(getWorld(), targetUUID);
|
||||
user.sendMessage("commands.admin.unregister.unregistered-island", "[xyz]", Util.xyz(oldIsland.getCenter().toVector()));
|
||||
IslandBaseEvent event = IslandEvent.builder()
|
||||
.island(oldIsland)
|
||||
.location(oldIsland.getCenter())
|
||||
@ -77,7 +76,7 @@ public class AdminUnregisterCommand extends ConfirmableCommand {
|
||||
getIslands().removePlayer(getWorld(), m);
|
||||
getPlayers().clearHomeLocations(getWorld(), m);
|
||||
});
|
||||
user.sendMessage("general.success");
|
||||
user.sendMessage("commands.admin.unregister.unregistered-island", "[xyz]", Util.xyz(oldIsland.getCenter().toVector()));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -151,7 +151,8 @@ commands:
|
||||
parameters: "<player> <number>"
|
||||
description: "switch player's island to the numbered one in trash"
|
||||
out-of-range: "&cNumber must be between 1 and [number]. Use &l[label] trash [player] &r&cto see island numbers"
|
||||
cannot-switch: "&cSwitch failed. See console log for error."
|
||||
cannot-switch: "&cSwitch failed. See console log for error."
|
||||
success: "&Successfully switched the player's island to the specified one."
|
||||
trash:
|
||||
no-unowned-in-trash: "&cNo unowned islands in trash"
|
||||
no-islands-in-trash: "&cPlayer has no islands in trash"
|
||||
@ -164,12 +165,13 @@ commands:
|
||||
emptytrash:
|
||||
parameters: "[player]"
|
||||
description: "Clear trash for player, or all unowned islands in trash"
|
||||
success: "&aTrash successfully emptied."
|
||||
version:
|
||||
description: "display BentoBox and addons versions"
|
||||
setrange:
|
||||
parameters: "<player> <range>"
|
||||
description: "set the range of player's island"
|
||||
range-updated: "Island range updated to [number]"
|
||||
range-updated: "&aIsland range updated to &b[number]&a."
|
||||
reload:
|
||||
description: "reload"
|
||||
tp:
|
||||
@ -186,10 +188,11 @@ commands:
|
||||
unknown-rank: "&cUnknown rank!"
|
||||
rank-set: "&aRank set from [from] to [to]."
|
||||
setspawn:
|
||||
description: "set an Island as spawn for this world"
|
||||
description: "set an island as spawn for this world"
|
||||
already-spawn: "&cThis island is already a spawn!"
|
||||
no-island-here: "&cThere is no island here."
|
||||
confirmation: "&cAre you sure you want to set this Island as the spawn for this world?"
|
||||
confirmation: "&cAre you sure you want to set this island as the spawn for this world?"
|
||||
success: "&aSuccessfully set this island as the spawn for this world."
|
||||
blueprint:
|
||||
parameters: "<load/copy/paste/pos1/pos2/save>"
|
||||
description: "manipulate blueprints"
|
||||
@ -279,6 +282,7 @@ commands:
|
||||
&aRight click to decrement
|
||||
resetflags:
|
||||
description: "Reset all islands to default flag settings in config.yml"
|
||||
success: "&aSuccessfully reset all islands' flags to the default settings."
|
||||
world:
|
||||
description: "Manage world settings"
|
||||
delete:
|
||||
|
@ -367,7 +367,7 @@ public class IslandExpelCommandTest {
|
||||
public void testExecuteUserStringListOfStringHasIsland() {
|
||||
testCanExecute();
|
||||
assertTrue(iec.execute(user, "", Collections.singletonList("tasty")));
|
||||
Mockito.verify(user).sendMessage("commands.island.expel.success");
|
||||
Mockito.verify(user).sendMessage("commands.island.expel.success", TextVariables.NAME, "target");
|
||||
Mockito.verify(im).homeTeleport(Mockito.any(), Mockito.any());
|
||||
}
|
||||
|
||||
@ -381,7 +381,7 @@ public class IslandExpelCommandTest {
|
||||
testCanExecute();
|
||||
when(im.hasIsland(Mockito.any(), Mockito.any(User.class))).thenReturn(false);
|
||||
assertTrue(iec.execute(user, "", Collections.singletonList("tasty")));
|
||||
Mockito.verify(user).sendMessage("commands.island.expel.success");
|
||||
Mockito.verify(user).sendMessage("commands.island.expel.success", TextVariables.NAME, "target");
|
||||
Mockito.verify(im).spawnTeleport(Mockito.any(), Mockito.any());
|
||||
}
|
||||
|
||||
@ -401,7 +401,7 @@ public class IslandExpelCommandTest {
|
||||
testCanExecute();
|
||||
when(im.hasIsland(Mockito.any(), Mockito.any(User.class))).thenReturn(false);
|
||||
assertTrue(iec.execute(user, "", Collections.singletonList("tasty")));
|
||||
Mockito.verify(user).sendMessage("commands.island.expel.success");
|
||||
Mockito.verify(user).sendMessage("commands.island.expel.success", TextVariables.NAME, "target");
|
||||
Mockito.verify(addon).logWarning(Mockito.eq("Expel: target had no island, so one was created"));
|
||||
}
|
||||
|
||||
|
@ -32,6 +32,7 @@ import org.powermock.reflect.Whitebox;
|
||||
import world.bentobox.bentobox.BentoBox;
|
||||
import world.bentobox.bentobox.Settings;
|
||||
import world.bentobox.bentobox.api.commands.CompositeCommand;
|
||||
import world.bentobox.bentobox.api.localization.TextVariables;
|
||||
import world.bentobox.bentobox.api.user.User;
|
||||
import world.bentobox.bentobox.database.objects.Island;
|
||||
import world.bentobox.bentobox.managers.CommandsManager;
|
||||
@ -298,9 +299,7 @@ public class IslandTeamCoopCommandTest {
|
||||
// Execute
|
||||
when(im.getIsland(any(), Mockito.any(UUID.class))).thenReturn(island);
|
||||
assertTrue(itl.execute(user, itl.getLabel(), Collections.singletonList("tastybento")));
|
||||
verify(user).sendMessage(eq("general.success"));
|
||||
verify(user).sendMessage("commands.island.team.coop.success", TextVariables.NAME, null);
|
||||
verify(island).setRank(target, RanksManager.COOP_RANK);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user