Package com.ranull.graves.listener
Class PlayerDeathListener
java.lang.Object
com.ranull.graves.listener.PlayerDeathListener
- All Implemented Interfaces:
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 -
Constructor Summary
ConstructorsConstructorDescriptionPlayerDeathListener
(Graves plugin) Constructs a PlayerDeathListener with the specified Graves plugin. -
Method Summary
Modifier and TypeMethodDescriptionprivate 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.
-
Field Details
-
plugin
-
-
Constructor Details
-
PlayerDeathListener
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.
-