Fix invites and accepts.

This commit is contained in:
tastybento 2024-03-30 20:57:20 -07:00
parent 0e6a25d74b
commit 81f765df36
3 changed files with 30 additions and 14 deletions

View File

@ -165,12 +165,13 @@ public class IslandTeamInviteAcceptCommand extends ConfirmableCommand {
if (getIWM().getWorldSettings(getWorld()).isDisallowTeamMemberIslands()) { if (getIWM().getWorldSettings(getWorld()).isDisallowTeamMemberIslands()) {
// Remove the player's other islands // Remove the player's other islands
getIslands().removePlayer(getWorld(), user.getUniqueId()); 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().setPrimaryIsland(user.getUniqueId(), teamIsland);
getIslands().homeTeleportAsync(getWorld(), user.getPlayer()).thenRun(() -> { getIslands().homeTeleportAsync(getWorld(), user.getPlayer()).thenRun(() -> {
if (getIWM().getWorldSettings(getWorld()).isDisallowTeamMemberIslands()) { if (getIWM().getWorldSettings(getWorld()).isDisallowTeamMemberIslands()) {
// Delete the old islands // Delete the old islands
@ -184,10 +185,12 @@ public class IslandTeamInviteAcceptCommand extends ConfirmableCommand {
Util.runCommands(user, ownerName, getIWM().getOnJoinCommands(getWorld()), "join"); Util.runCommands(user, ownerName, getIWM().getOnJoinCommands(getWorld()), "join");
}); });
if (getIWM().getWorldSettings(getWorld()).isDisallowTeamMemberIslands()) {
// Reset deaths // Reset deaths
if (getIWM().isTeamJoinDeathReset(getWorld())) { if (getIWM().isTeamJoinDeathReset(getWorld())) {
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());
User inviter = User.getInstance(invite.getInviter()); User inviter = User.getInstance(invite.getInviter());
if (inviter.isOnline()) { if (inviter.isOnline()) {

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())

View File

@ -678,8 +678,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>
@ -696,8 +698,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 .'
@ -714,10 +718,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"
@ -758,9 +766,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.'