Skip to content

Comments

Add folia support#54

Closed
yL3oft wants to merge 2 commits intoMrMicky-FR:masterfrom
yL3oft:master
Closed

Add folia support#54
yL3oft wants to merge 2 commits intoMrMicky-FR:masterfrom
yL3oft:master

Conversation

@yL3oft
Copy link

@yL3oft yL3oft commented Sep 20, 2025

This PR aims to adding folia support.

Tested in:

  • Paper 1.21.8
  • Folia 1.21.8

@MrMicky-FR
Copy link
Owner

Thanks for your pull request! Could you please indicate which version of WorldEdit you used for testing (which should also supports Folia) ? Thanks

@yL3oft
Copy link
Author

yL3oft commented Sep 21, 2025

Yes i can, i used a fork from Euphillya: https://github.com/Euphillya/WorldEdit-Folia/releases

@MrMicky-FR
Copy link
Owner

Thanks! Have you checked the thread safety of the WESV internal data structures? I will test it soon, but I'm pretty sure they can be accessed by different threads (are commands, events, and repeated tasks still run on the same thread in Folia?). This could cause concurrency issues since the plugin is not thread-safe yet, even if no errors occurred during testing.

@MrMicky-FR MrMicky-FR added the enhancement New feature or request label Sep 24, 2025
@yL3oft
Copy link
Author

yL3oft commented Sep 24, 2025

So i did a bunch of testing... I found 2 issues in the commands that i missed out when testing. It should all be working now, and i'm pretty sure it's thread-safe. You can do more testing if you want tho just to be sure.

@MrMicky-FR
Copy link
Owner

Still haven’t found the time to look closely, but for example the player commands and events (join/quit/world change/item change) are executed in the context of the region owning the player, but the WESV loops are executed in the context of the global region, so couldn’t this cause some concurrency issues ?

Especially as concurrency issues cannot always be detected by doing a lot of testing, and such issues are way more likely to occur on big servers with many entities/regions than during testing without an important number of players where threads overlapping are not frequent

@yL3oft
Copy link
Author

yL3oft commented Sep 26, 2025

Nah i don't think so, besides if we wanted it to not loop in the global server scheduler where would it loop then?

@MrMicky-FR
Copy link
Owner

After some verification (thanks also to PaperMC Discord for their hints), on Folia player join/quit are always called on the thread that is currently ticking that player (like that's the whole point of Folia!), which might be different from the global region scheduler.

I've added Folia support on the above commit, by using volatile/ConcurrentHashMap for concurrent support, and removing reflection calls (and suppressing a lot of Paper deprecation to keep Bukkit compatibility 😅). Also took this opportunity to make the particle tasks asynchronous to reduce load on main thread (for non-Folia) or on global region thread (for Folia).

Thanks again for your help!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants