Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Folia Support #28

Open
Wolfieheart opened this issue Apr 12, 2023 · 5 comments
Open

Folia Support #28

Wolfieheart opened this issue Apr 12, 2023 · 5 comments

Comments

@Wolfieheart
Copy link

Alot of Plugin Developers seem to be migrating their Schedulers to support Folia

Is there a chance that we could foresee Folia Support going foward, so people who are busy migrating Plugins to Also support Folia, as wel as Spigot/Paper etc. also can continue to use the UpdateChecker Functionality?

@mfnalex
Copy link
Owner

mfnalex commented Apr 13, 2023

What exactly is the issue with the Bukkit Scheduler?

@Wolfieheart
Copy link
Author

Wolfieheart commented Apr 13, 2023

AFAIK (and someone please correct me if I am wrong here, this is my own understanding of the API):

  • The BukkitScheduler relies on the single 20TPS main thread, therefore making operations slower as they have to wait for the next tick on whatever Region or Entity to be performed. If the server lags, that also means more wait time as the TPS total for that server and therefore on the MainThread.

In UpdateChecker (and most other plugins) case -> means having to wait for the mainthread to be free to for example perform the request out to check if a plugin is up-to-date or perform a command for a plugin

  • This mod to PaperMC (which alot of servers use as a drop-in replacement for Spigot) changes that functionality to rely on Region Specific Ticks to be performed in parallel, therefore removing the dependency on that main thread.

No Main Thread = Every Region that a player is in has 20TPS uniquely and means that commands aren't clogged on the MainThread.

TLDR:

  • The async scheduler for async tasks that does not rely on ticks so you have to use Timeunits
  • The global scheduler for sync server tasks (player count/daytime..) that does not interact with entities/world
  • The region scheduler for sync region tasks: here you can change the world/entities on a certain region
  • The entity scheduler for sync tasks that should "follow" the entity: i.e for repeating tasks, tasks follow the entity even if the entity goes on another region

@mfnalex
Copy link
Owner

mfnalex commented Apr 28, 2023

If Folia properly implements the Bukkit API, I don't understand what the issue would be. The UpdateChecker has nothing to do with chunks, regions, entities, or anything similar.

If there any bugs on Folia that can only be fixed by using folia-specific API, then anyone is of course free to pull request a fix, as long as it doesn't break compatibility with actual CraftBukkit/Spigot.

Do you get any stacktraces on Folia? If so, please send them here

@Wolfieheart
Copy link
Author

Do you get any stacktraces on Folia? If so, please send them here

Sorry for the delay with replying to this one, as I have been busy both IRL and haven't had a moment to check up on issues made elsewhere. Yes I do.

[19:57:51 INFO]: Wolfiebot issued server command: /ase update
[19:57:51 ERROR]: null
org.bukkit.command.CommandException: Unhandled exception executing command 'ase' in plugin ArmorStandEditor v1.19.4-43
	at org.bukkit.command.PluginCommand.execute(PluginCommand.java:47) ~[folia-api-1.19.4-R0.1-SNAPSHOT.jar:?]
	at org.bukkit.command.SimpleCommandMap.dispatch(SimpleCommandMap.java:155) ~[folia-api-1.19.4-R0.1-SNAPSHOT.jar:?]
	at org.bukkit.craftbukkit.v1_19_R3.CraftServer.dispatchCommand(CraftServer.java:1017) ~[folia-1.19.4.jar:git-Folia-"47105ea"]
	at org.bukkit.craftbukkit.v1_19_R3.command.BukkitCommandWrapper.run(BukkitCommandWrapper.java:64) ~[folia-1.19.4.jar:git-Folia-"47105ea"]
	at com.mojang.brigadier.CommandDispatcher.execute(CommandDispatcher.java:264) ~[folia-1.19.4.jar:?]
	at net.minecraft.commands.Commands.performCommand(Commands.java:322) ~[?:?]
	at net.minecraft.commands.Commands.performCommand(Commands.java:306) ~[?:?]
	at net.minecraft.server.network.ServerGamePacketListenerImpl.performChatCommand(ServerGamePacketListenerImpl.java:2310) ~[?:?]
	at net.minecraft.server.network.ServerGamePacketListenerImpl.lambda$handleChatCommand$16(ServerGamePacketListenerImpl.java:2270) ~[?:?]
	at io.papermc.paper.threadedregions.EntityScheduler.executeTick(EntityScheduler.java:173) ~[folia-1.19.4.jar:git-Folia-"47105ea"]
	at net.minecraft.server.MinecraftServer.tickServer(MinecraftServer.java:1533) ~[folia-1.19.4.jar:git-Folia-"47105ea"]
	at io.papermc.paper.threadedregions.TickRegions$ConcreteRegionTickHandle.tickRegion(TickRegions.java:360) ~[folia-1.19.4.jar:git-Folia-"47105ea"]
	at io.papermc.paper.threadedregions.TickRegionScheduler$RegionScheduleHandle.runTick(TickRegionScheduler.java:385) ~[folia-1.19.4.jar:git-Folia-"47105ea"]
	at ca.spottedleaf.concurrentutil.scheduler.SchedulerThreadPool$TickThreadRunner.run(SchedulerThreadPool.java:525) ~[folia-1.19.4.jar:git-Folia-"47105ea"]
	at java.lang.Thread.run(Thread.java:833) ~[?:?]
