Cube-Space / Yamler

21 stars 33 forks source link

Saving an ItemStack results in an NullPointerException #18

Closed bibo38 closed 9 years ago

bibo38 commented 9 years ago
import java.io.File;

import org.bukkit.Material;
import org.bukkit.inventory.ItemStack;

import net.cubespace.Yamler.Config.Config;

public class TestConfig extends Config
{
    public ItemStack is = new ItemStack(Material.COOKIE);

    public TestConfig()
    {
        CONFIG_FILE = new File("test.yml");
        try
        {
            addConverter(net.cubespace.Yamler.Converter.ItemStack.class);
            init();
        } catch (Exception e)
        {
            e.printStackTrace();
        }
    }

    public static void main(String args[])
    {
        new TestConfig();
    }
}

This produces the following NullPointerException:

net.cubespace.Yamler.Config.InvalidConfigurationException: Could not save the Field
    at net.cubespace.Yamler.Config.Config.internalSave(Config.java:84)
    at net.cubespace.Yamler.Config.Config.save(Config.java:36)
    at net.cubespace.Yamler.Config.Config.init(Config.java:108)
    at TestConfig.<init>(TestConfig.java:18)
    at TestConfig.main(TestConfig.java:27)
Caused by: java.lang.NullPointerException
    at org.bukkit.Bukkit.getItemFactory(Bukkit.java:1038)
    at org.bukkit.inventory.ItemStack.getItemMeta(ItemStack.java:568)
    at net.cubespace.Yamler.Converter.ItemStack.toConfig(ItemStack.java:34)
    at net.cubespace.Yamler.Config.InternalConverter.toConfig(InternalConverter.java:102)
    at net.cubespace.Yamler.Config.Config.internalSave(Config.java:80)
    ... 4 more