Inventory Help

Discussion in 'Plugin Development' started by Gingerbreadman, Nov 12, 2014.

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

    Gingerbreadman

    Hello everyone
    I am making a plugin and I can not figure out how to do this!
    I made an ArrayList of Strings [Has to be Strings]
    I want to convert them to ItemStacks so I can add them to the players inventory

    -Gingerbreadman
     
  2. Offline

    Tecno_Wizard

  3. Offline

    Gingerbreadman

  4. Offline

    Cyber_Pigeon

    Can you be more descriptive? Also, an ArrayList does not have to be a string. Neither does an ItemStack name.
    You can simply put "ArrayList<Double, Integer, Player, String, ItemStack, etc.> = new ArrayList<Double, Integer, Player, String, ItemStack, etc.>();"
     
  5. Offline

    tangster132

    I think you can use Material.getMaterial(String name)
     
  6. Offline

    Gingerbreadman

    tangster132 Cyber_Pigeon I know how it dosent need to be string
    I am telling you now I made a config that stores strings for each player
    and I want to be able to give them the items that are stored
     
  7. Offline

    tangster132

    So then you can just do
    Code:java
    1. ItemStack item = new ItemStack(Material.getMaterial(materialName));


    You just need to make sure that the Strings are formatted for Material (all caps and "_" for spaces)
     
  8. Offline

    Tecno_Wizard

    Gingerbreadman, create a service provider with the method StringToMatrial. In the on enable, loop through each of the material.toString() and see if you get a match. If you do, add it to a itemstack arraylist
     
  9. Offline

    Konato_K

    Or use Material#matchMaterial(String) ?
     
  10. Offline

    Tecno_Wizard

    If I knew that was a thing I would have suggested that. LOL. Still add them to an ArrayList<Itemstack>
     
Thread Status:
Not open for further replies.

Share This Page