Italics on ItemStack?

Discussion in 'Plugin Development' started by xigsag, Dec 9, 2013.

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

    xigsag

    Is it not possible? Doesn't seem to be working for me.
     
  2. Offline

    Maulss

    Do you mean setting an italic color format onto the display name of the item? Can you be more specific?
     
  3. Offline

    Sayf

    Code:java
    1. public ItemStack testItem() {
    2. List<String> lores = new ArrayList<String>();
    3.  
    4. lores.clear();
    5. lores.add(ChatColor.GREEN + "" + ChatColor.ITALIC + "Yolo swaggins!");
    6.  
    7. ItemStack item = new ItemStack(Material.DIAMOND_SPADE, 1);
    8. ItemMeta im = item.getItemMeta();
    9.  
    10. im.setDisplayName(ChatColor.GOLD + "" + ChatColor.ITALIC + "Swag.");
    11. im.setLore(lores);
    12.  
    13. item.setItemMeta(im);
    14. return item;
    15. }


    There's a nice little example code for you. :)
     
  4. Offline

    L33m4n123

    If you mean for Displayname or Lore works both like a charm
     
  5. Offline

    xigsag

    Heh, whoops. I meant, Italics color format, ChatColor.ITALIC + "insert name here" on ItemMeta of an ItemStack.
     
  6. Offline

    L33m4n123

    Code:java
    1.  
    2. ItemStack item = new ItemStack(Material.STONE, 1);
    3. ItemMeta meta = item.getItemMeta();
    4. meta.setDisplayName(ChatColor.ITALIC + "" + ChatColor.RED + "It now has an red italic name");
    5. List<String> lore = new ArrayList<String>();
    6. lore.add(ChatColor.ITALIC + "Italic Lore");
    7. meta.setLore(lore);
    8. item.setItemMeta(meta);
    9.  


    And you have a Stone with an Italic, Red Display Name and an Italic Lore. Works on latest CB 1.7.2 build
     
  7. Offline

    xigsag

    Hm, Color works fine for me, but Italics/Matrix/Strikethrough/Underline don't. I will try again later and get back.
     
  8. Offline

    L33m4n123

    Ok my bad. Just tested it aswell. Only seems to work for the Lore. Doesn't work for the DisplayName either. Not sure if it is a bug or if it is meant that way. Sowwy
     
  9. Offline

    xigsag

    Thanks. Could be a bug with the API code, since I remember doing it before, and the name becomes italic when manually renamed through an anvil.
     
  10. Offline

    XvBaseballkidvX

    Its:
    Code:java
    1. (ChatColor.RED + ChatColor.ITALIC + "String");

    Hopefully this works :p
     
  11. Offline

    L33m4n123


    Not even close ;) try it out yourself =P

    "The operator + is undefined for the argument type(s) org.bukkit.ChatColor, org.bukkit.ChatColor"
     
  12. Offline

    xigsag

    XvBaseballkidvX

    Yea, not gonna give the full explanation, but yea. That doesn't work.
    Nevertheless, even if you did it the right way, it doesn't seem to be working with ItemStack displaynames. Though it works in chat.
     
  13. Offline

    Gater12

    xigsag Always wondered about that... Maybe set a string to to have italics with color with the "&" symbol and translate it with
    Code:java
    1. ChatColor.translateAlternateColorCodes('&', stringhere);
     
  14. Code:
    (ChatColor.RED + "" + ChatColor.ITALIC + "String");
     
  15. Offline

    xigsag

    I noticed that when an itemstack's displayname does not have a chatcolor in it, the italics automatically show up upon mouse-over. But with colors, they don't.

    Either way, italics does not show up on hotbar tooltip.

    I must be the most confused person in the world right now.

    Theory inb4 post did not happen to me after i tried to re-simulate the effect. I had recoded a class of a plugin I was making, but I am pretty sure I did not touch the strings that determine the name of the item.

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

Share This Page