Merge pull request #2335 from BentoBoxWorld/2328_team_members_can_have_islands

Remove restrictions on having multiple islands for team members.
This commit is contained in:
tastybento 2024-04-04 10:23:12 -07:00 committed by GitHub
commit 6106b661e9
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
36 changed files with 157 additions and 57 deletions

View File

@ -524,6 +524,7 @@ public abstract class CompositeCommand extends Command implements PluginIdentifi
* @param world - the world to check * @param world - the world to check
* @param user - the User * @param user - the User
* @return true if player is in a team * @return true if player is in a team
* @see Consider checking the island itself {@link Island#inTeam(UUID)}
*/ */
protected boolean inTeam(World world, User user) { protected boolean inTeam(World world, User user) {
return plugin.getIslands().inTeam(world, user.getUniqueId()); return plugin.getIslands().inTeam(world, user.getUniqueId());

View File

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

View File

@ -44,17 +44,17 @@ public class AdminTeamAddCommand extends CompositeCommand {
user.sendMessage("general.errors.unknown-player", TextVariables.NAME, args.get(1)); user.sendMessage("general.errors.unknown-player", TextVariables.NAME, args.get(1));
return false; return false;
} }
if (!getIslands().hasIsland(getWorld(), ownerUUID)) { Island island = getIslands().getPrimaryIsland(getWorld(), ownerUUID);
if (island == null || !getIslands().hasIsland(getWorld(), ownerUUID)) {
user.sendMessage("general.errors.player-has-no-island"); user.sendMessage("general.errors.player-has-no-island");
return false; return false;
} }
Island island = getIslands().getPrimaryIsland(getWorld(), ownerUUID); if (getIslands().inTeam(getWorld(), ownerUUID) && !ownerUUID.equals(island.getOwner())) {
if (getIslands().inTeam(getWorld(), ownerUUID) && island != null && !ownerUUID.equals(island.getOwner())) {
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));
new IslandInfo(island).showMembers(user); new IslandInfo(island).showMembers(user);
return false; return false;
} }
if (getIslands().inTeam(getWorld(), targetUUID)) { if (getIWM().getWorldSettings(getWorld()).isDisallowTeamMemberIslands() && island.inTeam(targetUUID)) {
user.sendMessage("commands.island.team.invite.errors.already-on-team"); user.sendMessage("commands.island.team.invite.errors.already-on-team");
return false; return false;
} }

View File

@ -52,10 +52,7 @@ public class AdminTeamDisbandCommand extends CompositeCommand {
user.sendMessage("general.errors.unknown-player", TextVariables.NAME, args.get(0)); user.sendMessage("general.errors.unknown-player", TextVariables.NAME, args.get(0));
return false; return false;
} }
if (!getIslands().inTeam(getWorld(), targetUUID)) {
user.sendMessage("general.errors.player-is-not-owner", TextVariables.NAME, args.get(0));
return false;
}
// Find the island the player is an owner of // Find the island the player is an owner of
Map<String, Island> islands = getIslandsXYZ(targetUUID); Map<String, Island> islands = getIslandsXYZ(targetUUID);
if (islands.isEmpty()) { if (islands.isEmpty()) {
@ -77,6 +74,11 @@ public class AdminTeamDisbandCommand extends CompositeCommand {
// Get the only island // Get the only island
island = islands.values().iterator().next(); island = islands.values().iterator().next();
} }
// Check that the target owns the island
if (island.getOwner() == null || !island.getOwner().equals(targetUUID)) {
user.sendMessage("general.errors.player-is-not-owner", TextVariables.NAME, args.get(0));
return false;
}
return true; return true;
} }

View File

@ -70,7 +70,7 @@ public class IslandBanCommand extends CompositeCommand {
user.sendMessage("commands.island.ban.cannot-ban-yourself"); user.sendMessage("commands.island.ban.cannot-ban-yourself");
return false; return false;
} }
if (getIslands().getPrimaryIsland(getWorld(), user.getUniqueId()).getMemberSet().contains(targetUUID)) { if (getIslands().getPrimaryIsland(getWorld(), user.getUniqueId()).inTeam(targetUUID)) {
user.sendMessage("commands.island.ban.cannot-ban-member"); user.sendMessage("commands.island.ban.cannot-ban-member");
return false; return false;
} }

View File

