Package com.ranull.graves.compatibility
Class CompatibilityMaterialData
java.lang.Object
com.ranull.graves.compatibility.CompatibilityMaterialData
- All Implemented Interfaces:
Compatibility
An implementation of the Compatibility interface for handling material data.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionboolean
Checks if a player can build at a given location by simulating a block placement.private static <T extends Enum<T>>
TgetEnumConstant
(Class<?> enumClass, String name) org.bukkit.inventory.ItemStack
getSkullItemStack
(Grave grave, Graves plugin) Gets the skull item stack for a given grave.getSkullTexture
(org.bukkit.inventory.ItemStack itemStack) Gets the texture of a skull item stack.boolean
hasTitleData
(org.bukkit.block.Block block) Checks if a block has title data (e.g., a name or custom title).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.private void
updateSkullBlock
(org.bukkit.block.Block block, Grave grave, Graves plugin) Updates the skull block with the owner or texture 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 interfaceCompatibility
- 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 interfaceCompatibility
- 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
-
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 interfaceCompatibility
- Parameters:
block
- The block to check.- Returns:
- True if the block has title data, false otherwise.
-
updateSkullBlock
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
Gets the skull item stack for a given grave.- Specified by:
getSkullItemStack
in interfaceCompatibility
- Parameters:
grave
- The grave associated with the skull.plugin
- The Graves plugin instance.- Returns:
- The ItemStack representing the skull.
-
getSkullTexture
Gets the texture of a skull item stack.- Specified by:
getSkullTexture
in interfaceCompatibility
- Parameters:
itemStack
- The item stack representing the skull.- Returns:
- The texture of the skull as a string.
-