Solved Load ItemStack[] from the config - NPE

Discussion in 'Plugin Development' started by re4ly, Oct 10, 2013.

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

    re4ly

    hello, i want to load itemstack[]'s from the config, but there is a NPE.

    Code:java
    1. @SuppressWarnings("unchecked")
    2. private void loadModes() {
    3. //GET FILE
    4. File file = new File("plugins/SimpleArena", "modes.yml");
    5. FileConfiguration cfg = YamlConfiguration.loadConfiguration(file);
    6. for (String mode : cfg.getConfigurationSection("").getKeys(false)) {
    7. List<ItemStack> invList = (List<ItemStack>)cfg.get(mode + "inv");
    8. List<ItemStack> armorList = (List<ItemStack>)cfg.get(mode + "armor");
    9. ItemStack[] inv = (ItemStack[]) invList.toArray();
    10. ItemStack[] armor = (ItemStack[]) armorList.toArray();
    11. this.modes.put(mode.toLowerCase(), new Mode(inv,armor));
    12. }
    13. }


    Config: http://pastebin.com/QjqSc4TX

    Can someone help me?
     
  2. Offline

    The_Doctor_123

    You'll need to serialize and unserialize those ItemStacks.
     
  3. Offline

    re4ly

    And without serialize?
     
  4. Offline

    The_Doctor_123

Thread Status:
Not open for further replies.

Share This Page