mirror of
https://github.com/BentoBoxWorld/BentoBox.git
synced 2024-11-28 05:35:44 +01:00
Deprecated Island#showInfo() and Island#showMembers() that were using useless parameters
Replaced them with equivalents only requiring an User as parameter.
This commit is contained in:
parent
08be1e15d1
commit
fa5c7905da
@ -30,7 +30,7 @@ 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 -> i.showInfo(getPlugin(), user, getWorld())).orElse(false)) {
|
if (!getIslands().getIslandAt(user.getLocation()).map(i -> i.showInfo(user)).orElse(false)) {
|
||||||
user.sendMessage("commands.admin.info.no-island");
|
user.sendMessage("commands.admin.info.no-island");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -47,7 +47,7 @@ public class AdminInfoCommand extends CompositeCommand {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
// Show info for this player
|
// Show info for this player
|
||||||
getIslands().getIsland(getWorld(), targetUUID).showInfo(getPlugin(), user, getWorld());
|
getIslands().getIsland(getWorld(), targetUUID).showInfo(user);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -44,7 +44,7 @@ public class AdminTeamAddCommand extends CompositeCommand {
|
|||||||
}
|
}
|
||||||
if (getIslands().inTeam(getWorld(), ownerUUID) && !getIslands().getOwner(getWorld(), ownerUUID).equals(ownerUUID)) {
|
if (getIslands().inTeam(getWorld(), ownerUUID) && !getIslands().getOwner(getWorld(), ownerUUID).equals(ownerUUID)) {
|
||||||
user.sendMessage("commands.admin.team.add.name-not-owner", TextVariables.NAME, args.get(0));
|
user.sendMessage("commands.admin.team.add.name-not-owner", TextVariables.NAME, args.get(0));
|
||||||
getIslands().getIsland(getWorld(), ownerUUID).showMembers(getPlugin(), user, getWorld());
|
getIslands().getIsland(getWorld(), ownerUUID).showMembers(user);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (getIslands().inTeam(getWorld(), targetUUID)) {
|
if (getIslands().inTeam(getWorld(), targetUUID)) {
|
||||||
|
@ -44,7 +44,7 @@ public class AdminTeamKickCommand extends CompositeCommand {
|
|||||||
}
|
}
|
||||||
if (getIslands().getOwner(getWorld(), targetUUID).equals(targetUUID)) {
|
if (getIslands().getOwner(getWorld(), targetUUID).equals(targetUUID)) {
|
||||||
user.sendMessage("commands.admin.team.kick.cannot-kick-owner");
|
user.sendMessage("commands.admin.team.kick.cannot-kick-owner");
|
||||||
getIslands().getIsland(getWorld(), targetUUID).showMembers(getPlugin(), user, getWorld());
|
getIslands().getIsland(getWorld(), targetUUID).showMembers(user);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
User.getInstance(targetUUID).sendMessage("commands.admin.team.kick.admin-kicked");
|
User.getInstance(targetUUID).sendMessage("commands.admin.team.kick.admin-kicked");
|
||||||
|
@ -33,7 +33,7 @@ public class IslandInfoCommand 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 -> i.showInfo(getPlugin(), user, getWorld())).orElse(false)) {
|
if (!getIslands().getIslandAt(user.getLocation()).map(i -> i.showInfo(user)).orElse(false)) {
|
||||||
user.sendMessage("commands.admin.info.no-island");
|
user.sendMessage("commands.admin.info.no-island");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -50,7 +50,7 @@ public class IslandInfoCommand extends CompositeCommand {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
// Show info for this player
|
// Show info for this player
|
||||||
getIslands().getIsland(getWorld(), targetUUID).showInfo(getPlugin(), user, getWorld());
|
getIslands().getIsland(getWorld(), targetUUID).showInfo(user);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -63,7 +63,7 @@ public class IslandTeamCommand extends CompositeCommand {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Show members of island
|
// Show members of island
|
||||||
getIslands().getIsland(getWorld(), playerUUID).showMembers(getPlugin(), user, getWorld());
|
getIslands().getIsland(getWorld(), playerUUID).showMembers(user);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -595,8 +595,21 @@ public class Island implements DataObject {
|
|||||||
* @param user - the user who is receiving the info
|
* @param user - the user who is receiving the info
|
||||||
* @param world - world to check
|
* @param world - world to check
|
||||||
* @return true always
|
* @return true always
|
||||||
|
*
|
||||||
|
* @deprecated Renamed to {@link #showInfo(User)}.
|
||||||
*/
|
*/
|
||||||
|
@Deprecated
|
||||||
public boolean showInfo(BentoBox plugin, User user, World world) {
|
public boolean showInfo(BentoBox plugin, User user, World world) {
|
||||||
|
return showInfo(user);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Shows info of this island to this user.
|
||||||
|
* @param user the User who is requesting it
|
||||||
|
* @return always true
|
||||||
|
*/
|
||||||
|
public boolean showInfo(User user) {
|
||||||
|
BentoBox plugin = BentoBox.getInstance();
|
||||||
user.sendMessage("commands.admin.info.title");
|
user.sendMessage("commands.admin.info.title");
|
||||||
if (owner == null) {
|
if (owner == null) {
|
||||||
user.sendMessage("commands.admin.info.unowned");
|
user.sendMessage("commands.admin.info.unowned");
|
||||||
@ -606,14 +619,14 @@ public class Island implements DataObject {
|
|||||||
// Fixes #getLastPlayed() returning 0 when it is the owner's first connection.
|
// Fixes #getLastPlayed() returning 0 when it is the owner's first connection.
|
||||||
long lastPlayed = (plugin.getServer().getOfflinePlayer(owner).getLastPlayed() != 0) ?
|
long lastPlayed = (plugin.getServer().getOfflinePlayer(owner).getLastPlayed() != 0) ?
|
||||||
plugin.getServer().getOfflinePlayer(owner).getLastPlayed() : plugin.getServer().getOfflinePlayer(owner).getFirstPlayed();
|
plugin.getServer().getOfflinePlayer(owner).getLastPlayed() : plugin.getServer().getOfflinePlayer(owner).getFirstPlayed();
|
||||||
user.sendMessage("commands.admin.info.last-login","[date]", new Date(lastPlayed).toString());
|
user.sendMessage("commands.admin.info.last-login","[date]", new Date(lastPlayed).toString());
|
||||||
|
|
||||||
user.sendMessage("commands.admin.info.deaths", "[number]", String.valueOf(plugin.getPlayers().getDeaths(world, 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 resets = String.valueOf(plugin.getPlayers().getResets(world, owner));
|
||||||
String total = plugin.getIWM().getResetLimit(world) < 0 ? "Unlimited" : String.valueOf(plugin.getIWM().getResetLimit(world));
|
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);
|
user.sendMessage("commands.admin.info.resets-left", "[number]", resets, "[total]", total);
|
||||||
// Show team members
|
// Show team members
|
||||||
showMembers(plugin, user, world);
|
showMembers(user);
|
||||||
}
|
}
|
||||||
Vector location = center.toVector();
|
Vector location = center.toVector();
|
||||||
user.sendMessage("commands.admin.info.island-location", "[xyz]", Util.xyz(location));
|
user.sendMessage("commands.admin.info.island-location", "[xyz]", Util.xyz(location));
|
||||||
@ -640,8 +653,20 @@ public class Island implements DataObject {
|
|||||||
* @param plugin - plugin
|
* @param plugin - plugin
|
||||||
* @param user - user who is requesting
|
* @param user - user who is requesting
|
||||||
* @param world - world to check
|
* @param world - world to check
|
||||||
|
*
|
||||||
|
* @deprecated Renamed to {@link #showMembers(User)}.
|
||||||
*/
|
*/
|
||||||
|
@Deprecated
|
||||||
public void showMembers(BentoBox plugin, User user, World world) {
|
public void showMembers(BentoBox plugin, User user, World world) {
|
||||||
|
showMembers(user);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Shows the members of this island to this user.
|
||||||
|
* @param user the User who is requesting it
|
||||||
|
*/
|
||||||
|
public void showMembers(User user) {
|
||||||
|
BentoBox plugin = BentoBox.getInstance();
|
||||||
user.sendMessage("commands.admin.info.team-members-title");
|
user.sendMessage("commands.admin.info.team-members-title");
|
||||||
members.forEach((u, i) -> {
|
members.forEach((u, i) -> {
|
||||||
if (owner.equals(u)) {
|
if (owner.equals(u)) {
|
||||||
|
@ -166,7 +166,7 @@ public class AdminInfoCommandTest {
|
|||||||
Island is = mock(Island.class);
|
Island is = mock(Island.class);
|
||||||
when(im.getIsland(Mockito.any(), Mockito.eq(notUUID))).thenReturn(is);
|
when(im.getIsland(Mockito.any(), Mockito.eq(notUUID))).thenReturn(is);
|
||||||
assertTrue(itl.execute(user, itl.getLabel(), Arrays.asList(name)));
|
assertTrue(itl.execute(user, itl.getLabel(), Arrays.asList(name)));
|
||||||
Mockito.verify(is).showInfo(Mockito.eq(plugin), Mockito.eq(user), Mockito.any());
|
Mockito.verify(is).showInfo(Mockito.eq(user));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -195,7 +195,7 @@ public class AdminInfoCommandTest {
|
|||||||
// Island has owner
|
// Island has owner
|
||||||
Island is = mock(Island.class);
|
Island is = mock(Island.class);
|
||||||
when(is.getOwner()).thenReturn(uuid);
|
when(is.getOwner()).thenReturn(uuid);
|
||||||
when(is.showInfo(Mockito.any(), Mockito.any(), Mockito.any())).thenReturn(true);
|
when(is.showInfo(Mockito.any())).thenReturn(true);
|
||||||
Optional<Island> opi = Optional.of(is);
|
Optional<Island> opi = Optional.of(is);
|
||||||
when(im.getIslandAt(Mockito.any())).thenReturn(opi);
|
when(im.getIslandAt(Mockito.any())).thenReturn(opi);
|
||||||
when(user.getLocation()).thenReturn(loc);
|
when(user.getLocation()).thenReturn(loc);
|
||||||
@ -203,6 +203,6 @@ public class AdminInfoCommandTest {
|
|||||||
|
|
||||||
assertTrue(itl.execute(user, itl.getLabel(), new ArrayList<>()));
|
assertTrue(itl.execute(user, itl.getLabel(), new ArrayList<>()));
|
||||||
// Confirm other verifications
|
// Confirm other verifications
|
||||||
Mockito.verify(is).showInfo(Mockito.eq(plugin), Mockito.eq(user), Mockito.any());
|
Mockito.verify(is).showInfo(Mockito.eq(user));
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -211,7 +211,7 @@ public class AdminTeamAddCommandTest {
|
|||||||
|
|
||||||
assertFalse(itl.execute(user, itl.getLabel(), Arrays.asList(name)));
|
assertFalse(itl.execute(user, itl.getLabel(), Arrays.asList(name)));
|
||||||
Mockito.verify(user).sendMessage("commands.admin.team.add.name-not-owner", "[name]", "tastybento");
|
Mockito.verify(user).sendMessage("commands.admin.team.add.name-not-owner", "[name]", "tastybento");
|
||||||
Mockito.verify(island).showMembers(Mockito.eq(plugin), Mockito.any(), Mockito.any());
|
Mockito.verify(island).showMembers(Mockito.any());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -166,7 +166,7 @@ public class AdminTeamKickCommandTest {
|
|||||||
AdminTeamKickCommand itl = new AdminTeamKickCommand(ac);
|
AdminTeamKickCommand itl = new AdminTeamKickCommand(ac);
|
||||||
assertFalse(itl.execute(user, itl.getLabel(), Arrays.asList(name)));
|
assertFalse(itl.execute(user, itl.getLabel(), Arrays.asList(name)));
|
||||||
Mockito.verify(user).sendMessage(Mockito.eq("commands.admin.team.kick.cannot-kick-owner"));
|
Mockito.verify(user).sendMessage(Mockito.eq("commands.admin.team.kick.cannot-kick-owner"));
|
||||||
Mockito.verify(is).showMembers(Mockito.any(), Mockito.any(), Mockito.any());
|
Mockito.verify(is).showMembers(Mockito.any());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
Reference in New Issue
Block a user