Issue With Coloring Leather Armor

Discussion in 'Plugin Development' started by microgeek, Jan 9, 2013.

Thread Status:
Not open for further replies.
  1. Offline

    microgeek

    Hey, I was looking at an older post on coloring leather armor, but I've ran into some issues.
    PHP:
        public static ItemStack colorize(ItemStack iColor c) {
            
    LeatherArmorMeta meta = (LeatherArmorMetai.getData();
            
    meta.setColor(c);
            
    i.setData(meta);
            return 
    i;
        }
    Is what I'm using.
    i.setData is wanting me to cast meta to MaterialData, but throws: Caused by: java.lang.ClassCastException: org.bukkit.material.MaterialData cannot be cast to org.bukkit.inventory.meta.LeatherArmorMeta when used.
    Any ideas?
    Thanks.
     
  2. Offline

    Jogy34

    it should be i.getMetaData(); and i.setMetaDate(meta);
     
  3. Offline

    microgeek

    'The method getMetaData() is undefined for the type ItemStack'
    That's why I was using getData().
     
  4. Offline

    chasechocolate

    getData won't return metadata. Try this:
    Code:java
    1. public static ItemStack colorize(ItemStack item, Color color){
    2. LeatherArmorMeta meta = (LeatherArmorMeta) item.getItemMeta();
    3. meta.setColor(color);
    4. item.setItemMeta(meta);
    5. return item;
    6. }
     
  5. Offline

    microgeek

    'The method getItemMeta() is undefined for the type ItemStack'
    Using the latest Bukkit.
     
  6. Offline

    chasechocolate

    You are importing the net.minecraft.server ItemStack rather than the org.bukkit ItemStack.
     
  7. Offline

    microgeek

    Nope.
    Code:
    import org.bukkit.inventory.ItemStack;
     
  8. Offline

    chasechocolate

    Are you importing the org.bukkit Color and also remembering to cast LeatherArmorMeta to item.getItemMeta()?
     
  9. Offline

    microgeek

    I
    I'm using the exact code that you posted, and yes, they're imported.
     
  10. Offline

    fireblast709

    what is the current problem. If you are using the latest Bukkit I cannot see how you have a problem with chasechocolate 's method
     
Thread Status:
Not open for further replies.

Share This Page