JorelAli / CommandAPI

A Bukkit/Spigot API for the command UI introduced in Minecraft 1.13
https://commandapi.jorel.dev
MIT License
531 stars 68 forks source link

Functions with custom commands fail to load with Spigot 1.16 #114

Closed endorpersand closed 4 years ago

endorpersand commented 4 years ago

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:

[18:44:22 ERROR]: Failed to load function test:hi
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(CompletableFuture.java:314) ~[?:?]
    at java.util.concurrent.CompletableFuture.completeThrowable(CompletableFuture.java:319) ~[?:?]
    at java.util.concurrent.CompletableFuture$AsyncSupply.run(CompletableFuture.java:1766) ~[?:?]
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1130) [?:?]
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:630) [?:?]
    at java.lang.Thread.run(Thread.java:832) [?:?]
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(CustomFunction.java:69) ~[patched_1.16.1.jar:git-Paper-90]
    at net.minecraft.server.v1_16_R1.CustomFunctionManager.a(SourceFile:84) ~[patched_1.16.1.jar:git-Paper-90]
    at java.util.concurrent.CompletableFuture$AsyncSupply.run(CompletableFuture.java:1764) ~[?:?]
    ... 3 more

My code This code (copied from documentation) reproduces the behavior:

    public void onLoad() {
        new CommandAPICommand("killall")
            .executes((sender, args) -> {
                //Kills all enemies in all worlds
                Bukkit.getWorlds().forEach(w -> w.getLivingEntities().forEach(e -> e.setHealth(0)));
            })
            .register();
    }

function test:hi

say hi
killall

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.

JorelAli commented 4 years ago

Interesting... Thanks for bringing this to my attention, I'll start an investigation within the next 24 hours.

JorelAli commented 4 years ago

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.

JorelAli commented 4 years ago

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.

endorpersand commented 4 years ago

Darn, that sucks.

JorelAli commented 4 years ago

Yup.

JorelAli commented 4 years ago

@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.

