Search code examples
javaintellij-ideaminecraftbukkit

Spigot | PersistantDataContainer() says Cannot Resolve


may be a stupid question, but there is a message calle cannot resolve if i use getPersistentDataContainer() in my method. How can i fix this?

    private ItemStack createItem(String name, ArrayList<String> lore, Material mat, String itemfunc, int amount) {

    ItemStack iStack = new ItemStack(mat, amount);
    ItemMeta iMeta = iStack.getItemMeta();
    iMeta.getPersistentDataContainer().set(this.ITEMFUNC, PersistentDataType.STRING, itemfunc);
    iMeta.setDisplayName(name);
    iMeta.setLore(lore);
    iStack.setItemMeta(iMeta);


    return iStack;
}

Solution

  • Fixed it:

    <dependency>
            <groupId>com.github.MilkBowl</groupId>
            <artifactId>VaultAPI</artifactId>
            <version>1.7</version>
            <scope>provided</scope>
            <exclusions>
                <exclusion>
                    <groupId>org.bukkit</groupId>
                    <artifactId>bukkit</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
    

    Only if you use the VaultAPI, you have to exclude org.bukkit. So that we can use it from the original dependency