summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorsunkid <sunkid@iminurnetz.com>2011-03-14 18:08:57 -0700
committerErik Broes <erikbroes@ripe.net>2011-03-21 17:25:34 +0100
commit7e8118c81dc3bc1a3a89c7456c7b0a3d8991c25b (patch)
treecc7817d61d52f8e33f22958f2d8ef6d24d3bc323 /src
parentf89e47ba9c9bb4db5d7cdb91aa5b88765733ee01 (diff)
downloadbukkit-7e8118c81dc3bc1a3a89c7456c7b0a3d8991c25b.tar
bukkit-7e8118c81dc3bc1a3a89c7456c7b0a3d8991c25b.tar.gz
bukkit-7e8118c81dc3bc1a3a89c7456c7b0a3d8991c25b.tar.lz
bukkit-7e8118c81dc3bc1a3a89c7456c7b0a3d8991c25b.tar.xz
bukkit-7e8118c81dc3bc1a3a89c7456c7b0a3d8991c25b.zip
added MaterialData classes and associated Enums for COAL, CROPS, LOG, LEAVES, STEP, and DOUBLE_STEP
Diffstat (limited to 'src')
-rw-r--r--src/main/java/org/bukkit/CoalType.java47
-rw-r--r--src/main/java/org/bukkit/CropState.java77
-rw-r--r--src/main/java/org/bukkit/Material.java12
-rw-r--r--src/main/java/org/bukkit/TreeSpecies.java58
-rw-r--r--src/main/java/org/bukkit/material/Coal.java44
-rw-r--r--src/main/java/org/bukkit/material/Crops.java44
-rw-r--r--src/main/java/org/bukkit/material/Leaves.java44
-rw-r--r--src/main/java/org/bukkit/material/Step.java63
-rw-r--r--src/main/java/org/bukkit/material/Tree.java44
9 files changed, 427 insertions, 6 deletions
diff --git a/src/main/java/org/bukkit/CoalType.java b/src/main/java/org/bukkit/CoalType.java
new file mode 100644
index 00000000..32a84e90
--- /dev/null
+++ b/src/main/java/org/bukkit/CoalType.java
@@ -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);
+ }
+ }
+}
diff --git a/src/main/java/org/bukkit/CropState.java b/src/main/java/org/bukkit/CropState.java
new file mode 100644
index 00000000..60de1e13
--- /dev/null
+++ b/src/main/java/org/bukkit/CropState.java
@@ -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);
+ }
+ }
+}
diff --git a/src/main/java/org/bukkit/Material.java b/src/main/java/org/bukkit/Material.java
index 53ef5854..31ffb862 100644
--- a/src/main/java/org/bukkit/Material.java
+++ b/src/main/java/org/bukkit/Material.java
@@ -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),
diff --git a/src/main/java/org/bukkit/TreeSpecies.java b/src/main/java/org/bukkit/TreeSpecies.java
new file mode 100644
index 00000000..3764bd9d
--- /dev/null
+++ b/src/main/java/org/bukkit/TreeSpecies.java
@@ -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);
+ }
+ }
+}
diff --git a/src/main/java/org/bukkit/material/Coal.java b/src/main/java/org/bukkit/material/Coal.java
new file mode 100644
index 00000000..25d43146
--- /dev/null
+++ b/src/main/java/org/bukkit/material/Coal.java
@@ -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());
+ }
+}
diff --git a/src/main/java/org/bukkit/material/Crops.java b/src/main/java/org/bukkit/material/Crops.java
new file mode 100644
index 00000000..0dacac6e
--- /dev/null
+++ b/src/main/java/org/bukkit/material/Crops.java
@@ -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());
+ }
+}
diff --git a/src/main/java/org/bukkit/material/Leaves.java b/src/main/java/org/bukkit/material/Leaves.java
new file mode 100644
index 00000000..20c957c0
--- /dev/null
+++ b/src/main/java/org/bukkit/material/Leaves.java
@@ -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());
+ }
+}
diff --git a/src/main/java/org/bukkit/material/Step.java b/src/main/java/org/bukkit/material/Step.java
new file mode 100644
index 00000000..e2980e14
--- /dev/null
+++ b/src/main/java/org/bukkit/material/Step.java
@@ -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);
+ }
+ }
+}
diff --git a/src/main/java/org/bukkit/material/Tree.java b/src/main/java/org/bukkit/material/Tree.java
new file mode 100644
index 00000000..c81e468e
--- /dev/null
+++ b/src/main/java/org/bukkit/material/Tree.java
@@ -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());
+ }
+}