Solved getItemMeta().hasDisplayName() not working

Discussion in 'Plugin Development' started by Neilnet, Jan 10, 2015.

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

    Neilnet

    Code:
    System.out.println("HAZ DISPLAZ NAIMZZZ: " + shop.getShop().getItem(slot-1).getItemMeta().hasDisplayName());
    
    Doesn't work, although when I do:
    Code:
    itemName = shop.getShop().getItem(slot-1).getType().toString();
    
    It manages to get the actual name of the item, which is diamond sword, not what it is renamed to.

    As you can see here, I've set the display name of this item:
    http://prntscr.com/5qopln

    and, well when I click it, it runs
    Code:
    System.out.println("HAZ DISPLAZ NAIMZZZ: " + shop.getShop().getItem(slot-1).getItemMeta().hasDisplayName());
    
    and the console thinks it doesn't have a display name, when it does:
    http://prntscr.com/5qopte
     
  2. How are you setting the display name?
     
  3. Moved to Plugin Development.
     
  4. Offline

    Neilnet

    ItemStack

    Well, I get the item and I get it's item meta, then I do: itemMeta.setDisplayName(itemName);

    and the output works when I hover over the item (http://prntscr.com/5qopln), although for some reason when I later try and get the name of it, it thinks there isn't a name.
     
  5. Offline

    Ozcr

    Is this an example? Because you seem to be trying to print this to System which Bukkit does not support. Try broadcasting the displayName instead.

    Otherwise do you get any errors in your console?
     
  6. Well this is how I set the itemMeta and display name:
    ItemMeta itemMeta = enderBow.getItemMeta();
    itemMeta.setDisplayName("Ender bow");
    enderBow.setItemMeta(itemMeta);
     
  7. Offline

    Neilnet

    I also did that with my ItemStack.

    System.out.println can also be used to print to the console, i don't get any errors. It just says that there isn't a display name associated with this item.

    I don't fathom how this is happening, the item isn't null. It does have a name (in italics 'b*tch slayer'). I set the name through getting the item meta and setting the display name to that.
     
  8. Maybe getItemMeta().hasDisplayName() is broken, just check if getDisplayName() is null for a similar check
     
  9. Offline

    Neilnet

    I've got it, I've documentedd the change of an item in a .txt file, and then I check to see what that name of the item is in the text file. Imo, it shouldn't have to come down to this.
     
  10. Offline

    nverdier

    Bukkit does support printing to the System. Where did you hear it doesn't?
     
  11. Offline

    1Rogue

    I'm sorry but wat

    System.out is a PrintStream which accepts String arguments. Bukkit uses a Logger which accepts string arguments. broadcastMessage accepts a string. None of these things care what you're sending if it's a string.
     
    nverdier likes this.
Thread Status:
Not open for further replies.

Share This Page