Getting material type from config

Discussion in 'Spigot Plugin Development' started by Ean244, Jun 5, 2017.

  1. Hi, I have some material ids in my config and I want to create them. But when I used the ItemStack(int type) constructor, It shows that it's deprecated.
    What should I do?
     
  2. Yes, getting Materials using IDs is deprecated. This doesn't mean that it won't work though.
     
  3. Yepp, but it still works!
     
  4. can it still function in future versions of mc?
     
  5. I think he has a config file full of ID-s. It will works, but you should convert into material strings like "WOODEN_SWORD". You can do it with code.
     
    • Useful Useful x 1
  6. Better is save them as string. Then load them from config by Material.valueOf(pathToString)

    Dont forget, the string must be in UPPERCASE !
     
  7. https://hub.spigotmc.org/javadocs/spigot/org/bukkit/Material.html#getMaterial-int- the one I used and the only one I think would work.
    no one could say.