Quick Question...

Discussion in 'Spigot Plugin Help' started by Kozs, Dec 30, 2016.

  1. IS there a way to loop through each item not Material, ITEM with the Spigot API?

    I tried looping through Items but there doesn't seem to be a values method, I thought all Enum's have values() method?
  2. So basically you wanna know all the existing Material and maybe add that to a list?

    Sent from my iPhone using Tapatalk
  3. Well some Material is STONE with the Durability of 1-5 like the Granite, Diorite, Coarsed Dirt
  4. ItemStack iS = new ItemStack(Material.STONE);
    iS.setDurability(3); //there You have granite? Or?

    Sent from my iPhone using Tapatalk
  5. I know how to do that, I am simply trying to print the names of every item so I can make put them into my config.
  6. Would not calling getType().toString() return your wanted value?

    Sent from my iPhone using Tapatalk
  7. getType.toString() returns the Material name so it would return STONE, in my case.
  8. Hmm, yeah.

    Well would it be so hard with the config? Just use ID's?

    item: '3:4'

    String s = YamlConfiguration#getString("item");

    String[] split = s.split(":");
    ItemStack item = new ItemStack(Integer.parseInt(split[0]));

    There you have your item, but idk how to get the actual proper name of this item.

    Sent from my iPhone using Tapatalk
  9. yeah the name is the issue, so I guess I am going to make a huge enum with all of the items, name, Material, durability, ect.

    Code (Text):

        STONE("Stone" , 0, Material.STONE),
        GRANITE("Granite", 1, Material.STONE),
        POLISHED_GRANITE("Polished Granite", 2,Material.STONE),
        DIORITE("Diorite", 3, Material.STONE),
        POLISHED_DIORITE("Polished Diorite", 4, Material.STONE),
        ANDESITE("Andesite", 5, Material.STONE),
        POLISHED_ANDESITE("Polished Andesite", 6, Material.STONE),
        GRASS("Grass", 0, Material.GRASS),
        DIRT("Dirt", 0, Material.DIRT),
        COARSE_DIRT("Coarse Dirt", 1, Material.DIRT),
        PODZOL("Podzol", 2, Material.DIRT),
        COBBLESTONE("Cobblestone", 0, Material.COBBLESTONE),

    Then make the config names = the name in the enum and grab the information from the enum to build the item properly.
  10. I'd use the Vault item API.

    Iterate over Items#getItemList() for saving the names to your config and get the info from config with Items#itemByName(String).
  11. I'm almost 100% sure there is another way, I just can't think of it. Got damn. I'm looking into it

    Sent from my iPhone using Tapatalk
  12. Didn't even know this object existed in the API. See ^_^

    Sent from my iPhone using Tapatalk
  13. Does vault update their Items#getItemList per version? I am using an older version of Spigot so I would need to just find the according Vault, correct?

    ref: 1.8.8 spigot
  14. Correct. And having the newest version wouldn't hurt I think

    Sent from my iPhone using Tapatalk
  15. They used to until 1.8.x (Vault 1.5.6).