--- miscJava/bukkit-minecraft-plugins/HoerupUtils/src/main/java/dk/thoerup/bukkit/hoeruputils/chests/AdvancedChest.java 2012/06/04 18:27:14 1810 +++ miscJava/bukkit-minecraft-plugins/HoerupUtils/src/main/java/dk/thoerup/bukkit/hoeruputils/chests/AdvancedChest.java 2012/10/02 16:40:56 1853 @@ -140,12 +140,18 @@ } if (cmd.equals("remove")) { - if (chest != null) { - player.sendMessage("[LockedChest] Removing protection from chest"); - removeChest(loc); - } else { - player.sendMessage("This chest is not protected"); + if (chest == null) { + player.sendMessage("This chest is not protected"); + return true; + } + if (! chest.getOwner().equals( player.getName() ) ) { + player.sendMessage("You can not remove lock from a chest you don't own"); + return true; } + + player.sendMessage("[LockedChest] Removing protection from chest"); + removeChest(loc); + return true; } @@ -154,6 +160,10 @@ player.sendMessage("This chest is not protected"); return true; } + if (! chest.getOwner().equals( player.getName() ) ) { + player.sendMessage("You can not add/remove players from a chest you don't own"); + return true; + } if (args.length != 2) { player.sendMessage("You need to specify which player to add or remove"); return true; @@ -265,7 +275,7 @@ void loadChests() { int count = loadChestsWorker(); - plugin.getLogger().info("[AdvancedChest] loaded " + count + " chests"); + server.getLogger().info("[AdvancedChest] loaded " + count + " chests"); } @@ -403,7 +413,7 @@ } - + 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); } @@ -513,7 +523,7 @@ } - plugin.getLogger().info(msg); + server.getLogger().info( "[AdvancedChest]" + msg); plugin.getMessageWrapper().sendMessage("system", owner, msg); }