Don't kick players when spectate-on-death: true.

This commit forgoes some of the work done in the join/leave refactoring
of commit b1c6b61827.

The intent behind the original commit was to make the join/leave process
a very strictly defined set of steps that would work atomically to try
to ensure a stable, predictable process. As a result, the idea of making
spectators out of respawning players meant first kicking them out of the
arena and then re-joining as spectators, as if they had manually typed
`/ma leave` followed by `/ma spec`.

However, on some multi-world setups, this process causes people to get
thrown around a bit, which makes for a poor user experience. This commit
changes the behavior when `spectate-on-death: true` such that the player
isn't kicked, but is instead added to the spectator player pool when
they respawn. If the flag is false, players will still get sent to the
spectator area for one tick and then immediately kicked out as if they
had manually typed `/ma leave`. This does create a little bit of jumping
around, but because there is only one world change (as there would be
anyway), it is deemed acceptable at this point in time.

Closes #508
This commit is contained in:
Andreas Troelsen
2020-08-19 22:51:27 +02:00
parent 7fc0473a72
commit 84a7a2ed8a
2 changed files with 8 additions and 4 deletions
@@ -854,8 +854,7 @@ public class ArenaImpl implements Arena
@Override
public void playerRespawn(Player p) {
deadPlayers.remove(p);
plugin.getServer().getScheduler()
.scheduleSyncDelayedTask(plugin, () -> revivePlayer(p));
revivePlayer(p);
}
@Override
@@ -863,9 +862,13 @@ public class ArenaImpl implements Arena
removePermissionAttachments(p);
removePotionEffects(p);
discardPlayer(p);
specPlayers.add(p);
if (settings.getBoolean("spectate-on-death", true)) {
playerSpec(p, null);
messenger.tell(p, Msg.SPEC_PLAYER_SPECTATE);
} else {
plugin.getServer().getScheduler()
.scheduleSyncDelayedTask(plugin, () -> discardPlayer(p));
}
}