Class GraveManager
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionGraveManager(@NotNull Graves plugin) Initializes the GraveManager with the specified plugin instance. -
Method Summary
Modifier and TypeMethodDescriptionvoidabandonGrave(Grave grave) Abandons a grave.voidautoLootGrave(org.bukkit.entity.Entity entity, org.bukkit.Location location, Grave grave) Automatically loots a grave for a player.voidbreakGrave(Grave grave) Breaks a grave at its death location.voidbreakGrave(org.bukkit.Location location, Grave grave) Breaks a grave at the specified location.private voidChecks and updates graves, entities, and blocks, removing expired elements and triggering necessary events.voidcleanupCompasses(org.bukkit.entity.Player player, Grave grave) Cleans up compasses from a player's inventory that are associated with a grave.voidcloseGrave(Grave grave) Closes any open inventories associated with a grave.createGrave(org.bukkit.entity.Entity entity, List<org.bukkit.inventory.ItemStack> itemStackList) Creates a new grave for the specified entity and list of item stacks.createGrave(org.bukkit.entity.Entity entity, List<org.bukkit.inventory.ItemStack> itemStackList, List<String> permissionList) Creates a new grave for the specified entity, list of item stacks, and permissions.org.bukkit.inventory.InventorycreateGraveInventory(org.bukkit.inventory.InventoryHolder inventoryHolder, org.bukkit.Location location, List<org.bukkit.inventory.ItemStack> itemStackList, String title, Grave.StorageMode storageMode) Creates a grave inventory with the specified parameters.voiddropGraveExperience(org.bukkit.Location location, Grave grave) Drops the experience from a grave at the specified location.voiddropGraveItems(org.bukkit.Location location, Grave grave) Drops the items from a grave at the specified location.extractNamespacedKeys(org.bukkit.inventory.ItemStack itemStack) Collects namespaced keys present on this item.List<org.bukkit.inventory.ItemStack> filterGraveItemStackList(List<org.bukkit.inventory.ItemStack> itemStackList, List<org.bukkit.inventory.ItemStack> removedItemStackList, org.bukkit.entity.LivingEntity livingEntity, List<String> permissionList) Filters the grave item stack list based on the living entity, removed item stacks, and permission list.Gets a list of all graves.getDamageReason(org.bukkit.event.entity.EntityDamageEvent.DamageCause damageCause, Grave grave) Retrieves the damage reason for a specified damage cause and grave.intgetGraveCount(org.bukkit.entity.Entity entity) Retrieves the number of graves associated with an entity.org.bukkit.inventory.InventorygetGraveInventory(Grave grave, org.bukkit.entity.LivingEntity livingEntity, List<org.bukkit.inventory.ItemStack> graveItemStackList, List<org.bukkit.inventory.ItemStack> removedItemStackList, List<String> permissionList) Retrieves the grave inventory for a specified grave and living entity.getGraveList(UUID uuid) Retrieves a list of graves associated with a UUID.getGraveList(org.bukkit.entity.Entity entity) Retrieves a list of graves associated with an entity.getGraveList(org.bukkit.entity.Player player) Retrieves a list of graves associated with a player.getGraveList(org.bukkit.OfflinePlayer player) Retrieves a list of graves associated with an offline player.org.bukkit.LocationgetGraveLocation(org.bukkit.Location location, Grave grave) Retrieves the nearest grave location to a specified location.List<org.bukkit.Location> getGraveLocationList(org.bukkit.Location baseLocation, Grave grave) Retrieves a list of locations associated with a grave.intgetItemStacksSize(org.bukkit.inventory.ItemStack[] itemStacks) Gets the size of the item stacks array.getStorageMode(String string) Retrieves the storage mode for a given string representation.voidgiveGraveExperience(org.bukkit.entity.Player player, Grave grave) Gives the experience from a grave to a player.voidgraveParticle(org.bukkit.Location location, Grave grave) Spawns particle effects around a grave.private voidhandleGraveTimeout(Grave grave, List<Grave> graveRemoveList) Handles the timeout or abandonment of a grave by firing the GraveTimeoutEvent and then either dropping its contents (timeout) or moving it into abandoned logic.booleanisGraveAbandoned(Grave grave) Checks if a block should be ignored based on the entity and permissions.booleanisGravePlaced(Grave grave) Determines if the grave is placed in the world by checking for any physical block or entity presence at the grave's location.private booleanisHeadBlock(org.bukkit.block.Block block) booleanisNearGrave(org.bukkit.Location location) Checks if the given location is within configured blocks of any grave.booleanisNearGrave(org.bukkit.Location location, org.bukkit.block.Block block) Overload for block-specific checks.booleanisNearGrave(org.bukkit.Location location, org.bukkit.entity.Player player) Overload for player-specific checks.booleanisNearGrave(org.bukkit.Location location, org.bukkit.entity.Player player, org.bukkit.block.Block block) Checks if the given location is within configured blocks of any grave.private booleannamespacedKeys(org.bukkit.inventory.ItemStack itemStack, List<String> keysToMatch) Exact match against any namespaced key on the item.private booleannamespacedKeysContains(org.bukkit.inventory.ItemStack itemStack, List<String> patterns) Substring match against any namespaced key on the item.booleanOpens a grave for a player.booleanopenGrave(org.bukkit.entity.Entity entity, org.bukkit.Location location, Grave grave, boolean preview) Opens a grave for a player.voidplaceGrave(org.bukkit.Location location, Grave grave) Places a grave at a specified location.voidplayEffect(String string, org.bukkit.Location location) Plays an effect at a specified location.voidplayEffect(String string, org.bukkit.Location location, int data, Grave grave) Plays an effect at a specified location with additional data for a grave.voidplayEffect(String string, org.bukkit.Location location, Grave grave) Plays an effect at a specified location for a grave.private voidprocessBlockData(ChunkData chunkData, List<BlockData> blockDataRemoveList) Processes the block data within the given chunk.private voidprocessChunks(List<EntityData> entityDataRemoveList, List<BlockData> blockDataRemoveList) Processes all chunks to handle entities and blocks within them.private voidprocessEntityData(ChunkData chunkData, List<EntityData> entityDataRemoveList, org.bukkit.Location location) Processes the entity data within the given chunk.private voidprocessGraves(List<Grave> graveRemoveList) Processes all graves to check their remaining time and protection status.private voidprocessHologramData(HologramData hologramData, org.bukkit.Location location, List<EntityData> entityDataRemoveList) Processes hologram data within the chunk.voidremoveEntityData(EntityData entityData) Removes entity data associated with a grave.private voidremoveExpiredElements(List<Grave> graveRemoveList, List<EntityData> entityDataRemoveList, List<BlockData> blockDataRemoveList) Removes expired graves, entities, and blocks from the system.voidremoveGrave(Grave grave) Removes a grave and its associated data.voidremoveOldestGrave(org.bukkit.entity.LivingEntity livingEntity) Removes the oldest grave.private voidRestores graves that are in cache but missing from the world.private voidsendPlayerMessage(Grave grave, String messageKey, org.bukkit.Location location) Utility to send a message to the grave owner if they're online.booleanshouldIgnoreItemStack(org.bukkit.inventory.ItemStack itemStack, org.bukkit.entity.Entity entity, List<String> permissionList) Checks if an item stack should be ignored based on the entity and permissions.private voidStarts the grave timer task that periodically checks and updates graves.voidtoggleGraveProtection(Grave grave) Toggles the protection state of a grave.voidunload()Unloads all open grave inventories for online players.
-
Field Details
-
plugin
The main plugin instance associated with Graves.This
Gravesinstance represents the core plugin that this Graves is part of. It provides access to the plugin's functionality, configuration, and other services.
-
-
Constructor Details
-
GraveManager
Initializes the GraveManager with the specified plugin instance.- Parameters:
plugin- the Graves plugin instance.
-
-
Method Details
-
startGraveTimer
private void startGraveTimer()Starts the grave timer task that periodically checks and updates graves. -
checkAndUpdateGraves
private void checkAndUpdateGraves()Checks and updates graves, entities, and blocks, removing expired elements and triggering necessary events. -
processGraves
Processes all graves to check their remaining time and protection status.- Parameters:
graveRemoveList- the list to which graves to be removed will be added.
-
handleGraveTimeout
Handles the timeout or abandonment of a grave by firing the GraveTimeoutEvent and then either dropping its contents (timeout) or moving it into abandoned logic.- Parameters:
grave- the grave to check.graveRemoveList- graves to remove get added here.
-
sendPlayerMessage
Utility to send a message to the grave owner if they're online.- Parameters:
grave- the grave whose owner should be notifiedmessageKey- the message key to resolve from messages configurationlocation- the relevant location to include with the message
-
processChunks
private void processChunks(List<EntityData> entityDataRemoveList, List<BlockData> blockDataRemoveList) Processes all chunks to handle entities and blocks within them.- Parameters:
entityDataRemoveList- the list to which entity data to be removed will be added.blockDataRemoveList- the list to which block data to be removed will be added.
-
removeExpiredElements
private void removeExpiredElements(List<Grave> graveRemoveList, List<EntityData> entityDataRemoveList, List<BlockData> blockDataRemoveList) Removes expired graves, entities, and blocks from the system.- Parameters:
graveRemoveList- the list of graves to be removed.entityDataRemoveList- the list of entity data to be removed.blockDataRemoveList- the list of block data to be removed.
-
processEntityData
private void processEntityData(ChunkData chunkData, List<EntityData> entityDataRemoveList, org.bukkit.Location location) Processes the entity data within the given chunk.- Parameters:
chunkData- the data of the chunk being processed.entityDataRemoveList- the list to which entity data to be removed will be added.location- the location representing the chunk coordinates.
-
processHologramData
private void processHologramData(HologramData hologramData, org.bukkit.Location location, List<EntityData> entityDataRemoveList) Processes hologram data within the chunk.- Parameters:
hologramData- the hologram data to be processed.location- the location representing the chunk coordinates.entityDataRemoveList- the list to which hologram data to be removed will be added.
-
processBlockData
Processes the block data within the given chunk.- Parameters:
chunkData- the data of the chunk being processed.blockDataRemoveList- the list to which block data to be removed will be added.
-
unload
public void unload()Unloads all open grave inventories for online players. -
toggleGraveProtection
Toggles the protection state of a grave.- Parameters:
grave- the grave to toggle protection for.
-
abandonGrave
Abandons a grave.- Parameters:
grave- the grave to abandon.
-
graveParticle
Spawns particle effects around a grave.Folia-compatible: the actual particle spawning is scheduled on the correct region thread via the GravesX scheduler using the provided location.
- Parameters:
location- the location of the grave.grave- the grave to spawn particles for.
-
removeOldestGrave
public void removeOldestGrave(org.bukkit.entity.LivingEntity livingEntity) Removes the oldest grave.- Parameters:
livingEntity- the entity whose oldest grave should be removed
-
removeGrave
Removes a grave and its associated data.- Parameters:
grave- the grave to remove.
-
removeEntityData
Removes entity data associated with a grave.- Parameters:
entityData- the entity data to remove.
-
closeGrave
Closes any open inventories associated with a grave.- Parameters:
grave- the grave to close inventories for.
-
createGrave
public Grave createGrave(org.bukkit.entity.Entity entity, List<org.bukkit.inventory.ItemStack> itemStackList) Creates a new grave for the specified entity and list of item stacks.- Parameters:
entity- the entity to create the grave for.itemStackList- the list of item stacks to be included in the grave.- Returns:
- the created grave.
-
createGrave
public Grave createGrave(org.bukkit.entity.Entity entity, List<org.bukkit.inventory.ItemStack> itemStackList, List<String> permissionList) Creates a new grave for the specified entity, list of item stacks, and permissions.- Parameters:
entity- the entity to create the grave for.itemStackList- the list of item stacks to be included in the grave.permissionList- the list of permissions associated with the grave.- Returns:
- the created grave.
-
restoreMissingGraves
private void restoreMissingGraves()Restores graves that are in cache but missing from the world. -
isGravePlaced
Determines if the grave is placed in the world by checking for any physical block or entity presence at the grave's location. This includes checking for plugin-provided furniture/blocks and NPC corpses.- Parameters:
grave- the grave to check.- Returns:
- true if a block or entity is present at the grave's location (including integrations).
-
isHeadBlock
private boolean isHeadBlock(org.bukkit.block.Block block) -
getStorageMode
Retrieves the storage mode for a given string representation.- Parameters:
string- the string representation of the storage mode.- Returns:
- the corresponding storage mode.
-
placeGrave
Places a grave at a specified location.- Parameters:
location- the location to place the grave.grave- the grave to be placed.
-
getGraveInventory
public org.bukkit.inventory.Inventory getGraveInventory(Grave grave, org.bukkit.entity.LivingEntity livingEntity, List<org.bukkit.inventory.ItemStack> graveItemStackList, List<org.bukkit.inventory.ItemStack> removedItemStackList, List<String> permissionList) Retrieves the grave inventory for a specified grave and living entity.- Parameters:
grave- the grave.livingEntity- the living entity.graveItemStackList- the list of item stacks to be included in the grave.removedItemStackList- the list of item stacks to be removed.permissionList- the list of permissions associated with the grave.- Returns:
- the created grave inventory.
-
createGraveInventory
public org.bukkit.inventory.Inventory createGraveInventory(org.bukkit.inventory.InventoryHolder inventoryHolder, org.bukkit.Location location, List<org.bukkit.inventory.ItemStack> itemStackList, String title, Grave.StorageMode storageMode) Creates a grave inventory with the specified parameters.- Parameters:
inventoryHolder- the holder of the inventory.location- the location of the grave.itemStackList- the list of item stacks to be included in the inventory.title- the title of the inventory.storageMode- the storage mode for the inventory.- Returns:
- the created inventory.
-
getItemStacksSize
public int getItemStacksSize(org.bukkit.inventory.ItemStack[] itemStacks) Gets the size of the item stacks array.- Parameters:
itemStacks- the array of item stacks.- Returns:
- the number of non-null item stacks in the array.
-
filterGraveItemStackList
public List<org.bukkit.inventory.ItemStack> filterGraveItemStackList(List<org.bukkit.inventory.ItemStack> itemStackList, List<org.bukkit.inventory.ItemStack> removedItemStackList, org.bukkit.entity.LivingEntity livingEntity, List<String> permissionList) Filters the grave item stack list based on the living entity, removed item stacks, and permission list.- Parameters:
itemStackList- the original list of item stacks.removedItemStackList- the list of item stacks to be removed.livingEntity- the living entity.permissionList- the list of permissions associated with the grave.- Returns:
- the filtered list of item stacks.
-
breakGrave
Breaks a grave at its death location.- Parameters:
grave- the grave to be broken.
-
breakGrave
Breaks a grave at the specified location.- Parameters:
location- the location to break the grave.grave- the grave to be broken.
-
dropGraveItems
Drops the items from a grave at the specified location.Folia-compatible: item drops are executed on the correct region thread using
locationas the anchor.- Parameters:
location- the location to drop the items.grave- the grave containing the items.
-
giveGraveExperience
Gives the experience from a grave to a player.- Parameters:
player- the player to receive the experience.grave- the grave containing the experience.
-
dropGraveExperience
Drops the experience from a grave at the specified location.- Parameters:
location- the location to drop the experience.grave- the grave containing the experience.
-
getGraveList
Retrieves a list of graves associated with a player.- Parameters:
player- the player to retrieve the graves for.- Returns:
- the list of graves.
-
getGraveList
Retrieves a list of graves associated with an offline player.- Parameters:
player- the offline player to retrieve the graves for.- Returns:
- the list of graves.
-
getGraveList
Retrieves a list of graves associated with an entity.- Parameters:
entity- the entity to retrieve the graves for.- Returns:
- the list of graves.
-
getGraveList
Retrieves a list of graves associated with a UUID.- Parameters:
uuid- the UUID to retrieve the graves for.- Returns:
- the list of graves.
-
getGraveCount
public int getGraveCount(org.bukkit.entity.Entity entity) Retrieves the number of graves associated with an entity.- Parameters:
entity- the entity to retrieve the grave count for.- Returns:
- the number of graves.
-
openGrave
public boolean openGrave(org.bukkit.entity.Entity entity, org.bukkit.Location location, Grave grave) Opens a grave for a player.- Parameters:
entity- the entity attempting to open the grave.location- the location of the grave.grave- the grave to be opened.- Returns:
- true if the grave was opened successfully, false otherwise.
-
openGrave
public boolean openGrave(org.bukkit.entity.Entity entity, org.bukkit.Location location, Grave grave, boolean preview) Opens a grave for a player.Folia-compatible: world/player interactions (auto-loot, opening inventories, running commands, playing sounds) are executed on the correct region thread using the provided
locationas the anchor. The method returnstrueonce the operation has been scheduled (if permitted), not necessarily after it completes.- Parameters:
entity- the entity attempting to open the grave.location- the location of the grave.grave- the grave to be opened.preview- whether to open the grave in preview mode (when allowed by config).- Returns:
- true if the open/auto-loot operation was scheduled, false otherwise.
-
cleanupCompasses
Cleans up compasses from a player's inventory that are associated with a grave.- Parameters:
player- the player to clean up the compasses for.grave- the grave associated with the compasses.
-
getGraveLocationList
public List<org.bukkit.Location> getGraveLocationList(org.bukkit.Location baseLocation, Grave grave) Retrieves a list of locations associated with a grave.- Parameters:
baseLocation- the base location.grave- the grave to retrieve the locations for.- Returns:
- the list of locations ordered by proximity in the same world, followed by other worlds.
-
getGraveLocation
Retrieves the nearest grave location to a specified location.- Parameters:
location- the base location.grave- the grave to retrieve the location for.- Returns:
- the nearest grave location, or
nullif none found.
-
autoLootGrave
public void autoLootGrave(org.bukkit.entity.Entity entity, org.bukkit.Location location, Grave grave) Automatically loots a grave for a player.- Parameters:
entity- the entity looting the grave.location- the location of the grave.grave- the grave to be looted.
-
isNearGrave
public boolean isNearGrave(org.bukkit.Location location) Checks if the given location is within configured blocks of any grave.- Parameters:
location- The location to check.- Returns:
- True if the location is within configured blocks of any grave, false otherwise.
-
isNearGrave
public boolean isNearGrave(org.bukkit.Location location, org.bukkit.entity.Player player) Overload for player-specific checks. -
isNearGrave
public boolean isNearGrave(org.bukkit.Location location, org.bukkit.block.Block block) Overload for block-specific checks. -
isNearGrave
public boolean isNearGrave(org.bukkit.Location location, org.bukkit.entity.Player player, org.bukkit.block.Block block) Checks if the given location is within configured blocks of any grave.- Parameters:
location- The location to check.player- Optional player to consider for additional logic.block- Optional block to consider for additional logic.- Returns:
- true if the location is within the configured protection radius of any grave; false otherwise.
-
getDamageReason
public String getDamageReason(org.bukkit.event.entity.EntityDamageEvent.DamageCause damageCause, Grave grave) Retrieves the damage reason for a specified damage cause and grave.- Parameters:
damageCause- the cause of the damage.grave- the grave associated with the damage.- Returns:
- the damage reason.
-
playEffect
Plays an effect at a specified location.- Parameters:
string- the effect string.location- the location to play the effect.
-
playEffect
Plays an effect at a specified location for a grave.- Parameters:
string- the effect string.location- the location to play the effect.grave- the grave associated with the effect.
-
playEffect
Plays an effect at a specified location with additional data for a grave.Folia-compatible: effect playback is scheduled on the correct region thread using
locationas the anchor.- Parameters:
string- the effect string (config key or enum name).location- the location to play the effect.data- additional data for the effect.grave- the grave associated with the effect.
-
shouldIgnoreItemStack
public boolean shouldIgnoreItemStack(org.bukkit.inventory.ItemStack itemStack, org.bukkit.entity.Entity entity, List<String> permissionList) Checks if an item stack should be ignored based on the entity and permissions.- Parameters:
itemStack- the item stack to check.entity- the entity.permissionList- the list of permissions.- Returns:
- true if the item stack should be ignored, false otherwise.
-
getAllGraves
Gets a list of all graves.- Returns:
- a snapshot list of all graves currently known to the cache (never
null).
-
isGraveAbandoned
Checks if a block should be ignored based on the entity and permissions.- Parameters:
grave- checks to see if the following grave is abandoned.- Returns:
- true if grave is abandoned, false otherwise.
-
namespacedKeys
Exact match against any namespaced key on the item. Accepts "namespace:key" or just "key". -
namespacedKeysContains
private boolean namespacedKeysContains(org.bukkit.inventory.ItemStack itemStack, List<String> patterns) Substring match against any namespaced key on the item. Accepts partials like "silk" or "minecraft:". -
extractNamespacedKeys
Collects namespaced keys present on this item. Includes enchantment keys (applied and stored) and PDC keys. Keys are added in both "namespace:key" and "key" forms, lowercased.
-