mirror of
https://github.com/BentoBoxWorld/BentoBox.git
synced 2024-11-24 11:45:31 +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 (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");
|
||||
return false;
|
||||
}
|
||||
@ -47,7 +47,7 @@ public class AdminInfoCommand extends CompositeCommand {
|
||||
return false;
|
||||
}
|
||||
// Show info for this player
|
||||
getIslands().getIsland(getWorld(), targetUUID).showInfo(getPlugin(), user, getWorld());
|
||||
getIslands().getIsland(getWorld(), targetUUID).showInfo(user);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -44,7 +44,7 @@ public class AdminTeamAddCommand extends CompositeCommand {
|
||||
}
|
||||
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));
|
||||
getIslands().getIsland(getWorld(), ownerUUID).showMembers(getPlugin(), user, getWorld());
|
||||
getIslands().getIsland(getWorld(), ownerUUID).showMembers(user);
|
||||
return false;
|
||||
}
|
||||
if (getIslands().inTeam(getWorld(), targetUUID)) {
|
||||
|
@ -44,7 +44,7 @@ public class AdminTeamKickCommand extends CompositeCommand {
|
||||
}
|
||||
if (getIslands().getOwner(getWorld(), targetUUID).equals(targetUUID)) {
|
||||
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;
|
||||
}
|
||||
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 (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");
|
||||
return false;
|
||||
}
|
||||
@ -50,7 +50,7 @@ public class IslandInfoCommand extends CompositeCommand {
|
||||
return false;
|
||||
}
|
||||
// Show info for this player
|
||||
getIslands().getIsland(getWorld(), targetUUID).showInfo(getPlugin(), user, getWorld());
|
||||
getIslands().getIsland(getWorld(), targetUUID).showInfo(user);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -63,7 +63,7 @@ public class IslandTeamCommand extends CompositeCommand {
|
||||
}
|
||||
}
|
||||
// Show members of island
|
||||
getIslands().getIsland(getWorld(), playerUUID).showMembers(getPlugin(), user, getWorld());
|
||||
getIslands().getIsland(getWorld(), playerUUID).showMembers(user);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -595,8 +595,21 @@ public class Island implements DataObject {
|
||||
* @param user - the user who is receiving the info
|
||||
* @param world - world to check
|
||||
* @return true always
|
||||
*
|
||||
* @deprecated Renamed to {@link #showInfo(User)}.
|
||||
*/
|
||||
@Deprecated
|
||||
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");
|
||||
if (owner == null) {
|
||||
user.sendMessage("commands.admin.info.unowned");
|
||||
@ -613,7 +626,7 @@ public class Island implements DataObject {
|
||||
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(plugin, user, world);
|
||||
showMembers(user);
|
||||
}
|
||||
Vector location = center.toVector();
|
||||
user.sendMessage("commands.admin.info.island-location", "[xyz]", Util.xyz(location));
|
||||
@ -640,8 +653,20 @@ public class Island implements DataObject {
|
||||
* @param plugin - plugin
|
||||
* @param user - user who is requesting
|
||||
* @param world - world to check
|
||||
*
|
||||
* @deprecated Renamed to {@link #showMembers(User)}.
|
||||
*/
|
||||
@Deprecated
|
||||
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");
|
||||
members.forEach((u, i) -> {
|
||||
if (owner.equals(u)) {
|
||||
|
@ -166,7 +166,7 @@ public class AdminInfoCommandTest {
|
||||
Island is = mock(Island.class);
|
||||
when(im.getIsland(Mockito.any(), Mockito.eq(notUUID))).thenReturn(is);
|
||||
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 is = mock(Island.class);
|
||||
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);
|
||||
when(im.getIslandAt(Mockito.any())).thenReturn(opi);
|
||||
when(user.getLocation()).thenReturn(loc);
|
||||
@ -203,6 +203,6 @@ public class AdminInfoCommandTest {
|
||||
|
||||
assertTrue(itl.execute(user, itl.getLabel(), new ArrayList<>()));
|
||||
// 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)));
|
||||
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);
|
||||
assertFalse(itl.execute(user, itl.getLabel(), Arrays.asList(name)));
|
||||
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