use of io.zivoric.enchantmentcore.utils.lore.LoreHandler in project ZEnchantmentCore by zivoric.
the class EnchantmentUtils method updateItemLore.
/**
* Update the lore of the item meta
*
* @param meta the item meta
*/
public static void updateItemLore(ItemMeta meta) {
if (meta == null) {
return;
}
// Load enchants
Map<Enchantment, Integer> enchs;
if (meta instanceof EnchantmentStorageMeta) {
enchs = ((EnchantmentStorageMeta) meta).getStoredEnchants();
} else {
enchs = meta.getEnchants();
}
// Filter the custom enchantments
Map<CustomEnch, Integer> customEnchs = new HashMap<>();
for (Map.Entry<Enchantment, Integer> entry : enchs.entrySet()) {
if (entry.getKey() instanceof CustomEnch) {
customEnchs.put((CustomEnch) entry.getKey(), entry.getValue());
}
}
// Update the lore
for (LoreHandler loreHandler : LORE_HANDLER_LIST) {
customEnchs = loreHandler.updateItemLore(meta, customEnchs);
}
}
Aggregations