Skip to content

Death and respawn

Walid Korchi edited this page May 26, 2026 · 3 revisions

Summary

Condition Outcome
Bed intact Respawn at bed with protection
Bed destroyed Become permanent spectator
Fall below islandY − void-threshold (default 20) Teleport to bed/spawn, no damage

Respawn protection (default 6 seconds):

  • Slowness IX applied (prevents movement)
  • Jump strength set to 0
  • Player hidden from all enemies (bidirectional)
  • Incoming damage fully cancelled
  • Action bar shows countdown: §aProtection: Xs
  • Disabled by setting respawn-protection: 0

Spectator

A player in a GameRoom who is not part of any team. Two distinct origins, same treatment:

  • Eliminated — bed was destroyed; became spectator automatically mid-game
  • Observer — joined a RUNNING room from the room listing

Both are in SPECTATOR gamemode, hidden from team players, given a compass (slot 0) to return to the main lobby, and teleported back to the main lobby when the game ends.

Spectator compass (slot 0): right-clicking returns the player to the main lobby and clears their inventory.

Disconnect & Reconnect

When a player disconnects from a RUNNING GameRoom, a ReconnectData snapshot is saved in GameManager keyed by UUID. On reconnect, the snapshot is consumed and one of four outcomes applies:

Condition on reconnect Outcome
No snapshot, or room no longer exists, or room not RUNNING Hub lobby state applied immediately
Snapshot present, wasSpectator = true Re-added as observer (addObserver)
Snapshot present, team found, bed intact Respawned at bed — SURVIVAL mode, full health/food, equipped, addProtection()
Snapshot present, team found, bed destroyed Eliminated spectator (addSpectator)
Snapshot present, team color not found in room Observer fallback

Implementation:

  • GameManager.ReconnectData record: (roomId, teamColorName, wasSpectator) — team identified by color name string, not object reference, to survive disconnect/reconnect Player object churn
  • GameManager.recordDisconnect(UUID, ReconnectData) — called from onPlayerQuit before the player is removed from the room
  • GameManager.consumeReconnectData(UUID) — called from onPlayerJoin; removes and returns the snapshot (one-shot)
  • GameManager.handleReconnect(Player, GameRoom, ReconnectData) — scheduled 1 tick after join to ensure full player initialization; applies the appropriate outcome above
  • applyHubLobbyState(Player) in PlayerActivity — SURVIVAL mode, MAX_HEALTH, food level 20, saturation 20f, restoreHubInventory(), teleport to lobby-spawn config location

Clone this wiki locally