--- miscJava/bukkit-minecraft-plugins/HoerupUtils/src/main/java/dk/thoerup/bukkit/hoeruputils/SnitchingChest.java 2012/04/05 12:37:13 1773 +++ miscJava/bukkit-minecraft-plugins/HoerupUtils/src/main/java/dk/thoerup/bukkit/hoeruputils/SnitchingChest.java 2012/04/05 14:27:24 1779 @@ -91,13 +91,11 @@ } SnitchingChestBean chest1 = createChest(player.getName(), "", loc); - //chestMap.put(loc, chest1); addChest(loc, chest1); if (loc2 != null) { SnitchingChestBean chest2 = createChest (player.getName(), "", loc2); addChest(loc, chest2); - //chestMap.put(loc2, chest2 ); } player.sendMessage("[SnitchingChest] Chest is now under surveillance"); @@ -127,7 +125,9 @@ void removeChest(Location loc) { SnitchingChestBean chest = chestMap.remove(loc); - plugin.getDatabase().delete(chest); + if (chest != null) { + plugin.getDatabase().delete(chest); + } } void loadChests() { @@ -136,6 +136,8 @@ Location loc = getChestLocation(server, chest); chestMap.put(loc, chest); } + + plugin.getLogger().info("[SnitchingChest] loaded " + chestMap.size() + " chests"); } @@ -198,6 +200,10 @@ } else { loc = ( (DoubleChest)holder).getLocation(); } + + loc.setX( loc.getBlockX() ); //round to integer, since double chests apparently are placed at pos + 0.5 + loc.setZ( loc.getBlockZ() ); // -- // -- + return loc; } @@ -241,6 +247,11 @@ if (holder instanceof Chest || holder instanceof DoubleChest) { Location loc = getChestLocation(holder); SnitchingChestBean chest = chestMap.get(loc); + + if (chest == null) { //chest was not a snitching chest + return; + } + OfflinePlayer owner = server.getOfflinePlayer( chest.getOwner() );