public static void transferPages(BookMeta meta, JsonObject json, boolean meta2json) { if (meta2json) { if (!meta.hasTitle()) return; json.add(BOOK_PAGES, convertStringList(meta.getPages())); } else { JsonElement element = json.get(BOOK_PAGES); if (element == null) return; meta.setPages(convertStringList(element)); } }
public static void transferLore(ItemMeta meta, JsonObject json, boolean meta2json) { if (meta2json) { if (!meta.hasLore()) return; json.add(LORE, convertStringList(meta.getLore())); } else { JsonElement element = json.get(LORE); if (element == null) return; meta.setLore(convertStringList(element)); } }
public static void transferFireworkEffectMeta( FireworkEffectMeta meta, JsonObject json, boolean meta2json) { if (meta2json) { if (!meta.hasEffect()) return; json.add(FIREWORK_EFFECT, FireworkEffectAdapter.toJson(meta.getEffect())); } else { JsonElement element = json.get(FIREWORK_EFFECT); if (element == null) return; meta.setEffect(FireworkEffectAdapter.fromJson(element)); } }
public static void transferFireworkMetaEffects( FireworkMeta meta, JsonObject json, boolean meta2json) { if (meta2json) { if (!meta.hasEffects()) return; json.add(FIREWORK_EFFECTS, convertFireworkEffectList(meta.getEffects())); } else { JsonElement element = json.get(FIREWORK_EFFECTS); if (element == null) return; meta.clearEffects(); meta.addEffects(convertFireworkEffectList(element)); } }
public static void transferEnchants(ItemMeta meta, JsonObject json, boolean meta2json) { if (meta2json) { if (!meta.hasEnchants()) return; json.add(ENCHANTS, convertEnchantLevelMap(meta.getEnchants())); } else { JsonElement element = json.get(ENCHANTS); if (element == null) return; for (Entry<Enchantment, Integer> entry : convertEnchantLevelMap(element).entrySet()) { meta.addEnchant(entry.getKey(), entry.getValue(), true); } } }
public static void transferEnchantmentStorageMeta( EnchantmentStorageMeta meta, JsonObject json, boolean meta2json) { if (meta2json) { if (!meta.hasStoredEnchants()) return; json.add(STORED_ENCHANTS, convertEnchantLevelMap(meta.getStoredEnchants())); } else { JsonElement element = json.get(STORED_ENCHANTS); if (element == null) return; // TODO: Add a pull request to get rid of this entry set loop! // TODO: A set, clear, remove all system is missing for (Entry<Enchantment, Integer> entry : convertEnchantLevelMap(element).entrySet()) { meta.addStoredEnchant(entry.getKey(), entry.getValue(), true); } } }
public static void transferPotionMeta(PotionMeta meta, JsonObject json, boolean meta2json) { if (meta2json) { if (!meta.hasCustomEffects()) return; json.add(POTION_EFFECTS, convertPotionEffectList(meta.getCustomEffects())); } else { JsonElement element = json.get(POTION_EFFECTS); if (element == null) element = json.get(POTION_EFFECTS_OLD); if (element == null) return; meta.clearCustomEffects(); for (PotionEffect pe : convertPotionEffectList(element)) { meta.addCustomEffect(pe, false); } } }