/[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 1948 by torben, Fri Jan 18 09:44:30 2013 UTC revision 1949 by torben, Fri Mar 22 19:38:26 2013 UTC
# Line 43  public class AdvancedChest  implements L Line 43  public class AdvancedChest  implements L
43          class ItemCount extends TreeMap<Integer,Integer> {          class ItemCount extends TreeMap<Integer,Integer> {
44                  private static final long serialVersionUID = 1L;                  private static final long serialVersionUID = 1L;
45          };          };
46            
47          HashMap<String, ItemCount> contentMap = new HashMap<String, ItemCount>();          HashMap<String, ItemCount> contentMap = new HashMap<String, ItemCount>();
48            
49                    
50          HashMap<Location,ChestBean> chestMap = new HashMap<Location, ChestBean>();          HashMap<Location,ChestBean> chestMap = new HashMap<Location, ChestBean>();
51    
52            
53          HoerupUtilsPlugin plugin;          HoerupUtilsPlugin plugin;
54          Server server;          Server server;
55            
56          public AdvancedChest(HoerupUtilsPlugin plugin, Runnable r) {          public AdvancedChest(HoerupUtilsPlugin plugin, Runnable r) {
57                  this.plugin = plugin;                  this.plugin = plugin;
58                  server = plugin.getServer();                  server = plugin.getServer();
# Line 64  public class AdvancedChest  implements L Line 64  public class AdvancedChest  implements L
64                          loadChests();                          loadChests();
65                  }                  }
66          }          }
67            
68    
69          @Override          @Override
70          public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {          public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
# Line 72  public class AdvancedChest  implements L Line 72  public class AdvancedChest  implements L
72                          sender.sendMessage("this is not a console command!");                          sender.sendMessage("this is not a console command!");
73                          return true;                          return true;
74                  }                  }
75                    
76                  Player player = (Player) sender;                  Player player = (Player) sender;
77                    
78                  if (args.length == 0) {                  if (args.length == 0) {
79                          player.sendMessage("Usage:");                          player.sendMessage("Usage:");
80                          player.sendMessage("/chest (status|lock|snitch|remove|addplayer|removeplayer|setowner|comment) [player]");                          player.sendMessage("/chest (status|lock|snitch|remove|addplayer|removeplayer|setowner|comment) [player]");
81                          return true;                          return true;
82                  }                  }
83                    
84                                    
85                  Block b = player.getTargetBlock(null, 30);                                        Block b = player.getTargetBlock(null, 30);                      
86                    
87                  if (b.getTypeId() != 54) {                  if (b.getTypeId() != 54 && b.getTypeId() != 154) {
88                          player.sendMessage("[Chest] Please look at the chest you want to protect");                          player.sendMessage("[Chest] Please look at the chest/hopper you want to protect");
89                          return true;                          return true;
90                  }                  }
91                    
92                  Location loc = b.getLocation();                  Location loc = b.getLocation();
93                  Location loc2 = getNeighborChest(loc);                  Location loc2 = null;
94                                    if ( b.getTypeId() == 54) { //dont find neighbours for Hoppers
95                            loc2 = getNeighborChest(loc);
96                    }
97    
98                  ChestBean chest = chestMap.get(loc);                  ChestBean chest = chestMap.get(loc);
99                  String cmd = args[0].toLowerCase();                  String cmd = args[0].toLowerCase();
100                    
101                  if (cmd.equals("status")) {                  if (cmd.equals("status")) {
102                          if (chest != null) {                                                      if (chest != null) {                            
103                                  String mode = "";                                  String mode = "";
# Line 108  public class AdvancedChest  implements L Line 111  public class AdvancedChest  implements L
111                                  default:                                  default:
112                                          mode = "unknown ??";                                          mode = "unknown ??";
113                                  }                                                                }                              
114                                    
115                                  player.sendMessage(ChatColor.GREEN + "Chest is  a " + mode + " chest owned by " + chest.getOwner());                                  player.sendMessage(ChatColor.GREEN + "Chest is  a " + mode + " chest owned by " + chest.getOwner());
116                                  player.sendMessage(ChatColor.GREEN + "Allowed players: " + chest.getModifyPlayers() );                                  player.sendMessage(ChatColor.GREEN + "Allowed players: " + chest.getModifyPlayers() );
117                                  player.sendMessage(ChatColor.GREEN + "Comment: " + chest.getComment() );                                  player.sendMessage(ChatColor.GREEN + "Comment: " + chest.getComment() );
# Line 117  public class AdvancedChest  implements L Line 120  public class AdvancedChest  implements L
120                          }                          }
121                          return true;                          return true;
122                  }                  }
123                    
124                  if (cmd.equals("lock") || cmd.equals("snitch")) {                  if (cmd.equals("lock") || cmd.equals("snitch")) {
125                          if (chest == null) {                          if (chest == null) {
126                                  chest = createChest(player.getName(), "", loc);                                          chest = createChest(player.getName(), "", loc);        
# Line 142  public class AdvancedChest  implements L Line 145  public class AdvancedChest  implements L
145                          }                          }
146                          return true;                          return true;
147                  }                  }
148                    
149                  if (cmd.equals("remove")) {                  if (cmd.equals("remove")) {
150                          if (chest == null) {                          if (chest == null) {
151                                  player.sendMessage("This chest is not protected");                                  player.sendMessage("This chest is not protected");
# Line 188  public class AdvancedChest  implements L Line 191  public class AdvancedChest  implements L
191                          player.sendMessage("ok");                          player.sendMessage("ok");
192                          return true;                          return true;
193                  }                  }
194                    
195                  if (cmd.equals("addplayer") || cmd.equals("removeplayer")) {                  if (cmd.equals("addplayer") || cmd.equals("removeplayer")) {
196                          if (chest == null) {                          if (chest == null) {
197                                  player.sendMessage("This chest is not protected");                                  player.sendMessage("This chest is not protected");
# Line 208  public class AdvancedChest  implements L Line 211  public class AdvancedChest  implements L
211                                  player.sendMessage("Unknown user: " + args[1] );                                  player.sendMessage("Unknown user: " + args[1] );
212                                  return true;                                  return true;
213                          }                          }
214                            
215                          Set<String> players = Util.stringToSet( chest.getModifyPlayers() );                          Set<String> players = Util.stringToSet( chest.getModifyPlayers() );
216                          if (cmd.equals("addplayer")) {                          if (cmd.equals("addplayer")) {
217                                  players.add(p2.getName());                                  players.add(p2.getName());
218                          } else {                          } else {
219                                  players.remove(p2.getName());                                  players.remove(p2.getName());
220                          }                          }
221                            
222                          chest.setModifyPlayers( Util.setToString(players) );                          chest.setModifyPlayers( Util.setToString(players) );
223                          plugin.getDatabase().save( chest );                          plugin.getDatabase().save( chest );
224                          player.sendMessage("ok");                          player.sendMessage("ok");
# Line 244  public class AdvancedChest  implements L Line 247  public class AdvancedChest  implements L
247    
248                          return true;                          return true;
249                  }                  }
250                    
251                  /*                  /*
252                  if (chest != null) {                  if (chest != null) {
253                          if (chest.getOwner().equals(player.getName())) {                          if (chest.getOwner().equals(player.getName())) {
# Line 253  public class AdvancedChest  implements L Line 256  public class AdvancedChest  implements L
256                          } else {                          } else {
257                                  player.sendMessage("[LockedChest] Chest is already protected");                                  player.sendMessage("[LockedChest] Chest is already protected");
258                          }                          }
259                            
260                          return true;                          return true;
261                  }                  }
262                    
263                  chest = createChest(player.getName(), "", loc);                          chest = createChest(player.getName(), "", loc);        
264                  if (loc2 != null) {                  if (loc2 != null) {
265                          chest.setDoublechest(true);                          chest.setDoublechest(true);
266                  }                  }
267                    
268                  addChest(loc, chest);                  addChest(loc, chest);
269                    
270            
271                  player.sendMessage("[LockedChest] Chest is now locked");                  player.sendMessage("[LockedChest] Chest is now locked");
272                  */                   */
273                    
274                  player.sendMessage("Unknown argument, " + cmd);                  player.sendMessage("Unknown argument, " + cmd);
275                    
276                  return true;                  return true;
277          }          }
278            
279          @EventHandler          @EventHandler
280          public void onBlockBreak(BlockBreakEvent event) {          public void onBlockBreak(BlockBreakEvent event) {
281                  Location loc = event.getBlock().getLocation();                  Location loc = event.getBlock().getLocation();
# Line 295  public class AdvancedChest  implements L Line 298  public class AdvancedChest  implements L
298                          chestMap.put(loc2, chest);                          chestMap.put(loc2, chest);
299                  }                                }              
300                  plugin.getDatabase().save(chest);                  plugin.getDatabase().save(chest);
301                    
302                  reloadChests();                  reloadChests();
303                    
304          }          }
305            
306          void removeChest(Location loc) {          void removeChest(Location loc) {
307                  ChestBean chest = chestMap.remove(loc);                  ChestBean chest = chestMap.remove(loc);
308                  if (chest != null) {                                                                                      if (chest != null) {                                                                    
# Line 310  public class AdvancedChest  implements L Line 313  public class AdvancedChest  implements L
313                          plugin.getDatabase().delete(chest);                          plugin.getDatabase().delete(chest);
314                  }                  }
315          }          }
316            
317          int loadChestsWorker() {          int loadChestsWorker() {
318                  List<ChestBean> chestlist = plugin.getDatabase().find( ChestBean.class).findList();                  List<ChestBean> chestlist = plugin.getDatabase().find( ChestBean.class).findList();
319                  for (ChestBean chest : chestlist) {                  for (ChestBean chest : chestlist) {
320                          Location loc = getChestLocation(server, chest);                          Location loc = getChestLocation(server, chest);
321                          chestMap.put(loc, chest);                                chestMap.put(loc, chest);      
322                            
323                          if (chest.isDoublechest()) {                          if (chest.isDoublechest()) {
324                                  Location loc2 = getNeighborChest(loc);                                  Location loc2 = getNeighborChest(loc);
325                                  chestMap.put(loc2, chest);                                        chestMap.put(loc2, chest);      
# Line 325  public class AdvancedChest  implements L Line 328  public class AdvancedChest  implements L
328    
329                  return chestlist.size();                  return chestlist.size();
330          }          }
331            
332          void reloadChests() {                    void reloadChests() {          
333                  chestMap.clear();                  chestMap.clear();
334                  loadChestsWorker();                              loadChestsWorker();            
335          }          }
336            
337          void loadChests() {                      void loadChests() {            
338                  int count = loadChestsWorker();                  int count = loadChestsWorker();
339                  server.getLogger().info("[AdvancedChest] loaded " + count + " chests");                  server.getLogger().info("[AdvancedChest] loaded " + count + " chests");
340          }          }
341            
342            
343          public ChestBean createChest(String owner, String description, Location loc) {          public ChestBean createChest(String owner, String description, Location loc) {
344                    
345                  ChestBean chest = new ChestBean();                  ChestBean chest = new ChestBean();
346                  chest.setOwner(owner);                  chest.setOwner(owner);
347                  chest.setDescription(description);                  chest.setDescription(description);
# Line 346  public class AdvancedChest  implements L Line 349  public class AdvancedChest  implements L
349    
350                  return chest;                  return chest;
351          }          }
352            
353            
354          public void setChestLocation(ChestBean chest, Location loc) {          public void setChestLocation(ChestBean chest, Location loc) {
355                  chest.setWorld( loc.getWorld().getName() );                  chest.setWorld( loc.getWorld().getName() );
356                  chest.setX( loc.getBlockX() );                  chest.setX( loc.getBlockX() );
357                  chest.setY( loc.getBlockY() );                  chest.setY( loc.getBlockY() );
358                  chest.setZ( loc.getBlockZ() );                            chest.setZ( loc.getBlockZ() );          
359          }          }
360            
361          public Location getChestLocation(Server server, ChestBean chest) {          public Location getChestLocation(Server server, ChestBean chest) {
362                  World wrld = server.getWorld(chest.getWorld());                  World wrld = server.getWorld(chest.getWorld());
363                  return new Location(wrld,chest.getX(),chest.getY(),chest.getZ());                                return new Location(wrld,chest.getX(),chest.getY(),chest.getZ());              
364          }          }
365            
366    
367          /*          /*
368          void saveChests() {          void saveChests() {
369                    
370          }*/          }*/
371            
372          Location getNeighborChest(Location loc) {          Location getNeighborChest(Location loc) {
373                  World world = loc.getWorld();                  World world = loc.getWorld();
374                    
375                  Location target = new Location(world, loc.getX()+1, loc.getY(), loc.getZ() );                  Location target = new Location(world, loc.getX()+1, loc.getY(), loc.getZ() );
376                  if (world.getBlockAt(target).getType() == Material.CHEST )                  if (world.getBlockAt(target).getType() == Material.CHEST )
377                          return target;                          return target;
378                    
379                  target = new Location(world, loc.getX()-1, loc.getY(), loc.getZ() );                  target = new Location(world, loc.getX()-1, loc.getY(), loc.getZ() );
380                  if (world.getBlockAt(target).getType() == Material.CHEST )                  if (world.getBlockAt(target).getType() == Material.CHEST )
381                          return target;                                    return target;          
# Line 384  public class AdvancedChest  implements L Line 387  public class AdvancedChest  implements L
387                  target = new Location(world, loc.getX(), loc.getY(), loc.getZ() -1);                  target = new Location(world, loc.getX(), loc.getY(), loc.getZ() -1);
388                  if (world.getBlockAt(target).getType() == Material.CHEST )                  if (world.getBlockAt(target).getType() == Material.CHEST )
389                          return target;                                                                    return target;                                          
390                    
391                  return null;                  return null;
392          }          }
393            
394            
395          Location getChestLocation(InventoryHolder holder) {          Location getChestLocation(InventoryHolder holder) {
396                  Location loc;                  Location loc;
397                  if ( holder instanceof Chest) {                  if ( holder instanceof Chest) {
# Line 396  public class AdvancedChest  implements L Line 399  public class AdvancedChest  implements L
399                  } else {                  } else {
400                          loc =  ( (DoubleChest)holder).getLocation();                          loc =  ( (DoubleChest)holder).getLocation();
401                  }                  }
402                    
403                  loc.setX( loc.getBlockX() ); //round to integer, since double chests apparently are placed at pos + 0.5                  loc.setX( loc.getBlockX() ); //round to integer, since double chests apparently are placed at pos + 0.5
404                  loc.setZ( loc.getBlockZ() ); // -- // --                  loc.setZ( loc.getBlockZ() ); // -- // --
405                    
406                  return loc;                  return loc;
407          }          }
408            
409          @EventHandler          @EventHandler
410          public void onChestPlaced(BlockPlaceEvent event) {          public void onChestPlaced(BlockPlaceEvent event) {
411                  Block block = event.getBlock();                  Block block = event.getBlock();
412                    
413                  if (block.getType() != Material.CHEST) {                  if (block.getType() != Material.CHEST) {
414                          return;                          return;
415                  }                  }
416                    
417                  Location chestloc = getNeighborChest( block.getLocation() );                  Location chestloc = getNeighborChest( block.getLocation() );
418                  if (chestloc != null) {                  if (chestloc == null)
419                          ChestBean chest = chestMap.get(chestloc);                          return;
420                            
421                          if (chest != null) { //the neighbor is a locked chest                  ChestBean chest = chestMap.get(chestloc);
422                    
423                                                    if (chest == null)//the neighbor is not a locked chest
424                                  chest.setDoublechest(true);                          return;
425                                  addChest(chestloc, chest);                  
426                                    
427                                                    chest.setDoublechest(true);
428                                  event.getPlayer().sendMessage( "[AdvancedChest] Chest has been expanded" );                  addChest(chestloc, chest);
429                          }                        
430                            
431                  }                  event.getPlayer().sendMessage( "[AdvancedChest] Chest has been expanded" );
432          }          }
433    
434    
# Line 449  public class AdvancedChest  implements L Line 452  public class AdvancedChest  implements L
452                          event.setCancelled( true);                          event.setCancelled( true);
453                  }                  }
454          }          }
455            
456          // prevent a user from opening a chest          // prevent a user from opening a chest
457          @EventHandler          @EventHandler
458          public void onChestInteract(PlayerInteractEvent event) {          public void onChestInteract(PlayerInteractEvent event) {
459                  if (event.getAction() == Action.RIGHT_CLICK_BLOCK) {                  if (event.getAction() == Action.RIGHT_CLICK_BLOCK) {
460                          Block b = event.getClickedBlock();                          Block b = event.getClickedBlock();
461                            
462                          if (b.getType() == Material.CHEST) {                          if (b.getType() == Material.CHEST) {
463                                    
464                                  Location loc = b.getLocation();                                  Location loc = b.getLocation();
465                                    
466                                  ChestBean chest = chestMap.get( loc );                                  ChestBean chest = chestMap.get( loc );
467                                  if (chest == null) {                                                              if (chest == null) {                            
468                                          return; //chest not surveyed by this plugin                                          return; //chest not surveyed by this plugin
469                                  }                                  }
470                                    
471                                  if (chest.getChestType() != ChestBean.LOCKED ) {                                  if (chest.getChestType() != ChestBean.LOCKED ) {
472                                          return; //this is not a locked chests                                          return; //this is not a locked chests
473                                  }                                  }
474                                    
475                                  Player player = (Player) event.getPlayer();                                  Player player = (Player) event.getPlayer();
476                                  if (player.getName().equals(chest.getOwner() )) {                                  if (player.getName().equals(chest.getOwner() )) {
477                                          return; //chest is opened by it's owner                                          return; //chest is opened by it's owner
478                                  }                                  }
479                                    
480                                  Set<String> players = chest.getModifyPlayersSet() ;                                  Set<String> players = chest.getModifyPlayersSet() ;
481                                  if ( players.contains(player.getName()) ) {                                  if ( players.contains(player.getName()) ) {
482                                          return; //this player is on the whitelist so he may open                                          return; //this player is on the whitelist so he may open
# Line 489  public class AdvancedChest  implements L Line 492  public class AdvancedChest  implements L
492    
493          @EventHandler          @EventHandler
494          public void onChestOpen(InventoryOpenEvent event) {          public void onChestOpen(InventoryOpenEvent event) {
495                    
496                  if (! (event.getPlayer() instanceof Player)) {                  if (! (event.getPlayer() instanceof Player)) {
497                          return;                          return;
498                  }                  }
499    
500    
501                    
502                  InventoryHolder holder = event.getInventory().getHolder();                  InventoryHolder holder = event.getInventory().getHolder();
503                  if (holder instanceof Chest || holder instanceof DoubleChest) {                  if (holder instanceof Chest || holder instanceof DoubleChest) {
504                          Location loc = getChestLocation(holder);                          Location loc = getChestLocation(holder);
505                            
506                          ChestBean chest = chestMap.get( loc );                          ChestBean chest = chestMap.get( loc );
507                          if (chest == null) {                                                      if (chest == null) {                            
508                                  return; //chest not surveyed by this plugin                                  return; //chest not surveyed by this plugin
509                          }                          }
510                            
511                          if (chest.getChestType() != ChestBean.SNITCHING) {                          if (chest.getChestType() != ChestBean.SNITCHING) {
512                                  return; // not a snitching chest                                  return; // not a snitching chest
513                          }                          }
514                            
515                                                    
516                          Player player = (Player) event.getPlayer();                          Player player = (Player) event.getPlayer();
517                          if (player.getName().equals(chest.getOwner() )) {                          if (player.getName().equals(chest.getOwner() )) {
518                                  return; //chest is owned by it's own player                                  return; //chest is owned by it's own player
519                          }                          }
520                            
521                          Set<String> players = chest.getModifyPlayersSet();                          Set<String> players = chest.getModifyPlayersSet();
522                          if ( players.contains(player.getName()) ) {                          if ( players.contains(player.getName()) ) {
523                                  return; //this player is on the whitelist so he may open                                  return; //this player is on the whitelist so he may open
524                          }                          }
525                            
526                            
527                          server.getLogger().info( "[AdvancedChest] " + event.getPlayer().getName() + " opened a snitching chest owned by " + chest.getOwner()  + chest.getCommentString()  );                          server.getLogger().info( "[AdvancedChest] " + event.getPlayer().getName() + " opened a snitching chest owned by " + chest.getOwner()  + chest.getCommentString()  );
528    
529                          ItemCount contents = countItems( event.getInventory().getContents() );                                            ItemCount contents = countItems( event.getInventory().getContents() );                  
530                            
531                          contentMap.put(player.getName(), contents );                          contentMap.put(player.getName(), contents );
532                  }                  }
533          }          }
534            
535          @EventHandler          @EventHandler
536          public void onChestClose(InventoryCloseEvent event) {          public void onChestClose(InventoryCloseEvent event) {
537                  if (! (event.getPlayer() instanceof Player)) {                  if (! (event.getPlayer() instanceof Player)) {
538                          return;                          return;
539                  }                  }
540                    
541                    
542                  InventoryHolder holder = event.getInventory().getHolder();                  InventoryHolder holder = event.getInventory().getHolder();
543                  if (holder instanceof Chest || holder instanceof DoubleChest) {                  if (holder instanceof Chest || holder instanceof DoubleChest) {
544                          Location loc = getChestLocation(holder);                          Location loc = getChestLocation(holder);
545                          ChestBean chest = chestMap.get(loc);                          ChestBean chest = chestMap.get(loc);
546                            
547                          if (chest == null) { //chest was not a snitching chest                          if (chest == null) { //chest was not a snitching chest
548                                  return;                                  return;
549                          }                          }
550                            
551                          if (chest.getChestType() != ChestBean.SNITCHING) {                          if (chest.getChestType() != ChestBean.SNITCHING) {
552                                  return; // not a snitching chest                                  return; // not a snitching chest
553                          }                          }
554                            
555                            
556                          OfflinePlayer owner = server.getOfflinePlayer( chest.getOwner() );                          OfflinePlayer owner = server.getOfflinePlayer( chest.getOwner() );
557                            
558                            
559                          Player player = (Player) event.getPlayer();                          Player player = (Player) event.getPlayer();
560                            
561                          ItemCount savedContent = contentMap.get( player.getName() );                          ItemCount savedContent = contentMap.get( player.getName() );
562                            
563                          if (savedContent == null) {                          if (savedContent == null) {
564                                  return;                                  return;
565                          }                          }
566                            
567                          contentMap.remove( player.getName() );                          contentMap.remove( player.getName() );
568                            
569                          ItemCount content = countItems( event.getInventory().getContents() );                          ItemCount content = countItems( event.getInventory().getContents() );
570                                                    
571                          Set<Integer> combinedKeyset = new TreeSet<Integer>();                                            Set<Integer> combinedKeyset = new TreeSet<Integer>();                  
572                          combinedKeyset.addAll( savedContent.keySet() );                          combinedKeyset.addAll( savedContent.keySet() );
573                          combinedKeyset.addAll( content.keySet() );                          combinedKeyset.addAll( content.keySet() );
574                            
575                          for (Integer item : combinedKeyset ) {                          for (Integer item : combinedKeyset ) {
576                                  Integer savedcount = savedContent.get(item);                                                              Integer savedcount = savedContent.get(item);                            
577                                  Integer count = content.get(item);                                  Integer count = content.get(item);
578                                    
579                                  if (savedcount == null)                                  if (savedcount == null)
580                                          savedcount = 0;                                          savedcount = 0;
581                                  if (count == null)                                  if (count == null)
582                                          count = 0;                                          count = 0;
583                                    
584                                    
585                                  int diff = Math.abs( savedcount - count);                                  int diff = Math.abs( savedcount - count);
586                                    
587                                  if (diff > 0) {                                  if (diff > 0) {
588                                          String material = Material.getMaterial(item).name();                                          String material = Material.getMaterial(item).name();
589                                          String msg = null;                                          String msg = null;
590                                            
591                                          if (count > savedcount) {                                          if (count > savedcount) {
592                                                  msg = player.getName() + " added "   + diff + " units of " + material + "(" +item + ") to "   + owner.getName() + "'s chest at " + loc.getWorld().getName() + "," + loc.getBlockX() + "," +loc.getBlockY() + "," + loc.getBlockZ() + chest.getCommentString();                                                  msg = player.getName() + " added "   + diff + " units of " + material + "(" +item + ") to "   + owner.getName() + "'s chest at " + loc.getWorld().getName() + "," + loc.getBlockX() + "," +loc.getBlockY() + "," + loc.getBlockZ() + chest.getCommentString();
593                                          } else { //(count < savedcount)                                          } else { //(count < savedcount)
594                                                  msg = player.getName() + " removed " + diff + " units of " + material + "(" +item + ") from " + owner.getName() + "'s chest at " + loc.getWorld().getName() + "," + loc.getBlockX() + "," +loc.getBlockY() + "," + loc.getBlockZ() + chest.getCommentString();                                                  msg = player.getName() + " removed " + diff + " units of " + material + "(" +item + ") from " + owner.getName() + "'s chest at " + loc.getWorld().getName() + "," + loc.getBlockX() + "," +loc.getBlockY() + "," + loc.getBlockZ() + chest.getCommentString();
595                                          }                                          }
596                                    
597                                    
598                                          server.getLogger().info( "[AdvancedChest]" + msg);                                          server.getLogger().info( "[AdvancedChest]" + msg);
599                                          plugin.getMessageWrapper().sendMessage("system", owner, msg);                                          plugin.getMessageWrapper().sendMessage("system", owner, msg);
600                                  }                                  }
601                                    
602                          }                          }
603                            
604                            
605                  }                  }
606          }          }
607            
608          ItemCount countItems(ItemStack[] input) {          ItemCount countItems(ItemStack[] input) {
609                  ItemCount output = new ItemCount();                  ItemCount output = new ItemCount();
610                  for (int i=0; i<input.length; i++) {                  for (int i=0; i<input.length; i++) {
611                          ItemStack current = input[i];                          ItemStack current = input[i];
612                          if (current == null)                          if (current == null)
613                                  continue;                                  continue;
614                            
615                          int type = current.getTypeId();                          int type = current.getTypeId();
616                            
617                          Integer amount = output.get(type);                          Integer amount = output.get(type);
618                          if (amount == null)                          if (amount == null)
619                                  amount = 0;                                  amount = 0;
620                            
621                          output.put(type, amount + current.getAmount() );                                                  output.put(type, amount + current.getAmount() );                        
622                  }                  }
623                  return output;                  return output;
# Line 631  public class AdvancedChest  implements L Line 634  public class AdvancedChest  implements L
634                  }                  }
635                  return output;                  return output;
636          }*/          }*/
637            
638            
639  }  }

Legend:
Removed from v.1948  
changed lines
  Added in v.1949

  ViewVC Help
Powered by ViewVC 1.1.20