diff --git a/sponge/src/main/java/me/lucko/luckperms/sponge/LPSpongeBootstrap.java b/sponge/src/main/java/me/lucko/luckperms/sponge/LPSpongeBootstrap.java index e48271856..e7fa9be24 100644 --- 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,8 @@ import org.spongepowered.plugin.metadata.PluginMetadata; import java.io.IOException; import java.io.InputStream; +import java.lang.invoke.MethodHandles; +import java.lang.reflect.Method; import java.nio.file.Path; import java.time.Instant; import java.util.ArrayList; @@ -197,6 +199,15 @@ public class LPSpongeBootstrap implements LuckPermsBootstrap, LoaderBootstrap, B } public void registerListeners(Object obj) { + // Check if we are running Sponge API 9+ + try { + final Method method = org.spongepowered.api.event.EventManager.class.getDeclaredMethod("registerListeners", PluginContainer.class, Object.class, MethodHandles.Lookup.class); + method.invoke(this.game.eventManager(), this.pluginContainer, obj, MethodHandles.lookup()); + return; + } catch (Throwable t) { + // ignore + } + // Fallback to Sponge API 8 this.game.eventManager().registerListeners(this.pluginContainer, obj); }