summaryrefslogtreecommitdiffstats
path: root/src/main/java/org
diff options
context:
space:
mode:
authorWesley Wolfe <weswolf@aol.com>2012-03-31 08:35:59 -0500
committerWesley Wolfe <weswolf@aol.com>2012-03-31 08:35:59 -0500
commit6240b9a37ca9fe935d41bd3a3e8d1c1e73bf89fc (patch)
tree0dec4546e35e5d64864b56e0572d2f606d9af45d /src/main/java/org
parenta0be4ef41671b49f78a6c9344e6cdaa4a7497065 (diff)
downloadbukkit-6240b9a37ca9fe935d41bd3a3e8d1c1e73bf89fc.tar
bukkit-6240b9a37ca9fe935d41bd3a3e8d1c1e73bf89fc.tar.gz
bukkit-6240b9a37ca9fe935d41bd3a3e8d1c1e73bf89fc.tar.lz
bukkit-6240b9a37ca9fe935d41bd3a3e8d1c1e73bf89fc.tar.xz
bukkit-6240b9a37ca9fe935d41bd3a3e8d1c1e73bf89fc.zip
Fix Wood(plank) and add Sandstone MaterialData; addresses BUKKIT-1384
Diffstat (limited to 'src/main/java/org')
-rw-r--r--src/main/java/org/bukkit/Material.java4
-rw-r--r--src/main/java/org/bukkit/SandstoneType.java48
-rw-r--r--src/main/java/org/bukkit/material/Sandstone.java62
3 files changed, 112 insertions, 2 deletions
diff --git a/src/main/java/org/bukkit/Material.java b/src/main/java/org/bukkit/Material.java
index b184079e..74edacf0 100644
--- a/src/main/java/org/bukkit/Material.java
+++ b/src/main/java/org/bukkit/Material.java
@@ -23,7 +23,7 @@ public enum Material {
GRASS(2),
DIRT(3),
COBBLESTONE(4),
- WOOD(5),
+ WOOD(5, Tree.class),
SAPLING(6, Tree.class),
BEDROCK(7),
WATER(8, MaterialData.class),
@@ -42,7 +42,7 @@ public enum Material {
LAPIS_ORE(21),
LAPIS_BLOCK(22),
DISPENSER(23, Dispenser.class),
- SANDSTONE(24),
+ SANDSTONE(24, Sandstone.class),
NOTE_BLOCK(25),
BED_BLOCK(26, Bed.class),
POWERED_RAIL(27, PoweredRail.class),
diff --git a/src/main/java/org/bukkit/SandstoneType.java b/src/main/java/org/bukkit/SandstoneType.java
new file mode 100644
index 00000000..79f8ecf5
--- /dev/null
+++ b/src/main/java/org/bukkit/SandstoneType.java
@@ -0,0 +1,48 @@
+package org.bukkit;
+
+import java.util.Map;
+
+import com.google.common.collect.Maps;
+
+/**
+ * Represents the three different types of Sandstone
+ */
+public enum SandstoneType {
+ CRACKED(0x0),
+ GLYPHED(0x1),
+ SMOOTH(0x2);
+
+ private final byte data;
+ private final static Map<Byte, SandstoneType> BY_DATA = Maps.newHashMap();
+
+ private SandstoneType(final int data) {
+ this.data = (byte) data;
+ }
+
+ /**
+ * Gets the associated data value representing this type of sandstone
+ *
+ * @return A byte containing the data value of this sandstone type
+ */
+ public byte getData() {
+ return data;
+ }
+
+ /**
+ * Gets the type of sandstone with the given data value
+ *
+ * @param data
+ * Data value to fetch
+ * @return The {@link SandstoneType} representing the given value, or null if
+ * it doesn't exist
+ */
+ public static SandstoneType getByData(final byte data) {
+ return BY_DATA.get(data);
+ }
+
+ static {
+ for (SandstoneType type : values()) {
+ BY_DATA.put(type.data, type);
+ }
+ }
+}
diff --git a/src/main/java/org/bukkit/material/Sandstone.java b/src/main/java/org/bukkit/material/Sandstone.java
new file mode 100644
index 00000000..d2f6c267
--- /dev/null
+++ b/src/main/java/org/bukkit/material/Sandstone.java
@@ -0,0 +1,62 @@
+package org.bukkit.material;
+
+import org.bukkit.Material;
+import org.bukkit.SandstoneType;
+
+/**
+ * Represents the different types of sandstone.
+ */
+public class Sandstone extends MaterialData {
+ public Sandstone() {
+ super(Material.SANDSTONE);
+ }
+
+ public Sandstone(SandstoneType type) {
+ this();
+ setType(type);
+ }
+
+ public Sandstone(final int type) {
+ super(type);
+ }
+
+ public Sandstone(final Material type) {
+ super(type);
+ }
+
+ public Sandstone(final int type, final byte data) {
+ super(type, data);
+ }
+
+ public Sandstone(final Material type, final byte data) {
+ super(type, data);
+ }
+
+ /**
+ * Gets the current type of this sandstone
+ *
+ * @return SandstoneType of this sandstone
+ */
+ public SandstoneType getType() {
+ return SandstoneType.getByData(getData());
+ }
+
+ /**
+ * Sets the type of this sandstone
+ *
+ * @param type New type of this sandstone
+ */
+ public void setType(SandstoneType type) {
+ setData(type.getData());
+ }
+
+ @Override
+ public String toString() {
+ return getType() + " " + super.toString();
+ }
+
+ @Override
+ public Sandstone clone() {
+ return (Sandstone) super.clone();
+ }
+}