可以考虑使用 Adventure 库来实现。会简单很多,而且不只有这个功能。
https://github.com/KyoriPowered/adventure
文档地址
https://docs.advntr.dev/
在成功安装后,可以使用下面的方法来在聊天框显示一个物品信息复制代码
https://github.com/KyoriPowered/adventure
文档地址
https://docs.advntr.dev/
在成功安装后,可以使用下面的方法来在聊天框显示一个物品信息
- player.sendMessage(Component.text("物品信息").hoverEvent(HoverEvent.showItem(参数)));