From 31010c15766f9a4bdacbac4530c63c2dd714e3b9 Mon Sep 17 00:00:00 2001 From: Andreas Troelsen Date: Sat, 22 Aug 2020 09:42:45 +0200 Subject: [PATCH] Initiate player leave when `spectate-on-death: false`. Errata to commit 84a7a2ed8a9cf3c91ca9c638734f646fcc9aeae0. The protocol after the join/leave process rework was: - `spectate-on-death: true`: leave, then spec - `spectate-on-death: false`: leave The protocol now is: - `spectate-on-death: true`: spec - `spectate-on-death: false`: spec, then "leave" I put "leave" in quotes, because _discarding_ the player here does not invoke the part of the leave protocol that tries to ensure teleports go through according to plan. By capitalizing on the "leave" part, making it explicit that that's what we're doing in the next tick after warping the player to the spectator area, we return to the form of the original rework where we use coarser-grained state control to make things easier to reason about. A side-effect of this change is that if players somehow manage to kill themselves in the lobby, they will be refunded the entry fee. --- src/main/java/com/garbagemule/MobArena/ArenaImpl.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/garbagemule/MobArena/ArenaImpl.java b/src/main/java/com/garbagemule/MobArena/ArenaImpl.java index a9090c6..5316cc5 100644 --- a/src/main/java/com/garbagemule/MobArena/ArenaImpl.java +++ b/src/main/java/com/garbagemule/MobArena/ArenaImpl.java @@ -881,7 +881,7 @@ public class ArenaImpl implements Arena messenger.tell(p, Msg.SPEC_PLAYER_SPECTATE); } else { plugin.getServer().getScheduler() - .scheduleSyncDelayedTask(plugin, () -> discardPlayer(p)); + .scheduleSyncDelayedTask(plugin, () -> playerLeave(p)); } }