mirror of
https://github.com/BentoBoxWorld/BentoBox.git
synced 2024-11-12 13:54:22 +01:00
Slimmer trimmer island info for players.
https://github.com/BentoBoxWorld/BentoBox/issues/1501
This commit is contained in:
parent
547c266975
commit
0f7ca6ac60
@ -35,10 +35,8 @@ public class AdminInfoCommand extends CompositeCommand {
|
|||||||
}
|
}
|
||||||
// If there are no args, then the player wants info on the island at this location
|
// If there are no args, then the player wants info on the island at this location
|
||||||
if (args.isEmpty()) {
|
if (args.isEmpty()) {
|
||||||
if (!getIslands().getIslandAt(user.getLocation()).map(i -> new IslandInfo(i).showInfo(user)).orElse(false)) {
|
getIslands().getIslandAt(user.getLocation()).ifPresentOrElse(i -> new IslandInfo(i).showAdminInfo(user), () ->
|
||||||
user.sendMessage("commands.admin.info.no-island");
|
user.sendMessage("commands.admin.info.no-island"));
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
// Get target player
|
// Get target player
|
||||||
@ -50,7 +48,7 @@ public class AdminInfoCommand extends CompositeCommand {
|
|||||||
// Show info for this player
|
// Show info for this player
|
||||||
Island island = getIslands().getIsland(getWorld(), targetUUID);
|
Island island = getIslands().getIsland(getWorld(), targetUUID);
|
||||||
if (island != null) {
|
if (island != null) {
|
||||||
new IslandInfo(island).showInfo(user);
|
new IslandInfo(island).showAdminInfo(user);
|
||||||
if (!getIslands().getQuarantinedIslandByUser(getWorld(), targetUUID).isEmpty()) {
|
if (!getIslands().getQuarantinedIslandByUser(getWorld(), targetUUID).isEmpty()) {
|
||||||
user.sendMessage("commands.admin.info.islands-in-trash");
|
user.sendMessage("commands.admin.info.islands-in-trash");
|
||||||
}
|
}
|
||||||
|
@ -29,7 +29,7 @@ public class IslandInfo {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @param plugin
|
* @param plugin
|
||||||
* @param island
|
* @param island Island to show info
|
||||||
*/
|
*/
|
||||||
public IslandInfo(Island island) {
|
public IslandInfo(Island island) {
|
||||||
this.plugin = BentoBox.getInstance();
|
this.plugin = BentoBox.getInstance();
|
||||||
@ -39,11 +39,10 @@ public class IslandInfo {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Shows info of this island to this user.
|
* Shows admin info of this island
|
||||||
* @param user the User who is requesting it
|
* @param user user asking
|
||||||
* @return always true
|
|
||||||
*/
|
*/
|
||||||
public boolean showInfo(User user) {
|
public void showAdminInfo(User user) {
|
||||||
user.sendMessage("commands.admin.info.title");
|
user.sendMessage("commands.admin.info.title");
|
||||||
user.sendMessage("commands.admin.info.island-uuid", "[uuid]", island.getUniqueId());
|
user.sendMessage("commands.admin.info.island-uuid", "[uuid]", island.getUniqueId());
|
||||||
if (owner == null) {
|
if (owner == null) {
|
||||||
@ -87,6 +86,38 @@ public class IslandInfo {
|
|||||||
if (island.getPurgeProtected()) {
|
if (island.getPurgeProtected()) {
|
||||||
user.sendMessage("commands.admin.info.purge-protected");
|
user.sendMessage("commands.admin.info.purge-protected");
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Shows info of this island to this user.
|
||||||
|
* @param user the User who is requesting it
|
||||||
|
* @return always true
|
||||||
|
*/
|
||||||
|
public boolean showInfo(User user) {
|
||||||
|
user.sendMessage("commands.admin.info.title");
|
||||||
|
if (owner == null) {
|
||||||
|
user.sendMessage("commands.admin.info.unowned");
|
||||||
|
} else {
|
||||||
|
user.sendMessage("commands.admin.info.owner", "[owner]", plugin.getPlayers().getName(owner));
|
||||||
|
user.sendMessage("commands.admin.info.deaths", "[number]", String.valueOf(plugin.getPlayers().getDeaths(world, owner)));
|
||||||
|
String resets = String.valueOf(plugin.getPlayers().getResets(world, owner));
|
||||||
|
String total = plugin.getIWM().getResetLimit(world) < 0 ? "Unlimited" : String.valueOf(plugin.getIWM().getResetLimit(world));
|
||||||
|
user.sendMessage("commands.admin.info.resets-left", "[number]", resets, "[total]", total);
|
||||||
|
// Show team members
|
||||||
|
showMembers(user);
|
||||||
|
}
|
||||||
|
Vector location = island.getProtectionCenter().toVector();
|
||||||
|
user.sendMessage("commands.admin.info.island-center", TextVariables.XYZ, Util.xyz(location));
|
||||||
|
user.sendMessage("commands.admin.info.protection-range", "[range]", String.valueOf(island.getProtectionRange()));
|
||||||
|
user.sendMessage("commands.admin.info.protection-coords", "[xz1]", Util.xyz(new Vector(island.getMinProtectedX(), 0, island.getMinProtectedZ())), "[xz2]", Util.xyz(new Vector(island.getMaxProtectedX(), 0, island.getMaxProtectedZ())));
|
||||||
|
if (island.isSpawn()) {
|
||||||
|
user.sendMessage("commands.admin.info.is-spawn");
|
||||||
|
}
|
||||||
|
if (!island.getBanned().isEmpty()) {
|
||||||
|
user.sendMessage("commands.admin.info.banned-players");
|
||||||
|
island.getBanned().forEach(u -> user.sendMessage("commands.admin.info.banned-format", TextVariables.NAME, plugin.getPlayers().getName(u)));
|
||||||
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -185,7 +185,7 @@ public class AdminInfoCommandTest {
|
|||||||
@Test
|
@Test
|
||||||
public void testExecuteUserStringListOfStringNoArgsNoIsland() {
|
public void testExecuteUserStringListOfStringNoArgsNoIsland() {
|
||||||
when(im.getIslandAt(any())).thenReturn(Optional.empty());
|
when(im.getIslandAt(any())).thenReturn(Optional.empty());
|
||||||
assertFalse(iic.execute(user, "", Collections.emptyList()));
|
assertTrue(iic.execute(user, "", Collections.emptyList()));
|
||||||
verify(user).sendMessage("commands.admin.info.no-island");
|
verify(user).sendMessage("commands.admin.info.no-island");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -196,18 +196,13 @@ public class IslandInfoCommandTest {
|
|||||||
public void testExecuteUserStringListOfStringNoArgsSuccess() {
|
public void testExecuteUserStringListOfStringNoArgsSuccess() {
|
||||||
assertTrue(iic.execute(user, "", Collections.emptyList()));
|
assertTrue(iic.execute(user, "", Collections.emptyList()));
|
||||||
verify(user).sendMessage("commands.admin.info.title");
|
verify(user).sendMessage("commands.admin.info.title");
|
||||||
verify(user).sendMessage(eq("commands.admin.info.island-uuid"), eq("[uuid]"), any());
|
verify(user).sendMessage(eq("commands.admin.info.owner"), eq("[owner]"), eq(null));
|
||||||
verify(user).sendMessage(eq("commands.admin.info.owner"), eq("[owner]"), eq(null), eq("[uuid]"), any());
|
|
||||||
verify(user).sendMessage(eq("commands.admin.info.last-login"), eq("[date]"), any());
|
|
||||||
verify(user).sendMessage("commands.admin.info.deaths", "[number]", "0");
|
verify(user).sendMessage("commands.admin.info.deaths", "[number]", "0");
|
||||||
verify(user).sendMessage("commands.admin.info.resets-left", "[number]", "0", "[total]", "0");
|
verify(user).sendMessage("commands.admin.info.resets-left", "[number]", "0", "[total]", "0");
|
||||||
verify(user).sendMessage("commands.admin.info.team-members-title");
|
verify(user).sendMessage("commands.admin.info.team-members-title");
|
||||||
verify(user).sendMessage("commands.admin.info.team-owner-format", "[name]", null, "[rank]", "ranks.owner");
|
verify(user).sendMessage("commands.admin.info.team-owner-format", "[name]", null, "[rank]", "ranks.owner");
|
||||||
verify(user).sendMessage("commands.admin.info.island-protection-center", "[xyz]", "0,0,0");
|
|
||||||
verify(user).sendMessage("commands.admin.info.island-center", "[xyz]", "0,0,0");
|
verify(user).sendMessage("commands.admin.info.island-center", "[xyz]", "0,0,0");
|
||||||
verify(user).sendMessage("commands.admin.info.island-coords", "[xz1]", "0,0,0", "[xz2]", "0,0,0");
|
|
||||||
verify(user).sendMessage("commands.admin.info.protection-range", "[range]", "100");
|
verify(user).sendMessage("commands.admin.info.protection-range", "[range]", "100");
|
||||||
verify(user).sendMessage("commands.admin.info.max-protection-range", "[range]", "100");
|
|
||||||
verify(user).sendMessage("commands.admin.info.protection-coords", "[xz1]", "0,0,0", "[xz2]", "0,0,0");
|
verify(user).sendMessage("commands.admin.info.protection-coords", "[xz1]", "0,0,0", "[xz2]", "0,0,0");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -218,20 +213,14 @@ public class IslandInfoCommandTest {
|
|||||||
public void testExecuteUserStringListOfStringArgsSuccess() {
|
public void testExecuteUserStringListOfStringArgsSuccess() {
|
||||||
assertTrue(iic.execute(user, "", Collections.singletonList("tastybento")));
|
assertTrue(iic.execute(user, "", Collections.singletonList("tastybento")));
|
||||||
verify(user).sendMessage("commands.admin.info.title");
|
verify(user).sendMessage("commands.admin.info.title");
|
||||||
verify(user).sendMessage(eq("commands.admin.info.island-uuid"), eq("[uuid]"), any());
|
verify(user).sendMessage(eq("commands.admin.info.owner"), eq("[owner]"), eq(null));
|
||||||
verify(user).sendMessage(eq("commands.admin.info.owner"), eq("[owner]"), eq(null), eq("[uuid]"), any());
|
|
||||||
verify(user).sendMessage(eq("commands.admin.info.last-login"), eq("[date]"), any());
|
|
||||||
verify(user).sendMessage("commands.admin.info.deaths", "[number]", "0");
|
verify(user).sendMessage("commands.admin.info.deaths", "[number]", "0");
|
||||||
verify(user).sendMessage("commands.admin.info.resets-left", "[number]", "0", "[total]", "0");
|
verify(user).sendMessage("commands.admin.info.resets-left", "[number]", "0", "[total]", "0");
|
||||||
verify(user).sendMessage("commands.admin.info.team-members-title");
|
verify(user).sendMessage("commands.admin.info.team-members-title");
|
||||||
verify(user).sendMessage("commands.admin.info.team-owner-format", "[name]", null, "[rank]", "ranks.owner");
|
verify(user).sendMessage("commands.admin.info.team-owner-format", "[name]", null, "[rank]", "ranks.owner");
|
||||||
verify(user).sendMessage("commands.admin.info.island-protection-center", "[xyz]", "0,0,0");
|
|
||||||
verify(user).sendMessage("commands.admin.info.island-center", "[xyz]", "0,0,0");
|
verify(user).sendMessage("commands.admin.info.island-center", "[xyz]", "0,0,0");
|
||||||
verify(user).sendMessage("commands.admin.info.island-coords", "[xz1]", "0,0,0", "[xz2]", "0,0,0");
|
|
||||||
verify(user).sendMessage("commands.admin.info.protection-range", "[range]", "100");
|
verify(user).sendMessage("commands.admin.info.protection-range", "[range]", "100");
|
||||||
verify(user).sendMessage("commands.admin.info.max-protection-range", "[range]", "100");
|
|
||||||
verify(user).sendMessage("commands.admin.info.protection-coords", "[xz1]", "0,0,0", "[xz2]", "0,0,0");
|
verify(user).sendMessage("commands.admin.info.protection-coords", "[xz1]", "0,0,0", "[xz2]", "0,0,0");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
Reference in New Issue
Block a user