Search in sources :

Example 1 with LoreHandler

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);
    }
}
Also used : EnchantmentStorageMeta(org.bukkit.inventory.meta.EnchantmentStorageMeta) LoreHandler(io.zivoric.enchantmentcore.utils.lore.LoreHandler) PaperLoreHandler(io.zivoric.enchantmentcore.utils.lore.PaperLoreHandler) DefaultLoreHandler(io.zivoric.enchantmentcore.utils.lore.DefaultLoreHandler) CustomEnch(io.zivoric.enchantmentcore.CustomEnch) Enchantment(org.bukkit.enchantments.Enchantment)

Aggregations

CustomEnch (io.zivoric.enchantmentcore.CustomEnch)1 DefaultLoreHandler (io.zivoric.enchantmentcore.utils.lore.DefaultLoreHandler)1 LoreHandler (io.zivoric.enchantmentcore.utils.lore.LoreHandler)1 PaperLoreHandler (io.zivoric.enchantmentcore.utils.lore.PaperLoreHandler)1 Enchantment (org.bukkit.enchantments.Enchantment)1 EnchantmentStorageMeta (org.bukkit.inventory.meta.EnchantmentStorageMeta)1