--- miscJava/bukkit-minecraft-plugins/HoerupUtils/src/main/java/dk/thoerup/bukkit/hoeruputils/chests/AdvancedChest.java 2015/03/09 12:29:22 2429 +++ miscJava/bukkit-minecraft-plugins/HoerupUtils/src/main/java/dk/thoerup/bukkit/hoeruputils/chests/AdvancedChest.java 2016/11/18 13:14:07 3133 @@ -2,7 +2,6 @@ import java.util.HashMap; -import java.util.HashSet; import java.util.List; import java.util.Set; import java.util.TreeMap; @@ -41,7 +40,7 @@ public class AdvancedChest implements Listener, CommandExecutor{ - class ItemCount extends TreeMap { + class ItemCount extends TreeMap { private static final long serialVersionUID = 1L; }; @@ -84,15 +83,16 @@ Block b = player.getTargetBlock( (Set)null, 30); - - if (b.getTypeId() != 54 && b.getTypeId() != 154) { + Material mat = b.getType(); + + if (mat != Material.CHEST && mat != Material.HOPPER) { player.sendMessage("[Chest] Please look at the chest/hopper you want to protect"); return true; } Location loc = b.getLocation(); Location loc2 = null; - if ( b.getTypeId() == 54) { //dont find neighbours for Hoppers + if ( mat == Material.HOPPER) { //dont find neighbours for Hoppers loc2 = getNeighborChest(loc); } @@ -182,7 +182,10 @@ player.sendMessage("You need to specify which player should own this chest"); return true; } + + //@SuppressWarnings("deprecation")//user by name is our only option here OfflinePlayer p2 = server.getOfflinePlayer(args[1]); + if ( p2.hasPlayedBefore() == false && p2.isOnline() == false) { player.sendMessage("Unknown user: " + args[1] ); return true; @@ -207,6 +210,8 @@ player.sendMessage("You need to specify which player to add or remove"); return true; } + + //@SuppressWarnings("deprecation")//user by name is our only option here OfflinePlayer p2 = server.getOfflinePlayer(args[1]); if ( p2.hasPlayedBefore() == false && p2.isOnline() == false) { player.sendMessage("Unknown user: " + args[1] ); @@ -569,13 +574,13 @@ ItemCount content = countItems( event.getInventory().getContents() ); - Set combinedKeyset = new TreeSet(); + Set combinedKeyset = new TreeSet(); combinedKeyset.addAll( savedContent.keySet() ); combinedKeyset.addAll( content.keySet() ); - for (Integer item : combinedKeyset ) { - Integer savedcount = savedContent.get(item); - Integer count = content.get(item); + for (Material material : combinedKeyset ) { + Integer savedcount = savedContent.get(material); + Integer count = content.get(material); if (savedcount == null) savedcount = 0; @@ -586,13 +591,12 @@ int diff = Math.abs( savedcount - count); if (diff > 0) { - String material = Material.getMaterial(item).name(); String msg = null; if (count > savedcount) { - 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 + " to " + owner.getName() + "'s chest at " + loc.getWorld().getName() + "," + loc.getBlockX() + "," +loc.getBlockY() + "," + loc.getBlockZ() + chest.getCommentString(); } else { //(count < savedcount) - 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 + " from " + owner.getName() + "'s chest at " + loc.getWorld().getName() + "," + loc.getBlockX() + "," +loc.getBlockY() + "," + loc.getBlockZ() + chest.getCommentString(); } @@ -613,7 +617,7 @@ if (current == null) continue; - int type = current.getTypeId(); + Material type = current.getType(); Integer amount = output.get(type); if (amount == null)