/[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 1807 by torben, Sun Jun 3 18:05:09 2012 UTC revision 1811 by torben, Tue Jun 5 09:30:32 2012 UTC
# Line 166  public class AdvancedChest  implements L Line 166  public class AdvancedChest  implements L
166                                                    
167                          Set<String> players = Util.stringToSet( chest.getModifyPlayers() );                          Set<String> players = Util.stringToSet( chest.getModifyPlayers() );
168                          if (cmd.equals("addplayer")) {                          if (cmd.equals("addplayer")) {
169                                  players.add(args[1]);                                  players.add(p2.getName());
170                          } else {                          } else {
171                                  players.remove(args[1]);                                  players.remove(p2.getName());
172                          }                          }
173                                                    
174                          chest.setModifyPlayers( Util.setToString(players) );                          chest.setModifyPlayers( Util.setToString(players) );
# Line 216  public class AdvancedChest  implements L Line 216  public class AdvancedChest  implements L
216                          } else {                          } else {
217                                  event.setCancelled(true);                                  event.setCancelled(true);
218                                  event.getPlayer().sendMessage("You can't destroy that chest");                                  event.getPlayer().sendMessage("You can't destroy that chest");
219                                    server.getLogger().info( "[AdvancedChest] " + event.getPlayer().getName() + " tried breaking a chest owned by " + chest.getOwner() );
220                          }                          }
221                  }                  }
222          }          }
# Line 365  public class AdvancedChest  implements L Line 366  public class AdvancedChest  implements L
366                  for (Block b : event.blockList() ) {                  for (Block b : event.blockList() ) {
367                          ChestBean chest = chestMap.get( b.getLocation() );                          ChestBean chest = chestMap.get( b.getLocation() );
368                          if (chest != null) {                          if (chest != null) {
369                                    server.getLogger().info( "[AdvancedChest] Prevented an explosion from destroying chest owned by " + chest.getOwner() );
370                                  event.setCancelled( true );                                  event.setCancelled( true );
371                                  return;                                  return;
372                          }                          }
# Line 395  public class AdvancedChest  implements L Line 397  public class AdvancedChest  implements L
397                                          return; //chest is opened by it's owner                                          return; //chest is opened by it's owner
398                                  }                                  }
399                                                                    
400                                  if (chest.getModifyPlayers() != null && chest.getModifyPlayers().length()>0) {                                  Set<String> players = Util.stringToSet( chest.getModifyPlayers() );
401                                          String modplayers[] = chest.getModifyPlayers().split(",");                                  if ( players.contains(player.getName()) ) {
402                                          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  
                                                 }  
                                         }  
403                                  }                                  }
404    
405                            
406                                    server.getLogger().info( "[AdvancedChest] " + event.getPlayer().getName() + " tried opening a chest owned by " + chest.getOwner() );
407                                  player.sendMessage( ChatColor.BLUE +  "Sorry but this chest is locked !");                                  player.sendMessage( ChatColor.BLUE +  "Sorry but this chest is locked !");
408                                  event.setCancelled(true);                                  event.setCancelled(true);
409                          }                          }
# Line 437  public class AdvancedChest  implements L Line 436  public class AdvancedChest  implements L
436                          Player player = (Player) event.getPlayer();                          Player player = (Player) event.getPlayer();
437                          if (player.getName().equals(chest.getOwner() )) {                          if (player.getName().equals(chest.getOwner() )) {
438                                  return; //chest is owned by it's own player                                  return; //chest is owned by it's own player
439                          }                                                }
440                            
441                            Set<String> players = Util.stringToSet( chest.getModifyPlayers() );
442                            if ( players.contains(player.getName()) ) {
443                                    return; //this player is on the whitelist so he may open
444                            }
445                                                    
446                                                    
447                          ItemCount contents = countItems( event.getInventory().getContents() );                                            ItemCount contents = countItems( event.getInventory().getContents() );                  

Legend:
Removed from v.1807  
changed lines
  Added in v.1811

  ViewVC Help
Powered by ViewVC 1.1.20