[SPIGOT-8024] TextComponent/BaseComponent events no longer working. Created: 26/Mar/25 Updated: 28/Mar/25 Resolved: 28/Mar/25 |
|
Status: | Resolved |
Project: | Spigot |
Component/s: | None |
Affects Version/s: | None |
Fix Version/s: | None |
Type: | Bug | Priority: | Major |
Reporter: | Nothixal | Assignee: | md_5 |
Resolution: | Fixed | Votes: | 0 |
Labels: | API, bug |
Attachments: |
![]() |
Version: | CraftBukkit version 4466-Spigot-aa90801-0f147ef (MC: 1.21.5) (Implementing API version 1.21.5-R0.1-SNAPSHOT) |
Guidelines Read: | Yes |
Description |
Component events such as HoverEvent and ClickEvent are no longer working in this release. Any text styling that is set on the component will still be present, but any event that is added to the component won't be set.
Here is some example code that I have been using for a while. (Also tested in 1.21.4) TextComponent tip = new TextComponent( new ComponentBuilder() .append("[").color(ChatColor.DARK_GRAY) .append("PRO TIP").color(ChatColor.LIGHT_PURPLE).bold(true) .append("").reset().retain(FormatRetention.EVENTS) .append("]").color(ChatColor.DARK_GRAY) .create()); tip.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new ComponentBuilder() .append("Hover over the icon next to the command").color(ChatColor.GRAY) .append("\n") .append("to view the required permissions.") .append("\n\n") .append("You can also click on and hover over the commands!").color(ChatColor.GRAY) .append("\n") .append("COMMAND LEGEND: ").color(ChatColor.YELLOW).bold(true) .append("").reset() .append("<> = Required, [] = Optional").color(ChatColor.GRAY) .create())); BaseComponent[] test = new ComponentBuilder() .append("Hugs Commands").bold(true).color(ChatColor.of(PluginConstants.DEFAULT_PREFIX_COLOR_HEX)) .append(" >>").bold(true).color(ChatColor.DARK_GRAY) .append(" ").reset() .append("Viewing help page ").color(ChatColor.of("#67cbf8")) .append("(").color(ChatColor.DARK_GRAY) .append("1").color(ChatColor.WHITE) .append("/").color(ChatColor.GRAY) .append("2").color(ChatColor.WHITE) .append(")").color(ChatColor.DARK_GRAY) .append(" ") .append(tip) .create(); sender.spigot().sendMessage(test);
Here is another example using click events. ComponentBuilder website = new ComponentBuilder("[VISIT SITE]").color(ChatColor.of(PRIMARY_COLOR)).bold(true) .event(new ClickEvent(Action.OPEN_URL, PluginConstants.PLUGIN_SOURCE_CODE_LINK)) .event(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new ComponentBuilder("Click me to visit the site!").color(ChatColor.AQUA).create())); BaseComponent[] sourceCodeBook = new ComponentBuilder() .append(" ").append("Hugs").color(ChatColor.of(PRIMARY_COLOR)).bold(true).append("").reset() .append("\n") .append(" ").append("Source Code") .append("\n\n") .append("Consider contributing to the development!") .append("\n\n\n") .append(" ").append(website.create()).append("").reset() .create();
These examples work in older versions of Spigot, but have ceased to in this release. |
Comments |
Comment by md_5 [ 27/Mar/25 ] |
Probably required PR: https://github.com/SpigotMC/BungeeCord/pull/3812 Patch attached for when that PR merged |
Comment by PhilBox [ 26/Mar/25 ] |
To add to this, I was experiencing this same issue with TextComponents on 1.21.4 builds and versions previous to it. However we believed it was fixed in a PR on the BungeeCord GitHub and had assumed the bundled BungeeCord needed updating. If the code I was using is valuable I can post it. |