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 species of trees regardless of size.
8 *
9 * @author sunkid
10 */
11public enum TreeSpecies {
12
13 /**
14 * Represents the common tree species.
15 */
16 GENERIC((byte) 0x0),
17 /**
18 * Represents the darker barked/leaved tree species.
19 */
20 REDWOOD((byte) 0x1),
21 /**
22 * Represents birches.
23 */
24 BIRCH((byte) 0x2);
25
26 private final byte data;
27 private final static Map<Byte, TreeSpecies> species = new HashMap<Byte, TreeSpecies>();
28
29 private TreeSpecies(final byte data) {
30 this.data = data;
31 }
32
33 /**
34 * Gets the associated data value representing this species
35 *
36 * @return A byte containing the data value of this tree species
37 */
38 public byte getData() {
39 return data;
40 }
41
42 /**
43 * Gets the TreeSpecies with the given data value
44 *
45 * @param data Data value to fetch
46 * @return The {@link TreeSpecies} representing the given value, or null if
47 * it doesn't exist
48 */
49 public static TreeSpecies getByData(final byte data) {
50 return species.get(data);
51 }
52
53 static {
54 for (TreeSpecies s : TreeSpecies.values()) {
55 species.put(s.getData(), s);
56 }
57 }
58}