@ -51,7 +51,8 @@ public class IslandCreateCommand extends CompositeCommand {
} }
} }
// Check if this player is on a team in this world // Check if this player is on a team in this world
if (getIslands().inTeam(getWorld(), user.getUniqueId()) && island != null if (getIWM().getWorldSettings(getWorld()).isDisallowTeamMemberIslands()
&& getIslands().inTeam(getWorld(), user.getUniqueId()) && island != null
&& !user.getUniqueId().equals(island.getOwner())) { && !user.getUniqueId().equals(island.getOwner())) {
// Team members who are not owners cannot make additional islands // Team members who are not owners cannot make additional islands
user.sendMessage("commands.island.create.you-cannot-make-team"); user.sendMessage("commands.island.create.you-cannot-make-team");

View File

@ -76,7 +76,7 @@ public class IslandExpelCommand extends CompositeCommand {
return false; return false;
} }
// Or team member // Or team member
if (island.getMemberSet().contains(targetUUID)) { if (island.inTeam(targetUUID)) {
user.sendMessage("commands.island.expel.cannot-expel-member"); user.sendMessage("commands.island.expel.cannot-expel-member");
return false; return false;
} }

View File

@ -61,7 +61,8 @@ public class IslandTeamInviteAcceptCommand extends ConfirmableCommand {
} }
// Check if player is already in a team // Check if player is already in a team
if (getIslands().inTeam(getWorld(), playerUUID)) { if (getIWM().getWorldSettings(getWorld()).isDisallowTeamMemberIslands()
&& getIslands().inTeam(getWorld(), playerUUID)) {
user.sendMessage("commands.island.team.invite.errors.you-already-are-in-team"); user.sendMessage("commands.island.team.invite.errors.you-already-are-in-team");
return false; return false;
} }
@ -81,8 +82,14 @@ public class IslandTeamInviteAcceptCommand extends ConfirmableCommand {
switch (invite.getType()) { switch (invite.getType()) {
case COOP -> askConfirmation(user, () -> acceptCoopInvite(user, invite)); case COOP -> askConfirmation(user, () -> acceptCoopInvite(user, invite));
case TRUST -> askConfirmation(user, () -> acceptTrustInvite(user, invite)); case TRUST -> askConfirmation(user, () -> acceptTrustInvite(user, invite));
default -> askConfirmation(user, user.getTranslation("commands.island.team.invite.accept.confirmation"), default -> {
() -> acceptTeamInvite(user, invite)); if (getIWM().getWorldSettings(getWorld()).isDisallowTeamMemberIslands()) {
askConfirmation(user, user.getTranslation("commands.island.team.invite.accept.confirmation"),
() -> acceptTeamInvite(user, invite));
} else {
acceptTeamInvite(user, invite);
}
}
} }
return true; return true;
} }
@ -155,17 +162,21 @@ public class IslandTeamInviteAcceptCommand extends ConfirmableCommand {
user.sendMessage("commands.island.team.invite.errors.island-is-full"); user.sendMessage("commands.island.team.invite.errors.island-is-full");
return; return;
} }
// Remove the player's other islands if (getIWM().getWorldSettings(getWorld()).isDisallowTeamMemberIslands()) {
getIslands().removePlayer(getWorld(), user.getUniqueId()); // Remove the player's other islands
// Remove money inventory etc. for leaving getIslands().removePlayer(getWorld(), user.getUniqueId());
cleanPlayer(user); // Remove money inventory etc. for leaving
cleanPlayer(user);
}
// Add the player as a team member of the new island // Add the player as a team member of the new island
getIslands().setJoinTeam(teamIsland, user.getUniqueId()); getIslands().setJoinTeam(teamIsland, user.getUniqueId());
// Move player to team's island // Move player to team's island
getIslands().setPrimaryIsland(user.getUniqueId(), teamIsland);
getIslands().homeTeleportAsync(getWorld(), user.getPlayer()).thenRun(() -> { getIslands().homeTeleportAsync(getWorld(), user.getPlayer()).thenRun(() -> {
// Delete the old islands if (getIWM().getWorldSettings(getWorld()).isDisallowTeamMemberIslands()) {
islands.forEach(island -> getIslands().deleteIsland(island, true, user.getUniqueId())); // Delete the old islands
islands.forEach(island -> getIslands().deleteIsland(island, true, user.getUniqueId()));
}
// Put player back into normal mode // Put player back into normal mode
user.setGameMode(getIWM().getDefaultGameMode(getWorld())); user.setGameMode(getIWM().getDefaultGameMode(getWorld()));
@ -174,8 +185,9 @@ public class IslandTeamInviteAcceptCommand extends ConfirmableCommand {
Util.runCommands(user, ownerName, getIWM().getOnJoinCommands(getWorld()), "join"); Util.runCommands(user, ownerName, getIWM().getOnJoinCommands(getWorld()), "join");
}); });
// Reset deaths if (getIWM().getWorldSettings(getWorld()).isDisallowTeamMemberIslands()
if (getIWM().isTeamJoinDeathReset(getWorld())) { && getIWM().isTeamJoinDeathReset(getWorld())) {
// Reset deaths
getPlayers().setDeaths(getWorld(), user.getUniqueId(), 0); getPlayers().setDeaths(getWorld(), user.getUniqueId(), 0);
} }
user.sendMessage("commands.island.team.invite.accept.you-joined-island", TextVariables.LABEL, getTopLabel()); user.sendMessage("commands.island.team.invite.accept.you-joined-island", TextVariables.LABEL, getTopLabel());

View File

@ -105,7 +105,8 @@ public class IslandTeamInviteCommand extends CompositeCommand {
} }
// Player cannot invite someone already on a team // Player cannot invite someone already on a team
if (getIslands().inTeam(getWorld(), invitedPlayerUUID)) { if (getIWM().getWorldSettings(getWorld()).isDisallowTeamMemberIslands()
&& getIslands().inTeam(getWorld(), invitedPlayerUUID)) {
user.sendMessage("commands.island.team.invite.errors.already-on-team"); user.sendMessage("commands.island.team.invite.errors.already-on-team");
return false; return false;
} }
@ -170,7 +171,8 @@ public class IslandTeamInviteCommand extends CompositeCommand {
// Send message to online player // Send message to online player
invitedPlayer.sendMessage("commands.island.team.invite.name-has-invited-you", TextVariables.NAME, user.getName(), TextVariables.DISPLAY_NAME, user.getDisplayName()); invitedPlayer.sendMessage("commands.island.team.invite.name-has-invited-you", TextVariables.NAME, user.getName(), TextVariables.DISPLAY_NAME, user.getDisplayName());
invitedPlayer.sendMessage("commands.island.team.invite.to-accept-or-reject", TextVariables.LABEL, getTopLabel()); invitedPlayer.sendMessage("commands.island.team.invite.to-accept-or-reject", TextVariables.LABEL, getTopLabel());
if (getIslands().hasIsland(getWorld(), invitedPlayer.getUniqueId())) { if (getIWM().getWorldSettings(getWorld()).isDisallowTeamMemberIslands()
&& getIslands().hasIsland(getWorld(), invitedPlayer.getUniqueId())) {
invitedPlayer.sendMessage("commands.island.team.invite.you-will-lose-your-island"); invitedPlayer.sendMessage("commands.island.team.invite.you-will-lose-your-island");
} }
return true; return true;

View File

@ -63,7 +63,7 @@ public class IslandTeamKickCommand extends ConfirmableCommand {
user.sendMessage("commands.island.team.kick.cannot-kick"); user.sendMessage("commands.island.team.kick.cannot-kick");
return false; return false;
} }
if (!getIslands().getPrimaryIsland(getWorld(), user.getUniqueId()).getMemberSet().contains(targetUUID)) { if (!getIslands().getPrimaryIsland(getWorld(), user.getUniqueId()).inTeam(targetUUID)) {
user.sendMessage("general.errors.not-in-team"); user.sendMessage("general.errors.not-in-team");
return false; return false;
} }

View File

@ -69,7 +69,7 @@ public class IslandTeamPromoteCommand extends CompositeCommand {
return false; return false;
} }
// Check that target is a member of this island // Check that target is a member of this island
if (!island.getMemberSet().contains(target.getUniqueId())) { if (!island.inTeam(target.getUniqueId())) {
user.sendMessage("commands.island.team.promote.errors.must-be-member"); user.sendMessage("commands.island.team.promote.errors.must-be-member");
return false; return false;
} }

View File

