TechnicallyCoded / FoliaLib

This is a wrapper library for aiding in supporting the Folia Paper Fork. This library adds multiple scheduler options to use instead of the Bukkit or Folia native schedulers.
MIT License
70 stars 11 forks source link

IllegalArgumentException: The nativeTask provided must be a BukkitTask. #28

Open base2code opened 2 months ago

base2code commented 2 months ago

Hi, this is the full stacktrace regarding: https://github.com/TechnicallyCoded/FoliaLib/pull/27

server-1 | [20:35:10 WARN]: [TestPlugin] Task #117 for TestPlugin v2.51 generated an exception server-1 | java.lang.IllegalArgumentException: The nativeTask provided must be a BukkitTask. Got: com.tcoded.folialib.wrapper.task.WrappedBukkitTask instead. server-1 | at TestPlugin-2.51.jar/com.tcoded.folialib.impl.SpigotImplementation.wrapTask(SpigotImplementation.java:455) ~[TestPlugin-2.51.jar:?] server-1 | at TestPlugin-2.51.jar/com.tcoded.folialib.impl.SpigotImplementation.lambda$runAtEntityLater$8(SpigotImplementation.java:300) ~[TestPlugin-2.51.jar:?] server-1 | at TestPlugin-2.51.jar/com.tcoded.folialib.impl.SpigotImplementation.lambda$runLater$2(SpigotImplementation.java:110) ~[TestPlugin-2.51.jar:?] server-1 | at org.bukkit.craftbukkit.scheduler.CraftTask.run(CraftTask.java:88) ~[paper-1.21.jar:1.21-130-b1b5d4c] server-1 | at org.bukkit.craftbukkit.scheduler.CraftScheduler.mainThreadHeartbeat(CraftScheduler.java:475) ~[paper-1.21.jar:1.21-130-b1b5d4c] server-1 | at net.minecraft.server.MinecraftServer.tickChildren(MinecraftServer.java:1726) ~[paper-1.21.jar:1.21-130-b1b5d4c] server-1 | at net.minecraft.server.dedicated.DedicatedServer.tickChildren(DedicatedServer.java:473) ~[paper-1.21.jar:1.21-130-b1b5d4c] server-1 | at net.minecraft.server.MinecraftServer.tickServer(MinecraftServer.java:1598) ~[paper-1.21.jar:1.21-130-b1b5d4c] server-1 | at net.minecraft.server.MinecraftServer.runServer(MinecraftServer.java:1304) ~[paper-1.21.jar:1.21-130-b1b5d4c] server-1 | at net.minecraft.server.MinecraftServer.lambda$spin$0(MinecraftServer.java:330) ~[paper-1.21.jar:1.21-130-b1b5d4c] server-1 | at java.base/java.lang.Thread.run(Unknown Source) ~[?:?]

I currently can not say which call to the scheduler is causing this.

base2code commented 2 months ago

I found my issue: I used: getScheduler().runAtEntityLater(player, (task) -> { player.updateInventory(); }, 20L); but it should be: getScheduler().runAtEntityLater(player, player::updateInventory, 20L);

TechnicallyCoded commented 2 months ago

Still valid, unlikely user error. Using the overloaded method which takes in a runnable should work just as well as the one taking in the consumer.