Commits
md_5 authored 944aa2003b1
1 - | From 6a7d6bd4e8e3175db58638c137135ed21d50fefa Mon Sep 17 00:00:00 2001 |
1 + | From b1654ad7e863e76d060a7d21c240a56709bdfcf0 Mon Sep 17 00:00:00 2001 |
2 2 | From: md_5 <md_5@live.com.au> |
3 3 | Date: Sun, 2 Jun 2013 15:57:09 +1000 |
4 4 | Subject: [PATCH] Add Particle API |
5 5 | |
6 6 | |
7 7 | diff --git a/src/main/java/org/bukkit/Effect.java b/src/main/java/org/bukkit/Effect.java |
8 - | index fe29e1c..f28fecd 100644 |
8 + | index ba7dc49..b0f6da7 100644 |
9 9 | --- a/src/main/java/org/bukkit/Effect.java |
10 10 | +++ b/src/main/java/org/bukkit/Effect.java |
11 11 | |
12 12 | import com.google.common.collect.Maps; |
13 13 | |
14 14 | import org.bukkit.block.BlockFace; |
15 15 | +import org.bukkit.material.MaterialData; |
16 16 | import org.bukkit.potion.Potion; |
17 17 | |
18 18 | /** |
19 - | |
20 - | /** |
21 - | * The flames seen on a mobspawner; a visual effect. |
19 + | |
20 + | * The sound of an enderdragon growling |
22 21 | */ |
23 - | - MOBSPAWNER_FLAMES(2004, Type.VISUAL); |
24 - | + MOBSPAWNER_FLAMES(2004, Type.VISUAL), |
22 + | ENDERDRAGON_GROWL(3001, Type.SOUND), |
25 23 | + /** |
26 24 | + * The spark that comes off a fireworks |
27 25 | + */ |
28 26 | + FIREWORKS_SPARK("fireworksSpark", Type.PARTICLE), |
29 27 | + /** |
30 28 | + * Critical hit particles |
31 29 | + */ |
32 30 | + CRIT("crit", Type.PARTICLE), |
33 31 | + /** |
34 32 | + * Blue critical hit particles |
158 156 | + ITEM_BREAK("iconcrack", Type.PARTICLE, Material.class), |
159 157 | + /** |
160 158 | + * The particles generated while breaking a block. |
161 159 | + * This particle requires a Material and data value so that the client can select the correct texture. |
162 160 | + */ |
163 161 | + TILE_BREAK("blockcrack", Type.PARTICLE, MaterialData.class), |
164 162 | + /** |
165 163 | + * The particles generated while sprinting a block |
166 164 | + * This particle requires a Material and data value so that the client can select the correct texture. |
167 165 | + */ |
168 - | + TILE_DUST("blockdust", Type.PARTICLE, MaterialData.class); |
166 + | + TILE_DUST("blockdust", Type.PARTICLE, MaterialData.class) |
167 + | ; |
169 168 | |
170 169 | private final int id; |
171 170 | private final Type type; |
172 171 | private final Class<?> data; |
173 172 | private static final Map<Integer, Effect> BY_ID = Maps.newHashMap(); |
174 173 | + private static final Map<String, Effect> BY_NAME = Maps.newHashMap(); |
175 174 | + private final String particleName; |
176 175 | |
177 176 | - Effect(int id, Type type) { |
178 177 | + private Effect(int id, Type type) { |
202 201 | } |
203 202 | |
204 203 | /** |
205 204 | * Gets the ID for this effect. |
206 205 | * |
207 206 | - * @return ID of this effect |
208 207 | + * @return if this Effect isn't of type PARTICLE it returns ID of this effect |
209 208 | * @deprecated Magic value |
210 209 | */ |
211 210 | @Deprecated |
212 - | |
211 + | |
213 212 | } |
214 213 | |
215 214 | /** |
216 215 | + * Returns the effect's name. This returns null if the effect is not a particle |
217 216 | + * |
218 217 | + * @return The effect's name |
219 218 | + */ |
220 219 | + public String getName() { |
221 220 | + return particleName; |
222 221 | + } |
223 222 | + |
224 223 | + /** |
225 224 | * @return The type of the effect. |
226 225 | */ |
227 226 | public Type getType() { |
228 - | |
227 + | |
229 228 | } |
230 229 | |
231 230 | /** |
232 231 | - * @return The class which represents data for this effect, or null if |
233 232 | - * none |
234 233 | + * @return if this Effect isn't of type PARTICLE it returns the class which represents data for this effect, or null if none |
235 234 | */ |
236 235 | public Class<?> getData() { |
237 236 | return this.data; |
238 - | |
237 + | |
239 238 | |
240 239 | static { |
241 240 | for (Effect effect : values()) { |
242 241 | - BY_ID.put(effect.id, effect); |
243 242 | + if (effect.type != Type.PARTICLE) { |
244 243 | + BY_ID.put(effect.id, effect); |
245 244 | + } |
246 245 | + } |
247 246 | + } |
248 247 | + |