@ -42,7 +42,7 @@ public class IslandTeamSetownerCommand extends CompositeCommand {
} }
// Can use if in a team // Can use if in a team
Island is = getIslands().getPrimaryIsland(getWorld(), user.getUniqueId()); Island is = getIslands().getPrimaryIsland(getWorld(), user.getUniqueId());
if (is == null || !is.getMemberSet().contains(user.getUniqueId())) { if (is == null || !is.inTeam(user.getUniqueId())) {
user.sendMessage("general.errors.no-team"); user.sendMessage("general.errors.no-team");
return false; return false;
} }
@ -60,7 +60,7 @@ public class IslandTeamSetownerCommand extends CompositeCommand {
user.sendMessage("commands.island.team.setowner.errors.cant-transfer-to-yourself"); user.sendMessage("commands.island.team.setowner.errors.cant-transfer-to-yourself");
return false; return false;
} }
if (!is.getMemberSet().contains(targetUUID)) { if (!is.inTeam(targetUUID)) {
user.sendMessage("commands.island.team.setowner.errors.target-is-not-member"); user.sendMessage("commands.island.team.setowner.errors.target-is-not-member");
return false; return false;
} }

View File

@ -74,7 +74,7 @@ public class IslandTeamUncoopCommand extends CompositeCommand {
user.sendMessage("commands.island.team.uncoop.cannot-uncoop-yourself"); user.sendMessage("commands.island.team.uncoop.cannot-uncoop-yourself");
return false; return false;
} }
if (getIslands().getPrimaryIsland(getWorld(), user.getUniqueId()).getMemberSet().contains(targetUUID)) { if (getIslands().getPrimaryIsland(getWorld(), user.getUniqueId()).inTeam(targetUUID)) {
user.sendMessage("commands.island.team.uncoop.cannot-uncoop-member"); user.sendMessage("commands.island.team.uncoop.cannot-uncoop-member");
return false; return false;
} }

View File

@ -74,7 +74,7 @@ public class IslandTeamUntrustCommand extends CompositeCommand {
user.sendMessage("commands.island.team.untrust.cannot-untrust-yourself"); user.sendMessage("commands.island.team.untrust.cannot-untrust-yourself");
return false; return false;
} }
if (getIslands().getPrimaryIsland(getWorld(), user.getUniqueId()).getMemberSet().contains(targetUUID)) { if (getIslands().getPrimaryIsland(getWorld(), user.getUniqueId()).inTeam(targetUUID)) {
user.sendMessage("commands.island.team.untrust.cannot-untrust-member"); user.sendMessage("commands.island.team.untrust.cannot-untrust-member");
return false; return false;
} }

View File

@ -644,4 +644,12 @@ public interface WorldSettings extends ConfigObject {
default int getConcurrentIslands() { default int getConcurrentIslands() {
return BentoBox.getInstance().getSettings().getIslandNumber(); return BentoBox.getInstance().getSettings().getIslandNumber();
} }
/**
* Remove islands when players join a team and not allow players to have other islands if they are in a team.
* @return true or false
*/
default boolean isDisallowTeamMemberIslands() {
return true;
}
} }

View File

