--- miscJava/bukkit-minecraft-plugins/HoerupUtils/src/main/java/dk/thoerup/bukkit/hoeruputils/chests/AdvancedChest.java 2012/06/03 18:05:09 1807 +++ miscJava/bukkit-minecraft-plugins/HoerupUtils/src/main/java/dk/thoerup/bukkit/hoeruputils/chests/AdvancedChest.java 2012/06/28 10:19:26 1813 @@ -166,9 +166,9 @@ Set players = Util.stringToSet( chest.getModifyPlayers() ); if (cmd.equals("addplayer")) { - players.add(args[1]); + players.add(p2.getName()); } else { - players.remove(args[1]); + players.remove(p2.getName()); } chest.setModifyPlayers( Util.setToString(players) ); @@ -216,6 +216,7 @@ } else { event.setCancelled(true); event.getPlayer().sendMessage("You can't destroy that chest"); + server.getLogger().info( "[AdvancedChest] " + event.getPlayer().getName() + " tried breaking a chest owned by " + chest.getOwner() ); } } } @@ -264,7 +265,7 @@ void loadChests() { int count = loadChestsWorker(); - plugin.getLogger().info("[AdvancedChest] loaded " + count + " chests"); + server.getLogger().info("[AdvancedChest] loaded " + count + " chests"); } @@ -365,6 +366,7 @@ for (Block b : event.blockList() ) { ChestBean chest = chestMap.get( b.getLocation() ); if (chest != null) { + server.getLogger().info( "[AdvancedChest] Prevented an explosion from destroying chest owned by " + chest.getOwner() ); event.setCancelled( true ); return; } @@ -395,16 +397,13 @@ return; //chest is opened by it's owner } - if (chest.getModifyPlayers() != null && chest.getModifyPlayers().length()>0) { - String modplayers[] = chest.getModifyPlayers().split(","); - for (String p : modplayers) { - if ( player.getName().equals(p) ) { - return; //this player is on the whitelist so he may open - } - } + Set players = Util.stringToSet( chest.getModifyPlayers() ); + if ( players.contains(player.getName()) ) { + return; //this player is on the whitelist so he may open } - + + server.getLogger().info( "[AdvancedChest] " + event.getPlayer().getName() + " tried opening a chest owned by " + chest.getOwner() ); player.sendMessage( ChatColor.BLUE + "Sorry but this chest is locked !"); event.setCancelled(true); } @@ -437,7 +436,12 @@ Player player = (Player) event.getPlayer(); if (player.getName().equals(chest.getOwner() )) { return; //chest is owned by it's own player - } + } + + Set players = Util.stringToSet( chest.getModifyPlayers() ); + if ( players.contains(player.getName()) ) { + return; //this player is on the whitelist so he may open + } ItemCount contents = countItems( event.getInventory().getContents() ); @@ -509,7 +513,7 @@ } - plugin.getLogger().info(msg); + server.getLogger().info( "[AdvancedChest]" + msg); plugin.getMessageWrapper().sendMessage("system", owner, msg); }