summaryrefslogtreecommitdiffstats
path: root/src/main/java/org
diff options
context:
space:
mode:
authorCeltic Minstrel <celtic.minstrel.ca@some.place>2012-03-12 16:46:47 -0400
committerEvilSeph <evilseph@gmail.com>2012-03-15 22:12:43 -0400
commit8b67cad4cc13f2cc547ae4572bd9205adb337d8a (patch)
treec28a0c63f2999ed7f1cac5e84b62402b705bec68 /src/main/java/org
parent74ff160f58b059177ad5080b6f1a7f75f13a74de (diff)
downloadbukkit-8b67cad4cc13f2cc547ae4572bd9205adb337d8a.tar
bukkit-8b67cad4cc13f2cc547ae4572bd9205adb337d8a.tar.gz
bukkit-8b67cad4cc13f2cc547ae4572bd9205adb337d8a.tar.lz
bukkit-8b67cad4cc13f2cc547ae4572bd9205adb337d8a.tar.xz
bukkit-8b67cad4cc13f2cc547ae4572bd9205adb337d8a.zip
[Bleeding] Added DoubleChest wrapper so that DoubleChestInventory can return something other than null. Addresses BUKKIT-995
Diffstat (limited to 'src/main/java/org')
-rw-r--r--src/main/java/org/bukkit/block/DoubleChest.java47
-rw-r--r--src/main/java/org/bukkit/inventory/DoubleChestInventory.java4
2 files changed, 51 insertions, 0 deletions
diff --git a/src/main/java/org/bukkit/block/DoubleChest.java b/src/main/java/org/bukkit/block/DoubleChest.java
new file mode 100644
index 00000000..cfc5b208
--- /dev/null
+++ b/src/main/java/org/bukkit/block/DoubleChest.java
@@ -0,0 +1,47 @@
+package org.bukkit.block;
+
+import org.bukkit.Location;
+import org.bukkit.World;
+import org.bukkit.inventory.DoubleChestInventory;
+import org.bukkit.inventory.Inventory;
+import org.bukkit.inventory.InventoryHolder;
+
+public class DoubleChest implements InventoryHolder {
+ private DoubleChestInventory inventory;
+
+ public DoubleChest(DoubleChestInventory chest) {
+ inventory = chest;
+ }
+
+ public Inventory getInventory() {
+ return inventory;
+ }
+
+ public InventoryHolder getLeftSide() {
+ return inventory.getLeftSide().getHolder();
+ }
+
+ public InventoryHolder getRightSide() {
+ return inventory.getRightSide().getHolder();
+ }
+
+ public Location getLocation() {
+ return new Location(getWorld(), getX(), getY(), getZ());
+ }
+
+ public World getWorld() {
+ return ((Chest)getLeftSide()).getWorld();
+ }
+
+ public double getX() {
+ return 0.5 * (((Chest)getLeftSide()).getX() + ((Chest)getRightSide()).getX());
+ }
+
+ public double getY() {
+ return 0.5 * (((Chest)getLeftSide()).getY() + ((Chest)getRightSide()).getY());
+ }
+
+ public double getZ() {
+ return 0.5 * (((Chest)getLeftSide()).getZ() + ((Chest)getRightSide()).getZ());
+ }
+}
diff --git a/src/main/java/org/bukkit/inventory/DoubleChestInventory.java b/src/main/java/org/bukkit/inventory/DoubleChestInventory.java
index 81d60304..7ad00eee 100644
--- a/src/main/java/org/bukkit/inventory/DoubleChestInventory.java
+++ b/src/main/java/org/bukkit/inventory/DoubleChestInventory.java
@@ -1,5 +1,7 @@
package org.bukkit.inventory;
+import org.bukkit.block.DoubleChest;
+
public interface DoubleChestInventory extends Inventory {
/**
* Get the left half of this double chest.
@@ -12,4 +14,6 @@ public interface DoubleChestInventory extends Inventory {
* @return The right side inventory
*/
Inventory getRightSide();
+
+ DoubleChest getHolder();
}