mirror of
https://github.com/PaperMC/Paper.git
synced 2025-08-14 03:35:51 -07:00
added MaterialData classes and associated Enums for COAL, CROPS, LOG, LEAVES, STEP, and DOUBLE_STEP
By: sunkid <sunkid@iminurnetz.com>
This commit is contained in:
58
paper-api/src/main/java/org/bukkit/TreeSpecies.java
Normal file
58
paper-api/src/main/java/org/bukkit/TreeSpecies.java
Normal file
@@ -0,0 +1,58 @@
|
||||
package org.bukkit;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* Represents the different species of trees regardless of size.
|
||||
* @author sunkid
|
||||
*/
|
||||
public enum TreeSpecies {
|
||||
|
||||
/**
|
||||
* Represents the common tree species.
|
||||
*/
|
||||
GENERIC((byte) 0x0),
|
||||
/**
|
||||
* Represents the darker barked/leaved tree species.
|
||||
*/
|
||||
REDWOOD((byte) 0x1),
|
||||
/**
|
||||
* Represents birches.
|
||||
*/
|
||||
BIRCH((byte) 0x2);
|
||||
|
||||
private final byte data;
|
||||
private final static Map<Byte, TreeSpecies> species = new HashMap<Byte, TreeSpecies>();
|
||||
|
||||
private TreeSpecies(final byte data) {
|
||||
this.data = data;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the associated data value representing this species
|
||||
*
|
||||
* @return A byte containing the data value of this tree species
|
||||
*/
|
||||
public byte getData() {
|
||||
return data;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the TreeSpecies with the given data value
|
||||
*
|
||||
* @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);
|
||||
}
|
||||
|
||||
static {
|
||||
for (TreeSpecies s : TreeSpecies.values()) {
|
||||
species.put(s.getData(), s);
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user