Deprecated #getTeamLeader(...) methods

These have been deprecated in CompositeCommand, IslandCache and IslandsManager and they got replaced by #getOwner(...).
This commit is contained in:
Florian CUNY 2018-11-18 11:12:54 +01:00
parent f0218d9f2a
commit 0322ffe0ce
34 changed files with 91 additions and 54 deletions

View File

@ -386,9 +386,21 @@ public abstract class CompositeCommand extends Command implements PluginIdentifi
* @param world - world to check * @param world - world to check
* @param user - the User * @param user - the User
* @return UUID of player's team leader or null if user has no island * @return UUID of player's team leader or null if user has no island
* @deprecated Renamed to {@link #getOwner(World, User)} for consistency.
*/ */
@Deprecated
protected UUID getTeamLeader(World world, User user) { protected UUID getTeamLeader(World world, User user) {
return plugin.getIslands().getTeamLeader(world, user.getUniqueId()); return getOwner(world, user);
}
/**
* Convenience method to obtain the user's island owner
* @param world world to check
* @param user -the User
* @return UUID of player's island owner or null if user has no island
*/
protected UUID getOwner(World world, User user) {
return plugin.getIslands().getOwner(world, user.getUniqueId());
} }
@Override @Override

View File

@ -43,7 +43,7 @@ public class AdminDeleteCommand extends ConfirmableCommand {
return false; return false;
} }
// Team leaders should be kicked before deleting otherwise the whole team will become weird // Team leaders should be kicked before deleting otherwise the whole team will become weird
if (getIslands().inTeam(getWorld(), targetUUID) && getIslands().getTeamLeader(getWorld(), targetUUID).equals(targetUUID)) { if (getIslands().inTeam(getWorld(), targetUUID) && getIslands().getOwner(getWorld(), targetUUID).equals(targetUUID)) {
user.sendMessage("commands.admin.delete.cannot-delete-team-leader"); user.sendMessage("commands.admin.delete.cannot-delete-team-leader");
return false; return false;
} }

View File

