Fork of Poseidon providing Bukkit #1060 to older Beta versions (b1.0-b1.7.3)
1package org.bukkit;
2
3import java.util.HashMap;
4import java.util.Map;
5
6/**
7 * Represents the different types of grass.
8 */
9public enum GrassSpecies {
10
11 /**
12 * Represents the dead looking grass.
13 */
14 DEAD((byte) 0x0),
15 /**
16 * Represents the normal grass species.
17 */
18 NORMAL((byte) 0x1),
19 /**
20 * Represents the fern-looking grass species.
21 */
22 FERN_LIKE((byte) 0x2);
23
24 private final byte data;
25 private final static Map<Byte, GrassSpecies> species = new HashMap<Byte, GrassSpecies>();
26
27 private GrassSpecies(final byte data) {
28 this.data = data;
29 }
30
31 /**
32 * Gets the associated data value representing this species
33 *
34 * @return A byte containing the data value of this grass species
35 */
36 public byte getData() {
37 return data;
38 }
39
40 /**
41 * Gets the GrassSpecies with the given data value
42 *
43 * @param data Data value to fetch
44 * @return The {@link GrassSpecies} representing the given value, or null if
45 * it doesn't exist
46 */
47 public static GrassSpecies getByData(final byte data) {
48 return species.get(data);
49 }
50
51 static {
52 for (GrassSpecies s : GrassSpecies.values()) {
53 species.put(s.getData(), s);
54 }
55 }
56}