summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorEvilSeph <evilseph@gmail.com>2011-10-01 13:30:59 -0400
committerEvilSeph <evilseph@gmail.com>2011-10-01 13:55:56 -0400
commit76b85c61ae1ae4b906cf00312ab0c8a428a24b28 (patch)
tree775c3437210c9f0f3109006afcfcd6e338127cf8 /src
parent7e210807f6769bbde048ec4a453a1935b8397371 (diff)
downloadbukkit-76b85c61ae1ae4b906cf00312ab0c8a428a24b28.tar
bukkit-76b85c61ae1ae4b906cf00312ab0c8a428a24b28.tar.gz
bukkit-76b85c61ae1ae4b906cf00312ab0c8a428a24b28.tar.lz
bukkit-76b85c61ae1ae4b906cf00312ab0c8a428a24b28.tar.xz
bukkit-76b85c61ae1ae4b906cf00312ab0c8a428a24b28.zip
Painting improvements. Thanks CelticMinstrel!
Added interface to get/set the art and facing direction on paintings, and expanded painting break events to catch more cases (including fire and lightning); removed PaintingBreakByWorldEvent since it's identical to its superclass
Diffstat (limited to 'src')
-rw-r--r--src/main/java/org/bukkit/Art.java96
-rw-r--r--src/main/java/org/bukkit/entity/Painting.java44
-rw-r--r--src/main/java/org/bukkit/event/painting/PaintingBreakByWorldEvent.java12
-rw-r--r--src/main/java/org/bukkit/event/painting/PaintingBreakEvent.java17
4 files changed, 147 insertions, 22 deletions
diff --git a/src/main/java/org/bukkit/Art.java b/src/main/java/org/bukkit/Art.java
new file mode 100644
index 00000000..fef562bb
--- /dev/null
+++ b/src/main/java/org/bukkit/Art.java
@@ -0,0 +1,96 @@
+package org.bukkit;
+
+import java.util.HashMap;
+
+/**
+ * Represents the art on a painting
+ */
+public enum Art {
+ KEBAB(0,1,1),
+ AZTEC(1,1,1),
+ ALBAN(2,1,1),
+ AZTEC2(3,1,1),
+ BOMB(4,1,1),
+ PLANT(5,1,1),
+ WASTELAND(6,1,1),
+ POOL(7,2,1),
+ COURBET(8,2,1),
+ SEA(9,2,1),
+ SUNSET(10,2,1),
+ CREEBET(11,2,1),
+ WANDERER(12,1,2),
+ GRAHAM(13,1,2),
+ MATCH(14,4,2),
+ BUST(15,2,2),
+ STAGE(16,2,2),
+ VOID(17,2,2),
+ SKULL_AND_ROSES(18,2,2),
+ FIGHTERS(19,2,2),
+ POINTER(20,4,4),
+ PIGSCENE(21,4,4),
+ BURNINGSKULL(22,4,4),
+ SKELETON(23,4,3),
+ DONKEYKONG(24,4,3);
+ private int id, width, height;
+ private static HashMap<String,Art> names = new HashMap<String,Art>();
+ private static HashMap<Integer,Art> ids = new HashMap<Integer,Art>();
+ static {
+ for (Art art : Art.values()) {
+ ids.put(art.id, art);
+ names.put(art.toString(), art);
+ }
+ }
+
+ private Art(int id, int width, int height) {
+ this.id = id;
+ this.width = width;
+ this.height = height;
+ }
+
+ /**
+ * Gets the width of the painting, in blocks
+ *
+ * @return The width of the painting, in blocks
+ */
+ public int getBlockWidth() {
+ return width;
+ }
+
+ /**
+ * Gets the height of the painting, in blocks
+ *
+ * @return The height of the painting, in blocks
+ */
+ public int getBlockHeight() {
+ return height;
+ }
+
+ /**
+ * Get the ID of this painting.
+ *
+ * @return The ID of this painting
+ */
+ public int getId() {
+ return id;
+ }
+
+ /**
+ * Get a painting by its numeric ID
+ *
+ * @param id The ID
+ * @return The painting
+ */
+ public static Art getById(int id) {
+ return ids.get(id);
+ }
+
+ /**
+ * Get a painting by its unique name
+ *
+ * @param name The name
+ * @return The painting
+ */
+ public static Art getByName(String name) {
+ return names.get(name);
+ }
+}
diff --git a/src/main/java/org/bukkit/entity/Painting.java b/src/main/java/org/bukkit/entity/Painting.java
index 3b12c35f..94e0e36e 100644
--- a/src/main/java/org/bukkit/entity/Painting.java
+++ b/src/main/java/org/bukkit/entity/Painting.java
@@ -1,12 +1,42 @@
-/**
- *
- */
package org.bukkit.entity;
+import org.bukkit.Art;
+import org.bukkit.block.BlockFace;
+import org.bukkit.material.Attachable;
+
/**
* Represents a Painting.
- *
- * @author Cogito
- *
*/
-public interface Painting extends Entity {}
+public interface Painting extends Entity, Attachable {
+ /**
+ * Get the art on this painting
+ * @return The art
+ */
+ public Art getArt();
+
+ /**
+ * Set the art on this painting
+ * @param art The new art
+ * @return False if the new art won't fit at the painting's current location
+ */
+ public boolean setArt(Art art);
+
+ /**
+ * Set the art on this painting
+ * @param art The new art
+ * @param force If true, force the new art regardless of whether it fits at the current location
+ * Note that forcing it where it can't fit normally causes it to drop as an item unless you override
+ * this by catching the PAINTING_BREAK event.
+ * @return False if force was false and the new art won't fit at the painting's current location
+ */
+ public boolean setArt(Art art, boolean force);
+
+ /**
+ * Sets the direction of the painting, potentially overriding rules of placement. Note that if the result
+ * is not valid the painting would normally drop as an item.
+ * @param face The new direction.
+ * @param force Whether to force it.
+ * @return False if force was false and there was no block for it to attach to in order to face the given direction.
+ */
+ public boolean setFacingDirection(BlockFace face, boolean force);
+}
diff --git a/src/main/java/org/bukkit/event/painting/PaintingBreakByWorldEvent.java b/src/main/java/org/bukkit/event/painting/PaintingBreakByWorldEvent.java
deleted file mode 100644
index 483988e5..00000000
--- a/src/main/java/org/bukkit/event/painting/PaintingBreakByWorldEvent.java
+++ /dev/null
@@ -1,12 +0,0 @@
-package org.bukkit.event.painting;
-
-import org.bukkit.entity.Painting;
-
-/**
- * Triggered when a painting is removed by the world (water flowing over it, block damaged behind it)
- */
-public class PaintingBreakByWorldEvent extends PaintingBreakEvent {
- public PaintingBreakByWorldEvent(final Painting painting) {
- super(painting, RemoveCause.WORLD);
- }
-}
diff --git a/src/main/java/org/bukkit/event/painting/PaintingBreakEvent.java b/src/main/java/org/bukkit/event/painting/PaintingBreakEvent.java
index 154c1d23..98420666 100644
--- a/src/main/java/org/bukkit/event/painting/PaintingBreakEvent.java
+++ b/src/main/java/org/bukkit/event/painting/PaintingBreakEvent.java
@@ -42,9 +42,20 @@ public class PaintingBreakEvent extends PaintingEvent implements Cancellable {
*/
ENTITY,
/**
- * Removed by the world - block the painting is on is destroyed, water flowing over etc
+ * Removed by fire
*/
- WORLD
-
+ FIRE,
+ /**
+ * Removed by placing a block on it
+ */
+ OBSTRUCTION,
+ /**
+ * Removed by water flowing over it
+ */
+ WATER,
+ /**
+ * Removed by destroying the block behind it, etc
+ */
+ PHYSICS,
}
}