Full log ```log $ ./run.sh spigot-1.16.1.jar Loading libraries, please wait... 2020-07-16 14:45:58,425 main WARN Unable to instantiate org.fusesource.jansi.WindowsAnsiOutputStream [14:46:02] [main/INFO]: Environment: authHost='https://authserver.mojang.com', accountsHost='https://api.mojang.com', sessionHost='https://sessionserver.mojang.com', name='PROD' [14:46:03] [main/INFO]: Reloading ResourceManager: Default, bukkit [14:46:03] [Worker-Main-6/INFO]: Loaded 7 recipes [14:46:04] [Worker-Main-6/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 [14:46:02] [main/INFO]: Environment: authHost='https://authserver.mojang.com', accountsHost='https://api.mojang.com', sessionHost='https://sessionserver.mojang.com', name='PROD' [14:46:03] [main/INFO]: Reloading ResourceManager: Default, bukkit [14:46:03] [Worker-Main-6/INFO]: Loaded 7 recipes [14:46:04] [Worker-Main-6/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 [14:46:06] [Server thread/INFO]: Starting minecraft server version 1.16.1 [14:46:06] [Server thread/INFO]: Loading properties [14:46:06] [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) [14:46:06] [Server thread/INFO]: Debug logging is disabled [14:46:06] [Server thread/INFO]: Server Ping Player Sample Count: 12 [14:46:06] [Server thread/INFO]: Using 4 threads for Netty based IO [14:46:06] [Server thread/INFO]: Default game type: CREATIVE [14:46:06] [Server thread/INFO]: Generating keypair [14:46:06] [Server thread/INFO]: Starting Minecraft server on *:25565 [14:46:06] [Server thread/INFO]: Using default channel type [14:46:09] [Server thread/INFO]: [CommandAPI] Loading CommandAPI v3.2 [14:46:09] [Server thread/INFO]: [CommandAPI] Hooked into NMS dev.jorel.commandapi.nms.NMS_1_16_R1 (compatible with 1.16.1) [14:46:09] [Server thread/WARN]: [CommandAPI] Couldn't hook into the NBTAPI for NBT support. See https://www.spigotmc.org/resources/nbt-api.7939/ [14:46:09] [Server thread/INFO]: [CommandAPI] Hooked into Spigot successfully for Chat/ChatComponents [14:46:09] [Server thread/INFO]: [CommandAPI] Registering command /killall [14:46:09] [Server thread/INFO]: Preparing level "world" [14:46:09] [Server thread/INFO]: -------- World Settings For [world] -------- [14:46:09] [Server thread/INFO]: Entity Tracking Range: Pl 48 / An 48 / Mo 48 / Mi 32 / Other 64 [14:46:09] [Server thread/INFO]: Item Merge Radius: 2.5 [14:46:09] [Server thread/INFO]: Item Despawn Rate: 6000 [14:46:09] [Server thread/INFO]: Allow Zombie Pigmen to spawn from portal blocks: true [14:46:09] [Server thread/INFO]: View Distance: 10 [14:46:09] [Server thread/INFO]: Experience Merge Radius: 3.0 [14:46:09] [Server thread/INFO]: Cactus Growth Modifier: 100% [14:46:09] [Server thread/INFO]: Cane Growth Modifier: 100% [14:46:09] [Server thread/INFO]: Melon Growth Modifier: 100% [14:46:09] [Server thread/INFO]: Mushroom Growth Modifier: 100% [14:46:09] [Server thread/INFO]: Pumpkin Growth Modifier: 100% [14:46:09] [Server thread/INFO]: Sapling Growth Modifier: 100% [14:46:09] [Server thread/INFO]: Beetroot Growth Modifier: 100% [14:46:09] [Server thread/INFO]: Carrot Growth Modifier: 100% [14:46:09] [Server thread/INFO]: Potato Growth Modifier: 100% [14:46:09] [Server thread/INFO]: Wheat Growth Modifier: 100% [14:46:09] [Server thread/INFO]: NetherWart Growth Modifier: 100% [14:46:09] [Server thread/INFO]: Vine Growth Modifier: 100% [14:46:09] [Server thread/INFO]: Cocoa Growth Modifier: 100% [14:46:09] [Server thread/INFO]: Bamboo Growth Modifier: 100% [14:46:09] [Server thread/INFO]: SweetBerry Growth Modifier: 100% [14:46:09] [Server thread/INFO]: Kelp Growth Modifier: 100% [14:46:09] [Server thread/INFO]: Mob Spawn Range: 6 [14:46:09] [Server thread/INFO]: Entity Activation Range: An 32 / Mo 32 / Ra 48 / Mi 16 / Tiv true [14:46:09] [Server thread/INFO]: Hopper Transfer: 8 Hopper Check: 1 Hopper Amount: 1 [14:46:09] [Server thread/INFO]: Max TNT Explosions: 100 [14:46:09] [Server thread/INFO]: Tile Max Tick Time: 50ms Entity max Tick Time: 50ms [14:46:09] [Server thread/INFO]: Nerfing mobs spawned from spawners: false [14:46:09] [Server thread/INFO]: Arrow Despawn Rate: 1200 Trident Respawn Rate:1200 [14:46:09] [Server thread/INFO]: Zombie Aggressive Towards Villager: true [14:46:09] [Server thread/INFO]: Custom Map Seeds: Village: 10387312 Desert: 14357617 Igloo: 14357618 Jungle: 14357619 Swamp: 14357620 Monument: 10387313 Ocean: 14357621 Shipwreck: 165745295 End City: 10387313 Slime: 987234911 Bastion: 30084232 Fortress: 30084232 Mansion: 10387319 Fossil: 14357921 Portal: 34222645 [14:46:10] [Server thread/INFO]: -------- World Settings For [world_nether] -------- [14:46:10] [Server thread/INFO]: Entity Tracking Range: Pl 48 / An 48 / Mo 48 / Mi 32 / Other 64 [14:46:10] [Server thread/INFO]: Item Merge Radius: 2.5 [14:46:10] [Server thread/INFO]: Item Despawn Rate: 6000 [14:46:10] [Server thread/INFO]: Allow Zombie Pigmen to spawn from portal blocks: true [14:46:10] [Server thread/INFO]: View Distance: 10 [14:46:10] [Server thread/INFO]: Experience Merge Radius: 3.0 [14:46:10] [Server thread/INFO]: Cactus Growth Modifier: 100% [14:46:10] [Server thread/INFO]: Cane Growth Modifier: 100% [14:46:10] [Server thread/INFO]: Melon Growth Modifier: 100% [14:46:10] [Server thread/INFO]: Mushroom Growth Modifier: 100% [14:46:10] [Server thread/INFO]: Pumpkin Growth Modifier: 100% [14:46:10] [Server thread/INFO]: Sapling Growth Modifier: 100% [14:46:10] [Server thread/INFO]: Beetroot Growth Modifier: 100% [14:46:10] [Server thread/INFO]: Carrot Growth Modifier: 100% [14:46:10] [Server thread/INFO]: Potato Growth Modifier: 100% [14:46:10] [Server thread/INFO]: Wheat Growth Modifier: 100% [14:46:10] [Server thread/INFO]: NetherWart Growth Modifier: 100% [14:46:10] [Server thread/INFO]: Vine Growth Modifier: 100% [14:46:10] [Server thread/INFO]: Cocoa Growth Modifier: 100% [14:46:10] [Server thread/INFO]: Bamboo Growth Modifier: 100% [14:46:10] [Server thread/INFO]: SweetBerry Growth Modifier: 100% [14:46:10] [Server thread/INFO]: Kelp Growth Modifier: 100% [14:46:10] [Server thread/INFO]: Mob Spawn Range: 6 [14:46:10] [Server thread/INFO]: Entity Activation Range: An 32 / Mo 32 / Ra 48 / Mi 16 / Tiv true [14:46:10] [Server thread/INFO]: Hopper Transfer: 8 Hopper Check: 1 Hopper Amount: 1 [14:46:10] [Server thread/INFO]: Max TNT Explosions: 100 [14:46:10] [Server thread/INFO]: Tile Max Tick Time: 50ms Entity max Tick Time: 50ms [14:46:10] [Server thread/INFO]: Nerfing mobs spawned from spawners: false [14:46:10] [Server thread/INFO]: Arrow Despawn Rate: 1200 Trident Respawn Rate:1200 [14:46:10] [Server thread/INFO]: Zombie Aggressive Towards Villager: true [14:46:10] [Server thread/INFO]: Custom Map Seeds: Village: 10387312 Desert: 14357617 Igloo: 14357618 Jungle: 14357619 Swamp: 14357620 Monument: 10387313 Ocean: 14357621 Shipwreck: 165745295 End City: 10387313 Slime: 987234911 Bastion: 30084232 Fortress: 30084232 Mansion: 10387319 Fossil: 14357921 Portal: 34222645 [14:46:10] [Server thread/INFO]: -------- World Settings For [world_the_end] -------- [14:46:10] [Server thread/INFO]: Entity Tracking Range: Pl 48 / An 48 / Mo 48 / Mi 32 / Other 64 [14:46:10] [Server thread/INFO]: Item Merge Radius: 2.5 [14:46:10] [Server thread/INFO]: Item Despawn Rate: 6000 [14:46:10] [Server thread/INFO]: Allow Zombie Pigmen to spawn from portal blocks: true [14:46:10] [Server thread/INFO]: View Distance: 10 [14:46:10] [Server thread/INFO]: Experience Merge Radius: 3.0 [14:46:10] [Server thread/INFO]: Cactus Growth Modifier: 100% [14:46:10] [Server thread/INFO]: Cane Growth Modifier: 100% [14:46:10] [Server thread/INFO]: Melon Growth Modifier: 100% [14:46:10] [Server thread/INFO]: Mushroom Growth Modifier: 100% [14:46:10] [Server thread/INFO]: Pumpkin Growth Modifier: 100% [14:46:10] [Server thread/INFO]: Sapling Growth Modifier: 100% [14:46:10] [Server thread/INFO]: Beetroot Growth Modifier: 100% [14:46:10] [Server thread/INFO]: Carrot Growth Modifier: 100% [14:46:10] [Server thread/INFO]: Potato Growth Modifier: 100% [14:46:10] [Server thread/INFO]: Wheat Growth Modifier: 100% [14:46:10] [Server thread/INFO]: NetherWart Growth Modifier: 100% [14:46:10] [Server thread/INFO]: Vine Growth Modifier: 100% [14:46:10] [Server thread/INFO]: Cocoa Growth Modifier: 100% [14:46:10] [Server thread/INFO]: Bamboo Growth Modifier: 100% [14:46:10] [Server thread/INFO]: SweetBerry Growth Modifier: 100% [14:46:10] [Server thread/INFO]: Kelp Growth Modifier: 100% [14:46:10] [Server thread/INFO]: Mob Spawn Range: 6 [14:46:10] [Server thread/INFO]: Entity Activation Range: An 32 / Mo 32 / Ra 48 / Mi 16 / Tiv true [14:46:10] [Server thread/INFO]: Hopper Transfer: 8 Hopper Check: 1 Hopper Amount: 1 [14:46:10] [Server thread/INFO]: Max TNT Explosions: 100 [14:46:10] [Server thread/INFO]: Tile Max Tick Time: 50ms Entity max Tick Time: 50ms [14:46:10] [Server thread/INFO]: Nerfing mobs spawned from spawners: false [14:46:10] [Server thread/INFO]: Arrow Despawn Rate: 1200 Trident Respawn Rate:1200 [14:46:10] [Server thread/INFO]: Zombie Aggressive Towards Villager: true [14:46:10] [Server thread/INFO]: Custom Map Seeds: Village: 10387312 Desert: 14357617 Igloo: 14357618 Jungle: 14357619 Swamp: 14357620 Monument: 10387313 Ocean: 14357621 Shipwreck: 165745295 End City: 10387313 Slime: 987234911 Bastion: 30084232 Fortress: 30084232 Mansion: 10387319 Fossil: 14357921 Portal: 34222645 [14:46:10] [Server thread/INFO]: Preparing start region for dimension minecraft:overworld [14:46:11] [Server thread/INFO]: Preparing spawn area: 0% [14:46:11] [Server thread/INFO]: Preparing spawn area: 0% [14:46:11] [Server thread/INFO]: Preparing spawn area: 0% [14:46:12] [Server thread/INFO]: Preparing spawn area: 0% [14:46:14] [Worker-Main-5/INFO]: Preparing spawn area: 83% [14:46:14] [Worker-Main-5/INFO]: Preparing spawn area: 83% [14:46:14] [Worker-Main-5/INFO]: Preparing spawn area: 83% [14:46:14] [Worker-Main-5/INFO]: Preparing spawn area: 83% [14:46:14] [Worker-Main-5/INFO]: Preparing spawn area: 83% [14:46:15] [Server thread/INFO]: Preparing spawn area: 83% [14:46:15] [Worker-Main-4/INFO]: Preparing spawn area: 99% [14:46:15] [Server thread/INFO]: Time elapsed: 5451 ms [14:46:15] [Server thread/INFO]: Preparing start region for dimension minecraft:the_nether [14:46:17] [Server thread/INFO]: Preparing spawn area: 0% [14:46:17] [Server thread/INFO]: Preparing spawn area: 0% [14:46:17] [Server thread/INFO]: Preparing spawn area: 0% [14:46:17] [Worker-Main-4/INFO]: Preparing spawn area: 83% [14:46:17] [Worker-Main-4/INFO]: Preparing spawn area: 83% [14:46:18] [Worker-Main-7/INFO]: Preparing spawn area: 83% [14:46:18] [Worker-Main-5/INFO]: Preparing spawn area: 83% [14:46:19] [Worker-Main-5/INFO]: Preparing spawn area: 83% [14:46:19] [Worker-Main-5/INFO]: Preparing spawn area: 90% [14:46:20] [Server thread/INFO]: Time elapsed: 4293 ms [14:46:20] [Server thread/INFO]: Preparing start region for dimension minecraft:the_end [14:46:22] [Server thread/INFO]: Preparing spawn area: 0% [14:46:22] [Server thread/INFO]: Preparing spawn area: 0% [14:46:22] [Server thread/INFO]: Preparing spawn area: 0% [14:46:22] [Server thread/INFO]: Preparing spawn area: 0% [14:46:22] [Worker-Main-7/INFO]: Preparing spawn area: 83% [14:46:22] [Server thread/INFO]: Time elapsed: 2367 ms [14:46:22] [Server thread/INFO]: [CommandAPI] Enabling CommandAPI v3.2 [14:46:22] [Server thread/INFO]: Server permissions file permissions.yml is empty, ignoring it [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' ```
JorelAli commented 4 years ago

I've included the fix in version 3.3. I'll update the documentation later to explain how the fix works.

endorpersand commented 4 years ago

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)

JorelAli commented 4 years ago

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?

endorpersand commented 4 years ago

Ah, I'm running Java 14, lemme try on Java 8 then.

endorpersand commented 4 years ago

Looks like that fixed it. I guess it would be important to point out in documentation then.

JorelAli commented 4 years ago

Will do.

JorelAli commented 4 years ago

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.

endorpersand commented 4 years ago

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.

Justsnoopy30 commented 4 years ago

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

JorelAli commented 4 years ago

@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.

JorelAli commented 4 years ago

@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 :)

JorelAli commented 4 years ago

@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!

JorelAli commented 4 years ago

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...

Justsnoopy30 commented 4 years ago

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.