Permalink
Browse files

remove all references to the deprecated ContainerBlock (replaced with…

… InventoryHolder)
  • Loading branch information...
1 parent 0802ff9 commit c9f44955e4e6ba3a2e880af2346a69cf04f6d97b @Hidendra committed Sep 5, 2012
@@ -44,12 +44,10 @@
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.block.Block;
-import org.bukkit.block.ContainerBlock;
import org.bukkit.entity.Player;
import org.bukkit.event.block.Action;
+import org.bukkit.inventory.InventoryHolder;
-import java.lang.Double;
-import java.lang.String;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
@@ -132,7 +130,7 @@ public void onProtectionInteract(LWCProtectionInteractEvent event) {
}
// is it actually a container? :p
- if (!(protection.getBlock().getState() instanceof ContainerBlock)) {
+ if (!(protection.getBlock().getState() instanceof InventoryHolder)) {
return;
}
@@ -34,8 +34,8 @@
import org.bukkit.World;
import org.bukkit.block.Block;
import org.bukkit.block.BlockState;
-import org.bukkit.block.ContainerBlock;
import org.bukkit.inventory.Inventory;
+import org.bukkit.inventory.InventoryHolder;
import org.bukkit.inventory.ItemStack;
import java.util.HashMap;
@@ -105,12 +105,12 @@ public void run() {
block.setData((byte) data);
if (items.size() > 0) {
- if (!(block.getState() instanceof ContainerBlock)) {
+ if (!(block.getState() instanceof InventoryHolder)) {
System.out.println(String.format("The block at [%d, %d, %d] has backed up items but no longer supports them. Why? %s", x, y, z, block.toString()));
}
// Get the block's inventory
- Inventory inventory = ((ContainerBlock) block.getState()).getInventory();
+ Inventory inventory = ((InventoryHolder) block.getState()).getInventory();
// Set all of the items to it
for (Map.Entry<Integer, ItemStack> entry : items.entrySet()) {
@@ -151,8 +151,8 @@ public static RestorableBlock wrapBlock(Block block) {
BlockState state = block.getState();
// Does it have an inventory? ^^
- if (state instanceof ContainerBlock) {
- Inventory inventory = ((ContainerBlock) state).getInventory();
+ if (state instanceof InventoryHolder) {
+ Inventory inventory = ((InventoryHolder) state).getInventory();
ItemStack[] stacks = inventory.getContents();
for (int slot = 0; slot < stacks.length; slot++) {
@@ -121,10 +121,10 @@
import org.bukkit.block.Block;
import org.bukkit.block.BlockFace;
import org.bukkit.block.BlockState;
-import org.bukkit.block.ContainerBlock;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.inventory.Inventory;
+import org.bukkit.inventory.InventoryHolder;
import org.bukkit.inventory.ItemStack;
import org.bukkit.plugin.Plugin;
@@ -446,15 +446,15 @@ public boolean canAdminProtection(Player player, Protection protection) {
public Map<Integer, ItemStack> depositItems(Block block, ItemStack itemStack) {
BlockState blockState;
- if ((blockState = block.getState()) != null && (blockState instanceof ContainerBlock)) {
+ if ((blockState = block.getState()) != null && (blockState instanceof InventoryHolder)) {
Block doubleChestBlock = findAdjacentBlock(block, Material.CHEST);
- ContainerBlock containerBlock = (ContainerBlock) blockState;
+ InventoryHolder holder = (InventoryHolder) blockState;
if (itemStack.getAmount() <= 0) {
return new HashMap<Integer, ItemStack>();
}
- Map<Integer, ItemStack> remaining = containerBlock.getInventory().addItem(itemStack);
+ Map<Integer, ItemStack> remaining = holder.getInventory().addItem(itemStack);
// we have remainders, deal with it
if (remaining.size() > 0) {
@@ -463,8 +463,8 @@ public boolean canAdminProtection(Player player, Protection protection) {
// is it a double chest ?????
if (doubleChestBlock != null) {
- ContainerBlock containerBlock2 = (ContainerBlock) doubleChestBlock.getState();
- remaining = containerBlock2.getInventory().addItem(remainingItemStack);
+ InventoryHolder holder2 = (InventoryHolder) doubleChestBlock.getState();
+ remaining = holder2.getInventory().addItem(remainingItemStack);
}
// recheck remaining in the event of double chest being used
@@ -1101,12 +1101,12 @@ private void removeInventory(Block block) {
return;
}
- if (!(block.getState() instanceof ContainerBlock)) {
+ if (!(block.getState() instanceof InventoryHolder)) {
return;
}
- ContainerBlock container = (ContainerBlock) block.getState();
- container.getInventory().clear();
+ InventoryHolder holder = (InventoryHolder) block.getState();
+ holder.getInventory().clear();
}
/**
@@ -1588,12 +1588,12 @@ private Plugin resolvePlugin(String name) {
try {
for (Block block : blocks) {
- if (!(block.getState() instanceof ContainerBlock)) {
+ if (!(block.getState() instanceof InventoryHolder)) {
continue;
}
- ContainerBlock containerBlock = (ContainerBlock) block.getState();
- Inventory inventory = containerBlock.getInventory();
+ InventoryHolder holder = (InventoryHolder) block.getState();
+ Inventory inventory = holder.getInventory();
// Add all the items from this inventory
for (ItemStack stack : inventory.getContents()) {
@@ -40,9 +40,9 @@
import org.bukkit.Server;
import org.bukkit.World;
import org.bukkit.block.Block;
-import org.bukkit.block.ContainerBlock;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Item;
+import org.bukkit.inventory.InventoryHolder;
import org.bukkit.inventory.ItemStack;
import java.util.ArrayList;
@@ -140,7 +140,7 @@ public void run() {
block = world.getBlockAt(protection.getX(), protection.getY(), protection.getZ());
// we only want inventory blocks
- if (!(block.getState() instanceof ContainerBlock)) {
+ if (!(block.getState() instanceof InventoryHolder)) {
continue;
}

0 comments on commit c9f4495

Please sign in to comment.