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
Listener for handling PlayerRespawnEvent to manage grave-related functionality upon player respawn.
  • Field Summary

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

    Constructors
    Constructor
    Description
    Constructs a PlayerRespawnListener with the specified Graves plugin.
  • Method Summary

    Modifier and Type
    Method
    Description
    private void
    applyPotionEffectIfWithinTime(org.bukkit.entity.Player player, List<String> permissionList, Grave grave)
    Applies a potion effect to the player if they respawn within the allowed time.
    private void
    giveCompassToPlayer(org.bukkit.event.player.PlayerRespawnEvent event, org.bukkit.entity.Player player, Grave grave)
    Gives a compass to the player that points to the location of their grave.
    void
    onPlayerRespawn(org.bukkit.event.player.PlayerRespawnEvent event)
    Handles the PlayerRespawnEvent to perform actions related to graves when a player respawns.
    private void
    scheduleRespawnFunction(org.bukkit.entity.Player player, List<String> permissionList, Grave grave)
    Schedules a function to run after the player respawns.
    private boolean
    shouldGiveCompass(org.bukkit.entity.Player player, List<String> permissionList, Grave grave)
    Checks if a compass should be given to the player based on the respawn time and configuration settings.

    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)
      Constructs a PlayerRespawnListener with the specified Graves plugin.
      Parameters:
      plugin - The Graves plugin instance.
  • Method Details

    • onPlayerRespawn

      public void onPlayerRespawn(org.bukkit.event.player.PlayerRespawnEvent event)
      Handles the PlayerRespawnEvent to perform actions related to graves when a player respawns. This method: - Runs a scheduled task to execute a function configured for respawn events. - Checks if a compass should be given to the player based on the respawn time and config settings. - Applies a potion effect if the player respawns within the allowed time.
      Parameters:
      event - The PlayerRespawnEvent to handle.
    • applyPotionEffectIfWithinTime

      private void applyPotionEffectIfWithinTime(org.bukkit.entity.Player player, List<String> permissionList, Grave grave)
      Applies a potion effect to the player if they respawn within the allowed time.
      Parameters:
      player - The player who respawned.
      permissionList - The list of permissions for the player.
      grave - The grave associated with the player.
    • scheduleRespawnFunction

      private void scheduleRespawnFunction(org.bukkit.entity.Player player, List<String> permissionList, Grave grave)
      Schedules a function to run after the player respawns.
      Parameters:
      player - The player who respawned.
      permissionList - The list of permissions for the player.
      grave - The grave associated with the player.
    • shouldGiveCompass

      private boolean shouldGiveCompass(org.bukkit.entity.Player player, List<String> permissionList, Grave grave)
      Checks if a compass should be given to the player based on the respawn time and configuration settings.
      Parameters:
      player - The player who respawned.
      permissionList - The list of permissions for the player.
      grave - The grave associated with the player.
      Returns:
      True if a compass should be given, false otherwise.
    • giveCompassToPlayer

      private void giveCompassToPlayer(org.bukkit.event.player.PlayerRespawnEvent event, org.bukkit.entity.Player player, Grave grave)
      Gives a compass to the player that points to the location of their grave.
      Parameters:
      event - The PlayerRespawnEvent.
      player - The player who respawned.
      grave - The grave associated with the player.