packetevents icon indicating copy to clipboard operation
packetevents copied to clipboard

Unable to use libraries that use Paper's instance of Adventure/MiniMessage

Open OakLoaf opened this issue 8 months ago • 0 comments

Describe the bug I have a chat message library that adds MiniMessage support to servers using Paper. It does this by depending on Paper's shaded instance of Adventure/MiniMessage.

I am shading PacketEvents into my plugin and cannot work out how to relocate Adventure in a way that doesn't also relocate all imports of my library as currently it is.

Software brand Paper 1.20.6

How To Reproduce

  1. Depend on PacketEvents and a library that soft-depends on MiniMessage (eg. ChatColorHandler)
  2. Use a player to audience cast (likely other castt issues too)
  3. See error in console

Additional context Here is an error that I was getting:

Caused by: java.lang.ClassCastException: class org.bukkit.craftbukkit.entity.CraftPlayer cannot be cast to class org.lushplugins.followers.libraries.kyori.adventure.audience.Audience (org.bukkit.craftbukkit.entity.CraftPlayer is in unnamed module of loader java.net.URLClassLoader @192d3247; org.lushplugins.followers.libraries.kyori.adventure.audience.Audience is in unnamed module of loader 'Followers-2.0.0-BETA.jar' @6544218f)
    at Followers-2.0.0-BETA.jar/org.lushplugins.followers.libraries.lushlib.libraries.chatcolor.messengers.MiniMessageMessenger.sendMessage(MiniMessageMessenger.java:30) ~[Followers-2.0.0-BETA.jar:?]
    at Followers-2.0.0-BETA.jar/org.lushplugins.followers.libraries.lushlib.libraries.chatcolor.ChatColorHandler.sendMessage(ChatColorHandler.java:70) ~[Followers-2.0.0-BETA.jar:?]
    at Followers-2.0.0-BETA.jar/org.lushplugins.followers.commands.FollowerCmd$CreateCmd.execute(FollowerCmd.java:75) ~[Followers-2.0.0-BETA.jar:?]
    at Followers-2.0.0-BETA.jar/org.lushplugins.followers.libraries.lushlib.command.Command.onCommand(Command.java:55) ~[Followers-2.0.0-BETA.jar:?]
    at org.bukkit.command.PluginCommand.execute(PluginCommand.java:45) ~[paper-api-1.20.6-R0.1-SNAPSHOT.jar:?]
    ... 26 more

OakLoaf avatar May 26 '24 16:05 OakLoaf