Class CompatibilityMaterialData

java.lang.Object
com.ranull.graves.compatibility.CompatibilityMaterialData
All Implemented Interfaces:
Compatibility

public final class CompatibilityMaterialData extends Object implements Compatibility
An implementation of the Compatibility interface for handling material data.
  • Constructor Details

    • CompatibilityMaterialData

      public CompatibilityMaterialData()
  • Method Details

    • setBlockData

      public BlockData setBlockData(org.bukkit.Location location, org.bukkit.Material material, Grave grave, Graves plugin)
      Sets the block data for a given location and material, associating it with a grave.
      Specified by:
      setBlockData in interface Compatibility
      Parameters:
      location - The location where the block data should be set.
      material - The material of the block to set.
      grave - The grave associated with the block.
      plugin - The Graves plugin instance.
      Returns:
      The BlockData representing the set block data.
    • canBuild

      public boolean canBuild(org.bukkit.entity.Player player, org.bukkit.Location location, Graves plugin)
      Checks if a player can build at a given location by simulating a block placement.

      This method supports both modern (1.9+) and legacy (1.8 and below) servers. On modern servers, it attempts placement with both main and off hand items. On legacy servers, it falls back to the deprecated BlockPlaceEvent constructor.

      Specified by:
      canBuild in interface Compatibility
      Parameters:
      player - The player attempting to build.
      location - The location where the block would be placed.
      plugin - The instance of the Graves plugin, used for version checking and event dispatch.
      Returns:
      true if the player is allowed to build at the specified location; false otherwise.
    • getEnumConstant

      private static <T extends Enum<T>> T getEnumConstant(Class<?> enumClass, String name)
    • hasTitleData

      public boolean hasTitleData(org.bukkit.block.Block block)
      Checks if a block has title data (e.g., a name or custom title). Supports signs (both front and back sides for 1.20+), skulls, and nameable containers.
      Specified by:
      hasTitleData in interface Compatibility
      Parameters:
      block - The block to check.
      Returns:
      True if the block has title data, false otherwise.
    • updateSkullBlock

      private void updateSkullBlock(org.bukkit.block.Block block, Grave grave, Graves plugin)
      Updates the skull block with the owner or texture data.
      Parameters:
      block - The skull block to update.
      grave - The grave associated with the skull.
      plugin - The Graves plugin instance.
    • getSkullItemStack

      public org.bukkit.inventory.ItemStack getSkullItemStack(Grave grave, Graves plugin)
      Gets the skull item stack for a given grave.
      Specified by:
      getSkullItemStack in interface Compatibility
      Parameters:
      grave - The grave associated with the skull.
      plugin - The Graves plugin instance.
      Returns:
      The ItemStack representing the skull.
    • getSkullTexture

      public String getSkullTexture(org.bukkit.inventory.ItemStack itemStack)
      Gets the texture of a skull item stack.
      Specified by:
      getSkullTexture in interface Compatibility
      Parameters:
      itemStack - The item stack representing the skull.
      Returns:
      The texture of the skull as a string.