--- miscJava/bukkit-minecraft-plugins/HoerupUtils/src/main/java/dk/thoerup/bukkit/hoeruputils/SnitchingChest.java 2012/04/05 14:27:24 1779 +++ miscJava/bukkit-minecraft-plugins/HoerupUtils/src/main/java/dk/thoerup/bukkit/hoeruputils/SnitchingChest.java 2012/04/05 20:40:38 1781 @@ -22,6 +22,7 @@ import org.bukkit.event.EventHandler; import org.bukkit.event.Listener; import org.bukkit.event.block.BlockBreakEvent; +import org.bukkit.event.block.BlockPlaceEvent; import org.bukkit.event.inventory.InventoryCloseEvent; import org.bukkit.event.inventory.InventoryOpenEvent; import org.bukkit.inventory.InventoryHolder; @@ -208,6 +209,27 @@ } @EventHandler + public void onChestPlaced(BlockPlaceEvent event) { + Block block = event.getBlock(); + + if (block.getType() != Material.CHEST) { + return; + } + + Location chestloc = getNeighborChest( block.getLocation() ); + if (chestloc != null) { + SnitchingChestBean chest = chestMap.get(chestloc); + + if (chest != null) { //the neighbor is a snitching chest + SnitchingChestBean newchest = createChest( chest.getOwner(), "", chestloc); + addChest(chestloc, newchest); + event.getPlayer().sendMessage( "[SnitchingChest] Chest has been expanded" ); + } + + } + } + + @EventHandler public void onChestOpen(InventoryOpenEvent event) { if (! (event.getPlayer() instanceof Player)) { @@ -283,10 +305,10 @@ int diff = Math.abs( savedcount - count); String msg = null; if (count > savedcount) { - msg = player.getName() + " added " + diff + " units of " + item + " to " + owner + "'s chest"; + msg = player.getName() + " added " + diff + " units of " + item + " to " + owner.getName() + "'s chest"; } if (count < savedcount) { - msg = player.getName() + " removed " + diff + " units of " + item + " from " + owner + "'s chest"; + msg = player.getName() + " removed " + diff + " units of " + item + " from " + owner.getName() + "'s chest"; } if (msg != null) {