How to save Inventory?

Discussion in 'Plugin Development' started by MrGriefer_HGTech, Dec 23, 2014.

?

_____________________________

Poll closed Dec 23, 2014.
  1. _____________________________

    1 vote(s)
    50.0%
  2. _____________________________

    1 vote(s)
    50.0%
Thread Status:
Not open for further replies.
  1. Hello!

    What I want is really easy, so what I want is I want to save players Inventory and when a player joins a game it will clear there inventory and when the game is finished or they leave it will give them the same items or enchantments on there item. I don't know how to make this. please help.

    Thanks MrGriefer [tnt].
     
  2. Offline

    JordyPwner

    Might help maybe not: http://bukkit.org/threads/help-save-load-inventory.92291/
     
  3. Code:Java
    1. HashMap<Player, Inventory> oldInvs = new HashMap<Player, Inventory>();

    save inventories with
    Code:Java
    1. oldInvs.put(player, player.getInventory());

    then clear the inventory.
    load inventories with
    Code:Java
    1. if (oldInvs.contains(player) {
    2. player.getInventory().setContents(oldInvs.get(player).getContents());
     
  4. Offline

    mine-care

    @FisheyLP but on server reloads they will be erased soooo... Mabe serialize it as well ( I can give u a custom class I made for serializable itemstack
     
  5. So I went with "_____________________________" this time.

    @MrGriefer_HGTech Seriously, what's with these polls? They're not required, you know. In either case, you can just store it in memory but, if you do, bare in mind that they will lose their inventory on reload/restart if you do that. If that's not acceptable, look into saving to file.
     
  6. Offline

    nverdier

    @MrGriefer_HGTech
    Well you could just give them the inventories on disable... Not sure what the entire plugin looks like but it could work..
     
  7. @AdamQpzm I don't want polls so I just put ________________ since I really don't know how to delete them. Is there a way to not make them lose there Inventory on reload/restart?
     
  8. @MrGriefer_HGTech You don't have to make a poll, just leave that section alone when filling out a thread :p And yes, you could give them their inventory back as @nverdier said, or save their inventory to file and reset at a later date.
     
Thread Status:
Not open for further replies.

Share This Page