Solved itemMeta.getDisplayName() not working-ish

Discussion in 'Plugin Development' started by pingpong1999, Apr 26, 2016.

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

    pingpong1999

    Code:
      
                    ItemStack item = player.getItemInHand();
                    ItemMeta itemMeta = item.getItemMeta();
                    itemMeta.setDisplayName(CurrentPickMeta.getDisplayName());
                    //Map<Enchantment, Integer> Enchants = player.getInventory().getItemInHand().getEnchantments();
                  
                    List<String> lore = new ArrayList<String>();
                    List<String> loreCurrent = new ArrayList<String>();
                    if(itemMeta.hasLore()){
                        List<String> oldLore = itemMeta.getLore();
                        lore.addAll(oldLore);
    
                }
    
    I am trying to make a gui, and get the item name and put it on an item in the inventory. It gets the item name, but not the custom one. say I had the name as "Kool Pick" on a Diamond pick itt would say Diamond Pick. If you need any more code, ask.

    -EDIT found what I did wrong. I double checked it. I swear I looked at that twice. sorry.
     
    Last edited: Apr 26, 2016
  2. Offline

    mine-care

    @pingpong1999
    What is this class?

    I think we need a bit more code because in the one provided i don't see where you get the name.
    Also i hope you set the meta back to the item when manipulating them rigjt?
     
  3. Offline

    pingpong1999

    probably shouldve added that part of the code to the post. but I declare it a bit higher up.

    and what item are you talking about when I set it back? I do not need to set the Current pick back since I am only getting the lore & name
     
  4. Offline

    mine-care

    in other words, are you setting the ItemMeta of the item, back to it when you change the display name?

    Declare what?
     
  5. Offline

    pingpong1999

    yes, I am setting the ietmMeta to the display name.

    Sorry if I used wrong terminology, not very good at that. But I mean I already "Called and named" the items for the inventory
     
  6. Offline

    mine-care

    @pingpong1999 right, I belive you that you set the ItemMet of the ItemStack to the ones with the changed name so I suppose that the item ingame has a custom name right?
    If yes, we need more code to see why the default name comes back.
     
    Last edited: Apr 26, 2016
  7. Offline

    pingpong1999

    yes, a custom name. Sorry I forgot to mark this solved I fixed this earlier
     
  8. Offline

    mine-care

    @pingpong1999 Oh its ok.
    Please provide the answer to your question for future reference.
     
Thread Status:
Not open for further replies.

Share This Page