How to get detailled material from string (whool colour)

Discussion in 'Plugin Development' started by Schwarzer Zylinder, Jan 23, 2012.

Thread Status:
Not open for further replies.
  1. Hi,
    I am writing a shop plugin and want to add the ability to trade detailled materials, like whool. But if I use the whool id and then ":4" and says no material found (Using Material.getMaterial(String))
    Is there any way to get these detailled materials?
     
  2. Offline

    tkausl

    Why you need the Material?

    Code:
    ItemStack item = new ItemStack(itemID, itemDamage);
     
  3. Example: A user types in wool:3 to get wool with the colour 3. How can I get the right wool from this string?
     
  4. Code:java
    1. string[] split = new yourString.split(":");
    2. Material mat = Material.getMaterial(split[0]);
    3. byte data = Byte.parseByte(split[1]);
    4. ItemStack coloredWool = new ItemStack(mat, data);
     
  5. Thanks, but there is a problem: The ItemStack does not have a constructor Material, Byte.
    It only has Material, amount, damage, data
    What is damage?
     
  6. Offline

    SirTyler

    Damage is the durability of an item, with tools it deals with their durability, with wool its color, with potions its the type.
     
Thread Status:
Not open for further replies.

Share This Page