Bukkit-API  1.7.9-R0.2
The inofficial Bukkit-API
TreeSpecies.java
1 package org.bukkit;
2 
3 import java.util.Map;
4 
5 import com.google.common.collect.Maps;
6 
7 /**
8  * Represents the different species of trees regardless of size.
9  */
10 public enum TreeSpecies {
11 
12  /**
13  * Represents the common tree species.
14  */
15  GENERIC(0x0),
16  /**
17  * Represents the darker barked/leaved tree species.
18  */
19  REDWOOD(0x1),
20  /**
21  * Represents birches.
22  */
23  BIRCH(0x2),
24  /**
25  * Represents jungle trees.
26  */
27  JUNGLE(0x3),
28  /**
29  * Represents acacia trees.
30  */
31  ACACIA(0x4),
32  /**
33  * Represents dark oak trees.
34  */
35  DARK_OAK(0x5),
36  ;
37 
38  private final byte data;
39  private final static Map<Byte, TreeSpecies> BY_DATA = Maps.newHashMap();
40 
41  private TreeSpecies(final int data) {
42  this.data = (byte) data;
43  }
44 
45  /**
46  * Gets the associated data value representing this species
47  *
48  * @return A byte containing the data value of this tree species
49  * @deprecated Magic value
50  */
51  @Deprecated
52  public byte getData() {
53  return data;
54  }
55 
56  /**
57  * Gets the TreeSpecies with the given data value
58  *
59  * @param data Data value to fetch
60  * @return The {@link TreeSpecies} representing the given value, or null
61  * if it doesn't exist
62  * @deprecated Magic value
63  */
64  @Deprecated
65  public static TreeSpecies getByData(final byte data) {
66  return BY_DATA.get(data);
67  }
68 
69  static {
70  for (TreeSpecies species : values()) {
71  BY_DATA.put(species.data, species);
72  }
73  }
74 }
static TreeSpecies getByData(final byte data)