Flan

Flan

850k Downloads

Failed to load function, NullPointerException: Cannot read field "permissionLevel"

HatTrkPatrk opened this issue ยท 1 comments

commented

Modloader

Fabric

Minecraft version

1.21

Modloader version

0.16.2

Mod version

flan-1.21-1.10.7-fabric

Description

I have some functions in a datapack I've made that uses the /flan command to give players blocks. When I start my server with this datapack installed/enabled, it fails to load functions that have those /flan commands:

[20:15:38] [main/ERROR]: Failed to load function namespace:name/of/function
java.util.concurrent.CompletionException: java.lang.NullPointerException: Cannot read field "permissionLevel" because "io.github.flemmli97.flan.config.ConfigHandler.config" is null
	at java.base/java.util.concurrent.CompletableFuture.encodeThrowable(CompletableFuture.java:315) ~[?:?]
	at java.base/java.util.concurrent.CompletableFuture.completeThrowable(CompletableFuture.java:320) ~[?:?]
	at java.base/java.util.concurrent.CompletableFuture$AsyncSupply.run(CompletableFuture.java:1770) ~[?:?]
	at java.base/java.util.concurrent.CompletableFuture$AsyncSupply.exec(CompletableFuture.java:1760) ~[?:?]
	at java.base/java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:387) ~[?:?]
	at java.base/java.util.concurrent.ForkJoinPool$WorkQueue.topLevelExec(ForkJoinPool.java:1312) ~[?:?]
	at java.base/java.util.concurrent.ForkJoinPool.scan(ForkJoinPool.java:1843) ~[?:?]
	at java.base/java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1808) ~[?:?]
	at java.base/java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:188) ~[?:?]
Caused by: java.lang.NullPointerException: Cannot read field "permissionLevel" because "io.github.flemmli97.flan.config.ConfigHandler.config" is null
	at io.github.flemmli97.flan.fabric.platform.integration.permissions.PermissionNodeHandlerImpl.perm(PermissionNodeHandlerImpl.java:17) ~[flan-1.21-1.10.7-fabric.jar:?]
	at io.github.flemmli97.flan.commands.CommandClaim.lambda$register$32(CommandClaim.java:106) ~[flan-1.21-1.10.7-fabric.jar:?]
	at com.mojang.brigadier.tree.CommandNode.canUse(CommandNode.java:65) ~[brigadier-1.2.9.jar:?]
	at com.mojang.brigadier.CommandDispatcher.parseNodes(CommandDispatcher.java:301) ~[brigadier-1.2.9.jar:?]
	at com.mojang.brigadier.CommandDispatcher.parseNodes(CommandDispatcher.java:335) ~[brigadier-1.2.9.jar:?]
	at com.mojang.brigadier.CommandDispatcher.parse(CommandDispatcher.java:291) ~[brigadier-1.2.9.jar:?]
	at MC/net.minecraft.server.function.CommandFunction.parse(CommandFunction.java:96) ~[server-intermediary.jar:?]
	at MC/net.minecraft.server.function.CommandFunction.create(CommandFunction.java:78) ~[server-intermediary.jar:?]
	at MC/net.minecraft.server.function.FunctionLoader.method_29451(FunctionLoader.java:89) ~[server-intermediary.jar:?]
	at java.base/java.util.concurrent.CompletableFuture$AsyncSupply.run(CompletableFuture.java:1768) ~[?:?]
	... 6 more

repeated for every function that has such a command in it.

Note that it is fixed by running a /reload manually on the server console, so it seems to only be an issue while the server is starting. However this error prevents those functions from being loaded and therefore breaks datapacks.

If it matters, this is an example of one of my .mcfunction files:

# Increases the player's block limit by 10 for land claims
flan giveClaimBlocks @s[type=minecraft:player] 10

(had to use that target selector because the /flan command seems to complain "Only players may be affected by this command, but the provided selector includes entities" if I don't specify that.)

Steps to reproduce

  1. Make a datapack with a function that runs /flan giveClaimBlocks @a 10 commands
  2. Add that datapack to a server and start it up
  3. Check the logs

Mods that might affect the issue

No response

Logs

n/a

commented

Should be noted that the error, in itself, doesn't cause any crashes, but it does break datapacks because it invalidates the function.