mirror of
https://github.com/LuckPerms/LuckPerms.git
synced 2024-12-02 15:43:22 +01:00
Add support for Sponge API 9+ (#3885)
This commit is contained in:
parent
d74a4dcb7e
commit
484b04c17b
@ -49,6 +49,8 @@ import org.spongepowered.plugin.metadata.PluginMetadata;
|
|||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
|
import java.lang.invoke.MethodHandles;
|
||||||
|
import java.lang.reflect.Method;
|
||||||
import java.nio.file.Path;
|
import java.nio.file.Path;
|
||||||
import java.time.Instant;
|
import java.time.Instant;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
@ -197,6 +199,15 @@ public class LPSpongeBootstrap implements LuckPermsBootstrap, LoaderBootstrap, B
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void registerListeners(Object obj) {
|
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);
|
this.game.eventManager().registerListeners(this.pluginContainer, obj);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user