mirror of
https://github.com/BentoBoxWorld/BentoBox.git
synced 2025-02-10 17:31:32 +01:00
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:
commit
6106b661e9
@ -524,6 +524,7 @@ public abstract class CompositeCommand extends Command implements PluginIdentifi
|
||||
* @param world - the world to check
|
||||
* @param user - the User
|
||||
* @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) {
|
||||
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
|
||||
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");
|
||||
return false;
|
||||
}
|
||||
|
@ -44,17 +44,17 @@ public class AdminTeamAddCommand extends CompositeCommand {
|
||||
user.sendMessage("general.errors.unknown-player", TextVariables.NAME, args.get(1));
|
||||
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");
|
||||
return false;
|
||||
}
|
||||
Island island = getIslands().getPrimaryIsland(getWorld(), ownerUUID);
|
||||
if (getIslands().inTeam(getWorld(), ownerUUID) && island != null && !ownerUUID.equals(island.getOwner())) {
|
||||
if (getIslands().inTeam(getWorld(), ownerUUID) && !ownerUUID.equals(island.getOwner())) {
|
||||
user.sendMessage("commands.admin.team.add.name-not-owner", TextVariables.NAME, args.get(0));
|
||||
new IslandInfo(island).showMembers(user);
|
||||
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");
|
||||
return false;
|
||||
}
|
||||
|
@ -52,10 +52,7 @@ public class AdminTeamDisbandCommand extends CompositeCommand {
|
||||
user.sendMessage("general.errors.unknown-player", TextVariables.NAME, args.get(0));
|
||||
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
|
||||
Map<String, Island> islands = getIslandsXYZ(targetUUID);
|
||||
if (islands.isEmpty()) {
|
||||
@ -77,6 +74,11 @@ public class AdminTeamDisbandCommand extends CompositeCommand {
|
||||
// Get the only island
|
||||
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;
|
||||
}
|
||||
|
||||
|
@ -70,7 +70,7 @@ public class IslandBanCommand extends CompositeCommand {
|
||||
user.sendMessage("commands.island.ban.cannot-ban-yourself");
|
||||
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");
|
||||
return false;
|
||||
}
|
||||
|
@ -51,7 +51,8 @@ public class IslandCreateCommand extends CompositeCommand {
|
||||
}
|
||||
}
|
||||
// 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())) {
|
||||
// Team members who are not owners cannot make additional islands
|
||||
user.sendMessage("commands.island.create.you-cannot-make-team");
|
||||
|
@ -76,7 +76,7 @@ public class IslandExpelCommand extends CompositeCommand {
|
||||
return false;
|
||||
}
|
||||
// Or team member
|
||||
if (island.getMemberSet().contains(targetUUID)) {
|
||||
if (island.inTeam(targetUUID)) {
|
||||
user.sendMessage("commands.island.expel.cannot-expel-member");
|
||||
return false;
|
||||
}
|
||||
|
@ -61,7 +61,8 @@ public class IslandTeamInviteAcceptCommand extends ConfirmableCommand {
|
||||
}
|
||||
|
||||
// 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");
|
||||
return false;
|
||||
}
|
||||
@ -81,8 +82,14 @@ public class IslandTeamInviteAcceptCommand extends ConfirmableCommand {
|
||||
switch (invite.getType()) {
|
||||
case COOP -> askConfirmation(user, () -> acceptCoopInvite(user, invite));
|
||||
case TRUST -> askConfirmation(user, () -> acceptTrustInvite(user, invite));
|
||||
default -> askConfirmation(user, user.getTranslation("commands.island.team.invite.accept.confirmation"),
|
||||
() -> acceptTeamInvite(user, invite));
|
||||
default -> {
|
||||
if (getIWM().getWorldSettings(getWorld()).isDisallowTeamMemberIslands()) {
|
||||
askConfirmation(user, user.getTranslation("commands.island.team.invite.accept.confirmation"),
|
||||
() -> acceptTeamInvite(user, invite));
|
||||
} else {
|
||||
acceptTeamInvite(user, invite);
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
@ -155,17 +162,21 @@ public class IslandTeamInviteAcceptCommand extends ConfirmableCommand {
|
||||
user.sendMessage("commands.island.team.invite.errors.island-is-full");
|
||||
return;
|
||||
}
|
||||
// Remove the player's other islands
|
||||
getIslands().removePlayer(getWorld(), user.getUniqueId());
|
||||
// Remove money inventory etc. for leaving
|
||||
cleanPlayer(user);
|
||||
if (getIWM().getWorldSettings(getWorld()).isDisallowTeamMemberIslands()) {
|
||||
// Remove the player's other islands
|
||||
getIslands().removePlayer(getWorld(), user.getUniqueId());
|
||||
// Remove money inventory etc. for leaving
|
||||
cleanPlayer(user);
|
||||
}
|
||||
// Add the player as a team member of the new island
|
||||
getIslands().setJoinTeam(teamIsland, user.getUniqueId());
|
||||
// Move player to team's island
|
||||
getIslands().setPrimaryIsland(user.getUniqueId(), teamIsland);
|
||||
getIslands().homeTeleportAsync(getWorld(), user.getPlayer()).thenRun(() -> {
|
||||
// Delete the old islands
|
||||
islands.forEach(island -> getIslands().deleteIsland(island, true, user.getUniqueId()));
|
||||
|
||||
if (getIWM().getWorldSettings(getWorld()).isDisallowTeamMemberIslands()) {
|
||||
// Delete the old islands
|
||||
islands.forEach(island -> getIslands().deleteIsland(island, true, user.getUniqueId()));
|
||||
}
|
||||
// Put player back into normal mode
|
||||
user.setGameMode(getIWM().getDefaultGameMode(getWorld()));
|
||||
|
||||
@ -174,8 +185,9 @@ public class IslandTeamInviteAcceptCommand extends ConfirmableCommand {
|
||||
Util.runCommands(user, ownerName, getIWM().getOnJoinCommands(getWorld()), "join");
|
||||
|
||||
});
|
||||
// Reset deaths
|
||||
if (getIWM().isTeamJoinDeathReset(getWorld())) {
|
||||
if (getIWM().getWorldSettings(getWorld()).isDisallowTeamMemberIslands()
|
||||
&& getIWM().isTeamJoinDeathReset(getWorld())) {
|
||||
// Reset deaths
|
||||
getPlayers().setDeaths(getWorld(), user.getUniqueId(), 0);
|
||||
}
|
||||
user.sendMessage("commands.island.team.invite.accept.you-joined-island", TextVariables.LABEL, getTopLabel());
|
||||
|
@ -105,7 +105,8 @@ public class IslandTeamInviteCommand extends CompositeCommand {
|
||||
}
|
||||
|
||||
// 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");
|
||||
return false;
|
||||
}
|
||||
@ -170,7 +171,8 @@ public class IslandTeamInviteCommand extends CompositeCommand {
|
||||
// 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.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");
|
||||
}
|
||||
return true;
|
||||
|
@ -63,7 +63,7 @@ public class IslandTeamKickCommand extends ConfirmableCommand {
|
||||
user.sendMessage("commands.island.team.kick.cannot-kick");
|
||||
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");
|
||||
return false;
|
||||
}
|
||||
|
@ -69,7 +69,7 @@ public class IslandTeamPromoteCommand extends CompositeCommand {
|
||||
return false;
|
||||
}
|
||||
// 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");
|
||||
return false;
|
||||
}
|
||||
|
@ -42,7 +42,7 @@ public class IslandTeamSetownerCommand extends CompositeCommand {
|
||||
}
|
||||
// Can use if in a team
|
||||
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");
|
||||
return false;
|
||||
}
|
||||
@ -60,7 +60,7 @@ public class IslandTeamSetownerCommand extends CompositeCommand {
|
||||
user.sendMessage("commands.island.team.setowner.errors.cant-transfer-to-yourself");
|
||||
return false;
|
||||
}
|
||||
if (!is.getMemberSet().contains(targetUUID)) {
|
||||
if (!is.inTeam(targetUUID)) {
|
||||
user.sendMessage("commands.island.team.setowner.errors.target-is-not-member");
|
||||
return false;
|
||||
}
|
||||
|
@ -74,7 +74,7 @@ public class IslandTeamUncoopCommand extends CompositeCommand {
|
||||
user.sendMessage("commands.island.team.uncoop.cannot-uncoop-yourself");
|
||||
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");
|
||||
return false;
|
||||
}
|
||||
|
@ -74,7 +74,7 @@ public class IslandTeamUntrustCommand extends CompositeCommand {
|
||||
user.sendMessage("commands.island.team.untrust.cannot-untrust-yourself");
|
||||
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");
|
||||
return false;
|
||||
}
|
||||
|
@ -644,4 +644,12 @@ public interface WorldSettings extends ConfigObject {
|
||||
default int getConcurrentIslands() {
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
@ -1950,6 +1950,25 @@ public class Island implements DataObject, MetaDataAble {
|
||||
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)
|
||||
*
|
||||
|
@ -79,6 +79,10 @@ public class JoinLeaveListener implements Listener {
|
||||
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
|
||||
// island.
|
||||
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 -> {
|
||||
// Are there any online players still for this island?
|
||||
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
|
||||
// Tell players they are being removed
|
||||
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
|
||||
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
|
||||
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);
|
||||
} else {
|
||||
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
|
||||
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
|
||||
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);
|
||||
} else {
|
||||
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
|
||||
e.setCancelled(getIslands().getProtectedIslandAt(e.getTo())
|
||||
// Not home island
|
||||
.map(i -> !i.getMemberSet().contains(t.getOwner().getUniqueId()))
|
||||
.map(i -> !i.inTeam(t.getOwner().getUniqueId()))
|
||||
// Not any island
|
||||
.orElse(true));
|
||||
}
|
||||
|
@ -49,7 +49,7 @@ public class VisitorsStartingRaidListener extends FlagListener
|
||||
|
||||
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);
|
||||
this.report(User.getInstance(event.getPlayer()),
|
||||
|
@ -1319,7 +1319,7 @@ public class IslandsManager {
|
||||
return false;
|
||||
}
|
||||
// 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);
|
||||
}
|
||||
|
||||
@ -1389,7 +1389,7 @@ public class IslandsManager {
|
||||
.filter(p -> p.getGameMode().equals(plugin.getIWM().getDefaultGameMode(island.getWorld())))
|
||||
.filter(p -> island.onIsland(p.getLocation())).forEach(p -> {
|
||||
// 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()))) {
|
||||
homeTeleportAsync(w, p);
|
||||
} 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.
|
||||
*
|
||||
* @param world - world
|
||||
* @param playerUUID - player's UUID
|
||||
* @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) {
|
||||
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));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -685,8 +685,10 @@ commands:
|
||||
already-has-rank: '&c Player already has a rank!'
|
||||
you-are-a-coop-member: '&2 You were cooped by &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
|
||||
of their island.'
|
||||
name-has-invited-you: |
|
||||
&a [name] has invited you
|
||||
&a to join as a coop member
|
||||
&a of their island.
|
||||
uncoop:
|
||||
description: remove a coop rank from player
|
||||
parameters: <player>
|
||||
@ -703,8 +705,10 @@ commands:
|
||||
description: give a player trusted rank on your island
|
||||
parameters: <player>
|
||||
trust-in-yourself: '&c Trust in yourself!'
|
||||
name-has-invited-you: '&a [name] has invited you to join as a trusted member
|
||||
of their island.'
|
||||
name-has-invited-you: |
|
||||
&a [name] has invited you
|
||||
&a to join as a trusted member
|
||||
&a of their island.
|
||||
player-already-trusted: '&c Player is already trusted!'
|
||||
you-are-trusted: '&2 You are trusted by &b [name]&a !'
|
||||
success: '&a You trusted &b [name]&a .'
|
||||
@ -721,10 +725,14 @@ commands:
|
||||
description: invite a player to join your island
|
||||
invitation-sent: '&a Invitation sent to &b[name]&a.'
|
||||
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
|
||||
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:
|
||||
titles:
|
||||
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
|
||||
the other members.'
|
||||
name-joined-your-island: '&a [name] joined your island!'
|
||||
confirmation: |-
|
||||
&c Are you sure you want to accept this invite?
|
||||
&c&l You will &n LOSE ALL &r&c&l your islands!
|
||||
confirmation: |
|
||||
&c Are you sure you
|
||||
&c want to accept this
|
||||
&c invite?
|
||||
reject:
|
||||
description: reject an invitation
|
||||
you-rejected-invite: '&a You rejected the invitation to join an island.'
|
||||
|
@ -121,6 +121,7 @@ public class AdminDeleteCommandTest {
|
||||
|
||||
// Island
|
||||
when(island.getOwner()).thenReturn(uuid);
|
||||
when(island.hasTeam()).thenReturn(true);
|
||||
|
||||
// Has team
|
||||
when(im.inTeam(any(), eq(uuid))).thenReturn(true);
|
||||
@ -190,6 +191,7 @@ public class AdminDeleteCommandTest {
|
||||
public void testExecuteOwner() {
|
||||
|
||||
when(im.inTeam(any(),any())).thenReturn(true);
|
||||
when(island.inTeam(notUUID)).thenReturn(true);
|
||||
//when(im.getOwner(any(), any())).thenReturn(notUUID);
|
||||
String[] name = {"tastybento"};
|
||||
when(pm.getUUID(any())).thenReturn(notUUID);
|
||||
@ -203,6 +205,7 @@ public class AdminDeleteCommandTest {
|
||||
*/
|
||||
@Test
|
||||
public void testcanExecuteSuccessUUID() {
|
||||
when(island.hasTeam()).thenReturn(false);
|
||||
when(im.inTeam(any(), any())).thenReturn(false);
|
||||
//when(im.getOwner(any(), any())).thenReturn(uuid);
|
||||
Island is = mock(Island.class);
|
||||
@ -243,6 +246,7 @@ public class AdminDeleteCommandTest {
|
||||
*/
|
||||
@Test
|
||||
public void testCanExecuteSuccess() {
|
||||
when(island.hasTeam()).thenReturn(false);
|
||||
when(im.inTeam(any(), any())).thenReturn(false);
|
||||
//when(im.getOwner(any(), any())).thenReturn(uuid);
|
||||
Island is = mock(Island.class);
|
||||
|
@ -19,6 +19,7 @@ import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.plugin.PluginManager;
|
||||
import org.bukkit.scheduler.BukkitScheduler;
|
||||
import org.eclipse.jdt.annotation.NonNull;
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
@ -31,7 +32,9 @@ import org.powermock.modules.junit4.PowerMockRunner;
|
||||
import org.powermock.reflect.Whitebox;
|
||||
|
||||
import world.bentobox.bentobox.BentoBox;
|
||||
import world.bentobox.bentobox.TestWorldSettings;
|
||||
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.user.User;
|
||||
import world.bentobox.bentobox.database.objects.Island;
|
||||
@ -123,6 +126,9 @@ public class AdminTeamAddCommandTest {
|
||||
// Island World Manager
|
||||
IslandWorldManager iwm = mock(IslandWorldManager.class);
|
||||
when(iwm.getFriendlyName(any())).thenReturn("BSkyBlock");
|
||||
@NonNull
|
||||
WorldSettings ws = new TestWorldSettings();
|
||||
when(iwm.getWorldSettings(any())).thenReturn(ws);
|
||||
when(plugin.getIWM()).thenReturn(iwm);
|
||||
|
||||
// Addon
|
||||
@ -187,7 +193,7 @@ public class AdminTeamAddCommandTest {
|
||||
when(pm.getUUID(eq("poslovich"))).thenReturn(notUUID);
|
||||
|
||||
when(im.inTeam(any(), eq(notUUID))).thenReturn(true);
|
||||
|
||||
when(island.inTeam(notUUID)).thenReturn(true);
|
||||
assertFalse(itl.execute(user, itl.getLabel(), Arrays.asList(name)));
|
||||
verify(user).sendMessage(eq("commands.island.team.invite.errors.already-on-team"));
|
||||
}
|
||||
|
@ -205,7 +205,7 @@ public class AdminTeamDisbandCommandTest {
|
||||
public void testExecutePlayerNotInTeam() {
|
||||
when(Util.getUUID("tastybento")).thenReturn(notUUID);
|
||||
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();
|
||||
when(pm.getUUID(anyString())).thenReturn(teamMate);
|
||||
when(island.getMemberSet()).thenReturn(ImmutableSet.of(uuid, teamMate));
|
||||
when(island.inTeam(teamMate)).thenReturn(true);
|
||||
assertFalse(ibc.canExecute(user, ibc.getLabel(), Collections.singletonList("bill")));
|
||||
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.Settings;
|
||||
import world.bentobox.bentobox.TestWorldSettings;
|
||||
import world.bentobox.bentobox.api.addons.Addon;
|
||||
import world.bentobox.bentobox.api.addons.GameModeAddon;
|
||||
import world.bentobox.bentobox.api.commands.CompositeCommand;
|
||||
@ -140,6 +141,8 @@ public class IslandExpelCommandTest extends RanksManagerBeforeClassTest {
|
||||
|
||||
// IWM friendly name
|
||||
when(iwm.getFriendlyName(any())).thenReturn("BSkyBlock");
|
||||
TestWorldSettings worldSettings = new TestWorldSettings();
|
||||
when(iwm.getWorldSettings(any())).thenReturn(worldSettings);
|
||||
when(plugin.getIWM()).thenReturn(iwm);
|
||||
|
||||
// Server and Plugin Manager for events
|
||||
@ -268,6 +271,7 @@ public class IslandExpelCommandTest extends RanksManagerBeforeClassTest {
|
||||
UUID target = UUID.randomUUID();
|
||||
when(pm.getUUID(anyString())).thenReturn(target);
|
||||
when(island.getMemberSet()).thenReturn(ImmutableSet.of(target));
|
||||
when(island.inTeam(target)).thenReturn(true);
|
||||
assertFalse(iec.canExecute(user, "", Collections.singletonList("tasty")));
|
||||
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.Settings;
|
||||
import world.bentobox.bentobox.TestWorldSettings;
|
||||
import world.bentobox.bentobox.api.commands.island.team.Invite.Type;
|
||||
import world.bentobox.bentobox.api.events.IslandBaseEvent;
|
||||
import world.bentobox.bentobox.api.events.team.TeamEvent;
|
||||
@ -142,6 +143,8 @@ public class IslandTeamInviteAcceptCommandTest {
|
||||
// IWM friendly name
|
||||
IslandWorldManager iwm = mock(IslandWorldManager.class);
|
||||
when(iwm.getFriendlyName(any())).thenReturn("BSkyBlock");
|
||||
TestWorldSettings worldSettings = new TestWorldSettings();
|
||||
when(iwm.getWorldSettings(any())).thenReturn(worldSettings);
|
||||
when(plugin.getIWM()).thenReturn(iwm);
|
||||
|
||||
// Invite
|
||||
|
@ -39,7 +39,9 @@ import com.google.common.collect.ImmutableSet;
|
||||
|
||||
import world.bentobox.bentobox.BentoBox;
|
||||
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.configuration.WorldSettings;
|
||||
import world.bentobox.bentobox.api.events.IslandBaseEvent;
|
||||
import world.bentobox.bentobox.api.localization.TextVariables;
|
||||
import world.bentobox.bentobox.api.user.User;
|
||||
@ -170,6 +172,9 @@ public class IslandTeamInviteCommandTest extends RanksManagerBeforeClassTest {
|
||||
// IWM friendly name
|
||||
IslandWorldManager iwm = mock(IslandWorldManager.class);
|
||||
when(iwm.getFriendlyName(any())).thenReturn("BSkyBlock");
|
||||
@NonNull
|
||||
WorldSettings ws = new TestWorldSettings();
|
||||
when(iwm.getWorldSettings(world)).thenReturn(ws);
|
||||
when(plugin.getIWM()).thenReturn(iwm);
|
||||
|
||||
// Parent command
|
||||
|
@ -211,7 +211,7 @@ public class IslandTeamKickCommandTest extends RanksManagerBeforeClassTest {
|
||||
when(pm.getName(notUUID)).thenReturn("poslovitch");
|
||||
|
||||
when(island.getMemberSet()).thenReturn(ImmutableSet.of(notUUID));
|
||||
|
||||
when(island.inTeam(notUUID)).thenReturn(true);
|
||||
IslandTeamKickCommand itl = new IslandTeamKickCommand(ic);
|
||||
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"));
|
||||
@ -229,7 +229,7 @@ public class IslandTeamKickCommandTest extends RanksManagerBeforeClassTest {
|
||||
when(pm.getName(notUUID)).thenReturn("poslovitch");
|
||||
|
||||
when(island.getMemberSet()).thenReturn(ImmutableSet.of(notUUID));
|
||||
|
||||
when(island.inTeam(notUUID)).thenReturn(true);
|
||||
IslandTeamKickCommand itl = new IslandTeamKickCommand(ic);
|
||||
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"));
|
||||
|
@ -33,6 +33,7 @@ import com.google.common.collect.ImmutableSet;
|
||||
|
||||
import world.bentobox.bentobox.BentoBox;
|
||||
import world.bentobox.bentobox.Settings;
|
||||
import world.bentobox.bentobox.TestWorldSettings;
|
||||
import world.bentobox.bentobox.api.localization.TextVariables;
|
||||
import world.bentobox.bentobox.api.user.User;
|
||||
import world.bentobox.bentobox.database.objects.Island;
|
||||
@ -119,6 +120,11 @@ public class IslandTeamPromoteCommandTest extends RanksManagerBeforeClassTest {
|
||||
|
||||
// In team
|
||||
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
|
||||
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.Settings;
|
||||
import world.bentobox.bentobox.TestWorldSettings;
|
||||
import world.bentobox.bentobox.api.commands.CompositeCommand;
|
||||
import world.bentobox.bentobox.api.configuration.WorldSettings;
|
||||
import world.bentobox.bentobox.api.localization.TextVariables;
|
||||
@ -119,7 +120,8 @@ public class IslandTeamSetownerCommandTest {
|
||||
when(plugin.getIslands()).thenReturn(im);
|
||||
|
||||
// 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);
|
||||
|
||||
// Server & Scheduler
|
||||
@ -128,6 +130,8 @@ public class IslandTeamSetownerCommandTest {
|
||||
when(Bukkit.getScheduler()).thenReturn(sch);
|
||||
|
||||
// Island World Manager
|
||||
TestWorldSettings worldSettings = new TestWorldSettings();
|
||||
when(iwm.getWorldSettings(any())).thenReturn(worldSettings);
|
||||
when(plugin.getIWM()).thenReturn(iwm);
|
||||
@NonNull
|
||||
WorldSettings ws = mock(WorldSettings.class);
|
||||
@ -194,7 +198,7 @@ public class IslandTeamSetownerCommandTest {
|
||||
*/
|
||||
@Test
|
||||
public void testCanExecuteUserStringListOfStringNotInTeam() {
|
||||
when(island.getMemberSet()).thenReturn(ImmutableSet.of());
|
||||
when(island.inTeam(uuid)).thenReturn(false);
|
||||
assertFalse(its.canExecute(user, "", List.of("gibby")));
|
||||
verify(user).sendMessage("general.errors.no-team");
|
||||
}
|
||||
@ -267,6 +271,7 @@ public class IslandTeamSetownerCommandTest {
|
||||
UUID target = UUID.randomUUID();
|
||||
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);
|
||||
assertTrue(its.canExecute(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);
|
||||
UUID target = UUID.randomUUID();
|
||||
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);
|
||||
assertTrue(its.canExecute(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(im.inTeam(any(), any())).thenReturn(true);
|
||||
when(island.getMemberSet()).thenReturn(ImmutableSet.of(notUUID));
|
||||
when(island.inTeam(notUUID)).thenReturn(true);
|
||||
assertFalse(itl.execute(user, itl.getLabel(), Collections.singletonList("bento")));
|
||||
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(im.inTeam(any(), any())).thenReturn(true);
|
||||
when(island.getMemberSet()).thenReturn(ImmutableSet.of(notUUID));
|
||||
when(island.inTeam(notUUID)).thenReturn(true);
|
||||
assertFalse(itl.execute(user, itl.getLabel(), Collections.singletonList("bento")));
|
||||
verify(user).sendMessage(eq("commands.island.team.untrust.cannot-untrust-member"));
|
||||
}
|
||||
|
@ -47,6 +47,8 @@ public class PetTeleportListenerTest extends AbstractCommonSetup {
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
super.setUp();
|
||||
// Island
|
||||
when(this.island.inTeam(uuid)).thenReturn(true);
|
||||
when(tamed.isTamed()).thenReturn(true);
|
||||
when(tamed.getOwner()).thenReturn(tamer);
|
||||
when(tamer.getUniqueId()).thenReturn(uuid);
|
||||
|
@ -830,6 +830,7 @@ public class IslandsManagerTest extends AbstractCommonSetup {
|
||||
Builder<UUID> members = new ImmutableSet.Builder<>();
|
||||
members.add(uuid);
|
||||
when(is.getMemberSet()).thenReturn(members.build());
|
||||
when(is.inTeam(uuid)).thenReturn(true);
|
||||
|
||||
when(player.getUniqueId()).thenReturn(uuid);
|
||||
|
||||
@ -842,10 +843,12 @@ public class IslandsManagerTest extends AbstractCommonSetup {
|
||||
// No members
|
||||
Builder<UUID> mem = new ImmutableSet.Builder<>();
|
||||
when(is.getMemberSet()).thenReturn(mem.build());
|
||||
when(is.inTeam(uuid)).thenReturn(false);
|
||||
assertFalse(im.locationIsOnIsland(player, location));
|
||||
|
||||
// Not on island
|
||||
when(is.getMemberSet()).thenReturn(members.build());
|
||||
when(is.inTeam(uuid)).thenReturn(true);
|
||||
when(is.onIsland(any())).thenReturn(false);
|
||||
assertFalse(im.locationIsOnIsland(player, location));
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user