@ -1950,6 +1950,25 @@ public class Island implements DataObject, MetaDataAble {
setChanged(); setChanged();
} }
/**
* Check if a player is in this island's team
* @param playerUUID player's UUID
* @return true if in team
* @since 2.3.0
*/
public boolean inTeam(UUID playerUUID) {
return this.getMemberSet().contains(playerUUID);
}
/**
* Check if this island has a team
* @return true if this island has a team
* @since 2.3.0
*/
public boolean hasTeam() {
return this.getMemberSet().size() > 1;
}
/* /*
* (non-Javadoc) * (non-Javadoc)
* *

View File

@ -79,6 +79,10 @@ public class JoinLeaveListener implements Listener {
plugin.logWarning("Player that just logged in has no name! " + playerUUID); plugin.logWarning("Player that just logged in has no name! " + playerUUID);
} }
// Set the primary island to the player's location if this is their island
plugin.getIslands().getIslandAt(user.getLocation()).filter(i -> user.getUniqueId().equals(i.getOwner()))
.ifPresent(i -> plugin.getIslands().setPrimaryIsland(playerUUID, i));
// If mobs have to be removed when a player joins, then wipe all the mobs on his // If mobs have to be removed when a player joins, then wipe all the mobs on his
// island. // island.
if (plugin.getIslands().locationIsOnIsland(event.getPlayer(), user.getLocation()) if (plugin.getIslands().locationIsOnIsland(event.getPlayer(), user.getLocation())
@ -219,7 +223,7 @@ public class JoinLeaveListener implements Listener {
.filter(island -> island.getMembers().containsKey(event.getPlayer().getUniqueId())).forEach(island -> { .filter(island -> island.getMembers().containsKey(event.getPlayer().getUniqueId())).forEach(island -> {
// Are there any online players still for this island? // Are there any online players still for this island?
if (Bukkit.getOnlinePlayers().stream().filter(p -> !event.getPlayer().equals(p)) if (Bukkit.getOnlinePlayers().stream().filter(p -> !event.getPlayer().equals(p))
.noneMatch(p -> island.getMemberSet().contains(p.getUniqueId()))) { .noneMatch(p -> island.inTeam(p.getUniqueId()))) {
// No, there are no more players online on this island // No, there are no more players online on this island
// Tell players they are being removed // Tell players they are being removed
island.getMembers().entrySet().stream().filter(e -> e.getValue() == RanksManager.COOP_RANK) island.getMembers().entrySet().stream().filter(e -> e.getValue() == RanksManager.COOP_RANK)

View File

@ -107,7 +107,7 @@ public class EnterExitListener extends FlagListener {
// Leave messages are always specific to this world // Leave messages are always specific to this world
String islandMessage = user.getTranslation(island.getWorld(), ISLAND_MESSAGE, TextVariables.NAME, getPlugin().getPlayers().getName(island.getOwner())); String islandMessage = user.getTranslation(island.getWorld(), ISLAND_MESSAGE, TextVariables.NAME, getPlugin().getPlayers().getName(island.getOwner()));
// Send specific message if the player is member of this island // Send specific message if the player is member of this island
if (island.getMemberSet().contains(user.getUniqueId())) { if (island.inTeam(user.getUniqueId())) {
user.notify(island.getWorld(), "protection.flags.ENTER_EXIT_MESSAGES.now-leaving-your-island", TextVariables.NAME, (island.getName() != null) ? island.getName() : islandMessage); user.notify(island.getWorld(), "protection.flags.ENTER_EXIT_MESSAGES.now-leaving-your-island", TextVariables.NAME, (island.getName() != null) ? island.getName() : islandMessage);
} else { } else {
user.notify(island.getWorld(), "protection.flags.ENTER_EXIT_MESSAGES.now-leaving", TextVariables.NAME, (island.getName() != null) ? island.getName() : islandMessage); user.notify(island.getWorld(), "protection.flags.ENTER_EXIT_MESSAGES.now-leaving", TextVariables.NAME, (island.getName() != null) ? island.getName() : islandMessage);
@ -135,7 +135,7 @@ public class EnterExitListener extends FlagListener {
// Enter messages are always specific to this world // Enter messages are always specific to this world
String islandMessage = user.getTranslation(island.getWorld(), ISLAND_MESSAGE, TextVariables.NAME, getPlugin().getPlayers().getName(island.getOwner())); String islandMessage = user.getTranslation(island.getWorld(), ISLAND_MESSAGE, TextVariables.NAME, getPlugin().getPlayers().getName(island.getOwner()));
// Send specific message if the player is member of this island // Send specific message if the player is member of this island
if (island.getMemberSet().contains(user.getUniqueId())) { if (island.inTeam(user.getUniqueId())) {
user.notify(island.getWorld(), "protection.flags.ENTER_EXIT_MESSAGES.now-entering-your-island", TextVariables.NAME, (island.getName() != null) ? island.getName() : islandMessage); user.notify(island.getWorld(), "protection.flags.ENTER_EXIT_MESSAGES.now-entering-your-island", TextVariables.NAME, (island.getName() != null) ? island.getName() : islandMessage);
} else { } else {
user.notify(island.getWorld(), "protection.flags.ENTER_EXIT_MESSAGES.now-entering", TextVariables.NAME, (island.getName() != null) ? island.getName() : islandMessage); user.notify(island.getWorld(), "protection.flags.ENTER_EXIT_MESSAGES.now-entering", TextVariables.NAME, (island.getName() != null) ? island.getName() : islandMessage);

View File

@ -31,7 +31,7 @@ public class PetTeleportListener extends FlagListener {
// Get where the pet is going // Get where the pet is going
e.setCancelled(getIslands().getProtectedIslandAt(e.getTo()) e.setCancelled(getIslands().getProtectedIslandAt(e.getTo())
// Not home island // Not home island
.map(i -> !i.getMemberSet().contains(t.getOwner().getUniqueId())) .map(i -> !i.inTeam(t.getOwner().getUniqueId()))
// Not any island // Not any island
.orElse(true)); .orElse(true));
} }

View File

@ -49,7 +49,7 @@ public class VisitorsStartingRaidListener extends FlagListener
Optional<Island> island = this.getIslands().getProtectedIslandAt(event.getPlayer().getLocation()); Optional<Island> island = this.getIslands().getProtectedIslandAt(event.getPlayer().getLocation());
if (island.isPresent() && !island.get().getMemberSet().contains(event.getPlayer().getUniqueId())) if (island.isPresent() && !island.get().inTeam(event.getPlayer().getUniqueId()))
{ {
event.setCancelled(true); event.setCancelled(true);
this.report(User.getInstance(event.getPlayer()), this.report(User.getInstance(event.getPlayer()),

View File

@ -1319,7 +1319,7 @@ public class IslandsManager {
return false; return false;
} }
// Get the player's island // Get the player's island
return getIslandAt(loc).filter(i -> i.onIsland(loc)).map(i -> i.getMemberSet().contains(player.getUniqueId())) return getIslandAt(loc).filter(i -> i.onIsland(loc)).map(i -> i.inTeam(player.getUniqueId()))
.orElse(false); .orElse(false);
} }
@ -1389,7 +1389,7 @@ public class IslandsManager {
.filter(p -> p.getGameMode().equals(plugin.getIWM().getDefaultGameMode(island.getWorld()))) .filter(p -> p.getGameMode().equals(plugin.getIWM().getDefaultGameMode(island.getWorld())))
.filter(p -> island.onIsland(p.getLocation())).forEach(p -> { .filter(p -> island.onIsland(p.getLocation())).forEach(p -> {
// Teleport island players to their island home // Teleport island players to their island home
if (!island.getMemberSet().contains(p.getUniqueId()) if (!island.inTeam(p.getUniqueId())
&& (hasIsland(w, p.getUniqueId()) || inTeam(w, p.getUniqueId()))) { && (hasIsland(w, p.getUniqueId()) || inTeam(w, p.getUniqueId()))) {
homeTeleportAsync(w, p); homeTeleportAsync(w, p);
} else { } else {
@ -1493,16 +1493,17 @@ public class IslandsManager {
} }
/** /**
* Checks if a player is in a team in this world. Note that the player may have * Checks if a player is in any team in this world. Note that the player may have
* multiple islands in the world, any one of which may have a team. * multiple islands in the world, any one of which may have a team.
* *
* @param world - world * @param world - world
* @param playerUUID - player's UUID * @param playerUUID - player's UUID
* @return true if in team, false if not * @return true if in team, false if not
* @see Consider checking the island itself {@link Island#inTeam(UUID)}
*/ */
public boolean inTeam(World world, @NonNull UUID playerUUID) { public boolean inTeam(World world, @NonNull UUID playerUUID) {
return this.islandCache.getIslands(world, playerUUID).stream() return this.islandCache.getIslands(world, playerUUID).stream()
.anyMatch(island -> island.getMemberSet().size() > 1 && island.getMemberSet().contains(playerUUID)); .anyMatch(island -> island.getMemberSet().size() > 1 && island.inTeam(playerUUID));
} }
/** /**

View File

@ -685,8 +685,10 @@ commands:
already-has-rank: '&c Player already has a rank!' already-has-rank: '&c Player already has a rank!'
you-are-a-coop-member: '&2 You were cooped by &b[name]&a.' you-are-a-coop-member: '&2 You were cooped by &b[name]&a.'
success: '&a You cooped &b [name]&a.' success: '&a You cooped &b [name]&a.'
name-has-invited-you: '&a [name] has invited you to join as a coop member name-has-invited-you: |
of their island.' &a [name] has invited you
&a to join as a coop member
&a of their island.
uncoop: uncoop:
description: remove a coop rank from player description: remove a coop rank from player
parameters: <player> parameters: <player>
@ -703,8 +705,10 @@ commands:
description: give a player trusted rank on your island description: give a player trusted rank on your island
parameters: <player> parameters: <player>
trust-in-yourself: '&c Trust in yourself!' trust-in-yourself: '&c Trust in yourself!'
name-has-invited-you: '&a [name] has invited you to join as a trusted member name-has-invited-you: |
of their island.' &a [name] has invited you
&a to join as a trusted member
&a of their island.
player-already-trusted: '&c Player is already trusted!' player-already-trusted: '&c Player is already trusted!'
you-are-trusted: '&2 You are trusted by &b [name]&a !' you-are-trusted: '&2 You are trusted by &b [name]&a !'
success: '&a You trusted &b [name]&a .' success: '&a You trusted &b [name]&a .'
@ -721,10 +725,14 @@ commands:
description: invite a player to join your island description: invite a player to join your island
invitation-sent: '&a Invitation sent to &b[name]&a.' invitation-sent: '&a Invitation sent to &b[name]&a.'
removing-invite: '&c Removing invite.' removing-invite: '&c Removing invite.'
name-has-invited-you: '&a [name] has invited you to join their island.' name-has-invited-you: |
&a [name] has invited you
&a to join their island.
to-accept-or-reject: '&a Do /[label] team accept to accept, or /[label] team to-accept-or-reject: '&a Do /[label] team accept to accept, or /[label] team
reject to reject' reject to reject'
you-will-lose-your-island: '&c WARNING! You will lose all your islands if you accept!' you-will-lose-your-island: |
&c WARNING! You will lose all
&c your islands if you accept!
gui: gui:
titles: titles:
team-invite-panel: "Invite Players" team-invite-panel: "Invite Players"
@ -765,9 +773,10 @@ commands:
you-joined-island: '&a You joined an island! Use &b/[label] team &a to see you-joined-island: '&a You joined an island! Use &b/[label] team &a to see
the other members.' the other members.'
name-joined-your-island: '&a [name] joined your island!' name-joined-your-island: '&a [name] joined your island!'
confirmation: |- confirmation: |
&c Are you sure you want to accept this invite? &c Are you sure you
&c&l You will &n LOSE ALL &r&c&l your islands! &c want to accept this
&c invite?
reject: reject:
description: reject an invitation description: reject an invitation
you-rejected-invite: '&a You rejected the invitation to join an island.' you-rejected-invite: '&a You rejected the invitation to join an island.'

View File

@ -121,6 +121,7 @@ public class AdminDeleteCommandTest {
// Island // Island
when(island.getOwner()).thenReturn(uuid); when(island.getOwner()).thenReturn(uuid);
when(island.hasTeam()).thenReturn(true);
// Has team // Has team
when(im.inTeam(any(), eq(uuid))).thenReturn(true); when(im.inTeam(any(), eq(uuid))).thenReturn(true);
@ -190,6 +191,7 @@ public class AdminDeleteCommandTest {
public void testExecuteOwner() { public void testExecuteOwner() {
when(im.inTeam(any(),any())).thenReturn(true); when(im.inTeam(any(),any())).thenReturn(true);
when(island.inTeam(notUUID)).thenReturn(true);
//when(im.getOwner(any(), any())).thenReturn(notUUID); //when(im.getOwner(any(), any())).thenReturn(notUUID);
String[] name = {"tastybento"}; String[] name = {"tastybento"};
when(pm.getUUID(any())).thenReturn(notUUID); when(pm.getUUID(any())).thenReturn(notUUID);
@ -203,6 +205,7 @@ public class AdminDeleteCommandTest {
*/ */
@Test @Test
public void testcanExecuteSuccessUUID() { public void testcanExecuteSuccessUUID() {
when(island.hasTeam()).thenReturn(false);
when(im.inTeam(any(), any())).thenReturn(false); when(im.inTeam(any(), any())).thenReturn(false);
//when(im.getOwner(any(), any())).thenReturn(uuid); //when(im.getOwner(any(), any())).thenReturn(uuid);
Island is = mock(Island.class); Island is = mock(Island.class);
@ -243,6 +246,7 @@ public class AdminDeleteCommandTest {
*/ */
@Test @Test
public void testCanExecuteSuccess() { public void testCanExecuteSuccess() {
when(island.hasTeam()).thenReturn(false);
when(im.inTeam(any(), any())).thenReturn(false); when(im.inTeam(any(), any())).thenReturn(false);
//when(im.getOwner(any(), any())).thenReturn(uuid); //when(im.getOwner(any(), any())).thenReturn(uuid);
Island is = mock(Island.class); Island is = mock(Island.class);

View File

@ -19,6 +19,7 @@ import org.bukkit.Bukkit;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.plugin.PluginManager; import org.bukkit.plugin.PluginManager;
import org.bukkit.scheduler.BukkitScheduler; import org.bukkit.scheduler.BukkitScheduler;
import org.eclipse.jdt.annotation.NonNull;
import org.junit.After; import org.junit.After;
import org.junit.Before; import org.junit.Before;
import org.junit.Test; import org.junit.Test;
@ -31,7 +32,9 @@ import org.powermock.modules.junit4.PowerMockRunner;
import org.powermock.reflect.Whitebox; import org.powermock.reflect.Whitebox;
import world.bentobox.bentobox.BentoBox; import world.bentobox.bentobox.BentoBox;
import world.bentobox.bentobox.TestWorldSettings;
import world.bentobox.bentobox.api.commands.CompositeCommand; import world.bentobox.bentobox.api.commands.CompositeCommand;
import world.bentobox.bentobox.api.configuration.WorldSettings;
import world.bentobox.bentobox.api.localization.TextVariables; 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;
@ -123,6 +126,9 @@ public class AdminTeamAddCommandTest {
// Island World Manager // Island World Manager
IslandWorldManager iwm = mock(IslandWorldManager.class); IslandWorldManager iwm = mock(IslandWorldManager.class);
when(iwm.getFriendlyName(any())).thenReturn("BSkyBlock"); when(iwm.getFriendlyName(any())).thenReturn("BSkyBlock");
@NonNull
WorldSettings ws = new TestWorldSettings();
when(iwm.getWorldSettings(any())).thenReturn(ws);
when(plugin.getIWM()).thenReturn(iwm); when(plugin.getIWM()).thenReturn(iwm);
// Addon // Addon
@ -187,7 +193,7 @@ public class AdminTeamAddCommandTest {
when(pm.getUUID(eq("poslovich"))).thenReturn(notUUID); when(pm.getUUID(eq("poslovich"))).thenReturn(notUUID);
when(im.inTeam(any(), eq(notUUID))).thenReturn(true); when(im.inTeam(any(), eq(notUUID))).thenReturn(true);
when(island.inTeam(notUUID)).thenReturn(true);
assertFalse(itl.execute(user, itl.getLabel(), Arrays.asList(name))); assertFalse(itl.execute(user, itl.getLabel(), Arrays.asList(name)));
verify(user).sendMessage(eq("commands.island.team.invite.errors.already-on-team")); verify(user).sendMessage(eq("commands.island.team.invite.errors.already-on-team"));
} }

View File

@ -205,7 +205,7 @@ public class AdminTeamDisbandCommandTest {
public void testExecutePlayerNotInTeam() { public void testExecutePlayerNotInTeam() {
when(Util.getUUID("tastybento")).thenReturn(notUUID); when(Util.getUUID("tastybento")).thenReturn(notUUID);
assertFalse(itl.canExecute(user, itl.getLabel(), List.of("tastybento"))); assertFalse(itl.canExecute(user, itl.getLabel(), List.of("tastybento")));
verify(user).sendMessage("general.errors.player-is-not-owner", "[name]", "tastybento"); verify(user).sendMessage("general.errors.player-has-no-island");
} }
/** /**

View File

@ -228,6 +228,7 @@ public class IslandBanCommandTest extends RanksManagerBeforeClassTest {
UUID teamMate = UUID.randomUUID(); UUID teamMate = UUID.randomUUID();
when(pm.getUUID(anyString())).thenReturn(teamMate); when(pm.getUUID(anyString())).thenReturn(teamMate);
when(island.getMemberSet()).thenReturn(ImmutableSet.of(uuid, teamMate)); when(island.getMemberSet()).thenReturn(ImmutableSet.of(uuid, teamMate));
when(island.inTeam(teamMate)).thenReturn(true);
assertFalse(ibc.canExecute(user, ibc.getLabel(), Collections.singletonList("bill"))); assertFalse(ibc.canExecute(user, ibc.getLabel(), Collections.singletonList("bill")));
verify(user).sendMessage("commands.island.ban.cannot-ban-member"); verify(user).sendMessage("commands.island.ban.cannot-ban-member");
} }

View File

@ -40,6 +40,7 @@ import com.google.common.collect.ImmutableSet;
import world.bentobox.bentobox.BentoBox; import world.bentobox.bentobox.BentoBox;
import world.bentobox.bentobox.Settings; import world.bentobox.bentobox.Settings;
import world.bentobox.bentobox.TestWorldSettings;
import world.bentobox.bentobox.api.addons.Addon; import world.bentobox.bentobox.api.addons.Addon;
import world.bentobox.bentobox.api.addons.GameModeAddon; import world.bentobox.bentobox.api.addons.GameModeAddon;
import world.bentobox.bentobox.api.commands.CompositeCommand; import world.bentobox.bentobox.api.commands.CompositeCommand;
@ -140,6 +141,8 @@ public class IslandExpelCommandTest extends RanksManagerBeforeClassTest {
// IWM friendly name // IWM friendly name
when(iwm.getFriendlyName(any())).thenReturn("BSkyBlock"); when(iwm.getFriendlyName(any())).thenReturn("BSkyBlock");
TestWorldSettings worldSettings = new TestWorldSettings();
when(iwm.getWorldSettings(any())).thenReturn(worldSettings);
when(plugin.getIWM()).thenReturn(iwm); when(plugin.getIWM()).thenReturn(iwm);
// Server and Plugin Manager for events // Server and Plugin Manager for events
@ -268,6 +271,7 @@ public class IslandExpelCommandTest extends RanksManagerBeforeClassTest {
UUID target = UUID.randomUUID(); UUID target = UUID.randomUUID();
when(pm.getUUID(anyString())).thenReturn(target); when(pm.getUUID(anyString())).thenReturn(target);
when(island.getMemberSet()).thenReturn(ImmutableSet.of(target)); when(island.getMemberSet()).thenReturn(ImmutableSet.of(target));
when(island.inTeam(target)).thenReturn(true);
assertFalse(iec.canExecute(user, "", Collections.singletonList("tasty"))); assertFalse(iec.canExecute(user, "", Collections.singletonList("tasty")));
verify(user).sendMessage("commands.island.expel.cannot-expel-member"); verify(user).sendMessage("commands.island.expel.cannot-expel-member");
} }

View File

@ -31,6 +31,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.TestWorldSettings;
import world.bentobox.bentobox.api.commands.island.team.Invite.Type; import world.bentobox.bentobox.api.commands.island.team.Invite.Type;
import world.bentobox.bentobox.api.events.IslandBaseEvent; import world.bentobox.bentobox.api.events.IslandBaseEvent;
import world.bentobox.bentobox.api.events.team.TeamEvent; import world.bentobox.bentobox.api.events.team.TeamEvent;
@ -142,6 +143,8 @@ public class IslandTeamInviteAcceptCommandTest {
// IWM friendly name // IWM friendly name
IslandWorldManager iwm = mock(IslandWorldManager.class); IslandWorldManager iwm = mock(IslandWorldManager.class);
when(iwm.getFriendlyName(any())).thenReturn("BSkyBlock"); when(iwm.getFriendlyName(any())).thenReturn("BSkyBlock");
TestWorldSettings worldSettings = new TestWorldSettings();
when(iwm.getWorldSettings(any())).thenReturn(worldSettings);
when(plugin.getIWM()).thenReturn(iwm); when(plugin.getIWM()).thenReturn(iwm);
// Invite // Invite

View File

@ -39,7 +39,9 @@ import com.google.common.collect.ImmutableSet;
import world.bentobox.bentobox.BentoBox; import world.bentobox.bentobox.BentoBox;
import world.bentobox.bentobox.Settings; import world.bentobox.bentobox.Settings;
import world.bentobox.bentobox.TestWorldSettings;
import world.bentobox.bentobox.api.commands.island.team.Invite.Type; import world.bentobox.bentobox.api.commands.island.team.Invite.Type;
import world.bentobox.bentobox.api.configuration.WorldSettings;
import world.bentobox.bentobox.api.events.IslandBaseEvent; import world.bentobox.bentobox.api.events.IslandBaseEvent;
import world.bentobox.bentobox.api.localization.TextVariables; import world.bentobox.bentobox.api.localization.TextVariables;
import world.bentobox.bentobox.api.user.User; import world.bentobox.bentobox.api.user.User;
@ -170,6 +172,9 @@ public class IslandTeamInviteCommandTest extends RanksManagerBeforeClassTest {
// IWM friendly name // IWM friendly name
IslandWorldManager iwm = mock(IslandWorldManager.class); IslandWorldManager iwm = mock(IslandWorldManager.class);
when(iwm.getFriendlyName(any())).thenReturn("BSkyBlock"); when(iwm.getFriendlyName(any())).thenReturn("BSkyBlock");
@NonNull
WorldSettings ws = new TestWorldSettings();
when(iwm.getWorldSettings(world)).thenReturn(ws);
when(plugin.getIWM()).thenReturn(iwm); when(plugin.getIWM()).thenReturn(iwm);
// Parent command // Parent command

View File

@ -211,7 +211,7 @@ public class IslandTeamKickCommandTest extends RanksManagerBeforeClassTest {
when(pm.getName(notUUID)).thenReturn("poslovitch"); when(pm.getName(notUUID)).thenReturn("poslovitch");
when(island.getMemberSet()).thenReturn(ImmutableSet.of(notUUID)); when(island.getMemberSet()).thenReturn(ImmutableSet.of(notUUID));
when(island.inTeam(notUUID)).thenReturn(true);
IslandTeamKickCommand itl = new IslandTeamKickCommand(ic); IslandTeamKickCommand itl = new IslandTeamKickCommand(ic);
assertFalse(itl.canExecute(user, itl.getLabel(), Collections.singletonList("poslovitch"))); assertFalse(itl.canExecute(user, itl.getLabel(), Collections.singletonList("poslovitch")));
verify(user).sendMessage(eq("commands.island.team.kick.cannot-kick-rank"), eq(TextVariables.NAME), eq("poslovitch")); verify(user).sendMessage(eq("commands.island.team.kick.cannot-kick-rank"), eq(TextVariables.NAME), eq("poslovitch"));
@ -229,7 +229,7 @@ public class IslandTeamKickCommandTest extends RanksManagerBeforeClassTest {
when(pm.getName(notUUID)).thenReturn("poslovitch"); when(pm.getName(notUUID)).thenReturn("poslovitch");
when(island.getMemberSet()).thenReturn(ImmutableSet.of(notUUID)); when(island.getMemberSet()).thenReturn(ImmutableSet.of(notUUID));
when(island.inTeam(notUUID)).thenReturn(true);
IslandTeamKickCommand itl = new IslandTeamKickCommand(ic); IslandTeamKickCommand itl = new IslandTeamKickCommand(ic);
assertFalse(itl.canExecute(user, itl.getLabel(), Collections.singletonList("poslovitch"))); assertFalse(itl.canExecute(user, itl.getLabel(), Collections.singletonList("poslovitch")));
verify(user).sendMessage(eq("commands.island.team.kick.cannot-kick-rank"), eq(TextVariables.NAME), eq("poslovitch")); verify(user).sendMessage(eq("commands.island.team.kick.cannot-kick-rank"), eq(TextVariables.NAME), eq("poslovitch"));

View File

@ -33,6 +33,7 @@ import com.google.common.collect.ImmutableSet;
import world.bentobox.bentobox.BentoBox; import world.bentobox.bentobox.BentoBox;
import world.bentobox.bentobox.Settings; import world.bentobox.bentobox.Settings;
import world.bentobox.bentobox.TestWorldSettings;
import world.bentobox.bentobox.api.localization.TextVariables; 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;
@ -119,6 +120,11 @@ public class IslandTeamPromoteCommandTest extends RanksManagerBeforeClassTest {
// In team // In team
when(im.inTeam(world, uuid)).thenReturn(true); when(im.inTeam(world, uuid)).thenReturn(true);
when(island.inTeam(uuid)).thenReturn(true);
// IWM
TestWorldSettings worldSettings = new TestWorldSettings();
when(iwm.getWorldSettings(any())).thenReturn(worldSettings);
// Ranks // Ranks
when(island.getRankCommand(anyString())).thenReturn(RanksManager.SUB_OWNER_RANK); // Allow sub owners when(island.getRankCommand(anyString())).thenReturn(RanksManager.SUB_OWNER_RANK); // Allow sub owners

View File

@ -38,6 +38,7 @@ import com.google.common.collect.ImmutableSet;
import world.bentobox.bentobox.BentoBox; import world.bentobox.bentobox.BentoBox;
import world.bentobox.bentobox.Settings; import world.bentobox.bentobox.Settings;
import world.bentobox.bentobox.TestWorldSettings;
import world.bentobox.bentobox.api.commands.CompositeCommand; import world.bentobox.bentobox.api.commands.CompositeCommand;
import world.bentobox.bentobox.api.configuration.WorldSettings; import world.bentobox.bentobox.api.configuration.WorldSettings;
import world.bentobox.bentobox.api.localization.TextVariables; import world.bentobox.bentobox.api.localization.TextVariables;
@ -119,7 +120,8 @@ public class IslandTeamSetownerCommandTest {
when(plugin.getIslands()).thenReturn(im); when(plugin.getIslands()).thenReturn(im);
// Has team // Has team
when(im.inTeam(any(), eq(uuid))).thenReturn(true); when(im.inTeam(world, uuid)).thenReturn(true);
when(island.inTeam(uuid)).thenReturn(true);
when(plugin.getPlayers()).thenReturn(pm); when(plugin.getPlayers()).thenReturn(pm);
// Server & Scheduler // Server & Scheduler
@ -128,6 +130,8 @@ public class IslandTeamSetownerCommandTest {
when(Bukkit.getScheduler()).thenReturn(sch); when(Bukkit.getScheduler()).thenReturn(sch);
// Island World Manager // Island World Manager
TestWorldSettings worldSettings = new TestWorldSettings();
when(iwm.getWorldSettings(any())).thenReturn(worldSettings);
when(plugin.getIWM()).thenReturn(iwm); when(plugin.getIWM()).thenReturn(iwm);
@NonNull @NonNull
WorldSettings ws = mock(WorldSettings.class); WorldSettings ws = mock(WorldSettings.class);
@ -194,7 +198,7 @@ public class IslandTeamSetownerCommandTest {
*/ */
@Test @Test
public void testCanExecuteUserStringListOfStringNotInTeam() { public void testCanExecuteUserStringListOfStringNotInTeam() {
when(island.getMemberSet()).thenReturn(ImmutableSet.of()); when(island.inTeam(uuid)).thenReturn(false);
assertFalse(its.canExecute(user, "", List.of("gibby"))); assertFalse(its.canExecute(user, "", List.of("gibby")));
verify(user).sendMessage("general.errors.no-team"); verify(user).sendMessage("general.errors.no-team");
} }
@ -267,6 +271,7 @@ public class IslandTeamSetownerCommandTest {
UUID target = UUID.randomUUID(); UUID target = UUID.randomUUID();
when(pm.getUUID(anyString())).thenReturn(target); when(pm.getUUID(anyString())).thenReturn(target);
when(island.getMemberSet()).thenReturn(ImmutableSet.of(uuid, target)); when(island.getMemberSet()).thenReturn(ImmutableSet.of(uuid, target));
when(island.inTeam(any())).thenReturn(true);
when(im.getIsland(any(), any(User.class))).thenReturn(island); when(im.getIsland(any(), any(User.class))).thenReturn(island);
assertTrue(its.canExecute(user, "", List.of("tastybento"))); assertTrue(its.canExecute(user, "", List.of("tastybento")));
assertTrue(its.execute(user, "", List.of("tastybento"))); assertTrue(its.execute(user, "", List.of("tastybento")));
@ -282,7 +287,7 @@ public class IslandTeamSetownerCommandTest {
when(im.inTeam(any(), any())).thenReturn(true); when(im.inTeam(any(), any())).thenReturn(true);
UUID target = UUID.randomUUID(); UUID target = UUID.randomUUID();
when(pm.getUUID(anyString())).thenReturn(target); when(pm.getUUID(anyString())).thenReturn(target);
when(island.getMemberSet()).thenReturn(ImmutableSet.of(uuid, target)); when(island.inTeam(any())).thenReturn(true);
when(im.getIsland(any(), any(User.class))).thenReturn(island); when(im.getIsland(any(), any(User.class))).thenReturn(island);
assertTrue(its.canExecute(user, "", List.of("tastybento"))); assertTrue(its.canExecute(user, "", List.of("tastybento")));
assertTrue(its.execute(user, "", List.of("tastybento"))); assertTrue(its.execute(user, "", List.of("tastybento")));

View File

@ -211,6 +211,7 @@ public class IslandTeamUncoopCommandTest extends RanksManagerBeforeClassTest {
when(pm.getUUID(any())).thenReturn(notUUID); when(pm.getUUID(any())).thenReturn(notUUID);
when(im.inTeam(any(), any())).thenReturn(true); when(im.inTeam(any(), any())).thenReturn(true);
when(island.getMemberSet()).thenReturn(ImmutableSet.of(notUUID)); when(island.getMemberSet()).thenReturn(ImmutableSet.of(notUUID));
when(island.inTeam(notUUID)).thenReturn(true);
assertFalse(itl.execute(user, itl.getLabel(), Collections.singletonList("bento"))); assertFalse(itl.execute(user, itl.getLabel(), Collections.singletonList("bento")));
verify(user).sendMessage(eq("commands.island.team.uncoop.cannot-uncoop-member")); verify(user).sendMessage(eq("commands.island.team.uncoop.cannot-uncoop-member"));
} }

View File

@ -211,6 +211,7 @@ public class IslandTeamUntrustCommandTest extends RanksManagerBeforeClassTest {
when(pm.getUUID(any())).thenReturn(notUUID); when(pm.getUUID(any())).thenReturn(notUUID);
when(im.inTeam(any(), any())).thenReturn(true); when(im.inTeam(any(), any())).thenReturn(true);
when(island.getMemberSet()).thenReturn(ImmutableSet.of(notUUID)); when(island.getMemberSet()).thenReturn(ImmutableSet.of(notUUID));
when(island.inTeam(notUUID)).thenReturn(true);
assertFalse(itl.execute(user, itl.getLabel(), Collections.singletonList("bento"))); assertFalse(itl.execute(user, itl.getLabel(), Collections.singletonList("bento")));
verify(user).sendMessage(eq("commands.island.team.untrust.cannot-untrust-member")); verify(user).sendMessage(eq("commands.island.team.untrust.cannot-untrust-member"));
} }

View File

@ -47,6 +47,8 @@ public class PetTeleportListenerTest extends AbstractCommonSetup {
@Before @Before
public void setUp() throws Exception { public void setUp() throws Exception {
super.setUp(); super.setUp();
// Island
when(this.island.inTeam(uuid)).thenReturn(true);
when(tamed.isTamed()).thenReturn(true); when(tamed.isTamed()).thenReturn(true);
when(tamed.getOwner()).thenReturn(tamer); when(tamed.getOwner()).thenReturn(tamer);
when(tamer.getUniqueId()).thenReturn(uuid); when(tamer.getUniqueId()).thenReturn(uuid);

View File

@ -830,6 +830,7 @@ public class IslandsManagerTest extends AbstractCommonSetup {
Builder<UUID> members = new ImmutableSet.Builder<>(); Builder<UUID> members = new ImmutableSet.Builder<>();
members.add(uuid); members.add(uuid);
when(is.getMemberSet()).thenReturn(members.build()); when(is.getMemberSet()).thenReturn(members.build());
when(is.inTeam(uuid)).thenReturn(true);
when(player.getUniqueId()).thenReturn(uuid); when(player.getUniqueId()).thenReturn(uuid);
@ -842,10 +843,12 @@ public class IslandsManagerTest extends AbstractCommonSetup {
// No members // No members
Builder<UUID> mem = new ImmutableSet.Builder<>(); Builder<UUID> mem = new ImmutableSet.Builder<>();
when(is.getMemberSet()).thenReturn(mem.build()); when(is.getMemberSet()).thenReturn(mem.build());
when(is.inTeam(uuid)).thenReturn(false);
assertFalse(im.locationIsOnIsland(player, location)); assertFalse(im.locationIsOnIsland(player, location));
// Not on island // Not on island
when(is.getMemberSet()).thenReturn(members.build()); when(is.getMemberSet()).thenReturn(members.build());
when(is.inTeam(uuid)).thenReturn(true);
when(is.onIsland(any())).thenReturn(false); when(is.onIsland(any())).thenReturn(false);
assertFalse(im.locationIsOnIsland(player, location)); assertFalse(im.locationIsOnIsland(player, location));
} }