Minecraft ItemName is not changed?

pr
8

Following problem, I'm trying to give an item to a player with a special name. The item is given to the player, but the name is not changed:

public void givePlayerItem (ItemStack item, Player p, String name) {
ItemMeta itemMeta = item.getItemMeta ();

itemMeta.setDisplayName (name);
item.setItemMeta (itemMeta);

p.getInventory (). AddItem (item);
}

Maybe you see a mistake

St

Maybe execute method

pr

Yes, of course I did Sherlock xD,

I also get the item but the name is not changed.

St

You have to do a nbt

pr

What is 'an nbt' ^^

St

If item metadata, inform yourself

pr

Do I have it?

gl

Did you write the name of the item in ""?

And where does it stand which item it is?

pr

It was a chest

Yes, there was a name. I tried the same thing in a Listner and it works perfectly,

I will then continue in the Listner hm thanks for the help