[SPIGOT5845] CHATCOLORRESET DOES NOT WORK IN ITEMMETA TO RESET

[SPIGOT5845] CHATCOLORRESET DOES NOT WORK IN ITEMMETA TO RESET






[#SPIGOT-5845] ChatColor.RESET does not work in ItemMeta to reset italics

[SPIGOT-5845] ChatColor.RESET does not work in ItemMeta to reset italics Created: 26/Jun/20  Updated: 27/Jun/20  Resolved: 27/Jun/20

Status:

Resolved

Project:

Spigot

Component/s:

None

Affects Version/s:

None

Fix Version/s:

None


Type:

Bug

Priority:

Minor

Reporter:

JishunaMatata

Assignee:

Unassigned

Resolution:

Fixed

Votes:

0

Labels:

ChatColor, itemmeta


Attachments:

[SPIGOT5845] CHATCOLORRESET DOES NOT WORK IN ITEMMETA TO RESET TestPlugin.jar    

Version:

git-Spigot-16d7899-4ff609e (MC: 1.16.1) (API version 1.16.1-R0.1-SNAPSHOT)

Guidelines Read:

Yes


 Description 

 

Using ChatColor.of, or one of the ChatColor constants on item names or lore makes the text italic even when ChatColor.ITALIC is not used.

 

Attached is example plugin that gives you a stick when logging in to demonstrate this. The following is the code used to create the item.

 

ItemStack item = new ItemStack(Material.STICK);

ItemMeta im = item.getItemMeta(); 

im.setDisplayName(ChatColor.of("#ffffff") + "Test " + ChatColor.GREEN + "Test2 " + ChatColor.RESET + "Test3"); 
im.setLore(Arrays.asList(ChatColor.of("#ffffff") + "Test ", ChatColor.GREEN + "Test2 ", ChatColor.RESET + "Test3"));

item.setItemMeta(im);



 Comments 

 

Comment by Aria Sangarin [ 26/Jun/20 ]

Can confirm

Doesn't matter if you use Bungee or Bukkit ChatColor happens on both. Not even the code below makes it non-italic.

ChatColor.RESET + "Test"

Comment by md_5 [ 26/Jun/20 ]

I suggest you test vanilla.
I’m pretty sure these things are italic by default.
There is no way in json text to insert the reset code except as a legacy symbol.

Comment by Aria Sangarin [ 26/Jun/20 ]

That's the thing, they're italic by default, but 1.15 and below let you 'reset' this behavior.
If we can't get this behavior back for 1.16 I request some way of setting the JSON values (or using a BaseComponent) since editing the NBT to have {"italics:false"} in it causes it to "display normally".

Currently we can only use `#setDisplayName(String)` and `#setLore(List<String>)` using the ItemMeta class, which doesn't allow us to put that needed JSON line in there, so hacky workarounds or NMS is required to remove the italics from items. (not tested tho)

Comment by md_5 [ 26/Jun/20 ]

Yes so the bug is not that ChatColor causes italics, it Is that ChatColor.RESET does not remove italics.
Very different things which is why it is necessary to be clear.

Comment by Aria Sangarin [ 26/Jun/20 ]

Ahh, true, didn't think of it that way!
Sorry for not being clear, but glad the issue is "figured" now [SPIGOT5845] CHATCOLORRESET DOES NOT WORK IN ITEMMETA TO RESET

Comment by JishunaMatata [ 26/Jun/20 ]

If I remember correctly, just having ChatColor.RED + text in 1.15 would make the text non-italic without needing ChatColor.RESET

Comment by Aria Sangarin [ 26/Jun/20 ]

@JishunaMatata Yeah, this also isn't a thing anymore. ChatColor.RED + text will indeed make the text red, but it will still be in italics when using 1.16.1

Comment by md_5 [ 26/Jun/20 ]

Red shouldn't reset italics so I think that's more Spigot aligning with Vanilla behaviour better now, again test /give in Vanilla

Comment by JishunaMatata [ 26/Jun/20 ]

After testing I can confirm changing the color of text in vanilla does not reset the formatting, tested with the following command test2 will also be italic.

/give @p minecraft:stick{display:{Name:'[{"text":"test ","italic":true},{"text":"test2","color":"red"}]'}} 1

Comment by Aria Sangarin [ 26/Jun/20 ]

Yeah, I suppose it aligns better with vanilla, but now there is no way for a plugin to remove italics from custom name/lore as there is no way to set italics to false using the setDisplayName and setLore ItemMeta methods, which breaks all the nicely formatted items from past versions

Comment by md_5 [ 27/Jun/20 ]

Color is such a mess. Hopefully the updated behaviour is at least acceptable.

Comment by Aria Sangarin [ 27/Jun/20 ]

Works like a charm, thank you [SPIGOT5845] CHATCOLORRESET DOES NOT WORK IN ITEMMETA TO RESET

Generated at Sun Oct 24 10:59:20 UTC 2021 using Jira 8.20.0#820000-sha1:12d32736019f23930cfd2092dd230e869932e04a.





Tags: [spigot5845], reset, itemmeta, chatcolorreset