Class CustomToolComponent.CustomToolRule
java.lang.Object
io.github.lucfr1746.llibrary.itemstack.component.CustomToolComponent.CustomToolRule
- All Implemented Interfaces:
org.bukkit.configuration.serialization.ConfigurationSerializable,org.bukkit.inventory.meta.components.ToolComponent.ToolRule
- Enclosing class:
CustomToolComponent
public static class CustomToolComponent.CustomToolRule
extends Object
implements org.bukkit.inventory.meta.components.ToolComponent.ToolRule
Represents a custom implementation of the
ToolComponent.ToolRule interface.
This class defines rules for how a tool interacts with specific blocks,
including custom mining speeds and drop behavior.-
Constructor Summary
ConstructorsConstructorDescriptionCustomToolRule(@NotNull Collection<org.bukkit.Material> blocks, @Nullable Float speed, @Nullable Boolean correctForDrops) Constructs a new CustomToolRule. -
Method Summary
Modifier and TypeMethodDescription@NotNull Collection<org.bukkit.Material> Gets the collection of blocks this rule applies to.@Nullable FloatgetSpeed()Gets the mining speed for this rule.@Nullable BooleanGet whether this rule is considered the optimal tool for the blocks listed by this rule and will drop items.Serializes this tool rule into a map for data storage.voidsetBlocks(@NotNull Collection<org.bukkit.Material> blocks) Sets the rule to apply to a collection of block materials.voidsetBlocks(@NotNull org.bukkit.Material block) Sets the rule to apply to a single block material.voidsetBlocks(@NotNull org.bukkit.Tag<org.bukkit.Material> tag) Sets the rule to apply to blocks within a tag.voidsetCorrectForDrops(@Nullable Boolean correct) Set whether this rule is considered the optimal tool for the blocks listed by this rule and will drop items.voidSets the mining speed for this rule.
-
Constructor Details
-
CustomToolRule
public CustomToolRule(@NotNull @NotNull Collection<org.bukkit.Material> blocks, @Nullable @Nullable Float speed, @Nullable @Nullable Boolean correctForDrops) Constructs a new CustomToolRule.- Parameters:
blocks- the collection of block materials this rule applies tospeed- the custom mining speed, or null to use the defaultcorrectForDrops- whether the rule affects drops or null for default behavior
-
-
Method Details
-
getBlocks
Gets the collection of blocks this rule applies to.- Specified by:
getBlocksin interfaceorg.bukkit.inventory.meta.components.ToolComponent.ToolRule- Returns:
- an unmodifiable collection of block materials
-
setBlocks
public void setBlocks(@NotNull @NotNull org.bukkit.Material block) Sets the rule to apply to a single block material.- Specified by:
setBlocksin interfaceorg.bukkit.inventory.meta.components.ToolComponent.ToolRule- Parameters:
block- the material to set
-
setBlocks
Sets the rule to apply to a collection of block materials.- Specified by:
setBlocksin interfaceorg.bukkit.inventory.meta.components.ToolComponent.ToolRule- Parameters:
blocks- the collection of materials to set
-
setBlocks
public void setBlocks(@NotNull @NotNull org.bukkit.Tag<org.bukkit.Material> tag) Sets the rule to apply to blocks within a tag.- Specified by:
setBlocksin interfaceorg.bukkit.inventory.meta.components.ToolComponent.ToolRule- Parameters:
tag- the tag containing the blocks this rule should apply to
-
getSpeed
Gets the mining speed for this rule.- Specified by:
getSpeedin interfaceorg.bukkit.inventory.meta.components.ToolComponent.ToolRule- Returns:
- the mining speed, or null if using the default speed
-
setSpeed
Sets the mining speed for this rule.- Specified by:
setSpeedin interfaceorg.bukkit.inventory.meta.components.ToolComponent.ToolRule- Parameters:
speed- the new mining speed, or null to reset to default
-
isCorrectForDrops
Get whether this rule is considered the optimal tool for the blocks listed by this rule and will drop items.- Specified by:
isCorrectForDropsin interfaceorg.bukkit.inventory.meta.components.ToolComponent.ToolRule- Returns:
- true if drop correction is enabled, false otherwise, or null for default behavior
-
setCorrectForDrops
Set whether this rule is considered the optimal tool for the blocks listed by this rule and will drop items.- Specified by:
setCorrectForDropsin interfaceorg.bukkit.inventory.meta.components.ToolComponent.ToolRule- Parameters:
correct- true to enable drop correction, false to disable, or null for default
-
serialize
Serializes this tool rule into a map for data storage.- Specified by:
serializein interfaceorg.bukkit.configuration.serialization.ConfigurationSerializable- Returns:
- a map containing the blocks, mining speed, and drop correction settings
-