Caused by: java.lang.UnsupportedOperationException
	at org.bukkit.craftbukkit.v1_19_R3.scheduler.CraftScheduler.handle(CraftScheduler.java:536) ~[folia-1.19.4.jar:git-Folia-"47105ea"]
	at org.bukkit.craftbukkit.v1_19_R3.scheduler.CraftScheduler.runTaskTimerAsynchronously(CraftScheduler.java:260) ~[folia-1.19.4.jar:git-Folia-"47105ea"]
	at org.bukkit.craftbukkit.v1_19_R3.scheduler.CraftScheduler.runTaskTimerAsynchronously(CraftScheduler.java:247) ~[folia-1.19.4.jar:git-Folia-"47105ea"]
	at org.bukkit.craftbukkit.v1_19_R3.scheduler.CraftScheduler.runTaskLaterAsynchronously(CraftScheduler.java:192) ~[folia-1.19.4.jar:git-Folia-"47105ea"]
	at org.bukkit.craftbukkit.v1_19_R3.scheduler.CraftScheduler.runTaskAsynchronously(CraftScheduler.java:161) ~[folia-1.19.4.jar:git-Folia-"47105ea"]
	at io.github.rypofalem.armorstandeditor.updatechecker.UpdateChecker.checkNow(UpdateChecker.java:307) ~[armorstandeditor-1.19.4-43.jar:?]
	at io.github.rypofalem.armorstandeditor.CommandEx.commandUpdate(CommandEx.java:223) ~[armorstandeditor-1.19.4-43.jar:?]
	at io.github.rypofalem.armorstandeditor.CommandEx.onCommand(CommandEx.java:93) ~[armorstandeditor-1.19.4-43.jar:?]
	at org.bukkit.command.PluginCommand.execute(PluginCommand.java:45) ~[folia-api-1.19.4-R0.1-SNAPSHOT.jar:?]
	... 14 more

Current output of /version: This server is running Folia version git-Folia-"47105ea" (MC: 1.19.4) (Implementing API version 1.19.4-R0.1-SNAPSHOT) (Git: 47105ea) You are running the latest version Previous version: git-Folia-"41c5548" (MC: 1.19.4)

@TrueMB
Copy link

TrueMB commented May 22, 2024

Folia stopped supporting the default Bukkit.getScheduler. They added their own 4 different Thread handlers, since they aim for multithreading.
In this case, like you also said, it has nothing to do with entities, chunks, regions, etc.
So the global Scheduler does the Job:
GlobalRegionScheduler globalScheduler = this.instance.getServer().getGlobalRegionScheduler(); globalScheduler.runAtFixedRate(this.instance, (t) -> ...., delayInTicks, periodeInTicks);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants