2011-05-15 19:33:03 +02:00
|
|
|
package com.Acrobot.ChestShop.Chests;
|
2011-05-15 18:16:25 +02:00
|
|
|
|
2011-07-05 19:08:55 +02:00
|
|
|
import com.Acrobot.ChestShop.Utils.uBlock;
|
|
|
|
import com.Acrobot.ChestShop.Utils.uInventory;
|
2011-05-15 18:16:25 +02:00
|
|
|
import org.bukkit.block.Chest;
|
|
|
|
import org.bukkit.inventory.ItemStack;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @author Acrobot
|
|
|
|
*/
|
2011-05-29 13:25:25 +02:00
|
|
|
public class MinecraftChest implements ChestObject {
|
2012-03-17 15:00:25 +01:00
|
|
|
private final Chest chest;
|
2011-05-29 13:25:25 +02:00
|
|
|
|
|
|
|
public MinecraftChest(Chest chest) {
|
2012-03-17 15:00:25 +01:00
|
|
|
this.chest = chest;
|
2011-05-15 18:16:25 +02:00
|
|
|
}
|
2011-05-29 13:25:25 +02:00
|
|
|
|
2011-05-15 18:16:25 +02:00
|
|
|
public ItemStack[] getContents() {
|
2012-03-17 15:00:25 +01:00
|
|
|
return chest.getInventory().getContents();
|
2011-05-15 18:16:25 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public void setSlot(int slot, ItemStack item) {
|
2012-03-17 15:00:25 +01:00
|
|
|
chest.getInventory().setItem(slot, item);
|
2011-05-15 18:16:25 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public void clearSlot(int slot) {
|
2012-03-17 15:00:25 +01:00
|
|
|
chest.getInventory().setItem(slot, null);
|
2011-05-15 18:16:25 +02:00
|
|
|
}
|
|
|
|
|
2011-06-14 15:07:44 +02:00
|
|
|
public void addItem(ItemStack item, int amount) {
|
2012-03-17 15:00:25 +01:00
|
|
|
uInventory.add(chest.getInventory(), item, amount);
|
2011-05-15 18:16:25 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public void removeItem(ItemStack item, short durability, int amount) {
|
2012-03-17 15:00:25 +01:00
|
|
|
uInventory.remove(chest.getInventory(), item, amount, durability);
|
2011-05-15 18:16:25 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public int amount(ItemStack item, short durability) {
|
2012-03-17 15:00:25 +01:00
|
|
|
return uInventory.amount(chest.getInventory(), item, durability);
|
2011-05-15 18:16:25 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public boolean hasEnough(ItemStack item, int amount, short durability) {
|
|
|
|
return amount(item, durability) >= amount;
|
|
|
|
}
|
|
|
|
|
|
|
|
public boolean fits(ItemStack item, int amount, short durability) {
|
2012-03-17 15:00:25 +01:00
|
|
|
return uInventory.fits(chest.getInventory(), item, amount, durability) <= 0;
|
2011-05-15 18:16:25 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public int getSize() {
|
2012-03-17 15:00:25 +01:00
|
|
|
return chest.getInventory().getSize();
|
2011-05-15 18:16:25 +02:00
|
|
|
}
|
|
|
|
|
2012-03-01 22:03:59 +01:00
|
|
|
public Chest getNeighbor() {
|
2012-03-17 15:00:25 +01:00
|
|
|
return uBlock.findNeighbor(chest);
|
2011-05-15 18:16:25 +02:00
|
|
|
}
|
2012-03-17 15:00:25 +01:00
|
|
|
}
|