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

View File

@ -17,6 +17,7 @@ These changes will (most likely) be included in the next version.
- Elytra and Netherite armor pieces now correctly auto-equip if specified in the generic `armor` node in classes in the config-file. - Elytra and Netherite armor pieces now correctly auto-equip if specified in the generic `armor` node in classes in the config-file.
- Boss names now support color codes. - Boss names now support color codes.
- The Root Target ability now uses potion effects (slowness, slow falling, and negative jump boost) instead of repeated teleports. This should make for a smoother root experience. - The Root Target ability now uses potion effects (slowness, slow falling, and negative jump boost) instead of repeated teleports. This should make for a smoother root experience.
- Using `spectate-on-death: true` no longer forces players out to their join location/exit warp before moving them to the spectator area. This should prevent "jumpy" behavior in multi-world setups.
- Config-files with missing `pet-items` nodes no longer errors. A missing `pet-items` node in `global-settings` is treated as empty, i.e. no pet items will be registered. - Config-files with missing `pet-items` nodes no longer errors. A missing `pet-items` node in `global-settings` is treated as empty, i.e. no pet items will be registered.
- The `player-time-in-arena` setting has been fixed. - The `player-time-in-arena` setting has been fixed.
- The `soft-restore` setting has been fixed for blocks broken by players. Note that the functionality is still unreliable for non-trivial blocks. - The `soft-restore` setting has been fixed for blocks broken by players. Note that the functionality is still unreliable for non-trivial blocks.

View File

@ -854,8 +854,7 @@ public class ArenaImpl implements Arena
@Override @Override
public void playerRespawn(Player p) { public void playerRespawn(Player p) {
deadPlayers.remove(p); deadPlayers.remove(p);
plugin.getServer().getScheduler() revivePlayer(p);
.scheduleSyncDelayedTask(plugin, () -> revivePlayer(p));
} }
@Override @Override
@ -863,9 +862,13 @@ public class ArenaImpl implements Arena
removePermissionAttachments(p); removePermissionAttachments(p);
removePotionEffects(p); removePotionEffects(p);
discardPlayer(p); specPlayers.add(p);
if (settings.getBoolean("spectate-on-death", true)) { 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));
} }
} }