BUKKIT MATERIAL NAME WITH INK SACK

Discussion in 'Spigot Plugin Help' started by Fomafomitch, Jun 13, 2018.

  1. Hello,

    I have a plugin that can list recipe and the ingredients must be in bukkit material name following this :
    https://hub.spigotmc.org/javadocs/spigot/org/bukkit/Material.html

    So the config look like this :

    - LIME_GLAZED_TERRACOTTA
    - MAGENTA_GLAZED_TERRACOTTA
    - INK_SACK

    But I want to use "INK_SACK" and not the first one, the 5th for exemple (dye purple).
    But "INK_SACK:5" doesn't work at all. Is this a way to make the plugin understant that I want the "INK_SACK:5" ? Nothing works I tried "INK_SACK,5" , "INK_SACK;5" "INK_SACK 5"...

    Please help !
     
  2. ItemStack dye = new ItemStack(351, 1, (short) 5) would give you purple dye, (Change the 5 to whichever value)
     
    • Like Like x 1
  3. Choco

    Moderator

    Do not use numerical IDs. They are removed in 1.13 and your plugin will break. Use instead Material.BONEMEAL. As for the data value, while you are correct, I recommend instead using the MaterialData implementation, Dye. While deprecated in 1.13, it should still function fine and at least it's not deprecated and set for removal.

    Code (Java):
    ItemStack ink = new ItemStack(Material.BONEMEAL);
    ink.setData(new Dye(DyeColor.BLACK));
    In Minecraft 1.13, there is a separate Material constant for INK_SAC
     
  4. Wow i didn't know that! Thanks :)
     
  5. So in my pluggin that remove recipe I write things like this to remove PURPLE DYE allong with shulker box :

    - WHITE_SHULKER_BOX
    - YELLOW_SHULKER_BOX
    - ink.setData(new Dye(DyeColor.PURPLE))

    ?
     
  6. did you make the plugin you are using?
     
  7. Feel free to use this class I made a while ago to handle any Material objects. This might be for advanced users only since I don't know how to explain how to use it in your context, but basically it has a method in it that'll parse the name of a material in pretty much any logical format and turn it into an object with the id and data value. https://hastebin.com/lavexegezu.java
     
  8. Ok thanks you all for your help but I asked the dev and he said that it will add the item data option !