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) {
|
private void deletePlayer(User user, UUID targetUUID) {
|
||||||
// Delete player and island
|
// 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
|
// Get the target's island
|
||||||
Island oldIsland = getIslands().getIsland(getWorld(), targetUUID);
|
Island oldIsland = getIslands().getIsland(getWorld(), targetUUID);
|
||||||
if (oldIsland != null) {
|
if (oldIsland != null) {
|
||||||
@ -89,7 +87,7 @@ public class AdminDeleteCommand extends ConfirmableCommand {
|
|||||||
getIslands().deleteIsland(oldIsland, true, targetUUID);
|
getIslands().deleteIsland(oldIsland, true, targetUUID);
|
||||||
}
|
}
|
||||||
getPlayers().clearHomeLocations(getWorld(), 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
|
@Override
|
||||||
|
@ -53,7 +53,7 @@ public class AdminEmptyTrashCommand extends ConfirmableCommand {
|
|||||||
} else {
|
} else {
|
||||||
this.askConfirmation(user, () -> {
|
this.askConfirmation(user, () -> {
|
||||||
getIslands().deleteQuarantinedIslandByUser(getWorld(), targetUUID);
|
getIslands().deleteQuarantinedIslandByUser(getWorld(), targetUUID);
|
||||||
user.sendMessage("general.success");
|
user.sendMessage("commands.admin.emptytrash.success");
|
||||||
});
|
});
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -94,7 +94,6 @@ public class AdminRegisterCommand extends ConfirmableCommand {
|
|||||||
getIslands().setOwner(user, targetUUID, i);
|
getIslands().setOwner(user, targetUUID, i);
|
||||||
getWorld().getBlockAt(i.getCenter()).setType(Material.BEDROCK);
|
getWorld().getBlockAt(i.getCenter()).setType(Material.BEDROCK);
|
||||||
user.sendMessage("commands.admin.register.registered-island", "[xyz]", Util.xyz(i.getCenter().toVector()));
|
user.sendMessage("commands.admin.register.registered-island", "[xyz]", Util.xyz(i.getCenter().toVector()));
|
||||||
user.sendMessage("general.success");
|
|
||||||
IslandBaseEvent event = IslandEvent.builder()
|
IslandBaseEvent event = IslandEvent.builder()
|
||||||
.island(i)
|
.island(i)
|
||||||
.location(i.getCenter())
|
.location(i.getCenter())
|
||||||
|
@ -29,7 +29,7 @@ public class AdminResetFlagsCommand extends ConfirmableCommand {
|
|||||||
// Everything's fine, we can set the island as spawn :)
|
// Everything's fine, we can set the island as spawn :)
|
||||||
askConfirmation(user, () -> {
|
askConfirmation(user, () -> {
|
||||||
getIslands().resetAllFlags(getWorld());
|
getIslands().resetAllFlags(getWorld());
|
||||||
user.sendMessage("general.success");
|
user.sendMessage("commands.admin.resetflags.success");
|
||||||
});
|
});
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -75,7 +75,6 @@ public class AdminSetspawnCommand extends ConfirmableCommand {
|
|||||||
}
|
}
|
||||||
getIslands().setSpawn(i);
|
getIslands().setSpawn(i);
|
||||||
i.setSpawnPoint(World.Environment.NORMAL, user.getLocation());
|
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, () -> {
|
this.askConfirmation(user, () -> {
|
||||||
if (getIslands().switchIsland(getWorld(), targetUUID, islands.get(n -1))) {
|
if (getIslands().switchIsland(getWorld(), targetUUID, islands.get(n -1))) {
|
||||||
user.sendMessage("general.success");
|
user.sendMessage("commands.admin.switchto.success");
|
||||||
} else {
|
} else {
|
||||||
user.sendMessage("commands.admin.switchto.cannot-switch");
|
user.sendMessage("commands.admin.switchto.cannot-switch");
|
||||||
}
|
}
|
||||||
|
@ -63,7 +63,6 @@ public class AdminUnregisterCommand extends ConfirmableCommand {
|
|||||||
private void unregisterPlayer(User user, UUID targetUUID) {
|
private void unregisterPlayer(User user, UUID targetUUID) {
|
||||||
// Unregister island
|
// Unregister island
|
||||||
Island oldIsland = getIslands().getIsland(getWorld(), targetUUID);
|
Island oldIsland = getIslands().getIsland(getWorld(), targetUUID);
|
||||||
user.sendMessage("commands.admin.unregister.unregistered-island", "[xyz]", Util.xyz(oldIsland.getCenter().toVector()));
|
|
||||||
IslandBaseEvent event = IslandEvent.builder()
|
IslandBaseEvent event = IslandEvent.builder()
|
||||||
.island(oldIsland)
|
.island(oldIsland)
|
||||||
.location(oldIsland.getCenter())
|
.location(oldIsland.getCenter())
|
||||||
@ -77,7 +76,7 @@ public class AdminUnregisterCommand extends ConfirmableCommand {
|
|||||||
getIslands().removePlayer(getWorld(), m);
|
getIslands().removePlayer(getWorld(), m);
|
||||||
getPlayers().clearHomeLocations(getWorld(), m);
|
getPlayers().clearHomeLocations(getWorld(), m);
|
||||||
});
|
});
|
||||||
user.sendMessage("general.success");
|
user.sendMessage("commands.admin.unregister.unregistered-island", "[xyz]", Util.xyz(oldIsland.getCenter().toVector()));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -151,7 +151,8 @@ commands:
|
|||||||
parameters: "<player> <number>"
|
parameters: "<player> <number>"
|
||||||
description: "switch player's island to the numbered one in trash"
|
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"
|
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:
|
trash:
|
||||||
no-unowned-in-trash: "&cNo unowned islands in trash"
|
no-unowned-in-trash: "&cNo unowned islands in trash"
|
||||||
no-islands-in-trash: "&cPlayer has no islands in trash"
|
no-islands-in-trash: "&cPlayer has no islands in trash"
|
||||||
@ -164,12 +165,13 @@ commands:
|
|||||||
emptytrash:
|
emptytrash:
|
||||||
parameters: "[player]"
|
parameters: "[player]"
|
||||||
description: "Clear trash for player, or all unowned islands in trash"
|
description: "Clear trash for player, or all unowned islands in trash"
|
||||||
|
success: "&aTrash successfully emptied."
|
||||||
version:
|
version:
|
||||||
description: "display BentoBox and addons versions"
|
description: "display BentoBox and addons versions"
|
||||||
setrange:
|
setrange:
|
||||||
parameters: "<player> <range>"
|
parameters: "<player> <range>"
|
||||||
description: "set the range of player's island"
|
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:
|
reload:
|
||||||
description: "reload"
|
description: "reload"
|
||||||
tp:
|
tp:
|
||||||
@ -186,10 +188,11 @@ commands:
|
|||||||
unknown-rank: "&cUnknown rank!"
|
unknown-rank: "&cUnknown rank!"
|
||||||
rank-set: "&aRank set from [from] to [to]."
|
rank-set: "&aRank set from [from] to [to]."
|
||||||
setspawn:
|
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!"
|
already-spawn: "&cThis island is already a spawn!"
|
||||||
no-island-here: "&cThere is no island here."
|
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:
|
blueprint:
|
||||||
parameters: "<load/copy/paste/pos1/pos2/save>"
|
parameters: "<load/copy/paste/pos1/pos2/save>"
|
||||||
description: "manipulate blueprints"
|
description: "manipulate blueprints"
|
||||||
@ -279,6 +282,7 @@ commands:
|
|||||||
&aRight click to decrement
|
&aRight click to decrement
|
||||||
resetflags:
|
resetflags:
|
||||||
description: "Reset all islands to default flag settings in config.yml"
|
description: "Reset all islands to default flag settings in config.yml"
|
||||||
|
success: "&aSuccessfully reset all islands' flags to the default settings."
|
||||||
world:
|
world:
|
||||||
description: "Manage world settings"
|
description: "Manage world settings"
|
||||||
delete:
|
delete:
|
||||||
|
@ -367,7 +367,7 @@ public class IslandExpelCommandTest {
|
|||||||
public void testExecuteUserStringListOfStringHasIsland() {
|
public void testExecuteUserStringListOfStringHasIsland() {
|
||||||
testCanExecute();
|
testCanExecute();
|
||||||
assertTrue(iec.execute(user, "", Collections.singletonList("tasty")));
|
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());
|
Mockito.verify(im).homeTeleport(Mockito.any(), Mockito.any());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -381,7 +381,7 @@ public class IslandExpelCommandTest {
|
|||||||
testCanExecute();
|
testCanExecute();
|
||||||
when(im.hasIsland(Mockito.any(), Mockito.any(User.class))).thenReturn(false);
|
when(im.hasIsland(Mockito.any(), Mockito.any(User.class))).thenReturn(false);
|
||||||
assertTrue(iec.execute(user, "", Collections.singletonList("tasty")));
|
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());
|
Mockito.verify(im).spawnTeleport(Mockito.any(), Mockito.any());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -401,7 +401,7 @@ public class IslandExpelCommandTest {
|
|||||||
testCanExecute();
|
testCanExecute();
|
||||||
when(im.hasIsland(Mockito.any(), Mockito.any(User.class))).thenReturn(false);
|
when(im.hasIsland(Mockito.any(), Mockito.any(User.class))).thenReturn(false);
|
||||||
assertTrue(iec.execute(user, "", Collections.singletonList("tasty")));
|
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"));
|
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.BentoBox;
|
||||||
import world.bentobox.bentobox.Settings;
|
import world.bentobox.bentobox.Settings;
|
||||||
import world.bentobox.bentobox.api.commands.CompositeCommand;
|
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.api.user.User;
|
||||||
import world.bentobox.bentobox.database.objects.Island;
|
import world.bentobox.bentobox.database.objects.Island;
|
||||||
import world.bentobox.bentobox.managers.CommandsManager;
|
import world.bentobox.bentobox.managers.CommandsManager;
|
||||||
@ -298,9 +299,7 @@ public class IslandTeamCoopCommandTest {
|
|||||||
// Execute
|
// Execute
|
||||||
when(im.getIsland(any(), Mockito.any(UUID.class))).thenReturn(island);
|
when(im.getIsland(any(), Mockito.any(UUID.class))).thenReturn(island);
|
||||||
assertTrue(itl.execute(user, itl.getLabel(), Collections.singletonList("tastybento")));
|
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);
|
verify(island).setRank(target, RanksManager.COOP_RANK);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user