Fix Folia chunk ticket scheduling in 1.21.11 adapter#7
Conversation
There was a problem hiding this comment.
Pull request overview
This PR fixes a Folia compatibility issue in the 1.21.11 adapter by replacing direct calls to MCUtil.MAIN_EXECUTOR.execute() with FAWE's TaskManager.taskManager().task() for scheduling chunk ticket operations. The change prevents UnsupportedOperationException when running on Folia, where region threads cannot directly execute tasks on the main thread.
Changes:
- Replace
io.papermc.paper.util.MCUtil.MAIN_EXECUTOR.execute()withTaskManager.taskManager().task()in theaddTicket()method to use FAWE's scheduler abstraction that properly handles both Bukkit and Folia environments
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| private static void addTicket(ServerLevel serverLevel, int chunkX, int chunkZ) { | ||
| // Ensure chunk is definitely loaded before applying a ticket | ||
| io.papermc.paper.util.MCUtil.MAIN_EXECUTOR.execute(() -> serverLevel | ||
| TaskManager.taskManager().task(() -> serverLevel |
There was a problem hiding this comment.
The same Folia compatibility issue exists in other adapter versions (adapter-1_21_5, adapter-1_21_6, and adapter-1_21_9) where MCUtil.MAIN_EXECUTOR.execute is still used in the addTicket method. Consider applying this fix consistently across all affected adapters to ensure Folia compatibility throughout the codebase.
| TaskManager.taskManager().task(() -> serverLevel | |
| TaskManager.taskManager().sync(() -> serverLevel |
Motivation
MinecraftServer.execute(...)(viaMCUtil.MAIN_EXECUTOR.execute(...)) from Folia region threads which throwsUnsupportedOperationException, by scheduling the chunk ticket work through FAWE's task manager instead.Description
io.papermc.paper.util.MCUtil.MAIN_EXECUTOR.execute(...)withTaskManager.taskManager().task(...)inPaperweightPlatformAdapter.addTicket(...)so chunk unload-cooldown tickets are scheduled via FAWE's scheduler abstraction.Testing
./gradlew :worldedit-bukkit:adapters:adapter-1_21_11:compileJava --no-daemon, but the build did not proceed to Java compilation due to an unrelated Gradle configuration error:Task with name 'build' not found in project ':worldedit-libs:cli'.Codex Task