mirror of
https://github.com/PaperMC/Paper.git
synced 2025-01-17 23:01:01 +01: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:
parent
e36fc0c867
commit
f240cdf831
9 changed files with 427 additions and 6 deletions
47
paper-api/src/main/java/org/bukkit/CoalType.java
Normal file
47
paper-api/src/main/java/org/bukkit/CoalType.java
Normal file
|
@ -0,0 +1,47 @@
|
|||
package org.bukkit;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* Represents the two types of coal
|
||||
* @author sunkid
|
||||
*/
|
||||
public enum CoalType {
|
||||
COAL((byte) 0x0),
|
||||
CHARCOAL((byte) 0x1);
|
||||
|
||||
private final byte data;
|
||||
private final static Map<Byte, CoalType> types = new HashMap<Byte, CoalType>();
|
||||
|
||||
private CoalType(byte data) {
|
||||
this.data = data;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the associated data value representing this type of coal
|
||||
*
|
||||
* @return A byte containing the data value of this coal type
|
||||
*/
|
||||
public byte getData() {
|
||||
return data;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the type of coal with the given data value
|
||||
*
|
||||
* @param data
|
||||
* Data value to fetch
|
||||
* @return The {@link CoalType} representing the given value, or null if
|
||||
* it doesn't exist
|
||||
*/
|
||||
public static CoalType getByData(final byte data) {
|
||||
return types.get(data);
|
||||
}
|
||||
|
||||
static {
|
||||
for (CoalType type : CoalType.values()) {
|
||||
types.put(type.getData(), type);
|
||||
}
|
||||
}
|
||||
}
|
77
paper-api/src/main/java/org/bukkit/CropState.java
Normal file
77
paper-api/src/main/java/org/bukkit/CropState.java
Normal file
|
@ -0,0 +1,77 @@
|
|||
package org.bukkit;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* Represents the different growth states of crops
|
||||
* @author sunkid
|
||||
*/
|
||||
public enum CropState {
|
||||
/**
|
||||
* State when first seeded
|
||||
*/
|
||||
SEEDED((byte) 0x0),
|
||||
/**
|
||||
* First growth stage
|
||||
*/
|
||||
GERMINATED((byte) 0x1),
|
||||
/**
|
||||
* Second growth stage
|
||||
*/
|
||||
VERY_SMALL((byte) 0x2),
|
||||
/**
|
||||
* Third growth stage
|
||||
*/
|
||||
SMALL((byte) 0x3),
|
||||
/**
|
||||
* Fourth growth stage
|
||||
*/
|
||||
MEDIUM((byte) 0x4),
|
||||
/**
|
||||
* Fifth growth stage
|
||||
*/
|
||||
TALL((byte) 0x5),
|
||||
/**
|
||||
* Almost ripe stage
|
||||
*/
|
||||
VERY_TALL((byte) 0x6),
|
||||
/**
|
||||
* Ripe stage
|
||||
*/
|
||||
RIPE((byte) 0x7);
|
||||
|
||||
private final byte data;
|
||||
private final static Map<Byte, CropState> states = new HashMap<Byte, CropState>();
|
||||
|
||||
private CropState(final byte data) {
|
||||
this.data = data;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the associated data value representing this growth state
|
||||
*
|
||||
* @return A byte containing the data value of this growth state
|
||||
*/
|
||||
public byte getData() {
|
||||
return data;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the CropState with the given data value
|
||||
*
|
||||
* @param data
|
||||
* Data value to fetch
|
||||
* @return The {@link CropState} representing the given value, or null if
|
||||
* it doesn't exist
|
||||
*/
|
||||
public static CropState getByData(final byte data) {
|
||||
return states.get(data);
|
||||
}
|
||||
|
||||
static {
|
||||
for (CropState s : CropState.values()) {
|
||||
states.put(s.getData(), s);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -29,8 +29,8 @@ public enum Material {
|
|||
GOLD_ORE(14),
|
||||
IRON_ORE(15),
|
||||
COAL_ORE(16),
|
||||
LOG(17),
|
||||
LEAVES(18),
|
||||
LOG(17, Tree.class),
|
||||
LEAVES(18, Tree.class),
|
||||
SPONGE(19),
|
||||
GLASS(20),
|
||||
LAPIS_ORE(21),
|
||||
|
@ -46,8 +46,8 @@ public enum Material {
|
|||
RED_MUSHROOM(40),
|
||||
GOLD_BLOCK(41),
|
||||
IRON_BLOCK(42),
|
||||
DOUBLE_STEP(43),
|
||||
STEP(44),
|
||||
DOUBLE_STEP(43, Step.class),
|
||||
STEP(44, Step.class),
|
||||
BRICK(45),
|
||||
TNT(46),
|
||||
BOOKSHELF(47),
|
||||
|
@ -62,7 +62,7 @@ public enum Material {
|
|||
DIAMOND_ORE(56),
|
||||
DIAMOND_BLOCK(57),
|
||||
WORKBENCH(58),
|
||||
CROPS(59),
|
||||
CROPS(59, Crops.class),
|
||||
SOIL(60),
|
||||
FURNACE(61),
|
||||
BURNING_FURNACE(62),
|
||||
|
@ -106,7 +106,7 @@ public enum Material {
|
|||
APPLE(260, 1),
|
||||
BOW(261, 1),
|
||||
ARROW(262),
|
||||
COAL(263),
|
||||
COAL(263, Coal.class),
|
||||
DIAMOND(264),
|
||||
IRON_INGOT(265),
|
||||
GOLD_INGOT(266),
|
||||
|
|
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);
|
||||
}
|
||||
}
|
||||
}
|
44
paper-api/src/main/java/org/bukkit/material/Coal.java
Normal file
44
paper-api/src/main/java/org/bukkit/material/Coal.java
Normal file
|
@ -0,0 +1,44 @@
|
|||
package org.bukkit.material;
|
||||
|
||||
import org.bukkit.CoalType;
|
||||
import org.bukkit.Material;
|
||||
|
||||
/**
|
||||
* Represents the different types of coals.
|
||||
* @author sunkid
|
||||
*/
|
||||
public class Coal extends MaterialData {
|
||||
public Coal(final int type) {
|
||||
super(type);
|
||||
}
|
||||
|
||||
public Coal(final Material type) {
|
||||
super(type);
|
||||
}
|
||||
|
||||
public Coal(final int type, final byte data) {
|
||||
super(type, data);
|
||||
}
|
||||
|
||||
public Coal(final Material type, final byte data) {
|
||||
super(type, data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the current type of this coal
|
||||
*
|
||||
* @return CoalType of this coal
|
||||
*/
|
||||
public CoalType getType() {
|
||||
return CoalType.getByData(getData());
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the type of this coal
|
||||
*
|
||||
* @param type New type of this coal
|
||||
*/
|
||||
public void setSpecies(CoalType type) {
|
||||
setData(type.getData());
|
||||
}
|
||||
}
|
44
paper-api/src/main/java/org/bukkit/material/Crops.java
Normal file
44
paper-api/src/main/java/org/bukkit/material/Crops.java
Normal file
|
@ -0,0 +1,44 @@
|
|||
package org.bukkit.material;
|
||||
|
||||
import org.bukkit.CropState;
|
||||
import org.bukkit.Material;
|
||||
|
||||
/**
|
||||
* Represents the different types of crops.
|
||||
* @author sunkid
|
||||
*/
|
||||
public class Crops extends MaterialData {
|
||||
public Crops(final int type) {
|
||||
super(type);
|
||||
}
|
||||
|
||||
public Crops(final Material type) {
|
||||
super(type);
|
||||
}
|
||||
|
||||
public Crops(final int type, final byte data) {
|
||||
super(type, data);
|
||||
}
|
||||
|
||||
public Crops(final Material type, final byte data) {
|
||||
super(type, data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the current growth state of this crop
|
||||
*
|
||||
* @return CropState of this leave
|
||||
*/
|
||||
public CropState getSpecies() {
|
||||
return CropState.getByData(getData());
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the growth state of this crop
|
||||
*
|
||||
* @param state New growth state of this crop
|
||||
*/
|
||||
public void setSpecies(CropState state) {
|
||||
setData(state.getData());
|
||||
}
|
||||
}
|
44
paper-api/src/main/java/org/bukkit/material/Leaves.java
Normal file
44
paper-api/src/main/java/org/bukkit/material/Leaves.java
Normal file
|
@ -0,0 +1,44 @@
|
|||
package org.bukkit.material;
|
||||
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.TreeSpecies;
|
||||
|
||||
/**
|
||||
* Represents the different types of leaves.
|
||||
* @author sunkid
|
||||
*/
|
||||
public class Leaves extends MaterialData {
|
||||
public Leaves(final int type) {
|
||||
super(type);
|
||||
}
|
||||
|
||||
public Leaves(final Material type) {
|
||||
super(type);
|
||||
}
|
||||
|
||||
public Leaves(final int type, final byte data) {
|
||||
super(type, data);
|
||||
}
|
||||
|
||||
public Leaves(final Material type, final byte data) {
|
||||
super(type, data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the current species of this leave
|
||||
*
|
||||
* @return TreeSpecies of this leave
|
||||
*/
|
||||
public TreeSpecies getSpecies() {
|
||||
return TreeSpecies.getByData(getData());
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the species of this leave
|
||||
*
|
||||
* @param species New species of this leave
|
||||
*/
|
||||
public void setSpecies(TreeSpecies species) {
|
||||
setData(species.getData());
|
||||
}
|
||||
}
|
63
paper-api/src/main/java/org/bukkit/material/Step.java
Normal file
63
paper-api/src/main/java/org/bukkit/material/Step.java
Normal file
|
@ -0,0 +1,63 @@
|
|||
package org.bukkit.material;
|
||||
|
||||
import org.bukkit.Material;
|
||||
|
||||
/**
|
||||
* Represents the different types of steps.
|
||||
* @author sunkid
|
||||
*/
|
||||
public class Step extends MaterialData {
|
||||
public Step(final int type) {
|
||||
super(type);
|
||||
}
|
||||
|
||||
public Step(final Material type) {
|
||||
super(type);
|
||||
}
|
||||
|
||||
public Step(final int type, final byte data) {
|
||||
super(type, data);
|
||||
}
|
||||
|
||||
public Step(final Material type, final byte data) {
|
||||
super(type, data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the current Material this step is made of
|
||||
*
|
||||
* @return Material of this step
|
||||
*/
|
||||
public Material getMaterial() {
|
||||
switch ((int) getData()) {
|
||||
case 1:
|
||||
return Material.SANDSTONE;
|
||||
case 2:
|
||||
return Material.WOOD;
|
||||
case 3:
|
||||
return Material.COBBLESTONE;
|
||||
case 0:
|
||||
default:
|
||||
return Material.STONE;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the material this step is made of
|
||||
*
|
||||
* @param material New material of this step
|
||||
*/
|
||||
public void setMaterial(Material material) {
|
||||
switch (material) {
|
||||
case SANDSTONE:
|
||||
setData((byte) 0x1);
|
||||
case WOOD:
|
||||
setData((byte) 0x2);
|
||||
case COBBLESTONE:
|
||||
setData((byte) 0x3);
|
||||
case STONE:
|
||||
default:
|
||||
setData((byte) 0x0);
|
||||
}
|
||||
}
|
||||
}
|
44
paper-api/src/main/java/org/bukkit/material/Tree.java
Normal file
44
paper-api/src/main/java/org/bukkit/material/Tree.java
Normal file
|
@ -0,0 +1,44 @@
|
|||
package org.bukkit.material;
|
||||
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.TreeSpecies;
|
||||
|
||||
/**
|
||||
* Represents the different types of Trees.
|
||||
* @author sunkid
|
||||
*/
|
||||
public class Tree extends MaterialData {
|
||||
public Tree(final int type) {
|
||||
super(type);
|
||||
}
|
||||
|
||||
public Tree(final Material type) {
|
||||
super(type);
|
||||
}
|
||||
|
||||
public Tree(final int type, final byte data) {
|
||||
super(type, data);
|
||||
}
|
||||
|
||||
public Tree(final Material type, final byte data) {
|
||||
super(type, data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the current species of this tree
|
||||
*
|
||||
* @return TreeSpecies of this tree
|
||||
*/
|
||||
public TreeSpecies getSpecies() {
|
||||
return TreeSpecies.getByData(getData());
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the species of this tree
|
||||
*
|
||||
* @param species New species of this tree
|
||||
*/
|
||||
public void setSpecies(TreeSpecies species) {
|
||||
setData(species.getData());
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue