mirror of
https://github.com/PaperMC/Paper.git
synced 2025-01-24 01:06:01 +01:00
[Bleeding] Added DoubleChest wrapper so that DoubleChestInventory can return something other than null. Addresses BUKKIT-995
By: Celtic Minstrel <celtic.minstrel.ca@some.place>
This commit is contained in:
parent
681a13dec1
commit
e3b0a0b98c
2 changed files with 51 additions and 0 deletions
47
paper-api/src/main/java/org/bukkit/block/DoubleChest.java
Normal file
47
paper-api/src/main/java/org/bukkit/block/DoubleChest.java
Normal file
|
@ -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());
|
||||
}
|
||||
}
|
|
@ -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();
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue