Save Inventory and Loading Inventory

Discussion in 'Plugin Development' started by Warreo, Aug 22, 2012.

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

    Warreo

    Hey guys, now I've been looking and I'm really hoping there's an easy way to do this. But I would like to be able to save a players inventory to a file with a method such as this one:

    PHP:
    ItemStack[] items player.getInventory().getContents();
                for(
    ItemStack i items){
                    if(
    != null){
                    
    String s i.getType().toString();
                    
    int z i.getAmount();
                    
    this.getBankConfig().set(player.getName() + "." +player.getWorld().getName() + "." sz);           
                    }
                }
                
    this.saveBankConfig();
                
    player.sendMessage("Writen");
    But now I would like to know a fast way to read this (or an edited version of that). And then be able to give it back to the player, if someone could point me in the right direction I would really appreciate that! Thanks!
     
  2. Offline

    yukinoraru

  3. Offline

    Warreo

  4. Nobody here seems to know that you can save an ItemStack in a yml without any converting... What do you think config.getItemStack(path) is for? ;)
     
  5. http://forums.bukkit.org/threads/serialize-inventory-to-single-string-and-vice-versa.92094/
    thats just great
     
  6. Offline

    Warreo

  7. That's what i thought when i saw it :p
     
Thread Status:
Not open for further replies.

Share This Page