Search in sources :

Example 1 with BukkitItemStack

use of io.github.wysohn.triggerreactor.bukkit.bridge.BukkitItemStack in project TriggerReactor by wysohn.

the class InventoryTriggerManager method parseItemsList.

@SuppressWarnings("unchecked")
private void parseItemsList(ConfigurationSection itemSection, Map<Integer, IItemStack> items, int size) {
    for (int i = 0; i < size; i++) {
        ConfigurationSection section = itemSection.getConfigurationSection(String.valueOf(i));
        if (section == null)
            continue;
        Material type = Material.valueOf((String) section.get("Type", Material.DIRT.name()));
        int amount = section.getInt("Amount", 1);
        short data = (short) section.getInt("Data", 0);
        ItemMeta IM = (ItemMeta) section.get("Meta");
        ItemStack IS = new ItemStack(type, amount, data);
        if (IM == null)
            IM = IS.getItemMeta();
        if (IM != null) {
            // leave these for backward compatibility
            String title = section.getString("Title", null);
            Object lore = section.get("Lore", null);
            if (title != null)
                IM.setDisplayName(title);
            if (lore != null && lore instanceof List)
                IM.setLore((List<String>) lore);
            IS.setItemMeta(IM);
        }
        items.put(i, new BukkitItemStack(IS));
    }
}
Also used : BukkitItemStack(io.github.wysohn.triggerreactor.bukkit.bridge.BukkitItemStack) Material(org.bukkit.Material) ArrayList(java.util.ArrayList) List(java.util.List) BukkitItemStack(io.github.wysohn.triggerreactor.bukkit.bridge.BukkitItemStack) IItemStack(io.github.wysohn.triggerreactor.core.bridge.IItemStack) ItemStack(org.bukkit.inventory.ItemStack) ItemMeta(org.bukkit.inventory.meta.ItemMeta) ConfigurationSection(org.bukkit.configuration.ConfigurationSection)

Aggregations

BukkitItemStack (io.github.wysohn.triggerreactor.bukkit.bridge.BukkitItemStack)1 IItemStack (io.github.wysohn.triggerreactor.core.bridge.IItemStack)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1 Material (org.bukkit.Material)1 ConfigurationSection (org.bukkit.configuration.ConfigurationSection)1 ItemStack (org.bukkit.inventory.ItemStack)1 ItemMeta (org.bukkit.inventory.meta.ItemMeta)1