From 84a7a2ed8a9cf3c91ca9c638734f646fcc9aeae0 Mon Sep 17 00:00:00 2001 From: Andreas Troelsen Date: Wed, 19 Aug 2020 22:51:27 +0200 Subject: [PATCH] Don't kick players when `spectate-on-death: true`. This commit forgoes some of the work done in the join/leave refactoring of commit b1c6b618279fd181799aeafdb041ad2d1775a585. 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 --- changelog.md | 1 + src/main/java/com/garbagemule/MobArena/ArenaImpl.java | 11 +++++++---- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/changelog.md b/changelog.md index 45f9ccb..6eb5b62 100644 --- a/changelog.md +++ b/changelog.md @@ -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. - 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. +- 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. - 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. diff --git a/src/main/java/com/garbagemule/MobArena/ArenaImpl.java b/src/main/java/com/garbagemule/MobArena/ArenaImpl.java index 066fcd2..8902c8f 100644 --- a/src/main/java/com/garbagemule/MobArena/ArenaImpl.java +++ b/src/main/java/com/garbagemule/MobArena/ArenaImpl.java @@ -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)); } }