Commits
DerFrZocker authored 391cc14539a
1 1 | package org.bukkit.inventory.meta.components; |
2 2 | |
3 3 | import java.util.Collection; |
4 4 | import java.util.List; |
5 - | import org.bukkit.Material; |
6 5 | import org.bukkit.Tag; |
6 + | import org.bukkit.block.BlockType; |
7 7 | import org.bukkit.configuration.serialization.ConfigurationSerializable; |
8 8 | import org.jetbrains.annotations.ApiStatus; |
9 9 | import org.jetbrains.annotations.NotNull; |
10 10 | import org.jetbrains.annotations.Nullable; |
11 11 | |
12 12 | /** |
13 13 | * Represents a component which can turn any item into a tool. |
14 14 | */ |
15 15 | Experimental | .
16 16 | public interface ToolComponent extends ConfigurationSerializable { |
73 73 | * @param block the block type to which the rule applies |
74 74 | * @param speed the mining speed to use when mining the block, or null to |
75 75 | * use the default mining speed |
76 76 | * @param correctForDrops whether or not this tool, when mining the block, |
77 77 | * is considered the optimal tool for the block and will drop its items when |
78 78 | * broken, or null to use the default tool checking behavior defined by |
79 79 | * Minecraft |
80 80 | * @return the {@link ToolRule} instance that was added to this tool |
81 81 | */ |
82 82 | |
83 - | ToolRule addRule( Material block, Float speed, Boolean correctForDrops); |
83 + | ToolRule addRule( BlockType block, Float speed, Boolean correctForDrops); |
84 84 | |
85 85 | /** |
86 86 | * Add a new rule to this tool component, which provides further information |
87 87 | * about a collection of block types. |
88 88 | * |
89 89 | * @param blocks the block types to which the rule applies |
90 90 | * @param speed the mining speed to use when mining one of the blocks, or |
91 91 | * null to use the default mining speed |
92 92 | * @param correctForDrops whether or not this tool, when mining one of the |
93 93 | * blocks, is considered the optimal tool for the block and will drop its |
94 94 | * items when broken, or null to use the default tool checking behavior |
95 95 | * defined by Minecraft |
96 96 | * @return the {@link ToolRule} instance that was added to this tool |
97 97 | */ |
98 98 | |
99 - | ToolRule addRule( Collection<Material> blocks, Float speed, Boolean correctForDrops); |
99 + | ToolRule addRule( Collection<BlockType> blocks, Float speed, Boolean correctForDrops); |
100 100 | |
101 101 | /** |
102 102 | * Add a new rule to this tool component, which provides further information |
103 103 | * about a collection of block types represented by a block {@link Tag}. |
104 104 | * |
105 105 | * @param tag the block tag containing block types to which the rule |
106 106 | * applies. |
107 107 | * @param speed the mining speed to use when mining one of the blocks, or |
108 108 | * null to use the default mining speed |
109 109 | * @param correctForDrops whether or not this tool, when mining one of the |
110 110 | * blocks, is considered the optimal tool for the block and will drop its |
111 111 | * items when broken, or null to use the default tool checking behavior |
112 112 | * defined by Minecraft |
113 113 | * @return the {@link ToolRule} instance that was added to this tool |
114 114 | * @throws IllegalArgumentException if the passed {@code tag} is not a block |
115 115 | * tag |
116 116 | */ |
117 117 | |
118 - | ToolRule addRule( Tag<Material> tag, Float speed, Boolean correctForDrops); |
118 + | ToolRule addRule( Tag<BlockType> tag, Float speed, Boolean correctForDrops); |
119 119 | |
120 120 | /** |
121 121 | * Remove the given {@link ToolRule} from this tool. |
122 122 | * |
123 123 | * @param rule the rule to remove |
124 124 | * @return true if the rule was removed, false if this component did not |
125 125 | * contain a matching rule |
126 126 | */ |
127 127 | boolean removeRule( ToolRule rule); |
128 128 | |
129 129 | /** |
130 130 | * A rule governing use of this tool and overriding attributes per-block. |
131 131 | */ |
132 132 | public interface ToolRule extends ConfigurationSerializable { |
133 133 | |
134 134 | /** |
135 135 | * Get a collection of the block types to which this tool rule applies. |
136 136 | * |
137 137 | * @return the blocks |
138 138 | */ |
139 139 | |
140 - | Collection<Material> getBlocks(); |
140 + | Collection<BlockType> getBlocks(); |
141 141 | |
142 142 | /** |
143 143 | * Set the block type to which this rule applies. |
144 144 | * |
145 145 | * @param block the block type |
146 146 | */ |
147 - | void setBlocks( Material block); |
147 + | void setBlocks( BlockType block); |
148 148 | |
149 149 | /** |
150 150 | * Set the block types to which this rule applies. |
151 151 | * |
152 152 | * @param blocks the block types |
153 153 | */ |
154 - | void setBlocks( Collection<Material> blocks); |
154 + | void setBlocks( Collection<BlockType> blocks); |
155 155 | |
156 156 | /** |
157 157 | * Set the block types (represented as a block {@link Tag}) to which |
158 158 | * this rule applies. |
159 159 | * |
160 160 | * @param tag the block tag |
161 161 | * @throws IllegalArgumentException if the passed {@code tag} is not a |
162 162 | * block tag |
163 163 | */ |
164 - | void setBlocks( Tag<Material> tag); |
164 + | void setBlocks( Tag<BlockType> tag); |
165 165 | |
166 166 | /** |
167 167 | * Get the mining speed of this rule. If non-null, this speed value is |
168 168 | * used in lieu of the default speed value of the tool. 1.0 is standard |
169 169 | * mining speed. |
170 170 | * |
171 171 | * @return the mining speed, or null if the default speed is used |
172 172 | */ |
173 173 | |
174 174 | Float getSpeed(); |