EssentialsX

EssentialsX

2M Downloads

[1.15.1] The /createkit command ignores the &f formatting tag

Nevrai opened this issue · 3 comments

commented

Information

Full output of /ess version:

Server version: 1.15.1-R0.1-SNAPSHOT git-Paper-62 (MC: 1.15.1)
EssentialsX version: 2.17.1.52
LuckPerms version: 5.0.39
Vault version: 1.7.2-b107
EssentialsXChat version: 2.17.1.52

Server log: https://gist.github.com/DeleteMetaInf/d9664ae84cbc6b2a065cc4efd620b14c

EssentialsX config https://gist.github.com/DeleteMetaInf/40ce76faf4d96d481220931218ee368b

Details

Description
Essentials’ /createkit command ignores the colour tag &f (white).
If you give yourself an item named &fTest and then create a kit, it creates a kit with an item named Test instead. This causes the text to be italic rather than non-italic.

In kits.yml, &f is nowhere to be found, but if it’s added manually, it works as expected. However, the /kitcreate command shouldn’t ignore &f.

Steps to reproduce

  1. Give yourself an item named &fTest.
  2. Use /createkit testkit 1.
  3. Use /kit testkit. Notice that the name is italic.

If you then look in kits.yml, you’ll see that &f is nowhere to be found.

Expected behavior
&f should be included with the item’s NBT data in the kit. While white is the default text colour, not including &f causes text to be italic, and if it’s an enchanted item, it also causes the colour of the item to be light blue rather than white since that’s the default name colour for enchanted items.

Screenshots

Item I gave myself

1

The same item added to my inventory using the /kit command

2

commented

You're correct, it appears to be a bug. Although, it seems like this is not a bug within Essentials, but CraftBukkit instead.

Consider the following line in AbstractItemDb which handles the serialisation of ItemStacks:

sb.append("name:").append(meta.getDisplayName().replaceAll(" ", "_")).append(" ");

Noteworthy is that the white color is not directly being stripped out here, but the method ItemMeta::getDisplayName is called.

Please see the implementation of ItemMeta::getDisplayName provided by CraftBukkit's CraftMetaItem class, which utilises CraftChatMessage::fromComponent(IChatBaseComponent, EnumChatFormat). The problem is caused by the fact that this method is called with EnumChatFormat.WHITE and thus this line of code ultimately ends up removing the white color. This is perfectly fine for actual chat messages, but not really for items as we can clearly see here.

It's not likely that this will be fixed anytime soon, so for the time being an appropriate workaround may be to use &r (reset) instead of &f (white) since that does not appear to get removed.

commented

I don’t see how this is an enhancement. I’d call it a bug.

commented

Closing as an upstream bug.