Class GraveManagementAPI

java.lang.Object
dev.cwhead.GravesX.api.grave.GraveManagementAPI

public class GraveManagementAPI extends Object
API for managing existing graves.
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    abandonGrave(@NotNull Grave grave)
    Marks the specified grave as abandoned, preventing further interaction.
    boolean
    addItemToGraveSlot(@NotNull Grave grave, @NotNull org.bukkit.inventory.ItemStack itemStack, int slot)
    Adds an item to a specific grave inventory slot if that slot is empty.
    int
    addItemToNextAvailableGraveSlot(@NotNull Grave grave, @NotNull org.bukkit.inventory.ItemStack itemStack)
    Adds an item to the next empty grave inventory slot.
    void
    autoLootGrave(@NotNull org.bukkit.entity.Entity entity, @NotNull org.bukkit.Location location, @NotNull Grave grave)
    Automatically loots the specified grave for the given entity at the given location.
    void
    breakGrave(@NotNull Grave grave)
    Breaks the specified grave, triggering its removal and handling any related events.
    void
    breakGrave(@NotNull org.bukkit.Location location, @NotNull Grave grave)
    Breaks the specified grave at a given location.
    void
    clearGraveProtection(@NotNull Grave grave)
    Clears protection from an existing grave.
    void
    dropGraveItems(@NotNull org.bukkit.Location location, @NotNull Grave grave)
    Drops the items stored in the specified grave at the given location.
    getGrave(@NotNull UUID uuid)
    Gets the grave type
    long
    Returns the total number of graves for all players.
    long
    getGraveAmount(@Nullable org.bukkit.entity.Player targetPlayer)
    Returns the number of graves associated with a specified player.
    @NotNull List<Grave>
    getGraves(@Nullable UUID ownerUUID)
    Gets loaded graves owned by the specified owner UUID.
    @NotNull List<Grave>
    getGraves(@Nullable org.bukkit.entity.Player targetPlayer)
    Gets loaded graves owned by the specified player.
    @NotNull List<UUID>
    Gets all loaded grave UUIDs.
    @NotNull List<UUID>
    getGraveUUIDs(@Nullable UUID ownerUUID)
    Gets loaded grave UUIDs owned by the specified owner UUID.
    @NotNull List<UUID>
    getGraveUUIDs(@Nullable org.bukkit.entity.Player targetPlayer)
    Gets loaded grave UUIDs owned by the specified player.
    @Nullable UUID
    getGraveViewerUUID(@NotNull Grave grave)
    Gets the UUID of the player currently viewing (locking) the specified grave.
    int
    Gets the next empty inventory slot for the specified grave.
    boolean
    hasAvailableGraveSlot(@NotNull Grave grave)
    Checks whether the specified grave has at least one empty inventory slot.
    boolean
    isGrave(@NotNull Grave grave)
    Deprecated.
    Use isGrave(Grave, Location) instead for precise location checking.
    boolean
    isGrave(@NotNull Grave grave, @NotNull org.bukkit.Location location)
    Checks if a given location matches the death location of a specific grave.
    boolean
    isGraveLocked(@NotNull Grave grave)
    Checks whether the specified grave is currently locked (being viewed) by any player.
    boolean
    isGraveLocked(@NotNull Grave grave, @NotNull org.bukkit.entity.Player player)
    Checks whether the specified grave is locked by someone other than the provided player.
    boolean
    isNearGrave(@NotNull org.bukkit.Location location)
    Determines if the specified location is near a grave.
    boolean
    isNearGrave(@NotNull org.bukkit.Location location, @NotNull org.bukkit.block.Block block)
    Determines if the specified location is near a grave, considering a specific block.
    boolean
    isNearGrave(@NotNull org.bukkit.Location location, @NotNull org.bukkit.entity.Player player)
    Determines if the specified location is near a grave, considering a specific player.
    boolean
    isNearGrave(@NotNull org.bukkit.Location location, @Nullable org.bukkit.entity.Player player, @Nullable org.bukkit.block.Block block)
    Determines if the specified location is near a grave.
    void
    removeGrave(@NotNull Grave grave)
    Removes the specified grave from the grave manager.
    void
    removeOldestGrave(@NotNull org.bukkit.entity.LivingEntity livingEntity)
    Removes the oldest grave associated with the specified living entity.
    void
    setGraveProtection(@NotNull Grave grave, boolean protectedGrave, long timeProtection)
    Updates the protection state and remaining protection time for an existing grave.
    boolean
    setItemInGraveSlot(@NotNull Grave grave, @NotNull org.bukkit.inventory.ItemStack itemStack, int slot)
    Sets an item in a specific grave inventory slot, replacing any existing item in that slot.
    boolean
    tryGetGraveViewerUUID(@NotNull Grave grave, @NotNull UUID[] outViewer)
    Attempts to get the UUID of the player currently viewing (locking) a grave.

    Methods inherited from class Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • GraveManagementAPI

      public GraveManagementAPI(Graves plugin)
  • Method Details

    • removeGrave

      public void removeGrave(@NotNull @NotNull Grave grave)
      Removes the specified grave from the grave manager.
      Parameters:
      grave - the grave to be removed
    • breakGrave

      public void breakGrave(@NotNull @NotNull Grave grave)
      Breaks the specified grave, triggering its removal and handling any related events.
      Parameters:
      grave - the grave to be broken
    • breakGrave

      public void breakGrave(@NotNull @NotNull org.bukkit.Location location, @NotNull @NotNull Grave grave)
      Breaks the specified grave at a given location.
      Parameters:
      location - the location where the grave is located
      grave - the grave to be broken
    • autoLootGrave

      public void autoLootGrave(@NotNull @NotNull org.bukkit.entity.Entity entity, @NotNull @NotNull org.bukkit.Location location, @NotNull @NotNull Grave grave)
      Automatically loots the specified grave for the given entity at the given location.
      Parameters:
      entity - the entity that will loot the grave
      location - the location of the grave
      grave - the grave to be looted
    • abandonGrave

      public void abandonGrave(@NotNull @NotNull Grave grave)
      Marks the specified grave as abandoned, preventing further interaction.
      Parameters:
      grave - the grave to be abandoned
    • dropGraveItems

      public void dropGraveItems(@NotNull @NotNull org.bukkit.Location location, @NotNull @NotNull Grave grave)
      Drops the items stored in the specified grave at the given location.
      Parameters:
      location - the location where the items will be dropped
      grave - the grave whose items are to be dropped
    • removeOldestGrave

      public void removeOldestGrave(@NotNull @NotNull org.bukkit.entity.LivingEntity livingEntity)
      Removes the oldest grave associated with the specified living entity.
      Parameters:
      livingEntity - the entity whose oldest grave will be removed
    • isNearGrave

      public boolean isNearGrave(@NotNull @NotNull org.bukkit.Location location, @Nullable @Nullable org.bukkit.entity.Player player, @Nullable @Nullable org.bukkit.block.Block block)
      Determines if the specified location is near a grave.

      This method serves as an overload to allow optional parameters such as a player or a block to be included in the proximity check.

      Parameters:
      location - the location to check for nearby graves (required).
      player - the player to consider in the proximity check (optional; nullable).
      block - the block to consider in the proximity check (optional; nullable).
      Returns:
      true if the location is near a grave, otherwise false.
    • isNearGrave

      public boolean isNearGrave(@NotNull @NotNull org.bukkit.Location location)
      Determines if the specified location is near a grave.

      This variant of the method omits the player and block parameters.

      Parameters:
      location - the location to check for nearby graves (required).
      Returns:
      true if the location is near a grave, otherwise false.
    • isNearGrave

      public boolean isNearGrave(@NotNull @NotNull org.bukkit.Location location, @NotNull @NotNull org.bukkit.entity.Player player)
      Determines if the specified location is near a grave, considering a specific player.

      This variant of the method includes the player parameter but omits the block parameter.

      Parameters:
      location - the location to check for nearby graves (required).
      player - the player to consider in the proximity check (required).
      Returns:
      true if the location is near a grave, otherwise false.
    • isNearGrave

      public boolean isNearGrave(@NotNull @NotNull org.bukkit.Location location, @NotNull @NotNull org.bukkit.block.Block block)
      Determines if the specified location is near a grave, considering a specific block.

      This variant of the method includes the block parameter but omits the player parameter.

      Parameters:
      location - the location to check for nearby graves (required).
      block - the block to consider in the proximity check (required).
      Returns:
      true if the location is near a grave, otherwise false.
    • getGrave

      public Grave getGrave(@NotNull @NotNull UUID uuid)
      Gets the grave type
      Parameters:
      uuid - the uuid of the grave
    • isGrave

      @Deprecated public boolean isGrave(@NotNull @NotNull Grave grave)
      Deprecated.
      Use isGrave(Grave, Location) instead for precise location checking. This code is added for debugging purposes. Checks if the specified location is a grave's location.
      Parameters:
      grave - the grave to check. This always returns true for the provided grave's death location. For more precise checking, use isGrave(Grave, Location) with a specific location.
      Returns:
      true if the location matches the grave's death location, false otherwise.
    • isGrave

      public boolean isGrave(@NotNull @NotNull Grave grave, @NotNull @NotNull org.bukkit.Location location)
      Checks if a given location matches the death location of a specific grave.
      Parameters:
      grave - the grave to check
      location - the location to compare with the grave's death location
      Returns:
      true if the location matches the grave's death location, false otherwise.
    • getGraveAmount

      public long getGraveAmount()
      Returns the total number of graves for all players.

      This method calls getGraveAmount(Player) with a null argument to count graves without filtering by any specific player.

      Returns:
      the total count of graves for all players.
    • getGraveAmount

      public long getGraveAmount(@Nullable @Nullable org.bukkit.entity.Player targetPlayer)
      Returns the number of graves associated with a specified player.

      If targetPlayer is provided, only graves owned by this player will be counted. If targetPlayer is null, all graves are counted.

      Parameters:
      targetPlayer - the player whose graves should be counted; if null, counts graves for all players.
      Returns:
      the number of graves associated with targetPlayer, or the total count of all graves if targetPlayer is null.
    • getGraveUUIDs

      @NotNull public @NotNull List<UUID> getGraveUUIDs()
      Gets all loaded grave UUIDs.
      Returns:
      a list of all loaded grave UUIDs.
    • getGraveUUIDs

      @NotNull public @NotNull List<UUID> getGraveUUIDs(@Nullable @Nullable org.bukkit.entity.Player targetPlayer)
      Gets loaded grave UUIDs owned by the specified player.
      Parameters:
      targetPlayer - the player whose grave UUIDs should be returned; if null, all grave UUIDs are returned.
      Returns:
      a list of loaded grave UUIDs.
    • getGraveUUIDs

      @NotNull public @NotNull List<UUID> getGraveUUIDs(@Nullable @Nullable UUID ownerUUID)
      Gets loaded grave UUIDs owned by the specified owner UUID.
      Parameters:
      ownerUUID - the owner UUID whose grave UUIDs should be returned; if null, all grave UUIDs are returned.
      Returns:
      a list of loaded grave UUIDs.
    • getGraves

      @NotNull public @NotNull List<Grave> getGraves(@Nullable @Nullable org.bukkit.entity.Player targetPlayer)
      Gets loaded graves owned by the specified player.
      Parameters:
      targetPlayer - the player whose graves should be returned; if null, all graves are returned.
      Returns:
      a list of loaded graves.
    • getGraves

      @NotNull public @NotNull List<Grave> getGraves(@Nullable @Nullable UUID ownerUUID)
      Gets loaded graves owned by the specified owner UUID.
      Parameters:
      ownerUUID - the owner UUID whose graves should be returned; if null, all graves are returned.
      Returns:
      a list of loaded graves.
    • isGraveLocked

      public boolean isGraveLocked(@NotNull @NotNull Grave grave)
      Checks whether the specified grave is currently locked (being viewed) by any player.
      Parameters:
      grave - the grave to check
      Returns:
      true if the grave is currently locked/in-use, otherwise false
    • isGraveLocked

      public boolean isGraveLocked(@NotNull @NotNull Grave grave, @NotNull @NotNull org.bukkit.entity.Player player)
      Checks whether the specified grave is locked by someone other than the provided player.
      Parameters:
      grave - the grave to check
      player - the player attempting access
      Returns:
      true if the grave is locked by another player, otherwise false
    • getGraveViewerUUID

      @Nullable public @Nullable UUID getGraveViewerUUID(@NotNull @NotNull Grave grave)
      Gets the UUID of the player currently viewing (locking) the specified grave.
      Parameters:
      grave - the grave to check
      Returns:
      the viewer's UUID if the grave is locked, or null if not locked
    • tryGetGraveViewerUUID

      public boolean tryGetGraveViewerUUID(@NotNull @NotNull Grave grave, @NotNull @NotNull UUID[] outViewer)
      Attempts to get the UUID of the player currently viewing (locking) a grave.

      If the grave is locked, the viewer UUID is written to outViewer[0] and this method returns true. If the grave is not locked, this method returns false and outViewer is unchanged.

      Parameters:
      grave - the grave to check
      outViewer - output array to receive the viewer UUID in outViewer[0] (length >= 1)
      Returns:
      true if the grave is locked, otherwise false
      Throws:
      GravesXIllegalArgumentException - if outViewer.length == 0
    • setGraveProtection

      public void setGraveProtection(@NotNull @NotNull Grave grave, boolean protectedGrave, long timeProtection)
      Updates the protection state and remaining protection time for an existing grave.

      This intentionally lives in the grave management API so Skript support does not modify grave internals directly.

      Parameters:
      grave - the grave to update
      protectedGrave - whether the grave should be protected
      timeProtection - the remaining protection time in milliseconds; ignored when protection is disabled
    • clearGraveProtection

      public void clearGraveProtection(@NotNull @NotNull Grave grave)
      Clears protection from an existing grave.
      Parameters:
      grave - the grave to update
    • getNextAvailableGraveSlot

      public int getNextAvailableGraveSlot(@NotNull @NotNull Grave grave)
      Gets the next empty inventory slot for the specified grave.
      Parameters:
      grave - the grave to inspect
      Returns:
      the next empty slot index, or -1 if no empty slot exists
    • hasAvailableGraveSlot

      public boolean hasAvailableGraveSlot(@NotNull @NotNull Grave grave)
      Checks whether the specified grave has at least one empty inventory slot.
      Parameters:
      grave - the grave to inspect
      Returns:
      true if the grave has an empty slot, otherwise false
    • addItemToGraveSlot

      public boolean addItemToGraveSlot(@NotNull @NotNull Grave grave, @NotNull @NotNull org.bukkit.inventory.ItemStack itemStack, int slot)
      Adds an item to a specific grave inventory slot if that slot is empty.

      Slot numbers are raw Bukkit inventory slot indexes. The first slot is 0.

      Parameters:
      grave - the grave to update
      itemStack - the item to add
      slot - the target slot index
      Returns:
      true if the item was added, otherwise false
    • setItemInGraveSlot

      public boolean setItemInGraveSlot(@NotNull @NotNull Grave grave, @NotNull @NotNull org.bukkit.inventory.ItemStack itemStack, int slot)
      Sets an item in a specific grave inventory slot, replacing any existing item in that slot.

      Slot numbers are raw Bukkit inventory slot indexes. The first slot is 0.

      Parameters:
      grave - the grave to update
      itemStack - the item to set
      slot - the target slot index
      Returns:
      true if the item was set, otherwise false
    • addItemToNextAvailableGraveSlot

      public int addItemToNextAvailableGraveSlot(@NotNull @NotNull Grave grave, @NotNull @NotNull org.bukkit.inventory.ItemStack itemStack)
      Adds an item to the next empty grave inventory slot.
      Parameters:
      grave - the grave to update
      itemStack - the item to add
      Returns:
      the slot index that received the item, or -1 if no slot was available