Solved Solved

Discussion in 'Plugin Development' started by Omel, May 18, 2016.

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

    Omel

    How do i Save the first 27 Items from an inv to a config?

    Code:
    public void saveInv(Player p, Inventory inv){
            File file = new File("plugins//" + main.directoryFolderName + "//EnderChests", p.getUniqueId().toString());
            FileConfiguration cfg = new YamlConfiguration().loadConfiguration(file);
         
         
            File file1 = new File("plugins//" + main.directoryFolderName + "//EnderChestSlots", p.getUniqueId().toString());
            FileConfiguration cfg1 = new YamlConfiguration().loadConfiguration(file1);
         
         
         
           //THIS DONT WORK BUT WHY? IT SAVES NOTHING THE CONFIG IS EMPTY AFTER THIS
    for(int in = 0; in < cfg1.getInt("slots"); in++){
              
                ItemStack i = inv.getItem(in);
                cfg.set("inventory", i);
              
            }
         
         
         
         
         
         
     
     
        try {
            cfg.save(file);
        } catch (IOException e) {
         
        }
     
        }
     
    Last edited: May 18, 2016
  2. Offline

    Irantwomiles

    Are you sure slots is not empty? Also I don't see where you're saving the slots so it would be helpful seeing that part of the code.
     
  3. Offline

    Omel

    Fixed
     
    Last edited: May 18, 2016
  4. Offline

    Sinnska

    Please share how you fix it, people can learn too
     
Thread Status:
Not open for further replies.

Share This Page