Hats plugin leather helmets switch

Discussion in 'Plugin Development' started by Ozeir, Sep 23, 2014.

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

    Ozeir

    Hey I'm coding a Hats plugin but i don't get it how to use multiple leather helmets in it.
    For example:
    Code:java
    1. case LEATHER_HELMET:
    2. if(player.hasPermission("hat.leather")){
    3. player.closeInventory();
    4. event.setCancelled(true);
    5. ItemStack aqua = new ItemStack(Material.LEATHER_HELMET);
    6. LeatherArmorMeta meta = (LeatherArmorMeta) aqua.getItemMeta();
    7. meta.setColor(Color.AQUA);
    8. meta.setDisplayName(ChatColor.GOLD + "Aqua Leather Hat");
    9. aqua.setItemMeta(meta);
    10. player.getInventory().setHelmet(aqua);


    But i also want other colors for the leather helmets like red, green.. how would i do that with switch case?
     
  2. Offline

    Unica

    Ozeir

    Code:java
    1. ItemStack leatherHelmet = new ItemStack(stuff);
    2. LeatherArmorMeta meta = (LeatherHelmetMeta) leatherHelmet.getITemMeta();
    3.  
    4. switch(meta.getColor()){
    5. case AQUA: break;
    6. case RED: break;
    7. case SOMETHING: break;
    8. }
     
  3. Offline

    Ozeir

    Unica it gives meta.getColor() red:
    Cannot switch on a value of type Color. Only convertible int values, strings or enum variables are permitted

    Someone?

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 14, 2016
Thread Status:
Not open for further replies.

Share This Page