From 81f765df3672e67a819d03d8559db57100880f4f Mon Sep 17 00:00:00 2001 From: tastybento Date: Sat, 30 Mar 2024 20:57:20 -0700 Subject: [PATCH] Fix invites and accepts. --- .../team/IslandTeamInviteAcceptCommand.java | 13 +++++---- .../bentobox/listeners/JoinLeaveListener.java | 4 +++ src/main/resources/locales/en-US.yml | 27 ++++++++++++------- 3 files changed, 30 insertions(+), 14 deletions(-) diff --git a/src/main/java/world/bentobox/bentobox/api/commands/island/team/IslandTeamInviteAcceptCommand.java b/src/main/java/world/bentobox/bentobox/api/commands/island/team/IslandTeamInviteAcceptCommand.java index 101412fc7..4f4d47cd2 100644 --- a/src/main/java/world/bentobox/bentobox/api/commands/island/team/IslandTeamInviteAcceptCommand.java +++ b/src/main/java/world/bentobox/bentobox/api/commands/island/team/IslandTeamInviteAcceptCommand.java @@ -165,12 +165,13 @@ public class IslandTeamInviteAcceptCommand extends ConfirmableCommand { if (getIWM().getWorldSettings(getWorld()).isDisallowTeamMemberIslands()) { // Remove the player's other islands getIslands().removePlayer(getWorld(), user.getUniqueId()); + // Remove money inventory etc. for leaving + cleanPlayer(user); } - // 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(() -> { if (getIWM().getWorldSettings(getWorld()).isDisallowTeamMemberIslands()) { // Delete the old islands @@ -184,9 +185,11 @@ public class IslandTeamInviteAcceptCommand extends ConfirmableCommand { Util.runCommands(user, ownerName, getIWM().getOnJoinCommands(getWorld()), "join"); }); - // Reset deaths - if (getIWM().isTeamJoinDeathReset(getWorld())) { - getPlayers().setDeaths(getWorld(), user.getUniqueId(), 0); + if (getIWM().getWorldSettings(getWorld()).isDisallowTeamMemberIslands()) { + // Reset deaths + if (getIWM().isTeamJoinDeathReset(getWorld())) { + getPlayers().setDeaths(getWorld(), user.getUniqueId(), 0); + } } user.sendMessage("commands.island.team.invite.accept.you-joined-island", TextVariables.LABEL, getTopLabel()); User inviter = User.getInstance(invite.getInviter()); diff --git a/src/main/java/world/bentobox/bentobox/listeners/JoinLeaveListener.java b/src/main/java/world/bentobox/bentobox/listeners/JoinLeaveListener.java index 37f5f0464..f73f3dac3 100644 --- a/src/main/java/world/bentobox/bentobox/listeners/JoinLeaveListener.java +++ b/src/main/java/world/bentobox/bentobox/listeners/JoinLeaveListener.java @@ -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()) diff --git a/src/main/resources/locales/en-US.yml b/src/main/resources/locales/en-US.yml index 9c0838c47..0b9fe73fe 100644 --- a/src/main/resources/locales/en-US.yml +++ b/src/main/resources/locales/en-US.yml @@ -678,8 +678,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: @@ -696,8 +698,10 @@ commands: description: give a player trusted rank on your island parameters: 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 .' @@ -714,10 +718,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" @@ -758,9 +766,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.'