Rapha149 / ClearFog

Unnerved by 1.18 fog? This Spigot plugin will remove it!
https://www.spigotmc.org/resources/clearfog.98448/
GNU General Public License v3.0
8 stars 2 forks source link

[Feature] Folia support #8

Open Potothingi opened 1 year ago

Potothingi commented 1 year ago

I hope someday this plugin will support Folia. Folia isn't a stable release yet, so don't rush.

Currently, 'ProtocolLib, Vault, LuckPerms, PlaceholderAPI, EssentialsX, ViaVersion, ViaBackwards, CoreProtect, DiscordSRV, Chunky, Spark' plugins already support Folia, or Folia support is ready in pull requests.

https://docs.papermc.io/folia

Rapha149 commented 1 year ago

The problem is that I really don't know anything about Folia. But it's a fork of Paper so it could work without adapting it.

Potothingi commented 1 year ago

The problem is that I really don't know anything about Folia. But it's a fork of Paper so it could work without adapting it.

https://github.com/PaperMC/Folia#plugin-compatibility

First, Folia breaks many plugins. To aid users in figuring out which plugins work, only plugins that have been explicitly marked by the author(s) to work with Folia will be loaded. By placing "folia-supported: true" into the plugin's plugin.yml, plugin authors can mark their plugin as compatible with regionised multithreading.

The other important rule is that the regions tick in parallel, and not concurrently. They do not share data, they do not expect to share data, and sharing of data will cause data corruption. Code that is running in one region under no circumstance can be accessing or modifying data that is in another region. Just because multithreading is in the name, it doesn't mean that everything is now thread-safe. In fact, there are only a few things that were made thread-safe to make this happen. As time goes on, the number of thread context checks will only grow, even if it comes at a performance penalty - nobody is going to use or develop for a server platform that is buggy as hell, and the only way to prevent and find these bugs is to make bad accesses fail hard at the source of the bad access.

This means that Folia compatible plugins need to take advantage of API like the RegionScheduler and the EntityScheduler to ensure their code is running on the correct thread context.

Add folia-supported: true to plugin.yml. And use RegionScheduler and EntityScheduler instead of Bukkit Scheduler.

Rapha149 commented 1 year ago

Okay, I'll check when I have time to implement that.

Potothingi commented 1 year ago

@Rapha149 You can refer to the commits that other plugins have added to support Folia.

https://github.com/ViaVersion/ViaVersion/commit/7c9c602cec1c73f818379b79e1c116c32a278580 https://github.com/ViaVersion/ViaVersion/commit/c46bb5bcf5e88a415dc045271fe1a174c3a623f4

https://github.com/ViaVersion/ViaBackwards/commit/4293289468a6840001ece99fb4285ba5215f9bbc

https://github.com/pop4959/Chunky/commit/2a3f089861c65e5448983b6ef98dcb3a93b7fa4f https://github.com/pop4959/Chunky/commit/38e99a87038c20ce8459228cd6c18634d35085a5 https://github.com/pop4959/Chunky/commit/3666d58e886bef17700aef66fef06ee43d49fb3b

https://github.com/dmulloy2/ProtocolLib/commit/65a9ef5acf00b978bd605090790a638384769c1c

https://github.com/MilkBowl/Vault/pull/915/files

https://github.com/LuckPerms/LuckPerms/pull/3615/files

https://github.com/lucko/spark/pull/312/files

https://github.com/PlaceholderAPI/PlaceholderAPI/commit/95786e32d2d5a877220705648c8139486549c781

https://github.com/EssentialsX/Essentials/pull/5291/files

https://github.com/PlayPro/CoreProtect/commit/7170e2945269f6aa7f6a8468cad8e2ae473357eb https://github.com/PlayPro/CoreProtect/commit/ace870b93016b900f4726fcf2bfe4e71fc98accf https://github.com/PlayPro/CoreProtect/commit/f2934fd876f4d5ec93e0488d7494b25ca41c9aff

https://github.com/DiscordSRV/DiscordSRV/commit/812c9b025bff260eb19e4ae4bb8c8cec61bb6829

https://github.com/e-im/FreedomChat/commit/dffbd3dc8e3381d0c6e5571ed00e1cdd28dd30de