Solved List<String> to ItemStack[]

Discussion in 'Plugin Development' started by mahbbazci, Dec 2, 2017.

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

    mahbbazci

    How do I save the inventory of a player in the config and return it to the player at any given time?

    I'm trying to save in List <String>, but I do not know how to turn it into item again!
     
  2. Offline

    Caderape2

    @mahbbazci Bukkit can save and load itemstack from config with the method set() and get()
    loop the inventory, and use the slot as key for save the itemstack.
     
  3. You'll need to label the slots in the config, and put an itemstack under each. @Caderape2 is correct, but this is only because ItemStack implements ConfigurationSerializable. This doesn't work for any random object, but for itemstacks it does.

    Example format in the config:
    Code:
    <player's inventory>:
        '3': (item data)
    You can get each slot then by doing getConfig().getConfigurationSection("Steve").keySet().
     
Thread Status:
Not open for further replies.

Share This Page