inv.getContents() to config

Discussion in 'Plugin Development' started by Innofly, Mar 12, 2014.

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

    Innofly

    Is there a way to save items of inv.getContents() in a config file?
     
  2. Offline

    xTigerRebornx

    Innofly ItemStack implements ConfigurationSerializable, and I believe Invetory#getContents() returns a ItemStack[], so you could loop through that and save it
     
  3. Offline

    Heirteir

    Innofly
    Why exactly would you need this trying to make it so you can edit the contents of an inventory while a player is
    off of the server?

    Well that guy kinda helped you before i could also

    xTigerRebornx
    How do you get that signature i want that
     
  4. Offline

    Innofly

    @Heirteir No I want to save a player custom inventory (vault) into a config file.
     
  5. Offline

    xTigerRebornx

    Heirteir Search the forums, Jade (a mod) made a generator for it and posted it somewhere on here
     
  6. Offline

    Heirteir

    Innofly
    Can you post the code you already have so i can get an idea of what your trying to aim for?
     
  7. Offline

    Innofly

    @Heirteir I have no code for now, I'm just wondering if its possible.
     
  8. Offline

    xTigerRebornx

    Innofly Its possible, and isn't that hard to do
     
  9. Offline

    Innofly

  10. Offline

    AoH_Ruthless

    Innofly
    Inventory.getContents(); returns ItemStack[]. This means you can iterate through each indiviual itemstack and save that to config.

    All you need to do is create a for loop that loops through the contents, and for each content save it's material type, amount, maybe it's itemmeta and data if you wanted to go that far.

    xTigerRebornx
    Didn't even recognize who you are without your tiger image.
     
  11. Offline

    xTigerRebornx

    AoH_Ruthless He can store the entire ItemStack into the config itself, it implements ConfigurationSerializable.
     
  12. Offline

    AoH_Ruthless

    xTigerRebornx
    That is true; I just always found it more helpful to store individual parts of the itemstack in case I only need individual parts of it later (If any of that made sense to you :p)
     
Thread Status:
Not open for further replies.

Share This Page