Class PlayerRespawnListener

java.lang.Object
com.ranull.graves.listener.PlayerRespawnListener
All Implemented Interfaces:
org.bukkit.event.Listener

public class PlayerRespawnListener extends Object implements org.bukkit.event.Listener
Handles player respawns and performs grave-related actions:
  • Runs a configured function shortly after respawn.
  • Optionally grants temporary potion effects if the grave is recent.
  • Optionally gives a compass pointing to the grave.
All world/player inventory interactions are deferred to the respawn location's region to ensure correct, thread-safe execution order after the player is placed in the world.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    private final Graves
     
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    private void
    applyPotionEffectIfWithinTime(org.bukkit.entity.Player player, List<String> permissionList, Grave grave, org.bukkit.Location respawnLoc)
    Applies temporary potion effects if the grave's lived time is within the configured limit.
    private void
    giveCompassToPlayer(org.bukkit.event.player.PlayerRespawnEvent event, org.bukkit.entity.Player player, Grave grave, org.bukkit.Location respawnLoc)
    Creates and gives the grave compass one tick after respawn, executing on the respawn location region to safely read locations and modify the player's inventory.
    void
    onPlayerRespawn(org.bukkit.event.player.PlayerRespawnEvent event)
     
    private void
    scheduleRespawnFunction(org.bukkit.entity.Player player, List<String> permissionList, Grave grave, org.bukkit.Location respawnLoc)
    Schedules the configured respawn function to run one tick after respawn on the player's respawn location region.
    private boolean
    shouldGiveCompass(org.bukkit.entity.Player player, List<String> permissionList, Grave grave)
    Returns true if a compass should be given: compass feature available, enabled, and within the configured time window relative to the grave's lived time.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • plugin

      private final Graves plugin
  • Constructor Details

    • PlayerRespawnListener

      public PlayerRespawnListener(Graves plugin)
  • Method Details

    • onPlayerRespawn

      public void onPlayerRespawn(org.bukkit.event.player.PlayerRespawnEvent event)
    • scheduleRespawnFunction

      private void scheduleRespawnFunction(org.bukkit.entity.Player player, List<String> permissionList, Grave grave, org.bukkit.Location respawnLoc)
      Schedules the configured respawn function to run one tick after respawn on the player's respawn location region.
    • applyPotionEffectIfWithinTime

      private void applyPotionEffectIfWithinTime(org.bukkit.entity.Player player, List<String> permissionList, Grave grave, org.bukkit.Location respawnLoc)
      Applies temporary potion effects if the grave's lived time is within the configured limit. Executed one tick after respawn on the respawn location region.
    • shouldGiveCompass

      private boolean shouldGiveCompass(org.bukkit.entity.Player player, List<String> permissionList, Grave grave)
      Returns true if a compass should be given: compass feature available, enabled, and within the configured time window relative to the grave's lived time.
    • giveCompassToPlayer

      private void giveCompassToPlayer(org.bukkit.event.player.PlayerRespawnEvent event, org.bukkit.entity.Player player, Grave grave, org.bukkit.Location respawnLoc)
      Creates and gives the grave compass one tick after respawn, executing on the respawn location region to safely read locations and modify the player's inventory.