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()) {
// 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());

View File

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

View File

@ -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: <player>
@ -696,8 +698,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 .'
@ -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.'