Solved My item builder class stopped working

Discussion in 'Spigot Plugin Development' started by DotRar, May 24, 2016.

  1. My custom item builder class has been working fine up until now, but I tried to use it in a project but I only get some of the methods show up: (The item builder is supposed to be chainable)
    [​IMG]

    It only shows setAmount, setLore, setName and getStack however, I have a lot of other methods in this class:

    Code (Text):

    package com.perkelle.dev.tntwars.utils;

    import java.util.Arrays;

    import org.bukkit.Color;
    import org.bukkit.Material;
    import org.bukkit.enchantments.Enchantment;
    import org.bukkit.inventory.ItemFlag;
    import org.bukkit.inventory.ItemStack;
    import org.bukkit.inventory.meta.ItemMeta;
    import org.bukkit.inventory.meta.LeatherArmorMeta;
    import org.bukkit.material.MaterialData;

    public class ItemBuilder {

        private final ItemStack stack;

        public ItemBuilder(final Material material) {
            stack = new ItemStack(material);
        }

        public ItemBuilder setAmount(final Integer amount) {
            stack.setAmount(amount);
            return this;
        }

        public ItemBuilder addEnchant(final Enchantment enchant, final Integer level) {
            final ItemMeta meta = stack.getItemMeta();
            meta.addEnchant(enchant, level, true);
            stack.setItemMeta(meta);
            return this;
        }

        public ItemBuilder setDisplayName(final String name) {
            final ItemMeta meta = stack.getItemMeta();
            meta.setDisplayName(name);
            stack.setItemMeta(meta);
            return this;
        }

        public ItemBuilder setLore(final String... lore) {
            final ItemMeta meta = stack.getItemMeta();
            meta.setLore(Arrays.asList(lore));
            stack.setItemMeta(meta);
            return this;
        }

        public ItemBuilder setColor(final Color color) {
            if (stack.getType() == Material.LEATHER_BOOTS || stack.getType() == Material.LEATHER_LEGGINGS || stack.getType() == Material.LEATHER_CHESTPLATE ||
                    stack.getType() == Material.LEATHER_HELMET) {
                final LeatherArmorMeta meta = (LeatherArmorMeta) stack.getItemMeta();
                meta.setColor(color);
                stack.setItemMeta(meta);
            }
            else {
                throw new IllegalArgumentException("setColor can only be used on leather armour!");
            }
            return this;
        }

        public ItemBuilder setDurability(final int durability) {
            if (durability >= Short.MIN_VALUE && durability <= Short.MAX_VALUE) {
                stack.setDurability((short)durability);
            }
            else {
                throw new IllegalArgumentException("The durability must be a short!");
            }
            return this;
        }

        public ItemBuilder addFlag(final ItemFlag flag) {
            final ItemMeta meta = stack.getItemMeta();
            meta.addItemFlags(flag);
            stack.setItemMeta(meta);
            return this;
        }

        public ItemBuilder setData(MaterialData data) {
            final ItemMeta meta = stack.getItemMeta();
            stack.setData(data);
            stack.setItemMeta(meta);
            return this;
        }

        public ItemStack getStack() {
            return stack;
        }
    }
     
     
  2. T
    Try refreshing your project.
     
    • Like Like x 1
  3. I've closed and reopened my project, also ctrl+f5'd the join and item builder class
     
  4. Type in the method name yourself and see if it shows you an error.
     
  5. Open the file menu (top left corner) and click invalidate caches and restart
    That should fix the issue
     
  6. Correct import? If it's an external source, make sure you have an up-to-date version of it.
     
    • Winner Winner x 1
  7. Cannot resolve method =/

    Still nope
     
  8. Turned out I imported a cut down version from my economy library. rip.