public HashMap<String, Integer> addChest(ShopChest chest) { Set<Integer> itemids = chest.getItemIds(); /// Trying to activate a chest with nothing in it, abort, everything_id is something and would // show up here if (itemids == null || itemids.isEmpty()) { return null; } Location cl = chest.getLocation(); /// Somehow occasionally, for (ShopChest sc : chests_by_loc.values()) { if (!sc.getWorld().getName().equals(cl.getWorld().getName())) continue; int distance = (cl.getY() == sc.getY()) ? (int) (Math.abs(cl.getX() - sc.getX()) + Math.abs(cl.getZ() - sc.getZ())) : Integer.MAX_VALUE; if (distance <= 1) { return null; } } String key = KeyUtil.getStringLoc(chest); chests_by_loc.put(key, chest); HashMap<String, Integer> itemname_count = new HashMap<String, Integer>(); List<Integer> ids_with_signs = new ArrayList<Integer>(); for (Integer id : itemids) { if (!chests_by_itemid.containsKey(id)) { chests_by_itemid.put(id, new HashMap<String, ShopChest>()); } Map<String, ShopChest> c = chests_by_itemid.get(id); c.put(key, chest); final String cn = ShopSign.getCommonName(id); if (cn.isEmpty()) { // / As of 1.0.0 sometimes this is empty for some reason, figure out why System.err.println("Commonname id=" + id + " location=" + chest.getLocation()); continue; } if (signs_by_itemid.containsKey(id)) { ids_with_signs.add(id); itemname_count.put(cn, signs_by_itemid.get(id).size()); } else { itemname_count.put(cn, 0); } } return itemname_count; }