Closed Ayymoss closed 4 years ago
can you give an example of how you made the item?
also, it looks like this may be partly a spigot issue (as to why it appears black) https://hub.spigotmc.org/jira/browse/SPIGOT-5829 supposedly it was fixed by a commit but possibly not fully. (are you up to date with the latest spigot?)
but when that is fixed, it will also probably need some advanced support in the plugin so that it appears styled at all. this is because the item replacement uses Spigot's ItemMeta.getDisplayName method which is supposed to be the name of the item with formatting codes included. There (probably?) arent formatting codes for the hex colors, so if the previous issue is fixed, the name will probably appear white or uncolored/unstyled.
to solve this properly, there needs to be an API method that can retrieve the ChatComponents of the item name, which isn't available in the Spigot-API that I can see.
But, I don't really get my hopes up about this being officially supported in Spigot because even the inbuilt chat event in spigot still only supports strings (no tags), The only way that this plugin is able to send messages with items is with the special Player.Spigot Draft API method for sending component messages (which then cannot be seen by events).
27.06 18:33:24 [Server] Server thread/INFO This server is running CraftBukkit version git-Spigot-6f4ff1b-983305b (MC: 1.16.1) (Implementing API version 1.16.1-R0.1-SNAPSHOT) 27.06 18:33:24 [Server] Server thread/INFO Checking version, please wait... 27.06 18:33:24 [Server] Thread-112/INFO You are running the latest version
Correction: it seems to have a formatting code corresponding to the last letter of the hex color
seems there's still a bug
I'll restart my server later today as I'm using some ancient version (2.4.1) see if that fixes anything.
After that, I'll let you know.
But I use CMI for colour handling and the format is {#FFFFFF}
which I used in an Anvil with some text. Printing [item]
to chat returns the black item name.
Decided to test on a different server, yep still broken.
As explained how I colour the items in-game it returns black item name.
Using 2.6.0.
I imagine there is still a lot of difference between servers on how getDisplayName decides how to format things it can't possibly represent.
I'll have to research a lot into how to accomplish this specifically for DisplayItem. In particular Spigot/Bukkit don't support hex colors except in the bugeechat API, while I have to get item names from the Bukkit API. Getting the fully formatted name may require me to do some extra work with the item's NBT, which I generally avoid because it introduces version-specific dependencies/behavior.
I'm imagining it will work like this, hypothetically:
usenbtname
) is enabled, replace the displayname macro with a placeholder stringusenbtname
) is enabled:
As you can see there is a lot of work to be done for this, the other problem with this approach is NMS code can change a lot between versions so you have to make a decision:
anyway not that any of this interesting to you, just planning ahead. For now, there is no immediate fix possible to support hex colors wiithout considerable work, but if you want the item names to stop being black, you can negate/deny the displayitem.colorname permission for regular users, which should prevent it from being having any color formatting at all aside from what you use in the config.
I've made an experimental edit to the plugin acf02476c493aa7ee2d2d3383865c2b079dd05b5 which works for me a dev build is available here https://ci.meme.tips/job/DisplayItem-Spigot/21/
However, I still need to do testing to ensure that the new approach doesn't reintroduce a crash from items with too much NBT for chat, and then I need to remove debug lines that may spam the console when sharing an item.
While the above build works, it reintroduces the NBT limit issue. Attempting to share a shulker box in chat with 11 custom-textured heads
04.07 18:49:32 [Server] Netty Epoll Server IO #1/WARN io.netty.handler.codec.EncoderException: String too big (was 66186 bytes encoded, max 32767)
04.07 18:49:32 [Server] Netty Epoll Server IO #1/WARN at net.minecraft.server.v1_16_R1.PacketDataSerializer.a(PacketDataSerializer.java:332)
04.07 18:49:32 [Server] Netty Epoll Server IO #1/WARN at net.minecraft.server.v1_16_R1.PacketDataSerializer.a(PacketDataSerializer.java:325)
04.07 18:49:32 [Server] Netty Epoll Server IO #1/WARN at net.minecraft.server.v1_16_R1.PacketPlayOutChat.b(PacketPlayOutChat.java:32)
04.07 18:49:32 [Server] Netty Epoll Server IO #1/WARN at net.minecraft.server.v1_16_R1.PacketEncoder.encode(SourceFile:46)
04.07 18:49:32 [Server] Netty Epoll Server IO #1/WARN ... 34 more
since the hover event has to be set on each separate component of the name, it multiplies the size of the item...
dev build 22 should fix the remaining issues: https://ci.meme.tips/job/DisplayItem-Spigot/22/ but I recommend lowering your personal config's jsonlimit value to 8000
Yep - This build works with CMI on my server. :)
Much appreciated.
Title, example: https://i.imgur.com/IThSRbV.png
Anything that's not using the old Minecraft colours gets converted to &0.