Package com.ranull.graves.listener
Class EntityDeathListener
java.lang.Object
com.ranull.graves.listener.EntityDeathListener
- All Implemented Interfaces:
org.bukkit.event.Listener
Listener for handling entity death events and creating graves.
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionEntityDeathListener(Graves plugin) Constructs an EntityDeathListener with the specified Graves plugin. -
Method Summary
Modifier and TypeMethodDescriptionprivate voidcreateGrave(org.bukkit.event.entity.EntityDeathEvent event, org.bukkit.entity.LivingEntity livingEntity, String entityName, List<String> permissionList, List<org.bukkit.inventory.ItemStack> removedItemStackList, List<org.bukkit.inventory.ItemStack> graveItemStackList, org.bukkit.Location location, org.bukkit.event.entity.PlayerDeathEvent pde, org.bukkit.entity.Player player) Creates a grave for the specified entity.private List<org.bukkit.inventory.ItemStack> getGraveItemStackList(org.bukkit.event.entity.EntityDeathEvent event, org.bukkit.entity.LivingEntity livingEntity, List<String> permissionList) Retrieves the list of item stacks for the grave.private intgetMaxGravesPermission(org.bukkit.entity.Player player) Retrieves the maximum number of graves a player is allowed to have based on their permissions.private List<org.bukkit.inventory.ItemStack> getRemovedItemStacks(org.bukkit.entity.LivingEntity livingEntity) Retrieves the list of removed item stacks for the specified entity.private voidhandleFailedGravePlacement(org.bukkit.event.entity.EntityDeathEvent event, Grave grave, org.bukkit.Location location, org.bukkit.entity.LivingEntity livingEntity) Handles failed grave placement.private booleanhandlePlayerDeath(org.bukkit.entity.Player player, String entityName) Handles player death and checks if a grave should be created.private booleanhasGravesXMetadata(org.bukkit.entity.Zombie zombie) Checks if the given entity has the GravesX metadata.private booleanhasValidToken(org.bukkit.entity.LivingEntity livingEntity, List<String> permissionList, String entityName, List<org.bukkit.inventory.ItemStack> drops) Checks if the entity has a valid grave token.private booleanisConfiguredZombieType(org.bukkit.entity.Zombie zombie) Checks if the zombie is of the type configured in config.yml.private booleanisEnabledGrave(org.bukkit.entity.LivingEntity livingEntity, List<String> permissionList, String entityName) Checks if graves are enabled for the specified entity.private booleanisInvalidCreatureSpawn(org.bukkit.entity.LivingEntity livingEntity, List<String> permissionList, String entityName) Checks if the creature spawn reason is valid.private booleanisInvalidGraveZombie(org.bukkit.event.entity.EntityDeathEvent event, org.bukkit.entity.LivingEntity livingEntity, String entityName) Checks if the entity is an invalid grave zombie.private booleanisInvalidMohistDeath(org.bukkit.event.entity.EntityDeathEvent event) Checks if the entity death event is an invalid Mohist death.private booleanisKeepInventory(org.bukkit.event.entity.PlayerDeathEvent event, String entityName) Checks if the player has keep inventory enabled.private booleanisValidDamageCause(org.bukkit.entity.LivingEntity livingEntity, List<String> permissionList, String entityName) Checks if the damage cause is valid for creating a grave.private booleanisValidWorld(List<String> worldList, org.bukkit.entity.LivingEntity livingEntity, String entityName) Checks if the entity is in a valid world.private voidnotifyGraveCreation(org.bukkit.event.entity.EntityDeathEvent event, Grave grave, Map<org.bukkit.Location, BlockData.BlockType> locationMap, org.bukkit.entity.LivingEntity livingEntity, List<String> permissionList, org.bukkit.entity.Player player) Notifies the creation of the grave and places the grave blocks.voidonEntityDeath(org.bukkit.event.entity.EntityDeathEvent event) Handles the EntityDeathEvent to create a grave based on various conditions.private voidplaceGrave(org.bukkit.event.entity.EntityDeathEvent event, Grave grave, List<org.bukkit.inventory.ItemStack> graveItemStackList, List<org.bukkit.inventory.ItemStack> removedItemStackList, org.bukkit.Location location, org.bukkit.entity.LivingEntity livingEntity, List<String> permissionList, org.bukkit.entity.Player player) Places the grave at the specified location.private voidplaceGraveBlocks(Grave grave, Map<org.bukkit.Location, BlockData.BlockType> locationMap, org.bukkit.entity.LivingEntity livingEntity) Places the grave blocks at the specified locations.private voidremovePlayerSkullFromDrops(org.bukkit.entity.LivingEntity entity, org.bukkit.event.entity.EntityDeathEvent event) Removes player skull from the drops of the entity if it is wearing one.private voidsetGraveExperience(Grave grave, org.bukkit.event.entity.EntityDeathEvent event, org.bukkit.entity.LivingEntity livingEntity, org.bukkit.event.entity.PlayerDeathEvent pde) Sets the experience for the grave.private voidsetupGrave(Grave grave, org.bukkit.entity.LivingEntity livingEntity, String entityName, List<String> permissionList) Sets up the basic properties of the grave.private voidsetupGraveKiller(Grave grave, org.bukkit.entity.LivingEntity livingEntity) Sets up the killer details for the grave.private voidsetupGraveProtection(org.bukkit.entity.LivingEntity livingEntity, Grave grave) Sets up the protection details for the grave.private voidsetupObituary(Grave grave, List<org.bukkit.inventory.ItemStack> graveItemStackList, org.bukkit.entity.LivingEntity livingEntity, org.bukkit.Location location) Sets up the obituary item for the grave.private voidsetupSkull(Grave grave, List<org.bukkit.inventory.ItemStack> graveItemStackList, org.bukkit.entity.LivingEntity livingEntity, org.bukkit.Location location) Sets up the skull item for the grave.
-
Field Details
-
plugin
-
-
Constructor Details
-
EntityDeathListener
Constructs an EntityDeathListener with the specified Graves plugin.- Parameters:
plugin- The Graves plugin instance.
-
-
Method Details
-
onEntityDeath
public void onEntityDeath(org.bukkit.event.entity.EntityDeathEvent event) Handles the EntityDeathEvent to create a grave based on various conditions.- Parameters:
event- The EntityDeathEvent to handle.
-
getMaxGravesPermission
private int getMaxGravesPermission(org.bukkit.entity.Player player) Retrieves the maximum number of graves a player is allowed to have based on their permissions.The method checks for permissions related to grave limits and returns the highest limit found. If the player has the "grave.max.limit.unlimited" permission, the method will return
Integer.MAX_VALUEindicating that the player has no limit on the number of graves. If no specific permissions are found, the method returns0by default, which should be interpreted as no specific limit set by permissions.- Parameters:
player- The player whose grave limit is being checked.- Returns:
- The maximum number of graves the player is allowed to have. Returns
Integer.MAX_VALUEfor unlimited graves, or0if no specific limit is set by permissions.
-
isConfiguredZombieType
private boolean isConfiguredZombieType(org.bukkit.entity.Zombie zombie) Checks if the zombie is of the type configured in config.yml.- Parameters:
zombie- the zombie entity to check- Returns:
- true if the zombie is of the configured type, false otherwise
-
removePlayerSkullFromDrops
private void removePlayerSkullFromDrops(org.bukkit.entity.LivingEntity entity, org.bukkit.event.entity.EntityDeathEvent event) Removes player skull from the drops of the entity if it is wearing one.- Parameters:
entity- the entity whose drops are to be modifiedevent- the EntityDeathEvent containing the drops
-
hasGravesXMetadata
private boolean hasGravesXMetadata(org.bukkit.entity.Zombie zombie) Checks if the given entity has the GravesX metadata.- Parameters:
zombie- the zombie entity to check- Returns:
- true if the entity has the GravesX metadata, false otherwise
-
getRemovedItemStacks
private List<org.bukkit.inventory.ItemStack> getRemovedItemStacks(org.bukkit.entity.LivingEntity livingEntity) Retrieves the list of removed item stacks for the specified entity.- Parameters:
livingEntity- The entity whose removed item stacks are to be retrieved.- Returns:
- The list of removed item stacks.
-
isInvalidMohistDeath
private boolean isInvalidMohistDeath(org.bukkit.event.entity.EntityDeathEvent event) Checks if the entity death event is an invalid Mohist death.- Parameters:
event- The entity death event to check.- Returns:
- True if the event is an invalid Mohist death, false otherwise.
-
isInvalidGraveZombie
private boolean isInvalidGraveZombie(org.bukkit.event.entity.EntityDeathEvent event, org.bukkit.entity.LivingEntity livingEntity, String entityName) Checks if the entity is an invalid grave zombie.- Parameters:
event- The entity death event.livingEntity- The entity to check.entityName- The name of the entity.- Returns:
- True if the entity is an invalid grave zombie, false otherwise.
-
handlePlayerDeath
Handles player death and checks if a grave should be created.- Parameters:
player- The player who died.entityName- The name of the player.- Returns:
- True if a grave should not be created, false otherwise.
-
isEnabledGrave
private boolean isEnabledGrave(org.bukkit.entity.LivingEntity livingEntity, List<String> permissionList, String entityName) Checks if graves are enabled for the specified entity.- Parameters:
livingEntity- The entity to check.permissionList- The list of permissions.entityName- The name of the entity.- Returns:
- True if graves are enabled, false otherwise.
-
isKeepInventory
Checks if the player has keep inventory enabled.- Parameters:
event- The player death event.entityName- The name of the player.- Returns:
- True if the player has keep inventory enabled, false otherwise.
-
isInvalidCreatureSpawn
private boolean isInvalidCreatureSpawn(org.bukkit.entity.LivingEntity livingEntity, List<String> permissionList, String entityName) Checks if the creature spawn reason is valid.- Parameters:
livingEntity- The creature entity.permissionList- The list of permissions.entityName- The name of the entity.- Returns:
- True if the spawn reason is invalid, false otherwise.
-
isValidWorld
private boolean isValidWorld(List<String> worldList, org.bukkit.entity.LivingEntity livingEntity, String entityName) Checks if the entity is in a valid world.- Parameters:
worldList- The list of valid worlds.livingEntity- The entity to check.entityName- The name of the entity.- Returns:
- True if the entity is in a valid world, false otherwise.
-
isValidDamageCause
private boolean isValidDamageCause(org.bukkit.entity.LivingEntity livingEntity, List<String> permissionList, String entityName) Checks if the damage cause is valid for creating a grave.- Parameters:
livingEntity- The entity that was damaged.permissionList- The list of permissions.entityName- The name of the entity.- Returns:
- True if the damage cause is valid, false otherwise.
-
hasValidToken
private boolean hasValidToken(org.bukkit.entity.LivingEntity livingEntity, List<String> permissionList, String entityName, List<org.bukkit.inventory.ItemStack> drops) Checks if the entity has a valid grave token.- Parameters:
livingEntity- The entity to check.permissionList- The list of permissions.entityName- The name of the entity.drops- The list of item drops.- Returns:
- True if the entity has a valid grave token, false otherwise.
-
getGraveItemStackList
private List<org.bukkit.inventory.ItemStack> getGraveItemStackList(org.bukkit.event.entity.EntityDeathEvent event, org.bukkit.entity.LivingEntity livingEntity, List<String> permissionList) Retrieves the list of item stacks for the grave.- Parameters:
event- The entity death event.livingEntity- The entity that died.permissionList- The list of permissions.- Returns:
- The list of item stacks for the grave.
-
createGrave
private void createGrave(org.bukkit.event.entity.EntityDeathEvent event, org.bukkit.entity.LivingEntity livingEntity, String entityName, List<String> permissionList, List<org.bukkit.inventory.ItemStack> removedItemStackList, List<org.bukkit.inventory.ItemStack> graveItemStackList, org.bukkit.Location location, org.bukkit.event.entity.PlayerDeathEvent pde, org.bukkit.entity.Player player) Creates a grave for the specified entity.- Parameters:
event- The entity death event.livingEntity- The entity that died.entityName- The name of the entity.permissionList- The list of permissions.removedItemStackList- The list of removed item stacks.graveItemStackList- The list of item stacks for the grave.location- The location of the grave.
-
setupGrave
private void setupGrave(Grave grave, org.bukkit.entity.LivingEntity livingEntity, String entityName, List<String> permissionList) Sets up the basic properties of the grave.- Parameters:
grave- The grave to set up.livingEntity- The entity that died.entityName- The name of the entity.permissionList- The list of permissions.
-
setGraveExperience
private void setGraveExperience(Grave grave, org.bukkit.event.entity.EntityDeathEvent event, org.bukkit.entity.LivingEntity livingEntity, org.bukkit.event.entity.PlayerDeathEvent pde) Sets the experience for the grave.- Parameters:
grave- The grave to set the experience for.event- The entity death event.livingEntity- The entity that died.
-
setupGraveKiller
Sets up the killer details for the grave.- Parameters:
grave- The grave to set up.livingEntity- The entity that died.
-
setupGraveProtection
Sets up the protection details for the grave.- Parameters:
grave- The grave to set up.
-
placeGrave
private void placeGrave(org.bukkit.event.entity.EntityDeathEvent event, Grave grave, List<org.bukkit.inventory.ItemStack> graveItemStackList, List<org.bukkit.inventory.ItemStack> removedItemStackList, org.bukkit.Location location, org.bukkit.entity.LivingEntity livingEntity, List<String> permissionList, org.bukkit.entity.Player player) Places the grave at the specified location.- Parameters:
event- The entity death event.grave- The grave to place.graveItemStackList- The list of item stacks for the grave.removedItemStackList- The list of removed item stacks.location- The location to place the grave.livingEntity- The entity that died.permissionList- The list of permissions.
-
setupObituary
private void setupObituary(Grave grave, List<org.bukkit.inventory.ItemStack> graveItemStackList, org.bukkit.entity.LivingEntity livingEntity, org.bukkit.Location location) Sets up the obituary item for the grave.- Parameters:
grave- The grave to set up.graveItemStackList- The list of item stacks for the grave.
-
setupSkull
private void setupSkull(Grave grave, List<org.bukkit.inventory.ItemStack> graveItemStackList, org.bukkit.entity.LivingEntity livingEntity, org.bukkit.Location location) Sets up the skull item for the grave.- Parameters:
grave- The grave to set up.graveItemStackList- The list of item stacks for the grave.
-
notifyGraveCreation
private void notifyGraveCreation(org.bukkit.event.entity.EntityDeathEvent event, Grave grave, Map<org.bukkit.Location, BlockData.BlockType> locationMap, org.bukkit.entity.LivingEntity livingEntity, List<String> permissionList, org.bukkit.entity.Player player) Notifies the creation of the grave and places the grave blocks.- Parameters:
event- The entity death event.grave- The grave that was created.locationMap- The map of locations for the grave.livingEntity- The entity that died.permissionList- The list of permissions.
-
placeGraveBlocks
private void placeGraveBlocks(Grave grave, Map<org.bukkit.Location, BlockData.BlockType> locationMap, org.bukkit.entity.LivingEntity livingEntity) Places the grave blocks at the specified locations.- Parameters:
grave- The grave to place.locationMap- The map of locations for the grave.livingEntity- The entity that died.
-
handleFailedGravePlacement
private void handleFailedGravePlacement(org.bukkit.event.entity.EntityDeathEvent event, Grave grave, org.bukkit.Location location, org.bukkit.entity.LivingEntity livingEntity) Handles failed grave placement.- Parameters:
event- The entity death event.grave- The grave that failed to be placed.location- The location where the grave was to be placed.livingEntity- The entity that died.
-