程序包 org.bukkit.inventory.meta.components

# 接口 ToolComponent

所有超级接口:
  `ConfigurationSerializable`

@Experimental public interface ToolComponent extends ConfigurationSerializable
Represents a component which can turn any item into a tool.

- ## 嵌套类概要

  嵌套类
  修饰符和类型
  接口
  说明
  `static interface`
  `ToolComponent.ToolRule`
  A rule governing use of this tool and overriding attributes per-block.

- ## 方法概要

  修饰符和类型
  方法
  说明
  `@NotNull ToolComponent.ToolRule`
  `addRule(@NotNull Collection<Material> blocks, @Nullable Float speed, @Nullable Boolean correctForDrops)`
  Add a new rule to this tool component, which provides further information about a collection of block types.
  `@NotNull ToolComponent.ToolRule`
  `addRule(@NotNull Material block, @Nullable Float speed, @Nullable Boolean correctForDrops)`
  Add a new rule to this tool component, which provides further information about a specific block type.
  `@NotNull ToolComponent.ToolRule`
  `addRule(@NotNull Tag<Material> tag, @Nullable Float speed, @Nullable Boolean correctForDrops)`
  Add a new rule to this tool component, which provides further information about a collection of block types represented by a block `Tag`.
  `int`
  `getDamagePerBlock()`
  Get the amount of durability to be removed from the tool each time a block is broken.
  `float`
  `getDefaultMiningSpeed()`
  Get the default mining speed of this tool.
  `@NotNull List<ToolComponent.ToolRule>`
  `getRules()`
  Get the list of `ToolRules` that apply to this tool.
  `boolean`
  `removeRule(@NotNull ToolComponent.ToolRule rule)`
  Remove the given `ToolComponent.ToolRule` from this tool.
  `void`
  `setDamagePerBlock(int damage)`
  Set the amount of durability to be removed from the tool each time a block is broken.
  `void`
  `setDefaultMiningSpeed(float speed)`
  Set the default mining speed of this tool.
  `void`
  `setRules(@NotNull List<ToolComponent.ToolRule> rules)`
  Set the list of `ToolRules` to apply to this tool.

  ### 从接口继承的方法 org.bukkit.configuration.serialization.ConfigurationSerializable

  `serialize`

- ## 方法详细资料

  - ### getDefaultMiningSpeed

    float getDefaultMiningSpeed()
    Get the default mining speed of this tool. This value is used by the tool if no rule explicitly overrides it. 1.0 is standard mining speed.
    返回:
      the default mining speed
    另请参阅:
      - `ToolComponent.ToolRule.getSpeed()`

  - ### setDefaultMiningSpeed

    void setDefaultMiningSpeed(float speed)
    Set the default mining speed of this tool. This value is used by the tool if no rule explicitly overrides it. 1.0 is standard mining speed.
    参数:
      `speed` - the speed to set

  - ### getDamagePerBlock

    int getDamagePerBlock()
    Get the amount of durability to be removed from the tool each time a block is broken.
    返回:
      the damage per block

  - ### setDamagePerBlock

    void setDamagePerBlock(int damage)
    Set the amount of durability to be removed from the tool each time a block is broken.
    参数:
      `damage` - the damage to set. Must be 0 or a positive integer

  - ### getRules

    @NotNull @NotNull List<ToolComponent.ToolRule> getRules()
    Get the list of `ToolRules` that apply to this tool.
    返回:
      all tool rules. The mutability of the returned list cannot be guaranteed, but its contents are mutable and can have their values changed

  - ### setRules

    void setRules(@NotNull @NotNull List<ToolComponent.ToolRule> rules)
    Set the list of `ToolRules` to apply to this tool. This will remove any existing tool rules.
    参数:
      `rules` - the rules to set

  - ### addRule

    @NotNull @NotNull ToolComponent.ToolRule addRule(@NotNull @NotNull Material block, @Nullable @Nullable Float speed, @Nullable @Nullable Boolean correctForDrops)
    Add a new rule to this tool component, which provides further information about a specific block type.
    参数:
      `block` - the block type to which the rule applies
      `speed` - the mining speed to use when mining the block, or null to use the default mining speed
      `correctForDrops` - whether or not this tool, when mining the block, is considered the optimal tool for the block and will drop its items when broken, or null to use the default tool checking behavior defined by Minecraft
    返回:
      the `ToolComponent.ToolRule` instance that was added to this tool

  - ### addRule

    @NotNull @NotNull ToolComponent.ToolRule addRule(@NotNull @NotNull Collection<Material> blocks, @Nullable @Nullable Float speed, @Nullable @Nullable Boolean correctForDrops)
    Add a new rule to this tool component, which provides further information about a collection of block types.
    参数:
      `blocks` - the block types to which the rule applies
      `speed` - the mining speed to use when mining one of the blocks, or null to use the default mining speed
      `correctForDrops` - whether or not this tool, when mining one of the blocks, is considered the optimal tool for the block and will drop its items when broken, or null to use the default tool checking behavior defined by Minecraft
    返回:
      the `ToolComponent.ToolRule` instance that was added to this tool

  - ### addRule

    @NotNull @NotNull ToolComponent.ToolRule addRule(@NotNull @NotNull Tag<Material> tag, @Nullable @Nullable Float speed, @Nullable @Nullable Boolean correctForDrops)
    Add a new rule to this tool component, which provides further information about a collection of block types represented by a block `Tag`.
    参数:
      `tag` - the block tag containing block types to which the rule applies.
      `speed` - the mining speed to use when mining one of the blocks, or null to use the default mining speed
      `correctForDrops` - whether or not this tool, when mining one of the blocks, is considered the optimal tool for the block and will drop its items when broken, or null to use the default tool checking behavior defined by Minecraft
    返回:
      the `ToolComponent.ToolRule` instance that was added to this tool
    抛出:
      `IllegalArgumentException` - if the passed `tag` is not a block tag

  - ### removeRule

    boolean removeRule(@NotNull @NotNull ToolComponent.ToolRule rule)
    Remove the given `ToolComponent.ToolRule` from this tool.
    参数:
      `rule` - the rule to remove
    返回:
      true if the rule was removed, false if this component did not contain a matching rule