Add NukkitX support
Closed this issue · 10 comments
I would like to see support for NukkitX/Nukkit with this plugin. I use Nukkit for my MCBE servers and I feel like it would be a nice enchancement to LuckPerms because the permission managers for Nukkit are all really crappy and I feel like it would help me and other server owners.
How does Nukkit (and the bedrock engine in general) differentiate between users?
UUIDs?
I'm not able to run & connect to a Nukkit server - which is gonna make it quite hard to test things if I do decide to add support.
Does the server only work with a specific version of the Bedrock protocol?
I've committed the code running above here: https://github.com/lucko/LuckPerms/tree/nukkit
There are still a number of issues though.
Nukkit doesn't have an AsyncPreLogin event (at least I couldn't find one). LuckPerms needs this to safely load user data when players login without lagging the server
Currently it just crashes. :(
22:17:01 [EMERGENCY] --------- Server stopped responding --------- (74.851s)
22:17:01 [EMERGENCY] Please report this to nukkit:
22:17:01 [EMERGENCY] - https://github.com/NukkitX/Nukkit/issues/new
22:17:01 [EMERGENCY] ---------------- Main thread ----------------
22:17:01 [EMERGENCY] Current Thread: main
22:17:01 [EMERGENCY] PID: 1 | Suspended: false | Native: false | State: WAITING
22:17:01 [EMERGENCY] Stack:
22:17:01 [EMERGENCY] sun.misc.Unsafe.park(Native Method)
22:17:01 [EMERGENCY] java.util.concurrent.locks.LockSupport.park(Unknown Source)
22:17:01 [EMERGENCY] java.util.concurrent.CompletableFuture$Signaller.block(Unknown Source)
22:17:01 [EMERGENCY] java.util.concurrent.ForkJoinPool.managedBlock(Unknown Source)
22:17:01 [EMERGENCY] java.util.concurrent.CompletableFuture.waitingGet(Unknown Source)
22:17:01 [EMERGENCY] java.util.concurrent.CompletableFuture.join(Unknown Source)
22:17:01 [EMERGENCY] me.lucko.luckperms.common.utils.AbstractLoginListener.loadUser(AbstractLoginListener.java:52)
22:17:01 [EMERGENCY] me.lucko.luckperms.nukkit.listeners.NukkitConnectionListener.onPlayerPreLogin(NukkitConnectionListener.java:93)
22:17:01 [EMERGENCY] sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
22:17:01 [EMERGENCY] sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
22:17:01 [EMERGENCY] sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
22:17:01 [EMERGENCY] java.lang.reflect.Method.invoke(Unknown Source)
22:17:01 [EMERGENCY] cn.nukkit.plugin.MethodEventExecutor.execute(MethodEventExecutor.java:29)
22:17:01 [EMERGENCY] cn.nukkit.plugin.RegisteredListener.callEvent(RegisteredListener.java:56)
22:17:01 [EMERGENCY] cn.nukkit.plugin.PluginManager.callEvent(PluginManager.java:553)
22:17:01 [EMERGENCY] cn.nukkit.Player.handleDataPacket(Player.java:2130)
22:17:01 [EMERGENCY] cn.nukkit.network.Network$$Lambda$110/614335089.accept(Unknown Source)
22:17:01 [EMERGENCY] java.util.ArrayList.forEach(Unknown Source)
22:17:01 [EMERGENCY] cn.nukkit.network.Network.processPackets(Network.java:178)
22:17:01 [EMERGENCY] cn.nukkit.network.Network.processBatch(Network.java:160)
22:17:01 [EMERGENCY] cn.nukkit.Player.handleDataPacket(Player.java:2038)
22:17:01 [EMERGENCY] cn.nukkit.network.RakNetInterface.handleEncapsulated(RakNetInterface.java:157)
22:17:01 [EMERGENCY] cn.nukkit.raknet.server.ServerHandler.handlePacket(ServerHandler.java:132)
22:17:01 [EMERGENCY] cn.nukkit.network.RakNetInterface.process(RakNetInterface.java:66)
22:17:01 [EMERGENCY] cn.nukkit.network.Network.processInterfaces(Network.java:76)
22:17:01 [EMERGENCY] cn.nukkit.Server.tick(Server.java:1068)
22:17:01 [EMERGENCY] cn.nukkit.Server.tickProcessor(Server.java:842)
22:17:01 [EMERGENCY] cn.nukkit.Server.start(Server.java:819)
22:17:01 [EMERGENCY] cn.nukkit.Server.<init>(Server.java:502)
22:17:01 [EMERGENCY] cn.nukkit.Nukkit.main(Nukkit.java:102)
Nukkit also makes some (very strange) changes to the way the Bukkit permissions API worked - which prevents part of the LP hook from functioning.
22:36:38 [ALERT] java.lang.ClassCastException: me.lucko.luckperms.nukkit.model.server.LPSubscriptionMap$LPSubscriptionValueMap cannot be cast to java.util.WeakHashMap
at cn.nukkit.plugin.PluginManager.getPermissionSubscriptions(PluginManager.java:389)
at cn.nukkit.permission.Permission.getPermissibles(Permission.java:103)
at cn.nukkit.permission.Permission.recalculatePermissibles(Permission.java:107)
at cn.nukkit.permission.Permission.<init>(Permission.java:72)
at cn.nukkit.permission.Permission.<init>(Permission.java:59)
at cn.nukkit.permission.DefaultPermissions.registerCorePermissions(DefaultPermissions.java:26)
at cn.nukkit.Server.enablePlugins(Server.java:659)
at cn.nukkit.Server.<init>(Server.java:497)
at cn.nukkit.Nukkit.main(Nukkit.java:102)
Doesn't allow a custom implementation of that map to be injected ^^.
Among some other really weird changes, such as
Map<Permissible, Permissible>
?? 🤷♂️
Really just makes no sense, haha. I don't know what that person was thinking at the time.
Aside from the issues above, it was fairly straightforward to implement.
It has a lot of similarities with Bukkit, and LP is (probably overly) abstract - which makes it quite easy to implement for new platforms.
If you want to make it load it without lagging the server, try to make an async runnable as shown in this code here: https://github.com/funniray/Mixer/blob/master/mixer-nukkit/src/main/java/pro/kdray/funniray/mixer/events/mixer.java#L44 The only problem is that the player can still login, I would suggest making an issue on Nukkit's side.
The only problem is that the player can still login, I would suggest making an issue on Nukkit's side.
Correct - which means this option isn't really viable.
I've opened a ticket on the NukkitX repo.