summaryrefslogtreecommitdiffstats
path: root/src/main/java/org
diff options
context:
space:
mode:
authorDinnerbone <dinnerbone@dinnerbone.com>2011-01-15 20:58:34 +0000
committerDinnerbone <dinnerbone@dinnerbone.com>2011-01-15 20:58:34 +0000
commitd923cd8c377016c70b5321a1c488a7064828bf2d (patch)
tree9f042ec9f629e09123748cc36a1009f148d0e21a /src/main/java/org
parentf56a6d31d79ac49f278214427d337ce1aa6d1aa5 (diff)
downloadbukkit-d923cd8c377016c70b5321a1c488a7064828bf2d.tar
bukkit-d923cd8c377016c70b5321a1c488a7064828bf2d.tar.gz
bukkit-d923cd8c377016c70b5321a1c488a7064828bf2d.tar.lz
bukkit-d923cd8c377016c70b5321a1c488a7064828bf2d.tar.xz
bukkit-d923cd8c377016c70b5321a1c488a7064828bf2d.zip
Added Button MaterialData
Diffstat (limited to 'src/main/java/org')
-rw-r--r--src/main/java/org/bukkit/Material.java2
-rw-r--r--src/main/java/org/bukkit/material/Button.java58
2 files changed, 59 insertions, 1 deletions
diff --git a/src/main/java/org/bukkit/Material.java b/src/main/java/org/bukkit/Material.java
index f15acb40..83d096e4 100644
--- a/src/main/java/org/bukkit/Material.java
+++ b/src/main/java/org/bukkit/Material.java
@@ -79,7 +79,7 @@ public enum Material {
GLOWING_REDSTONE_ORE(74),
REDSTONE_TORCH_OFF(75, RedstoneTorch.class),
REDSTONE_TORCH_ON(76, RedstoneTorch.class),
- STONE_BUTTON(77),
+ STONE_BUTTON(77, Button.class),
SNOW(78),
ICE(79),
SNOW_BLOCK(80),
diff --git a/src/main/java/org/bukkit/material/Button.java b/src/main/java/org/bukkit/material/Button.java
new file mode 100644
index 00000000..75b4d3da
--- /dev/null
+++ b/src/main/java/org/bukkit/material/Button.java
@@ -0,0 +1,58 @@
+
+package org.bukkit.material;
+
+import org.bukkit.BlockFace;
+import org.bukkit.Material;
+
+/**
+ * Represents a button
+ */
+public class Button extends MaterialData implements Redstone, Attachable {
+ public Button(final int type) {
+ super(type);
+ }
+
+ public Button(final Material type) {
+ super(type);
+ }
+
+ public Button(final int type, final byte data) {
+ super(type, data);
+ }
+
+ public Button(final Material type, final byte data) {
+ super(type, data);
+ }
+
+ /**
+ * Gets the current state of this Material, indicating if it's powered or
+ * unpowered
+ *
+ * @return true if powered, otherwise false
+ */
+ public boolean isPowered() {
+ return (getData() & 0x8) == 0x8;
+ }
+
+ /**
+ * Gets the face that this block is attached on
+ *
+ * @return BlockFace attached to
+ */
+ public BlockFace getAttachedFace() {
+ byte data = (byte) (getData() ^ 0x8);
+
+ switch (data) {
+ case 0x1:
+ return BlockFace.NORTH;
+ case 0x2:
+ return BlockFace.SOUTH;
+ case 0x3:
+ return BlockFace.EAST;
+ case 0x4:
+ return BlockFace.WEST;
+ }
+
+ return null;
+ }
+}