Reading An Array From A YAML

Discussion in 'Plugin Development' started by Quidam, Jun 15, 2013.

Thread Status:
Not open for further replies.
  1. Offline

    Quidam

    So, I've stored an array of ItemStack in a YAML file. Writing the array to the file works perfectly. However, when I cast (ItemStack[]) to the section of the YAML and try to read it, I get a ClassCastException.

    Writing it to the file:
    Code:java
    1. FileConfiguration config = YamlConfiguration.loadConfiguration(file);
    2. config.set("Inventory", save.get(p).getContents());


    Trying to read it:
    Code:java
    1. FileConfiguration config = YamlConfiguration.loadConfiguration(file);
    2. ItemStack[] iStack = (ItemStack[]) config.get("Inventory");
    3. i.setContents(iStack);
    4. if(i != null){
    5. save.put(p, i);
    6. }


    Any help would be greatly appreciated. Thanks.
     
  2. Offline

    chasechocolate

    Quidam likes this.
  3. Offline

    Quidam

    chasechocolate
     
Thread Status:
Not open for further replies.

Share This Page