Discussion in 'Spigot Plugin Development' started by MadMaxCookie, Jun 11, 2016.

  1. Hello how to give player multi itemstack with this config
    Code (Java):
        item 1:
           # Material enum
           type: 'String'

          # itemmeta displayname
          displayname: 'String'
    #1 MadMaxCookie, Jun 11, 2016
    Last edited: Jun 11, 2016
  2. Material#getMaterial


  3. well its working with single itemstack but with the config I gave creating many items which cause me NullPointerException bukkit says that I have to make a collection but I don't know what's the best way.
  4. Ok I'm not sure what problem you're having then? I don't know what context this is being used in so I don't know what direction to point you in.

    You could iterate over them by making a configuration section of the Items and then using FileConfiguration#getKeys, if you're trying to fill an inventory with them or something
  5. I did something like this

    Code (Java):
    Set<String> names = FileConfiguration#getConfigurationSection("Items").getKeys(false);
    ItemStack item = new ItemStack(Material.getMaterial(Config#getString(names + ".type"), 1);
    ItemMeta meta = item.getItemMeta();
    meta.setDisplayName(Config#getString(names + ".name"));
    giving me NullPointerException around Material.getMaterial(//)
  6. Are you literally using # symbol? o_O
  7. nope ofCourse dots.
  8. The material name has to conform to what the Material looks like, so Wood would need to be "WOOD" in the config. Or if you want your config to be more flexible, String.toUpperCase()
  9. hmm tried doing "wood" without getting strings in the config seems working.
  10. Hmm...

    Oh. You forgot to include the "Items" section in the Config.get.

    Like, config.getString("Items." + item + "...
  11. hehehe so silly :p yeah I focused with sets.