Class PlayerDeathListener

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

public class PlayerDeathListener extends Object implements org.bukkit.event.Listener
Listener for handling PlayerDeathEvent to manage items dropped upon player death. Specifically, it handles compass items based on their association with graves.
  • Field Summary

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

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

    Modifier and Type
    Method
    Description
    private void
    cacheRemainingItems(org.bukkit.event.entity.PlayerDeathEvent event, List<org.bukkit.inventory.ItemStack> itemStackList)
    Caches the remaining items from the drop list for later reference.
    private boolean
    isCompassToRemove(org.bukkit.event.entity.PlayerDeathEvent event, org.bukkit.inventory.ItemStack itemStack)
    Checks if the given item stack is a compass that should be removed based on the plugin configuration.
    void
    onPlayerDeath(org.bukkit.event.entity.PlayerDeathEvent event)
    Handles the PlayerDeathEvent to remove compass items from the drop list if they are associated with graves.

    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

    • PlayerDeathListener

      public PlayerDeathListener(Graves plugin)
      Constructs a PlayerDeathListener with the specified Graves plugin.
      Parameters:
      plugin - The Graves plugin instance.
  • Method Details

    • onPlayerDeath

      public void onPlayerDeath(org.bukkit.event.entity.PlayerDeathEvent event)
      Handles the PlayerDeathEvent to remove compass items from the drop list if they are associated with graves. If a compass item is linked to a grave and the configuration setting "compass.destroy" is true, the item is removed from the drop list. The remaining items are then cached for later reference.
      Parameters:
      event - The PlayerDeathEvent to handle.
    • isCompassToRemove

      private boolean isCompassToRemove(org.bukkit.event.entity.PlayerDeathEvent event, org.bukkit.inventory.ItemStack itemStack)
      Checks if the given item stack is a compass that should be removed based on the plugin configuration.
      Parameters:
      event - The PlayerDeathEvent.
      itemStack - The item stack to check.
      Returns:
      True if the item stack is a compass that should be removed, false otherwise.
    • cacheRemainingItems

      private void cacheRemainingItems(org.bukkit.event.entity.PlayerDeathEvent event, List<org.bukkit.inventory.ItemStack> itemStackList)
      Caches the remaining items from the drop list for later reference.
      Parameters:
      event - The PlayerDeathEvent.
      itemStackList - The list of remaining item stacks.