/[projects]/miscJava/bukkit-minecraft-plugins/HoerupUtils/src/main/java/dk/thoerup/bukkit/hoeruputils/chests/AdvancedChest.java
ViewVC logotype

Diff of /miscJava/bukkit-minecraft-plugins/HoerupUtils/src/main/java/dk/thoerup/bukkit/hoeruputils/chests/AdvancedChest.java

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1808 by torben, Sun Jun 3 20:16:40 2012 UTC revision 1852 by torben, Tue Oct 2 09:16:21 2012 UTC
# Line 140  public class AdvancedChest  implements L Line 140  public class AdvancedChest  implements L
140                  }                  }
141                                    
142                  if (cmd.equals("remove")) {                  if (cmd.equals("remove")) {
143                            if (! chest.getOwner().equals( player.getName() ) ) {
144                                    player.sendMessage("You can not remove lock from a chest you don't own");
145                                    return true;
146                            }
147                          if (chest != null) {                          if (chest != null) {
148                                  player.sendMessage("[LockedChest] Removing protection from chest");                                  player.sendMessage("[LockedChest] Removing protection from chest");
149                                  removeChest(loc);                                                                removeChest(loc);                              
# Line 154  public class AdvancedChest  implements L Line 158  public class AdvancedChest  implements L
158                                  player.sendMessage("This chest is not protected");                                  player.sendMessage("This chest is not protected");
159                                  return true;                                  return true;
160                          }                          }
161                            if (! chest.getOwner().equals( player.getName() ) ) {
162                                    player.sendMessage("You can not add/remove players from a chest you don't own");
163                                    return true;
164                            }
165                          if (args.length != 2) {                          if (args.length != 2) {
166                                  player.sendMessage("You need to specify which player to add or remove");                                  player.sendMessage("You need to specify which player to add or remove");
167                                  return true;                                  return true;
# Line 216  public class AdvancedChest  implements L Line 224  public class AdvancedChest  implements L
224                          } else {                          } else {
225                                  event.setCancelled(true);                                  event.setCancelled(true);
226                                  event.getPlayer().sendMessage("You can't destroy that chest");                                  event.getPlayer().sendMessage("You can't destroy that chest");
227                                    server.getLogger().info( "[AdvancedChest] " + event.getPlayer().getName() + " tried breaking a chest owned by " + chest.getOwner() );
228                          }                          }
229                  }                  }
230          }          }
# Line 264  public class AdvancedChest  implements L Line 273  public class AdvancedChest  implements L
273                    
274          void loadChests() {                      void loadChests() {            
275                  int count = loadChestsWorker();                  int count = loadChestsWorker();
276                  plugin.getLogger().info("[AdvancedChest] loaded " + count + " chests");                  server.getLogger().info("[AdvancedChest] loaded " + count + " chests");
277          }          }
278                    
279                    
# Line 365  public class AdvancedChest  implements L Line 374  public class AdvancedChest  implements L
374                  for (Block b : event.blockList() ) {                  for (Block b : event.blockList() ) {
375                          ChestBean chest = chestMap.get( b.getLocation() );                          ChestBean chest = chestMap.get( b.getLocation() );
376                          if (chest != null) {                          if (chest != null) {
377                                    server.getLogger().info( "[AdvancedChest] Prevented an explosion from destroying chest owned by " + chest.getOwner() );
378                                  event.setCancelled( true );                                  event.setCancelled( true );
379                                  return;                                  return;
380                          }                          }
# Line 395  public class AdvancedChest  implements L Line 405  public class AdvancedChest  implements L
405                                          return; //chest is opened by it's owner                                          return; //chest is opened by it's owner
406                                  }                                  }
407                                                                    
408                                  if (chest.getModifyPlayers() != null && chest.getModifyPlayers().length()>0) {                                  Set<String> players = Util.stringToSet( chest.getModifyPlayers() );
409                                          String modplayers[] = chest.getModifyPlayers().split(",");                                  if ( players.contains(player.getName()) ) {
410                                          for (String p : modplayers) {                                          return; //this player is on the whitelist so he may open
                                                 if ( player.getName().equals(p) ) {  
                                                         return; //this player is on the whitelist so he may open  
                                                 }  
                                         }  
411                                  }                                  }
412    
413                            
414                                    server.getLogger().info( "[AdvancedChest] " + event.getPlayer().getName() + " tried opening a chest owned by " + chest.getOwner() );
415                                  player.sendMessage( ChatColor.BLUE +  "Sorry but this chest is locked !");                                  player.sendMessage( ChatColor.BLUE +  "Sorry but this chest is locked !");
416                                  event.setCancelled(true);                                  event.setCancelled(true);
417                          }                          }
# Line 437  public class AdvancedChest  implements L Line 444  public class AdvancedChest  implements L
444                          Player player = (Player) event.getPlayer();                          Player player = (Player) event.getPlayer();
445                          if (player.getName().equals(chest.getOwner() )) {                          if (player.getName().equals(chest.getOwner() )) {
446                                  return; //chest is owned by it's own player                                  return; //chest is owned by it's own player
447                          }                                                }
448                            
449                            Set<String> players = Util.stringToSet( chest.getModifyPlayers() );
450                            if ( players.contains(player.getName()) ) {
451                                    return; //this player is on the whitelist so he may open
452                            }
453                                                    
454                                                    
455                          ItemCount contents = countItems( event.getInventory().getContents() );                                            ItemCount contents = countItems( event.getInventory().getContents() );                  
# Line 509  public class AdvancedChest  implements L Line 521  public class AdvancedChest  implements L
521                                          }                                          }
522                                                                    
523                                                                    
524                                          plugin.getLogger().info(msg);                                          server.getLogger().info( "[AdvancedChest]" + msg);
525                                          plugin.getMessageWrapper().sendMessage("system", owner, msg);                                          plugin.getMessageWrapper().sendMessage("system", owner, msg);
526                                  }                                  }
527                                                                    

Legend:
Removed from v.1808  
changed lines
  Added in v.1852

  ViewVC Help
Powered by ViewVC 1.1.20