Looping through configuration...ItemStacks

Discussion in 'Spigot Plugin Development' started by valaiyar, Jun 24, 2016.

  1. I am trying to loop through my configuration file (mainly used for storing itemstacks, and a few toggleable options) and the plugin is almost completely done, but I just want to make something, which needs to loop through the configuration file to get the itemstacks under one string (key.exampleitemstack, key.exampleitemstack2) and then put them into a gui, now I am using the default ItemStack storing thing for configuration files and it's kinda giving me aids so if someone could please help me this would be great!!! <3
  2. with your config variable, use the #getConfigurationSection() method with #getKeys(false) to loop through the values in there. If you directly stored the ItemStack, you can do something like this:
    Code (Java):
    ItemStack item= (ItemStack) config.getString("your.path.here");
  3. Choco


    Erm... No? You can't cast a String to an ItemStack. I think you mean config.getItemStack("path")
  4. I won't know the exact path as the item's path will be key.(the item's displayname here)
  5. Code (Java):
    List<ItemStack> list = (List<ItemStack>) config.get("path");
    // you can use list.
  6. getItemStack isn't a method. I meant to use just #get()
    • Like Like x 1