PaperMC / Folia

Fork of Paper which adds regionised multithreading to the dedicated server.
GNU General Public License v3.0
3.49k stars 438 forks source link

Developer mode flag #285

Closed SergioK29 closed 1 week ago

SergioK29 commented 1 week ago

Is your feature request related to a problem?

It's kinda hard as a plugin developer to tell what the do's and don'ts are of writing a folia plugin

Describe the solution you'd like.

A guide for plugin developers, with code snippets for paper vs folia version of code and answering questions such as:

Also more api for async stuff maybe like instead of:

for (World world : Bukkit.getWorlds()){
 for(Chunk chunk : world.getChunks()){
   // ran on main thread
 }
}

could be like this:

Folia.runOnEachRegion(tickRegion -> {
 tickRegion.getOwnedChunks().forEach(chunk -> {
  // ran on the different tick threads
 });
});

also a mode with strict thread checks everywhere, ensuring we are doing things correctly to avoid race conditions. For example thread checks EVERYWHERE where cross region access occurs, maybe plugin scanning for non thread-safe collections (silly idea maybe), stuff like that.

Describe alternatives you've considered.

idk

Other

No response

amaranth commented 1 week ago

I'm pretty sure your runOnEachRegion example would require locking the regions while it runs to prevent them from merging or splitting in the middle, all regions would have to stop ticking to process this.

Also, this is like 3-8 issues in one, you should split it up in to API requests, documentation requests, and server feature requests (the flag).

SergioK29 commented 1 week ago

I'm pretty sure your runOnEachRegion example would require locking the regions while it runs to prevent them from merging or splitting in the middle, all regions would have to stop ticking to process this.

Also, this is like 3-8 issues in one, you should split it up in to API requests, documentation requests, and server feature requests (the flag).

done