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

    Constructors
    Constructor
    Description
    CustomToolRule(@NotNull Collection<org.bukkit.Material> blocks, @Nullable Float speed, @Nullable Boolean correctForDrops)
    Constructs a new CustomToolRule.
  • Method Summary

    Modifier and Type
    Method
    Description
    @NotNull Collection<org.bukkit.Material>
    Gets the collection of blocks this rule applies to.
    @Nullable Float
    Gets the mining speed for this rule.
    @Nullable Boolean
    Get whether this rule is considered the optimal tool for the blocks listed by this rule and will drop items.
    @NotNull Map<String,Object>
    Serializes this tool rule into a map for data storage.
    void
    setBlocks(@NotNull Collection<org.bukkit.Material> blocks)
    Sets the rule to apply to a collection of block materials.
    void
    setBlocks(@NotNull org.bukkit.Material block)
    Sets the rule to apply to a single block material.
    void
    setBlocks(@NotNull org.bukkit.Tag<org.bukkit.Material> tag)
    Sets the rule to apply to blocks within a tag.
    void
    setCorrectForDrops(@Nullable Boolean correct)
    Set whether this rule is considered the optimal tool for the blocks listed by this rule and will drop items.
    void
    setSpeed(@Nullable Float speed)
    Sets the mining speed for this rule.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • 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 to
      speed - the custom mining speed, or null to use the default
      correctForDrops - whether the rule affects drops or null for default behavior
  • Method Details

    • getBlocks

      @NotNull public @NotNull Collection<org.bukkit.Material> getBlocks()
      Gets the collection of blocks this rule applies to.
      Specified by:
      getBlocks in interface org.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:
      setBlocks in interface org.bukkit.inventory.meta.components.ToolComponent.ToolRule
      Parameters:
      block - the material to set
    • setBlocks

      public void setBlocks(@NotNull @NotNull Collection<org.bukkit.Material> blocks)
      Sets the rule to apply to a collection of block materials.
      Specified by:
      setBlocks in interface org.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:
      setBlocks in interface org.bukkit.inventory.meta.components.ToolComponent.ToolRule
      Parameters:
      tag - the tag containing the blocks this rule should apply to
    • getSpeed

      @Nullable public @Nullable Float getSpeed()
      Gets the mining speed for this rule.
      Specified by:
      getSpeed in interface org.bukkit.inventory.meta.components.ToolComponent.ToolRule
      Returns:
      the mining speed, or null if using the default speed
    • setSpeed

      public void setSpeed(@Nullable @Nullable Float speed)
      Sets the mining speed for this rule.
      Specified by:
      setSpeed in interface org.bukkit.inventory.meta.components.ToolComponent.ToolRule
      Parameters:
      speed - the new mining speed, or null to reset to default
    • isCorrectForDrops

      @Nullable public @Nullable Boolean isCorrectForDrops()
      Get whether this rule is considered the optimal tool for the blocks listed by this rule and will drop items.
      Specified by:
      isCorrectForDrops in interface org.bukkit.inventory.meta.components.ToolComponent.ToolRule
      Returns:
      true if drop correction is enabled, false otherwise, or null for default behavior
    • setCorrectForDrops

      public void setCorrectForDrops(@Nullable @Nullable Boolean correct)
      Set whether this rule is considered the optimal tool for the blocks listed by this rule and will drop items.
      Specified by:
      setCorrectForDrops in interface org.bukkit.inventory.meta.components.ToolComponent.ToolRule
      Parameters:
      correct - true to enable drop correction, false to disable, or null for default
    • serialize

      @NotNull public @NotNull Map<String,Object> serialize()
      Serializes this tool rule into a map for data storage.
      Specified by:
      serialize in interface org.bukkit.configuration.serialization.ConfigurationSerializable
      Returns:
      a map containing the blocks, mining speed, and drop correction settings