mirror of
https://github.com/BentoBoxWorld/BentoBox.git
synced 2024-11-10 12:59:45 +01:00
Remove restrictions on having multiple islands for team members.
Added API to enable checking for teams on islands easier.
This commit is contained in:
parent
1bce4ec1b9
commit
2b19d43c85
2
pom.xml
2
pom.xml
@ -88,7 +88,7 @@
|
|||||||
<!-- Do not change unless you want different name for local builds. -->
|
<!-- Do not change unless you want different name for local builds. -->
|
||||||
<build.number>-LOCAL</build.number>
|
<build.number>-LOCAL</build.number>
|
||||||
<!-- This allows to change between versions. -->
|
<!-- This allows to change between versions. -->
|
||||||
<build.version>2.2.1</build.version>
|
<build.version>2.3.0</build.version>
|
||||||
<sonar.organization>bentobox-world</sonar.organization>
|
<sonar.organization>bentobox-world</sonar.organization>
|
||||||
<sonar.host.url>https://sonarcloud.io</sonar.host.url>
|
<sonar.host.url>https://sonarcloud.io</sonar.host.url>
|
||||||
<server.jars>${project.basedir}/lib</server.jars>
|
<server.jars>${project.basedir}/lib</server.jars>
|
||||||
|
@ -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());
|
||||||
|
@ -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;
|
||||||
}
|
}
|
||||||
|
@ -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) && island != null && !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()).isTeamMembersDropIsland() && 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;
|
||||||
}
|
}
|
||||||
|
@ -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().equals(targetUUID)) {
|
||||||
|
user.sendMessage("general.errors.player-is-not-owner", TextVariables.NAME, args.get(0));
|
||||||
|
return false;
|
||||||
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -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;
|
||||||
}
|
}
|
||||||
|
@ -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()).isTeamMembersDropIsland()
|
||||||
|
&& 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");
|
||||||
|
@ -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;
|
||||||
}
|
}
|
||||||
|
@ -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()).isTeamMembersDropIsland()
|
||||||
|
&& 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;
|
||||||
}
|
}
|
||||||
@ -155,17 +156,20 @@ 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()).isTeamMembersDropIsland()) {
|
||||||
getIslands().removePlayer(getWorld(), user.getUniqueId());
|
// Remove the player's other islands
|
||||||
|
getIslands().removePlayer(getWorld(), user.getUniqueId());
|
||||||
|
}
|
||||||
// Remove money inventory etc. for leaving
|
// Remove money inventory etc. for leaving
|
||||||
cleanPlayer(user);
|
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().homeTeleportAsync(getWorld(), user.getPlayer()).thenRun(() -> {
|
getIslands().homeTeleportAsync(getWorld(), user.getPlayer()).thenRun(() -> {
|
||||||
// Delete the old islands
|
if (getIWM().getWorldSettings(getWorld()).isTeamMembersDropIsland()) {
|
||||||
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()));
|
||||||
|
|
||||||
|
@ -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()).isTeamMembersDropIsland()
|
||||||
|
&& 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()).isTeamMembersDropIsland()
|
||||||
|
&& 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;
|
||||||
|
@ -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;
|
||||||
}
|
}
|
||||||
|
@ -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;
|
||||||
}
|
}
|
||||||
|
@ -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;
|
||||||
}
|
}
|
||||||
|
@ -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;
|
||||||
}
|
}
|
||||||
|
@ -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;
|
||||||
}
|
}
|
||||||
|
@ -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 isTeamMembersDropIsland() {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -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)
|
||||||
*
|
*
|
||||||
|
@ -219,7 +219,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)
|
||||||
|
@ -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);
|
||||||
|
@ -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));
|
||||||
}
|
}
|
||||||
|
@ -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()),
|
||||||
|
@ -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));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -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);
|
||||||
|
@ -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"));
|
||||||
}
|
}
|
||||||
|
@ -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");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -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");
|
||||||
}
|
}
|
||||||
|
@ -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");
|
||||||
}
|
}
|
||||||
|
@ -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
|
||||||
|
@ -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
|
||||||
|
@ -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"));
|
||||||
|
@ -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
|
||||||
|
@ -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")));
|
||||||
|
@ -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"));
|
||||||
}
|
}
|
||||||
|
@ -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"));
|
||||||
}
|
}
|
||||||
|
@ -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);
|
||||||
|
@ -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));
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user