// This is used in parallel with the isDefault. // Parallel usage is useful since we can then override isDeafult just like before. public static boolean isCustomDataDefault(Object entity) { if (!(entity instanceof Entity)) return true; JsonObject customData = ((Entity<?>) entity).getCustomData(); if (customData == null) return true; if (customData.entrySet().size() == 0) return true; return false; }
public static Map<Enchantment, Integer> convertEnchantLevelMap(JsonElement jsonElement) { JsonObject json = jsonElement.getAsJsonObject(); Map<Enchantment, Integer> ret = new HashMap<Enchantment, Integer>(); for (Entry<String, JsonElement> entry : json.entrySet()) { int id = Integer.valueOf(entry.getKey()); Enchantment ench = Enchantment.getById(id); int lvl = entry.getValue().getAsInt(); ret.put(ench, lvl); } return ret; }