LuckPerms

LuckPerms

41.4k Downloads

Support Sponge API 9

A248 opened this issue ยท 7 comments

commented

Description

Support Sponge API 9, which is quite similar to API 8.

Proposed Behaviour

To enable LuckPerms to function on this platform, a workaround will have to be found for registering event listeners. A change in Sponge API 9 means it is difficult to listen to events from inside an isolated classloader. See SpongePowered/Sponge#3747

Extra Details

With LuckPerms on SpongeVanilla 1.18.2-9.0.0-RC1157, the following error is generated:
https://pastebin.com/cuaCQH5u

commented

Just following up on this now that API 10 is the main supported API version (once again, not all that different from API 9). Using the test build of SpongeForge 1.19.4, the LP API seems to work fine, but it would be awesome to have LP fully integrated into modern SpongeVanilla environments.

commented

Hi lucko! Anything else you need to get Sponge API 10 supported? Thanks!

commented

Fwiw the following patch launches LuckPerms fine;

--- a/sponge/src/main/java/me/lucko/luckperms/sponge/LPSpongeBootstrap.java
+++ b/sponge/src/main/java/me/lucko/luckperms/sponge/LPSpongeBootstrap.java
@@ -49,6 +49,7 @@ import org.spongepowered.plugin.metadata.PluginMetadata;
 
 import java.io.IOException;
 import java.io.InputStream;
+import java.lang.invoke.MethodHandles;
 import java.nio.file.Path;
 import java.time.Instant;
 import java.util.ArrayList;
@@ -197,7 +198,7 @@ public class LPSpongeBootstrap implements LuckPermsBootstrap, LoaderBootstrap, B
     }
 
     public void registerListeners(Object obj) {
-        this.game.eventManager().registerListeners(this.pluginContainer, obj);
+        this.game.eventManager().registerListeners(this.pluginContainer, obj, MethodHandles.lookup());
     }
 
     // provide information about the plugin
commented

Thanks for opening this to track the issue @A248 - did you find a solution to the isolated classloader issue? I notice there hasn't been much movement on Sponge's side...

commented

I hastily wanted my own plugin to run on Sponge API 9, so I decided to manually scan methods and generate event listeners using reflection. You're free to use this code under the MIT license, but I may have made assumptions particular to my simple and elementary listeners https://github.com/A248/LibertyBans/blob/78f7b7d1727bafd49f10cfc3c6da469e646d9d04/bans-env/sponge/src/main/java/space/arim/libertybans/env/sponge/listener/RegisterListenersByMethodScan.java#L43

More likely, if you are patient, I suggest waiting for Sponge to update their API in SpongePowered/SpongeAPI#2441

commented

Looks like the pull request has been merged - awesome :)

I will get a chance to look into this soon hopefully!

commented