[SPIGOT-6013] item.getDisplayName does not include color codes Created: 21/Jul/20  Updated: 21/Jul/20  Resolved: 21/Jul/20

Status: Closed
Project: Spigot
Component/s: None
Affects Version/s: None
Fix Version/s: None

Type: Bug Priority: Minor
Reporter: Jumpin Carrot Assignee: Unassigned
Resolution: Done Votes: 0
Labels: 1.16.1

Version: 1.16.1
Guidelines Read: Yes

 Description   

In my plugin i have to check if an item name is equal to a config string.

 

private static List<String> sorter_names =  new ArrayList<>(Arrays.asList(sorter_primaryname));
...
return sorter_names.contains(item.getItemMeta().getDisplayName());

 

It has always worked well. But now all strings from the config have §r prefix in them.



 Comments   
Comment by Jumpin Carrot [ 21/Jul/20 ]

It's probably a problem with my code i failed to see, combined with some changes in 1.16.

Sorry. You can close this.

Comment by blablubbabc [ 21/Jul/20 ]

Can you make a concrete example? The item display names in the comment you posted and then deleted again did not contain any color or reset codes.
I.e. Which display name you set via meta#setDisplayName and which display name you get back when using meta#getDisplayName.

I know that certain reset codes are not getting reproduced by getDisplayName currently (eg. reset codes at the beginning of the name, or if you have multiple resets in a row). Also, the order of color and formatting codes is important currently (formatting in front of colors ghet removed, because they have no effect).

Comment by Jumpin Carrot [ 21/Jul/20 ]

I was wrong. The problem is with item.getDisplayName().

Before 1.16 it had included color codes. Now it ignores them.

Don't know if it's a bug or intentional.

Comment by blablubbabc [ 21/Jul/20 ]

Can you post your config entry with this string?
Also, how do you create the items with this display name (eg. ItemMeta#setDisplayName, config deserialization, some other means)?
And does this affect freshly created items as well, or only pre-existing items (eg. created before you updated your Spigot server)?

Generated at Tue Apr 08 02:45:48 UTC 2025 using Jira 10.3.3#10030003-sha1:d220e3fefc8dfc6d47f522d3b9a20c1455e12b7b.