mirror of
https://github.com/PaperMC/Paper.git
synced 2025-08-14 11:45:52 -07:00
@@ -1,8 +1,9 @@
|
||||
package org.bukkit;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import com.google.common.collect.Maps;
|
||||
|
||||
/**
|
||||
* Represents the different species of trees regardless of size.
|
||||
*/
|
||||
@@ -11,21 +12,21 @@ public enum TreeSpecies {
|
||||
/**
|
||||
* Represents the common tree species.
|
||||
*/
|
||||
GENERIC((byte) 0x0),
|
||||
GENERIC(0x0),
|
||||
/**
|
||||
* Represents the darker barked/leaved tree species.
|
||||
*/
|
||||
REDWOOD((byte) 0x1),
|
||||
REDWOOD(0x1),
|
||||
/**
|
||||
* Represents birches.
|
||||
*/
|
||||
BIRCH((byte) 0x2);
|
||||
BIRCH(0x2);
|
||||
|
||||
private final byte data;
|
||||
private final static Map<Byte, TreeSpecies> species = new HashMap<Byte, TreeSpecies>();
|
||||
private final static Map<Byte, TreeSpecies> BY_DATA = Maps.newHashMap();
|
||||
|
||||
private TreeSpecies(final byte data) {
|
||||
this.data = data;
|
||||
private TreeSpecies(final int data) {
|
||||
this.data = (byte) data;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -40,18 +41,17 @@ public enum TreeSpecies {
|
||||
/**
|
||||
* Gets the TreeSpecies with the given data value
|
||||
*
|
||||
* @param data
|
||||
* Data value to fetch
|
||||
* @param data Data value to fetch
|
||||
* @return The {@link TreeSpecies} representing the given value, or null if
|
||||
* it doesn't exist
|
||||
*/
|
||||
public static TreeSpecies getByData(final byte data) {
|
||||
return species.get(data);
|
||||
return BY_DATA.get(data);
|
||||
}
|
||||
|
||||
static {
|
||||
for (TreeSpecies s : TreeSpecies.values()) {
|
||||
species.put(s.getData(), s);
|
||||
for (TreeSpecies species : values()) {
|
||||
BY_DATA.put(species.data, species);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user