@ -42,7 +42,7 @@ public class AdminTeamAddCommand extends CompositeCommand {
user.sendMessage("general.errors.player-has-no-island"); user.sendMessage("general.errors.player-has-no-island");
return false; return false;
} }
if (getIslands().inTeam(getWorld(), leaderUUID) && !getIslands().getTeamLeader(getWorld(), leaderUUID).equals(leaderUUID)) { if (getIslands().inTeam(getWorld(), leaderUUID) && !getIslands().getOwner(getWorld(), leaderUUID).equals(leaderUUID)) {
user.sendMessage("commands.admin.team.add.name-not-leader", TextVariables.NAME, args.get(0)); user.sendMessage("commands.admin.team.add.name-not-leader", TextVariables.NAME, args.get(0));
getIslands().getIsland(getWorld(), leaderUUID).showMembers(getPlugin(), user, getWorld()); getIslands().getIsland(getWorld(), leaderUUID).showMembers(getPlugin(), user, getWorld());
return false; return false;

View File

@ -41,8 +41,8 @@ public class AdminTeamDisbandCommand extends CompositeCommand {
user.sendMessage("general.errors.not-in-team"); user.sendMessage("general.errors.not-in-team");
return false; return false;
} }
if (!getIslands().getTeamLeader(getWorld(), targetUUID).equals(targetUUID)) { if (!getIslands().getOwner(getWorld(), targetUUID).equals(targetUUID)) {
user.sendMessage("commands.admin.team.disband.use-disband-leader", "[leader]", getPlayers().getName(getIslands().getTeamLeader(getWorld(), targetUUID))); user.sendMessage("commands.admin.team.disband.use-disband-leader", "[leader]", getPlayers().getName(getIslands().getOwner(getWorld(), targetUUID)));
return false; return false;
} }
// Disband team // Disband team

View File

@ -42,7 +42,7 @@ public class AdminTeamKickCommand extends CompositeCommand {
user.sendMessage("general.errors.not-in-team"); user.sendMessage("general.errors.not-in-team");
return false; return false;
} }
if (getIslands().getTeamLeader(getWorld(), targetUUID).equals(targetUUID)) { if (getIslands().getOwner(getWorld(), targetUUID).equals(targetUUID)) {
user.sendMessage("commands.admin.team.kick.cannot-kick-leader"); user.sendMessage("commands.admin.team.kick.cannot-kick-leader");
getIslands().getIsland(getWorld(), targetUUID).showMembers(getPlugin(), user, getWorld()); getIslands().getIsland(getWorld(), targetUUID).showMembers(getPlugin(), user, getWorld());
return false; return false;

View File

@ -41,7 +41,7 @@ public class AdminTeamSetownerCommand extends CompositeCommand {
user.sendMessage("general.errors.not-in-team"); user.sendMessage("general.errors.not-in-team");
return false; return false;
} }
if (getIslands().getTeamLeader(getWorld(), targetUUID).equals(targetUUID)) { if (getIslands().getOwner(getWorld(), targetUUID).equals(targetUUID)) {
user.sendMessage("commands.admin.team.setowner.already-owner"); user.sendMessage("commands.admin.team.setowner.already-owner");
return false; return false;
} }

View File

@ -41,7 +41,7 @@ public class IslandTeamLeaveCommand extends ConfirmableCommand {
} }
private void leave(User user) { private void leave(User user) {
UUID leaderUUID = getIslands().getTeamLeader(getWorld(), user.getUniqueId()); UUID leaderUUID = getIslands().getOwner(getWorld(), user.getUniqueId());
if (leaderUUID != null) { if (leaderUUID != null) {
User.getInstance(leaderUUID).sendMessage("commands.island.team.leave.left-your-island", TextVariables.NAME, user.getName()); User.getInstance(leaderUUID).sendMessage("commands.island.team.leave.left-your-island", TextVariables.NAME, user.getName());
} }

View File

@ -394,7 +394,7 @@ public class IslandsManager {
return l; return l;
} else { } else {
// try team leader's home // try team leader's home
Location tlh = plugin.getPlayers().getHomeLocation(world, plugin.getIslands().getTeamLeader(world, user.getUniqueId())); Location tlh = plugin.getPlayers().getHomeLocation(world, plugin.getIslands().getOwner(world, user.getUniqueId()));
if (tlh != null && isSafeLocation(tlh)) { if (tlh != null && isSafeLocation(tlh)) {
plugin.getPlayers().setHomeLocation(user, tlh, number); plugin.getPlayers().setHomeLocation(user, tlh, number);
return tlh; return tlh;
@ -455,13 +455,26 @@ public class IslandsManager {
} }
/** /**
* Provides UUID of this player's team leader or null if it does not exist * Provides UUID of this player's island owner or null if it does not exist
* @param world - world to check * @param world - world to check
* @param leaderUUID - the leader's UUID * @param playerUUID - the player's UUID
* @return UUID of leader or null if player has no island * @return island owner's UUID or null if player has no island
*
* @deprecated Renamed to {@link #getOwner(World, UUID)} for consistency.
*/ */
public UUID getTeamLeader(World world, UUID leaderUUID) { @Deprecated
return islandCache.getTeamLeader(world, leaderUUID); public UUID getTeamLeader(World world, UUID playerUUID) {
return getOwner(world, playerUUID);
}
/**
* Provides UUID of this player's island owner or null if it does not exist
* @param world world to check
* @param playerUUID the player's UUID
* @return island owner's UUID or null if player has no island
*/
public UUID getOwner(World world, UUID playerUUID) {
return islandCache.getOwner(world, playerUUID);
} }
/** /**

View File

@ -143,8 +143,20 @@ public class IslandCache {
* @param world - the world to check * @param world - the world to check
* @param uuid - player's uuid * @param uuid - player's uuid
* @return team leader's UUID, the player UUID if they are not in a team, or null if there is no island * @return team leader's UUID, the player UUID if they are not in a team, or null if there is no island
*
* @deprecated Renamed to {@link #getOwner(World, UUID)} for consistency.
*/ */
@Deprecated
public UUID getTeamLeader(World world, UUID uuid) { public UUID getTeamLeader(World world, UUID uuid) {
return getOwner(world, uuid);
}
/**
* @param world the world to check
* @param uuid the player's UUID
* @return island owner's UUID, the player UUID if they are not in a team, or null if there is no island
*/
public UUID getOwner(World world, UUID uuid) {
islandsByUUID.putIfAbsent(Util.getWorld(world), new HashMap<>()); islandsByUUID.putIfAbsent(Util.getWorld(world), new HashMap<>());
Island island = islandsByUUID.get(Util.getWorld(world)).get(uuid); Island island = islandsByUUID.get(Util.getWorld(world)).get(uuid);
if (island != null) { if (island != null) {

View File

@ -94,7 +94,7 @@ public class AdminClearresetsCommandTest {
when(im.hasIsland(Mockito.any(), Mockito.any(UUID.class))).thenReturn(true); when(im.hasIsland(Mockito.any(), Mockito.any(UUID.class))).thenReturn(true);
when(im.hasIsland(Mockito.any(), Mockito.any(User.class))).thenReturn(true); when(im.hasIsland(Mockito.any(), Mockito.any(User.class))).thenReturn(true);
when(im.isOwner(Mockito.any(),Mockito.any())).thenReturn(true); when(im.isOwner(Mockito.any(),Mockito.any())).thenReturn(true);
when(im.getTeamLeader(Mockito.any(),Mockito.any())).thenReturn(uuid); when(im.getOwner(Mockito.any(),Mockito.any())).thenReturn(uuid);
when(plugin.getIslands()).thenReturn(im); when(plugin.getIslands()).thenReturn(im);
// Has team // Has team

View File

@ -85,7 +85,7 @@ public class AdminClearresetsallCommandTest {
when(im.hasIsland(Mockito.any(), Mockito.any(UUID.class))).thenReturn(true); when(im.hasIsland(Mockito.any(), Mockito.any(UUID.class))).thenReturn(true);
when(im.hasIsland(Mockito.any(), Mockito.any(User.class))).thenReturn(true); when(im.hasIsland(Mockito.any(), Mockito.any(User.class))).thenReturn(true);
when(im.isOwner(Mockito.any(),Mockito.any())).thenReturn(true); when(im.isOwner(Mockito.any(),Mockito.any())).thenReturn(true);
when(im.getTeamLeader(Mockito.any(),Mockito.any())).thenReturn(uuid); when(im.getOwner(Mockito.any(),Mockito.any())).thenReturn(uuid);
when(plugin.getIslands()).thenReturn(im); when(plugin.getIslands()).thenReturn(im);
// Has team // Has team

View File

@ -100,7 +100,7 @@ public class AdminDeleteCommandTest {
when(im.hasIsland(Mockito.any(), Mockito.any(UUID.class))).thenReturn(true); when(im.hasIsland(Mockito.any(), Mockito.any(UUID.class))).thenReturn(true);
when(im.hasIsland(Mockito.any(), Mockito.any(User.class))).thenReturn(true); when(im.hasIsland(Mockito.any(), Mockito.any(User.class))).thenReturn(true);
when(im.isOwner(Mockito.any(),Mockito.any())).thenReturn(true); when(im.isOwner(Mockito.any(),Mockito.any())).thenReturn(true);
when(im.getTeamLeader(Mockito.any(),Mockito.any())).thenReturn(uuid); when(im.getOwner(Mockito.any(),Mockito.any())).thenReturn(uuid);
when(plugin.getIslands()).thenReturn(im); when(plugin.getIslands()).thenReturn(im);
// Has team // Has team
@ -164,7 +164,7 @@ public class AdminDeleteCommandTest {
@Test @Test
public void testExecuteTeamLeader() { public void testExecuteTeamLeader() {
when(im.inTeam(Mockito.any(),Mockito.any())).thenReturn(true); when(im.inTeam(Mockito.any(),Mockito.any())).thenReturn(true);
when(im.getTeamLeader(Mockito.any(), Mockito.any())).thenReturn(notUUID); when(im.getOwner(Mockito.any(), Mockito.any())).thenReturn(notUUID);
String[] name = {"tastybento"}; String[] name = {"tastybento"};
when(pm.getUUID(Mockito.any())).thenReturn(notUUID); when(pm.getUUID(Mockito.any())).thenReturn(notUUID);
AdminDeleteCommand itl = new AdminDeleteCommand(ac); AdminDeleteCommand itl = new AdminDeleteCommand(ac);
@ -178,7 +178,7 @@ public class AdminDeleteCommandTest {
@Test @Test
public void testExecuteSuccess() { public void testExecuteSuccess() {
when(im.inTeam(Mockito.any(), Mockito.any())).thenReturn(false); when(im.inTeam(Mockito.any(), Mockito.any())).thenReturn(false);
when(im.getTeamLeader(Mockito.any(), Mockito.any())).thenReturn(uuid); when(im.getOwner(Mockito.any(), Mockito.any())).thenReturn(uuid);
Island is = mock(Island.class); Island is = mock(Island.class);
Location loc = mock(Location.class); Location loc = mock(Location.class);
when(loc.toVector()).thenReturn(new Vector(123,123,432)); when(loc.toVector()).thenReturn(new Vector(123,123,432));

View File

@ -95,7 +95,7 @@ public class AdminInfoCommandTest {
when(im.hasIsland(Mockito.any(), Mockito.any(UUID.class))).thenReturn(true); when(im.hasIsland(Mockito.any(), Mockito.any(UUID.class))).thenReturn(true);
when(im.hasIsland(Mockito.any(), Mockito.any(User.class))).thenReturn(true); when(im.hasIsland(Mockito.any(), Mockito.any(User.class))).thenReturn(true);
when(im.isOwner(Mockito.any(),Mockito.any())).thenReturn(true); when(im.isOwner(Mockito.any(),Mockito.any())).thenReturn(true);
when(im.getTeamLeader(Mockito.any(),Mockito.any())).thenReturn(uuid); when(im.getOwner(Mockito.any(),Mockito.any())).thenReturn(uuid);
when(plugin.getIslands()).thenReturn(im); when(plugin.getIslands()).thenReturn(im);
// Has team // Has team

View File

@ -93,7 +93,7 @@ public class AdminRegisterCommandTest {
when(im.hasIsland(Mockito.any(), Mockito.any(UUID.class))).thenReturn(true); when(im.hasIsland(Mockito.any(), Mockito.any(UUID.class))).thenReturn(true);
when(im.hasIsland(Mockito.any(), Mockito.any(User.class))).thenReturn(true); when(im.hasIsland(Mockito.any(), Mockito.any(User.class))).thenReturn(true);
when(im.isOwner(Mockito.any(),Mockito.any())).thenReturn(true); when(im.isOwner(Mockito.any(),Mockito.any())).thenReturn(true);
when(im.getTeamLeader(Mockito.any(),Mockito.any())).thenReturn(uuid); when(im.getOwner(Mockito.any(),Mockito.any())).thenReturn(uuid);
when(plugin.getIslands()).thenReturn(im); when(plugin.getIslands()).thenReturn(im);
// Has team // Has team

View File

@ -93,7 +93,7 @@ public class AdminTeleportCommandTest {
when(im.hasIsland(Mockito.any(), Mockito.any(UUID.class))).thenReturn(true); when(im.hasIsland(Mockito.any(), Mockito.any(UUID.class))).thenReturn(true);
when(im.hasIsland(Mockito.any(), Mockito.any(User.class))).thenReturn(true); when(im.hasIsland(Mockito.any(), Mockito.any(User.class))).thenReturn(true);
when(im.isOwner(Mockito.any(),Mockito.any())).thenReturn(true); when(im.isOwner(Mockito.any(),Mockito.any())).thenReturn(true);
when(im.getTeamLeader(Mockito.any(),Mockito.any())).thenReturn(uuid); when(im.getOwner(Mockito.any(),Mockito.any())).thenReturn(uuid);
when(plugin.getIslands()).thenReturn(im); when(plugin.getIslands()).thenReturn(im);
// Has team // Has team

View File

@ -91,7 +91,7 @@ public class AdminUnregisterCommandTest {
when(im.hasIsland(Mockito.any(), Mockito.any(UUID.class))).thenReturn(true); when(im.hasIsland(Mockito.any(), Mockito.any(UUID.class))).thenReturn(true);
when(im.hasIsland(Mockito.any(), Mockito.any(User.class))).thenReturn(true); when(im.hasIsland(Mockito.any(), Mockito.any(User.class))).thenReturn(true);
when(im.isOwner(Mockito.any(),Mockito.any())).thenReturn(true); when(im.isOwner(Mockito.any(),Mockito.any())).thenReturn(true);
when(im.getTeamLeader(Mockito.any(),Mockito.any())).thenReturn(uuid); when(im.getOwner(Mockito.any(),Mockito.any())).thenReturn(uuid);
when(plugin.getIslands()).thenReturn(im); when(plugin.getIslands()).thenReturn(im);
// Has team // Has team

View File

@ -84,7 +84,7 @@ public class AdminRangeCommandTest {
when(im.hasIsland(Mockito.any(), Mockito.any(UUID.class))).thenReturn(true); when(im.hasIsland(Mockito.any(), Mockito.any(UUID.class))).thenReturn(true);
when(im.hasIsland(Mockito.any(), Mockito.any(User.class))).thenReturn(true); when(im.hasIsland(Mockito.any(), Mockito.any(User.class))).thenReturn(true);
when(im.isOwner(Mockito.any(),Mockito.any())).thenReturn(true); when(im.isOwner(Mockito.any(),Mockito.any())).thenReturn(true);
when(im.getTeamLeader(Mockito.any(),Mockito.any())).thenReturn(uuid); when(im.getOwner(Mockito.any(),Mockito.any())).thenReturn(uuid);
when(plugin.getIslands()).thenReturn(im); when(plugin.getIslands()).thenReturn(im);
// Has team // Has team

View File

@ -87,7 +87,7 @@ public class AdminRangeDisplayCommandTest {
when(im.hasIsland(Mockito.any(), Mockito.any(UUID.class))).thenReturn(true); when(im.hasIsland(Mockito.any(), Mockito.any(UUID.class))).thenReturn(true);
when(im.hasIsland(Mockito.any(), Mockito.any(User.class))).thenReturn(true); when(im.hasIsland(Mockito.any(), Mockito.any(User.class))).thenReturn(true);
when(im.isOwner(Mockito.any(),Mockito.any())).thenReturn(true); when(im.isOwner(Mockito.any(),Mockito.any())).thenReturn(true);
when(im.getTeamLeader(Mockito.any(),Mockito.any())).thenReturn(uuid); when(im.getOwner(Mockito.any(),Mockito.any())).thenReturn(uuid);
when(plugin.getIslands()).thenReturn(im); when(plugin.getIslands()).thenReturn(im);
// Has team // Has team

View File

@ -94,7 +94,7 @@ public class AdminRangeResetCommandTest {
when(im.hasIsland(Mockito.any(), Mockito.any(UUID.class))).thenReturn(true); when(im.hasIsland(Mockito.any(), Mockito.any(UUID.class))).thenReturn(true);
when(im.hasIsland(Mockito.any(), Mockito.any(User.class))).thenReturn(true); when(im.hasIsland(Mockito.any(), Mockito.any(User.class))).thenReturn(true);
when(im.isOwner(Mockito.any(),Mockito.any())).thenReturn(true); when(im.isOwner(Mockito.any(),Mockito.any())).thenReturn(true);
when(im.getTeamLeader(Mockito.any(),Mockito.any())).thenReturn(uuid); when(im.getOwner(Mockito.any(),Mockito.any())).thenReturn(uuid);
Island island = mock(Island.class); Island island = mock(Island.class);
when(im.getIsland(Mockito.any(), Mockito.any(UUID.class))).thenReturn(island); when(im.getIsland(Mockito.any(), Mockito.any(UUID.class))).thenReturn(island);
when(plugin.getIslands()).thenReturn(im); when(plugin.getIslands()).thenReturn(im);

View File

@ -94,7 +94,7 @@ public class AdminRangeSetCommandTest {
when(im.hasIsland(Mockito.any(), Mockito.any(UUID.class))).thenReturn(true); when(im.hasIsland(Mockito.any(), Mockito.any(UUID.class))).thenReturn(true);
when(im.hasIsland(Mockito.any(), Mockito.any(User.class))).thenReturn(true); when(im.hasIsland(Mockito.any(), Mockito.any(User.class))).thenReturn(true);
when(im.isOwner(Mockito.any(),Mockito.any())).thenReturn(true); when(im.isOwner(Mockito.any(),Mockito.any())).thenReturn(true);
when(im.getTeamLeader(Mockito.any(),Mockito.any())).thenReturn(uuid); when(im.getOwner(Mockito.any(),Mockito.any())).thenReturn(uuid);
Island island = mock(Island.class); Island island = mock(Island.class);
when(island.getRange()).thenReturn(50); when(island.getRange()).thenReturn(50);
when(island.getProtectionRange()).thenReturn(50); when(island.getProtectionRange()).thenReturn(50);

View File

@ -87,7 +87,7 @@ public class AdminTeamAddCommandTest {
when(im.hasIsland(Mockito.any(), Mockito.any(User.class))).thenReturn(true); when(im.hasIsland(Mockito.any(), Mockito.any(User.class))).thenReturn(true);
when(im.hasIsland(Mockito.any(), Mockito.any(UUID.class))).thenReturn(true); when(im.hasIsland(Mockito.any(), Mockito.any(UUID.class))).thenReturn(true);
when(im.isOwner(Mockito.any(), Mockito.any())).thenReturn(true); when(im.isOwner(Mockito.any(), Mockito.any())).thenReturn(true);
when(im.getTeamLeader(Mockito.any(), Mockito.any())).thenReturn(uuid); when(im.getOwner(Mockito.any(), Mockito.any())).thenReturn(uuid);
when(plugin.getIslands()).thenReturn(im); when(plugin.getIslands()).thenReturn(im);
// Has team // Has team
@ -203,7 +203,7 @@ public class AdminTeamAddCommandTest {
// Has island, has team, but not a leader // Has island, has team, but not a leader
when(im.hasIsland(Mockito.any(),Mockito.eq(uuid))).thenReturn(true); when(im.hasIsland(Mockito.any(),Mockito.eq(uuid))).thenReturn(true);
when(im.inTeam(Mockito.any(),Mockito.eq(uuid))).thenReturn(true); when(im.inTeam(Mockito.any(),Mockito.eq(uuid))).thenReturn(true);
when(im.getTeamLeader(Mockito.any(),Mockito.eq(uuid))).thenReturn(notUUID); when(im.getOwner(Mockito.any(),Mockito.eq(uuid))).thenReturn(notUUID);
// Island // Island
Island island = mock(Island.class); Island island = mock(Island.class);
@ -228,7 +228,7 @@ public class AdminTeamAddCommandTest {
// Has island, has team, is leader // Has island, has team, is leader
when(im.hasIsland(Mockito.any(),Mockito.eq(uuid))).thenReturn(true); when(im.hasIsland(Mockito.any(),Mockito.eq(uuid))).thenReturn(true);
when(im.inTeam(Mockito.any(),Mockito.eq(uuid))).thenReturn(true); when(im.inTeam(Mockito.any(),Mockito.eq(uuid))).thenReturn(true);
when(im.getTeamLeader(Mockito.any(), Mockito.eq(uuid))).thenReturn(uuid); when(im.getOwner(Mockito.any(), Mockito.eq(uuid))).thenReturn(uuid);
// Target has island // Target has island
when(im.hasIsland(Mockito.any(), Mockito.eq(notUUID))).thenReturn(true); when(im.hasIsland(Mockito.any(), Mockito.eq(notUUID))).thenReturn(true);

View File

@ -92,7 +92,7 @@ public class AdminTeamDisbandCommandTest {
when(im.hasIsland(Mockito.any(), Mockito.any(UUID.class))).thenReturn(true); when(im.hasIsland(Mockito.any(), Mockito.any(UUID.class))).thenReturn(true);
when(im.hasIsland(Mockito.any(), Mockito.any(User.class))).thenReturn(true); when(im.hasIsland(Mockito.any(), Mockito.any(User.class))).thenReturn(true);
when(im.isOwner(Mockito.any(),Mockito.any())).thenReturn(true); when(im.isOwner(Mockito.any(),Mockito.any())).thenReturn(true);
when(im.getTeamLeader(Mockito.any(),Mockito.any())).thenReturn(uuid); when(im.getOwner(Mockito.any(),Mockito.any())).thenReturn(uuid);
when(plugin.getIslands()).thenReturn(im); when(plugin.getIslands()).thenReturn(im);
// Has team // Has team
@ -158,7 +158,7 @@ public class AdminTeamDisbandCommandTest {
String[] name = {"tastybento"}; String[] name = {"tastybento"};
when(pm.getUUID(Mockito.any())).thenReturn(notUUID); when(pm.getUUID(Mockito.any())).thenReturn(notUUID);
when(im.getTeamLeader(Mockito.any(), Mockito.eq(notUUID))).thenReturn(uuid); when(im.getOwner(Mockito.any(), Mockito.eq(notUUID))).thenReturn(uuid);
when(pm.getName(Mockito.any())).thenReturn("leader"); when(pm.getName(Mockito.any())).thenReturn("leader");
AdminTeamDisbandCommand itl = new AdminTeamDisbandCommand(ac); AdminTeamDisbandCommand itl = new AdminTeamDisbandCommand(ac);
@ -177,7 +177,7 @@ public class AdminTeamDisbandCommandTest {
String[] name = {"tastybento"}; String[] name = {"tastybento"};
when(pm.getUUID(Mockito.any())).thenReturn(notUUID); when(pm.getUUID(Mockito.any())).thenReturn(notUUID);
// Leader // Leader
when(im.getTeamLeader(Mockito.any(), Mockito.eq(notUUID))).thenReturn(notUUID); when(im.getOwner(Mockito.any(), Mockito.eq(notUUID))).thenReturn(notUUID);
// Members // Members
Set<UUID> members = new HashSet<>(); Set<UUID> members = new HashSet<>();
members.add(uuid); members.add(uuid);

View File

@ -94,7 +94,7 @@ public class AdminTeamKickCommandTest {
when(im.hasIsland(Mockito.any(), Mockito.any(UUID.class))).thenReturn(true); when(im.hasIsland(Mockito.any(), Mockito.any(UUID.class))).thenReturn(true);
when(im.hasIsland(Mockito.any(), Mockito.any(User.class))).thenReturn(true); when(im.hasIsland(Mockito.any(), Mockito.any(User.class))).thenReturn(true);
when(im.isOwner(Mockito.any(),Mockito.any())).thenReturn(true); when(im.isOwner(Mockito.any(),Mockito.any())).thenReturn(true);
when(im.getTeamLeader(Mockito.any(),Mockito.any())).thenReturn(uuid); when(im.getOwner(Mockito.any(),Mockito.any())).thenReturn(uuid);
when(plugin.getIslands()).thenReturn(im); when(plugin.getIslands()).thenReturn(im);
// Has team // Has team
@ -161,7 +161,7 @@ public class AdminTeamKickCommandTest {
String[] name = {"tastybento"}; String[] name = {"tastybento"};
when(pm.getUUID(Mockito.any())).thenReturn(notUUID); when(pm.getUUID(Mockito.any())).thenReturn(notUUID);
when(im.getTeamLeader(Mockito.any(), Mockito.eq(notUUID))).thenReturn(notUUID); when(im.getOwner(Mockito.any(), Mockito.eq(notUUID))).thenReturn(notUUID);
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)));
@ -180,7 +180,7 @@ public class AdminTeamKickCommandTest {
String[] name = {"tastybento"}; String[] name = {"tastybento"};
when(pm.getUUID(Mockito.any())).thenReturn(notUUID); when(pm.getUUID(Mockito.any())).thenReturn(notUUID);
when(im.getTeamLeader(Mockito.any(), Mockito.eq(notUUID))).thenReturn(uuid); when(im.getOwner(Mockito.any(), Mockito.eq(notUUID))).thenReturn(uuid);
AdminTeamKickCommand itl = new AdminTeamKickCommand(ac); AdminTeamKickCommand itl = new AdminTeamKickCommand(ac);
assertTrue(itl.execute(user, itl.getLabel(), Arrays.asList(name))); assertTrue(itl.execute(user, itl.getLabel(), Arrays.asList(name)));

View File

@ -92,7 +92,7 @@ public class AdminTeamSetownerCommandTest {
when(im.hasIsland(Mockito.any(), Mockito.any(UUID.class))).thenReturn(true); when(im.hasIsland(Mockito.any(), Mockito.any(UUID.class))).thenReturn(true);
when(im.hasIsland(Mockito.any(), Mockito.any(User.class))).thenReturn(true); when(im.hasIsland(Mockito.any(), Mockito.any(User.class))).thenReturn(true);
when(im.isOwner(Mockito.any(),Mockito.any())).thenReturn(true); when(im.isOwner(Mockito.any(),Mockito.any())).thenReturn(true);
when(im.getTeamLeader(Mockito.any(),Mockito.any())).thenReturn(uuid); when(im.getOwner(Mockito.any(),Mockito.any())).thenReturn(uuid);
when(plugin.getIslands()).thenReturn(im); when(plugin.getIslands()).thenReturn(im);
// Has team // Has team
@ -159,7 +159,7 @@ public class AdminTeamSetownerCommandTest {
String[] name = {"tastybento"}; String[] name = {"tastybento"};
when(pm.getUUID(Mockito.any())).thenReturn(notUUID); when(pm.getUUID(Mockito.any())).thenReturn(notUUID);
when(im.getTeamLeader(Mockito.any(), Mockito.eq(notUUID))).thenReturn(notUUID); when(im.getOwner(Mockito.any(), Mockito.eq(notUUID))).thenReturn(notUUID);
AdminTeamSetownerCommand itl = new AdminTeamSetownerCommand(ac); AdminTeamSetownerCommand itl = new AdminTeamSetownerCommand(ac);
assertFalse(itl.execute(user, itl.getLabel(), Arrays.asList(name))); assertFalse(itl.execute(user, itl.getLabel(), Arrays.asList(name)));
@ -177,7 +177,7 @@ public class AdminTeamSetownerCommandTest {
String[] name = {"tastybento"}; String[] name = {"tastybento"};
when(pm.getUUID(Mockito.any())).thenReturn(notUUID); when(pm.getUUID(Mockito.any())).thenReturn(notUUID);
// Leader // Leader
when(im.getTeamLeader(Mockito.any(), Mockito.eq(notUUID))).thenReturn(uuid); when(im.getOwner(Mockito.any(), Mockito.eq(notUUID))).thenReturn(uuid);
when(pm.getName(Mockito.eq(uuid))).thenReturn("owner"); when(pm.getName(Mockito.eq(uuid))).thenReturn("owner");
// Members // Members
Set<UUID> members = new HashSet<>(); Set<UUID> members = new HashSet<>();

View File

@ -97,7 +97,7 @@ public class IslandTeamCoopCommandTest {
when(im.hasIsland(Mockito.any(), Mockito.any(UUID.class))).thenReturn(true); when(im.hasIsland(Mockito.any(), Mockito.any(UUID.class))).thenReturn(true);
when(im.inTeam(Mockito.any(), Mockito.any(UUID.class))).thenReturn(true); when(im.inTeam(Mockito.any(), Mockito.any(UUID.class))).thenReturn(true);
when(im.isOwner(Mockito.any(), Mockito.any())).thenReturn(true); when(im.isOwner(Mockito.any(), Mockito.any())).thenReturn(true);
when(im.getTeamLeader(Mockito.any(), Mockito.any())).thenReturn(uuid); when(im.getOwner(Mockito.any(), Mockito.any())).thenReturn(uuid);
island = mock(Island.class); island = mock(Island.class);
when(island.getRank(Mockito.any())).thenReturn(RanksManager.OWNER_RANK); when(island.getRank(Mockito.any())).thenReturn(RanksManager.OWNER_RANK);
when(im.getIsland(Mockito.any(), Mockito.any(User.class))).thenReturn(island); when(im.getIsland(Mockito.any(), Mockito.any(User.class))).thenReturn(island);

View File

@ -95,7 +95,7 @@ public class IslandTeamInviteCommandTest {
when(im.hasIsland(Mockito.any(), Mockito.any(UUID.class))).thenReturn(true); when(im.hasIsland(Mockito.any(), Mockito.any(UUID.class))).thenReturn(true);
when(im.inTeam(Mockito.any(), Mockito.any(UUID.class))).thenReturn(true); when(im.inTeam(Mockito.any(), Mockito.any(UUID.class))).thenReturn(true);
when(im.isOwner(Mockito.any(), Mockito.any())).thenReturn(true); when(im.isOwner(Mockito.any(), Mockito.any())).thenReturn(true);
when(im.getTeamLeader(Mockito.any(), Mockito.any())).thenReturn(uuid); when(im.getOwner(Mockito.any(), Mockito.any())).thenReturn(uuid);
island = mock(Island.class); island = mock(Island.class);
when(island.getRank(Mockito.any())).thenReturn(RanksManager.OWNER_RANK); when(island.getRank(Mockito.any())).thenReturn(RanksManager.OWNER_RANK);
when(im.getIsland(Mockito.any(), Mockito.any(User.class))).thenReturn(island); when(im.getIsland(Mockito.any(), Mockito.any(User.class))).thenReturn(island);

View File

@ -102,7 +102,7 @@ public class IslandTeamKickCommandTest {
im = mock(IslandsManager.class); im = mock(IslandsManager.class);
when(im.hasIsland(Mockito.any(), Mockito.any(UUID.class))).thenReturn(true); when(im.hasIsland(Mockito.any(), Mockito.any(UUID.class))).thenReturn(true);
when(im.isOwner(Mockito.any(), Mockito.any())).thenReturn(true); when(im.isOwner(Mockito.any(), Mockito.any())).thenReturn(true);
when(im.getTeamLeader(Mockito.any(), Mockito.any())).thenReturn(uuid); when(im.getOwner(Mockito.any(), Mockito.any())).thenReturn(uuid);
when(plugin.getIslands()).thenReturn(im); when(plugin.getIslands()).thenReturn(im);
// Has team // Has team
@ -143,7 +143,7 @@ public class IslandTeamKickCommandTest {
*/ */
@Test @Test
public void testExecuteNotTeamLeader() { public void testExecuteNotTeamLeader() {
when(im.getTeamLeader(Mockito.any(), Mockito.any())).thenReturn(notUUID); when(im.getOwner(Mockito.any(), Mockito.any())).thenReturn(notUUID);
IslandTeamKickCommand itl = new IslandTeamKickCommand(ic); IslandTeamKickCommand itl = new IslandTeamKickCommand(ic);
assertFalse(itl.execute(user, itl.getLabel(), new ArrayList<>())); assertFalse(itl.execute(user, itl.getLabel(), new ArrayList<>()));
Mockito.verify(user).sendMessage(Mockito.eq("general.errors.not-leader")); Mockito.verify(user).sendMessage(Mockito.eq("general.errors.not-leader"));

View File

@ -134,7 +134,7 @@ public class IslandTeamLeaveCommandTest {
when(im.hasIsland(Mockito.any(), Mockito.eq(uuid))).thenReturn(false); when(im.hasIsland(Mockito.any(), Mockito.eq(uuid))).thenReturn(false);
when(im.isOwner(Mockito.any(), Mockito.eq(uuid))).thenReturn(false); when(im.isOwner(Mockito.any(), Mockito.eq(uuid))).thenReturn(false);
// Add a team leader - null // Add a team leader - null
when(im.getTeamLeader(Mockito.any(), Mockito.any())).thenReturn(null); when(im.getOwner(Mockito.any(), Mockito.any())).thenReturn(null);
IslandTeamLeaveCommand itl = new IslandTeamLeaveCommand(ic); IslandTeamLeaveCommand itl = new IslandTeamLeaveCommand(ic);
assertTrue(itl.execute(user, itl.getLabel(), new ArrayList<>())); assertTrue(itl.execute(user, itl.getLabel(), new ArrayList<>()));
@ -153,7 +153,7 @@ public class IslandTeamLeaveCommandTest {
when(im.hasIsland(Mockito.any(), Mockito.eq(uuid))).thenReturn(false); when(im.hasIsland(Mockito.any(), Mockito.eq(uuid))).thenReturn(false);
when(im.isOwner(Mockito.any(), Mockito.eq(uuid))).thenReturn(false); when(im.isOwner(Mockito.any(), Mockito.eq(uuid))).thenReturn(false);
// Add a team leader - null // Add a team leader - null
when(im.getTeamLeader(Mockito.any(), Mockito.any())).thenReturn(null); when(im.getOwner(Mockito.any(), Mockito.any())).thenReturn(null);
IslandTeamLeaveCommand itl = new IslandTeamLeaveCommand(ic); IslandTeamLeaveCommand itl = new IslandTeamLeaveCommand(ic);
assertFalse(itl.execute(user, itl.getLabel(), new ArrayList<>())); assertFalse(itl.execute(user, itl.getLabel(), new ArrayList<>()));
@ -170,7 +170,7 @@ public class IslandTeamLeaveCommandTest {
when(im.hasIsland(Mockito.any(), Mockito.eq(uuid))).thenReturn(false); when(im.hasIsland(Mockito.any(), Mockito.eq(uuid))).thenReturn(false);
when(im.isOwner(Mockito.any(), Mockito.eq(uuid))).thenReturn(false); when(im.isOwner(Mockito.any(), Mockito.eq(uuid))).thenReturn(false);
// Add a team leader - null // Add a team leader - null
when(im.getTeamLeader(Mockito.any(), Mockito.any())).thenReturn(null); when(im.getOwner(Mockito.any(), Mockito.any())).thenReturn(null);
// Require resets // Require resets
when(iwm.isOnLeaveResetEnderChest(Mockito.any())).thenReturn(true); when(iwm.isOnLeaveResetEnderChest(Mockito.any())).thenReturn(true);

View File

@ -97,7 +97,7 @@ public class IslandTeamTrustCommandTest {
when(im.hasIsland(Mockito.any(), Mockito.any(UUID.class))).thenReturn(true); when(im.hasIsland(Mockito.any(), Mockito.any(UUID.class))).thenReturn(true);
when(im.inTeam(Mockito.any(), Mockito.any(UUID.class))).thenReturn(true); when(im.inTeam(Mockito.any(), Mockito.any(UUID.class))).thenReturn(true);
when(im.isOwner(Mockito.any(), Mockito.any())).thenReturn(true); when(im.isOwner(Mockito.any(), Mockito.any())).thenReturn(true);
when(im.getTeamLeader(Mockito.any(), Mockito.any())).thenReturn(uuid); when(im.getOwner(Mockito.any(), Mockito.any())).thenReturn(uuid);
island = mock(Island.class); island = mock(Island.class);
when(island.getRank(Mockito.any())).thenReturn(RanksManager.OWNER_RANK); when(island.getRank(Mockito.any())).thenReturn(RanksManager.OWNER_RANK);
when(im.getIsland(Mockito.any(), Mockito.any(User.class))).thenReturn(island); when(im.getIsland(Mockito.any(), Mockito.any(User.class))).thenReturn(island);

View File

@ -97,7 +97,7 @@ public class IslandTeamUncoopCommandTest {
when(im.hasIsland(Mockito.any(), Mockito.any(UUID.class))).thenReturn(true); when(im.hasIsland(Mockito.any(), Mockito.any(UUID.class))).thenReturn(true);
when(im.inTeam(Mockito.any(), Mockito.any(UUID.class))).thenReturn(true); when(im.inTeam(Mockito.any(), Mockito.any(UUID.class))).thenReturn(true);
when(im.isOwner(Mockito.any(), Mockito.any())).thenReturn(true); when(im.isOwner(Mockito.any(), Mockito.any())).thenReturn(true);
when(im.getTeamLeader(Mockito.any(), Mockito.any())).thenReturn(uuid); when(im.getOwner(Mockito.any(), Mockito.any())).thenReturn(uuid);
island = mock(Island.class); island = mock(Island.class);
when(island.getRank(Mockito.any())).thenReturn(RanksManager.OWNER_RANK); when(island.getRank(Mockito.any())).thenReturn(RanksManager.OWNER_RANK);
when(im.getIsland(Mockito.any(), Mockito.any(User.class))).thenReturn(island); when(im.getIsland(Mockito.any(), Mockito.any(User.class))).thenReturn(island);

View File

@ -97,7 +97,7 @@ public class IslandTeamUntrustCommandTest {
when(im.hasIsland(Mockito.any(), Mockito.any(UUID.class))).thenReturn(true); when(im.hasIsland(Mockito.any(), Mockito.any(UUID.class))).thenReturn(true);
when(im.inTeam(Mockito.any(), Mockito.any(UUID.class))).thenReturn(true); when(im.inTeam(Mockito.any(), Mockito.any(UUID.class))).thenReturn(true);
when(im.isOwner(Mockito.any(), Mockito.any())).thenReturn(true); when(im.isOwner(Mockito.any(), Mockito.any())).thenReturn(true);
when(im.getTeamLeader(Mockito.any(), Mockito.any())).thenReturn(uuid); when(im.getOwner(Mockito.any(), Mockito.any())).thenReturn(uuid);
island = mock(Island.class); island = mock(Island.class);
when(island.getRank(Mockito.any())).thenReturn(RanksManager.OWNER_RANK); when(island.getRank(Mockito.any())).thenReturn(RanksManager.OWNER_RANK);
when(im.getIsland(Mockito.any(), Mockito.any(User.class))).thenReturn(island); when(im.getIsland(Mockito.any(), Mockito.any(User.class))).thenReturn(island);

View File

@ -127,7 +127,7 @@ public class NetherPortalsTest {
im = mock(IslandsManager.class); im = mock(IslandsManager.class);
when(im.hasIsland(Mockito.any(), Mockito.any(UUID.class))).thenReturn(true); when(im.hasIsland(Mockito.any(), Mockito.any(UUID.class))).thenReturn(true);
when(im.isOwner(Mockito.any(), Mockito.any())).thenReturn(true); when(im.isOwner(Mockito.any(), Mockito.any())).thenReturn(true);
when(im.getTeamLeader(Mockito.any(), Mockito.any())).thenReturn(uuid); when(im.getOwner(Mockito.any(), Mockito.any())).thenReturn(uuid);
Optional<Island> optionalIsland = Optional.empty(); Optional<Island> optionalIsland = Optional.empty();
when(im.getIslandAt(Mockito.any())).thenReturn(optionalIsland); when(im.getIslandAt(Mockito.any())).thenReturn(optionalIsland);
when(plugin.getIslands()).thenReturn(im); when(plugin.getIslands()).thenReturn(im);

View File

@ -124,7 +124,7 @@ public class PlayersManagerTest {
IslandsManager im = mock(IslandsManager.class); IslandsManager im = mock(IslandsManager.class);
when(im.hasIsland(Mockito.any(), Mockito.any(UUID.class))).thenReturn(true); when(im.hasIsland(Mockito.any(), Mockito.any(UUID.class))).thenReturn(true);
when(im.isOwner(Mockito.any(), Mockito.any())).thenReturn(true); when(im.isOwner(Mockito.any(), Mockito.any())).thenReturn(true);
when(im.getTeamLeader(Mockito.any(), Mockito.any())).thenReturn(uuid); when(im.getOwner(Mockito.any(), Mockito.any())).thenReturn(uuid);
when(plugin.getIslands()).thenReturn(im); when(plugin.getIslands()).thenReturn(im);

View File

@ -222,9 +222,9 @@ public class IslandCacheTest {
IslandCache ic = new IslandCache(); IslandCache ic = new IslandCache();
ic.addIsland(island); ic.addIsland(island);
assertEquals(owner, ic.getTeamLeader(world, owner)); assertEquals(owner, ic.getOwner(world, owner));
assertNull(ic.getTeamLeader(world, null)); assertNull(ic.getOwner(world, null));
assertNull(ic.getTeamLeader(world, UUID.randomUUID())); assertNull(ic.getOwner(world, UUID.randomUUID()));
} }