Interface ToolComponent
- All Superinterfaces:
- ConfigurationSerializable
Represents a component which can turn any item into a tool.
- 
Nested Class SummaryNested ClassesModifier and TypeInterfaceDescriptionstatic interfaceA rule governing use of this tool and overriding attributes per-block.
- 
Method SummaryModifier and TypeMethodDescriptionaddRule(Collection<Material> blocks, Float speed, Boolean correctForDrops) Add a new rule to this tool component, which provides further information about a collection of block types.Add a new rule to this tool component, which provides further information about a specific block type.Add a new rule to this tool component, which provides further information about a collection of block types represented by a blockTag.intGet the amount of durability to be removed from the tool each time a block is broken.floatGet the default mining speed of this tool.getRules()Get the list ofToolRulesthat apply to this tool.booleanRemove the givenToolComponent.ToolRulefrom this tool.voidsetDamagePerBlock(int damage) Set the amount of durability to be removed from the tool each time a block is broken.voidsetDefaultMiningSpeed(float speed) Set the default mining speed of this tool.voidsetRules(List<ToolComponent.ToolRule> rules) Set the list ofToolRulesto apply to this tool.Methods inherited from interface org.bukkit.configuration.serialization.ConfigurationSerializableserialize
- 
Method Details- 
getDefaultMiningSpeedfloat 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.- Returns:
- the default mining speed
- See Also:
 
- 
setDefaultMiningSpeedvoid 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.- Parameters:
- speed- the speed to set
 
- 
getDamagePerBlockint getDamagePerBlock()Get the amount of durability to be removed from the tool each time a block is broken.- Returns:
- the damage per block
 
- 
setDamagePerBlockvoid setDamagePerBlock(int damage) Set the amount of durability to be removed from the tool each time a block is broken.- Parameters:
- damage- the damage to set. Must be 0 or a positive integer
 
- 
getRulesGet the list ofToolRulesthat apply to this tool.- Returns:
- all tool rules. The mutability of the returned list cannot be guaranteed, but its contents are mutable and can have their values changed
 
- 
setRulesSet the list ofToolRulesto apply to this tool. This will remove any existing tool rules.- Parameters:
- rules- the rules to set
 
- 
addRule@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.- Parameters:
- 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
- Returns:
- the ToolComponent.ToolRuleinstance that was added to this tool
 
- 
addRule@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.- Parameters:
- 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
- Returns:
- the ToolComponent.ToolRuleinstance that was added to this tool
 
- 
addRule@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 blockTag.- Parameters:
- 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
- Returns:
- the ToolComponent.ToolRuleinstance that was added to this tool
- Throws:
- IllegalArgumentException- if the passed- tagis not a block tag
 
- 
removeRuleRemove the givenToolComponent.ToolRulefrom this tool.- Parameters:
- rule- the rule to remove
- Returns:
- true if the rule was removed, false if this component did not contain a matching rule
 
 
-