Closed endorpersand closed 4 years ago
Interesting... Thanks for bringing this to my attention, I'll start an investigation within the next 24 hours.
How utterly bizarre - it appears to be loading this before the server starts??
Take the 1.15.2 spigot startup log:
Loading libraries, please wait...
2020-07-16 01:53:31,694 main WARN Unable to instantiate org.fusesource.jansi.WindowsAnsiOutputStream
[01:53:37] [Server thread/INFO]: Starting minecraft server version 1.15.2
[01:53:37] [Server thread/INFO]: Loading properties
[01:53:38] [Server thread/INFO]: This server is running CraftBukkit version git-Spigot-a99063f-fad2494 (MC: 1.15.2) (Implementing API version 1.15.2-R0.1-SNAPSHOT)
[01:53:38] [Server thread/INFO]: Debug logging is disabled
And then compare that to the 1.16.1 spigot startup log:
Loading libraries, please wait...
2020-07-16 01:50:17,222 main WARN Unable to instantiate org.fusesource.jansi.WindowsAnsiOutputStream
[01:50:22] [main/INFO]: Environment: authHost='https://authserver.mojang.com', accountsHost='https://api.mojang.com', sessionHost='https://sessionserver.mojang.com', name='PROD'
[01:50:22] [main/INFO]: Reloading ResourceManager: Default, bukkit
[01:50:23] [Worker-Main-4/INFO]: Loaded 7 recipes
[01:50:23] [Worker-Main-4/ERROR]: Failed to load function mycustomnamespace:test
java.util.concurrent.CompletionException: java.lang.IllegalArgumentException: Whilst parsing command on line 2: Unknown or incomplete command, see below for error at position 0: <--[HERE]
at java.util.concurrent.CompletableFuture.encodeThrowable(Unknown Source) ~[?:1.8.0_261]
at java.util.concurrent.CompletableFuture.completeThrowable(Unknown Source) [?:1.8.0_261]
at java.util.concurrent.CompletableFuture$AsyncSupply.run(Unknown Source) [?:1.8.0_261]
at java.util.concurrent.CompletableFuture$AsyncSupply.exec(Unknown Source) [?:1.8.0_261]
at java.util.concurrent.ForkJoinTask.doExec(Unknown Source) [?:1.8.0_261]
at java.util.concurrent.ForkJoinPool$WorkQueue.runTask(Unknown Source) [?:1.8.0_261]
at java.util.concurrent.ForkJoinPool.runWorker(Unknown Source) [?:1.8.0_261]
at java.util.concurrent.ForkJoinWorkerThread.run(Unknown Source) [?:1.8.0_261]
Caused by: java.lang.IllegalArgumentException: Whilst parsing command on line 2: Unknown or incomplete command, see below for error at position 0: <--[HERE]
at net.minecraft.server.v1_16_R1.CustomFunction.a(SourceFile:62) ~[spigot-1.16.1.jar:git-Spigot-758abbe-8dc1da1]
at net.minecraft.server.v1_16_R1.CustomFunctionManager.a(SourceFile:84) ~[spigot-1.16.1.jar:git-Spigot-758abbe-8dc1da1]
... 6 more
[01:50:22] [main/INFO]: Environment: authHost='https://authserver.mojang.com', accountsHost='https://api.mojang.com', sessionHost='https://sessionserver.mojang.com', name='PROD'
[01:50:22] [main/INFO]: Reloading ResourceManager: Default, bukkit
[01:50:23] [Worker-Main-4/INFO]: Loaded 7 recipes
[01:50:23] [Worker-Main-4/ERROR]: Failed to load function mycustomnamespace:test
java.util.concurrent.CompletionException: java.lang.IllegalArgumentException: Whilst parsing command on line 2: Unknown or incomplete command, see below for error at position 0: <--[HERE]
at java.util.concurrent.CompletableFuture.encodeThrowable(Unknown Source) ~[?:1.8.0_261]
at java.util.concurrent.CompletableFuture.completeThrowable(Unknown Source) [?:1.8.0_261]
at java.util.concurrent.CompletableFuture$AsyncSupply.run(Unknown Source) [?:1.8.0_261]
at java.util.concurrent.CompletableFuture$AsyncSupply.exec(Unknown Source) [?:1.8.0_261]
at java.util.concurrent.ForkJoinTask.doExec(Unknown Source) [?:1.8.0_261]
at java.util.concurrent.ForkJoinPool$WorkQueue.runTask(Unknown Source) [?:1.8.0_261]
at java.util.concurrent.ForkJoinPool.runWorker(Unknown Source) [?:1.8.0_261]
at java.util.concurrent.ForkJoinWorkerThread.run(Unknown Source) [?:1.8.0_261]
Caused by: java.lang.IllegalArgumentException: Whilst parsing command on line 2: Unknown or incomplete command, see below for error at position 0: <--[HERE]
at net.minecraft.server.v1_16_R1.CustomFunction.a(SourceFile:62) ~[spigot-1.16.1.jar:git-Spigot-758abbe-8dc1da1]
at net.minecraft.server.v1_16_R1.CustomFunctionManager.a(SourceFile:84) ~[spigot-1.16.1.jar:git-Spigot-758abbe-8dc1da1]
... 6 more
[01:50:25] [Server thread/INFO]: Starting minecraft server version 1.16.1
[01:50:25] [Server thread/INFO]: Loading properties
[01:50:25] [Server thread/INFO]: This server is running CraftBukkit version git-Spigot-758abbe-8dc1da1 (MC: 1.16.1) (Implementing API version 1.16.1-R0.1-SNAPSHOT)
[01:50:25] [Server thread/INFO]: Debug logging is disabled
Note how the error occurs before the message "Starting minecraft server version ..."
Very strange indeed. I tried changing the loading order in the plugin.yml
file for the CommandAPI to load: STARTUP
, but that didn't help the issue. I have a feeling that this might be outside of the scope of what I can do as a plugin developer, but want to confirm that for certain first.
So, I've confirmed that this is indeed an issue outside of my control. In the 20w22a update, under General -> Data packs, it includes the following:
I have confirmed that datapacks now load before the "Starting minecraft server version ..." message is displayed. The earliest time for plugins to be loaded occurs not long after that message is displayed in the console. As a result, I hereby declare that there's nothing I can do to fix this.
Darn, that sucks.
Yup.
@endrdragon I've found a workaround. By re-loading the datapacks after the main server has loaded and injecting the newly constructed command dispatcher tree, it's possible to get it to work!
Here's a log (yeah, terrible evident I know, but hey~) showing that it was indeed possible to run the example from the documentation:
[14:46:22] [Server thread/INFO]: Done (12.881s)! For help, type "help"
[14:46:22] [Server thread/INFO]: [CommandAPI] Linking permissions to commands:
[14:46:22] [Server thread/INFO]: [CommandAPI] NONE -> /killall
[14:46:22] [Server thread/INFO]: Using default (constructed) datapackconfiguration
[14:46:22] [Server thread/INFO]: Loading resourcepack repo
[14:46:22] [Server thread/INFO]: Adding resourcepacks to something
[14:46:22] [Server thread/INFO]: Added vanilla
[14:46:22] [Server thread/INFO]: Added file/bukkit
[14:46:22] [Server thread/INFO]: Finished adding resourcepacks
[14:46:22] [Server thread/INFO]: Loading resourcepack file/bukkit
[14:46:22] [Server thread/INFO]: Loading resourcepack vanilla
[14:46:22] [Server thread/INFO]: Constructed new dpc: [vanilla, file/bukkit]:[]
[14:46:22] [Server thread/INFO]: a: java.util.concurrent.CompletableFuture@2c1f5963[Completed normally]
[14:46:22] [Server thread/INFO]: Reloading ResourceManager: Default, bukkit
[14:46:22] [Server thread/INFO]: Running completablefuture
[14:46:22] [Worker-Main-4/INFO]: Loaded 7 recipes
[14:46:23] [Server thread/INFO]: Finished completablefuture
function mycustomnamespace:test
[14:46:35] [Server thread/INFO]: [Server] hi
[14:46:35] [Server thread/INFO]: Executed 2 commands from function 'mycustomnamespace:test'
The solution isn't perfect, but it does work. When running the server, it will initially throw the error since it cannot be parsed properly. After that, the CommandAPI will reload datapacks (as described above) which would enable the functions to work again.
I've included the fix in version 3.3. I'll update the documentation later to explain how the fix works.
Hmmm, still seems like it doesn't work for me. There's an error trying to reload data packs:
[14:47:25] [Server thread/INFO]: Done (25.777s)! For help, type "help"
[14:47:25] [Server thread/INFO]: [CommandAPI] Linking permissions to commands:
[14:47:25] [Server thread/INFO]: [CommandAPI] NONE -> /killall
[14:47:25] [Server thread/INFO]: [CommandAPI] Reloading datapacks...
[14:47:25] [Server thread/WARN]: java.lang.NoSuchFieldException: modifiers
[14:47:25] [Server thread/WARN]: at java.base/java.lang.Class.getDeclaredField(Class.java:2489)
[14:47:25] [Server thread/WARN]: at dev.jorel.commandapi.nms.NMS_1_16_R1.reloadDataPacks(NMS_1_16_R1.java:154)
[14:47:25] [Server thread/WARN]: at dev.jorel.commandapi.CommandAPI.cleanup(CommandAPI.java:43)
[14:47:25] [Server thread/WARN]: at dev.jorel.commandapi.CommandAPIMain.lambda$onEnable$0(CommandAPIMain.java:52)
[14:47:25] [Server thread/WARN]: at org.bukkit.craftbukkit.v1_16_R1.scheduler.CraftTask.run(CraftTask.java:81)
[14:47:25] [Server thread/WARN]: at org.bukkit.craftbukkit.v1_16_R1.scheduler.CraftScheduler.mainThreadHeartbeat(CraftScheduler.java:400)
[14:47:25] [Server thread/WARN]: at net.minecraft.server.v1_16_R1.MinecraftServer.b(MinecraftServer.java:1061)
[14:47:25] [Server thread/WARN]: at net.minecraft.server.v1_16_R1.DedicatedServer.b(DedicatedServer.java:354)
[14:47:25] [Server thread/WARN]: at net.minecraft.server.v1_16_R1.MinecraftServer.a(MinecraftServer.java:1009)
[14:47:25] [Server thread/WARN]: at net.minecraft.server.v1_16_R1.MinecraftServer.v(MinecraftServer.java:848)
[14:47:25] [Server thread/WARN]: at net.minecraft.server.v1_16_R1.MinecraftServer.lambda$0(MinecraftServer.java:164)
[14:47:25] [Server thread/WARN]: at java.base/java.lang.Thread.run(Thread.java:832)
>function test:hi
[14:47:33] [Server thread/INFO]: Unknown function test:hi
(tested with Spigot)
What version of Java are you running? I was able to get this to work on Java 8 - I hear it might not work on Java 12 and onwards?
Ah, I'm running Java 14, lemme try on Java 8 then.
Looks like that fixed it. I guess it would be important to point out in documentation then.
Will do.
Just out of curiosity, what JRE installation are you using? It appears that the OpenJDK standard up to Java 15 should be supported by the CommandAPI. I don't know what versions of Oracle's JRE are incompatible.
I'm using the Homebrew installation of OpenJDK 14.0.1 which uses the same download file as the one you can normally get on jdk.java.net, so I'm not sure why it broke if that's the case.
I have the java.lang.NoSuchFieldException: modifiers
problem too. I have seen this before in plugins, and it usually means you're trying to use reflection to make something non-final. This happens on Java 12+. A workaround is found here: https://stackoverflow.com/a/56043252/8584806
@Justsnoopy30 Right, that makes sense. I'll try it out at some point later this week and push out a new release if it works.
@Justsnoopy30 Of course, I only now remembered this!
The solution from the Stack Overflow that you linked me to uses the MethodHandles.privateLookupIn();
method. Unfortunately, this method only exists in Java 9 onwards. Since most servers use Java 8, the CommandAPI is also compiled to fit Java 8 standards, and as such, I cannot use this without changing my entire development environment to accommodate for Java 9+ users. Of course, accommodating for Java 9+ users will then make the CommandAPI incompatible with users that are running Java 8.
Upon further research, "multi-release jar files" exist and is a way to bridge this exact issue. Testing this will be a little tricky as I don't have a Java 9+ environment on my computer, but I'll find a way nonetheless :)
@Justsnoopy30 CommandAPIv3.3_21_Jul2020(02-52-42pm).zip
I've included a copy of the CommandAPI (in the link above) which should have multi-release support for Java 9+. In short, this should work. If you could test that this is the case, it would be much appreciated!
After some personal testing, I have confirmed that the jar is packaged correctly as a multi-release jar, but I haven't been able to get it to load correctly... Not too sure what could cause this...
Oh, you shouldn't have to use multi-release jars to solve this. As I said, I've seen this before with other projects, and the solution did not require anything requiring multi-release jars, and worked with java 8, as well as new java versions. I'll get back to you tomorrow with more details.
CommandAPI version v3.2
Minecraft version 1.16.1, affecting both Spigot and Paper (tested on Paper-90 and Paper-1)
Describe the bug Functions that have commands created by the API do not load properly, acting as though the command does not exist. /execute and chat commands work properly.
Given error:
My code This code (copied from documentation) reproduces the behavior:
function test:hi
Expected behavior The function loads properly and successfully recognizes the commands.
Additional context In 1.14.4 and 1.15.2, Paper does load the function properly. The difference seems to be that Spigot 1.16 switched the startup sequence so that data packs load before plugins. Maybe that means that an issue should be reported to Spigot but I wanted to see if something could be done within the API first.
/minecraft:reload still errors, even after commands have been registered.