Plugins not made for Folia
Overview
Folia refuses every plugin whose plugin.yml lacks folia-supported: true. Prism loads them: their
Bukkit tasks run on Folia's schedulers, and the calls Folia refuses outright are turned into the ones it
takes. What such a plugin still does wrong under region threading fails where it is, and Prism tells you
which plugin, where in its code, and how often.
It is not a promise that every plugin works. A plugin written for one main thread may read or change a part of the world another thread owns at that moment; region threading forbids it, and no layer can make it safe. What this layer does is keep everything that can work working, and make what cannot visible.
What Prism does
| Folia | Prism |
|---|---|
| Refuses to load the plugin | Loads it, says so once in the console, marks it Non-Folia on the dashboard |
Bukkit.getScheduler() throws on every call |
Runs the task on Folia's schedulers, with Bukkit's task numbers, cancelling and pending lists |
entity.teleport(...) throws |
Teleports asynchronously and returns true |
Bukkit.dispatchCommand(...) from the wrong thread throws |
Runs the command on the right thread at the next tick and returns true |
A player's setScoreboard, addPotionEffect, removePotionEffect, setGameMode, saveData, loadData from another thread throw |
Made on the player's thread at the next tick |
Every World setter Folia keeps to the global region (time, weather, game rules, spawn limits, force-loaded chunks, metadata) throws off it |
Made on the global region at the next tick; a game rule is said set |
block.setType(...), setBlockData(...) from a thread that does not own the block throw |
Set by the region that owns the block, at the next tick |
Libraries many plugins carry (PaperLib) read (MC: 26.3) as a very old Minecraft and load chunks the old way, which Folia refuses from another region |
Plugins not made for Folia read the version as 1.26.3 (plugins.legacy-version) |
These are general rules of the API, not cases written for one plugin or one command: anything that changes something without asking for an answer back can be made on the thread that owns it, a tick later. Calls that must answer at once (reading a block of another region, listing the entities of a world) cannot, and still fail where they are. | Logs every failed thread check | Says each kind of error once with its plugin, then a line a minute at the most |
Where a task runs
Nothing in a Bukkit task says which thread it needs, so Prism looks at what the task holds and where it was scheduled from:
- An entity it holds (a player kept in a field, a lambda that captured one): the entity's own scheduler, which follows it from region to region. If the entity goes, a player who leaves for instance, the task carries on on the global region, when it was due.
- A block, a place or a chunk it holds: the region that owns that place.
- Where it was scheduled from: the entity or block of the event the plugin was handling, the player who typed its command, or the entity of the task it was running.
- Otherwise: the global region, the thread of the world's time, weather and server-wide state.
Asynchronous tasks run on Folia's asynchronous scheduler. callSyncMethod returns a future completed on
the thread chosen as above.
What works, what does not
Measured with a test plugin written as for one main thread:
| Pattern | Result |
|---|---|
runTask, runTaskLater, runTaskTimer from onEnable |
Works: global region, a timer runs 100 times in 100 ticks |
BukkitRunnable and Consumer<BukkitTask> timers that cancel themselves |
Works |
scheduleSyncRepeatingTask then cancelTask, isQueued |
Works |
runTaskAsynchronously, then callSyncMethod(...).get() from there |
Works |
A task scheduled in PlayerJoinEvent that holds the player: potion effect, teleport |
Works, on the player's thread |
| A task scheduled in an event that holds only the player's UUID | Works, on the player's thread |
| A task scheduled by a player's command | Works, on the player's thread |
A task that holds a Block, scheduled from the console |
Works, in the block's region |
Bukkit.dispatchCommand(console, ...) from a player's event |
Works, on the global region next tick |
| A timer on the global region that changes a block far away | Works, set by that block's region at the next tick |
setGameMode from an asynchronous task, a spawn limit set from a player's region |
Works |
| A timer on the global region that reads a block far away | Fails: said once with the plugin's line, counted on the dashboard |
As a rule, a plugin that reacts to its players (commands, events, effects, teleports, messages) mostly works. A plugin that walks every entity or loaded chunk of a world from one timer does not, and neither does one that changes, from one task, blocks or mobs spread over several regions. Players are an exception Folia already makes: most of what a plugin reads or changes on a player works from any thread, and the scoreboards and potion effects Folia refuses are moved to the player's thread.
Plugins tested
EssentialsX 2.22.0, with two players, on Prism Alpha #2: /sethome and /home, /setwarp and /warp, /tpa and
/tpaccept (the player lands on the other), /back (back where they were), /msg, /balance and /pay (the money
arrives), /afk (said to the others), /heal, /feed, /gamemode, /time set day, /weather sun, /seen, /list,
/broadcast and /nick all work, and so does /tp from the console to another region. The dashboard counts 4 tasks on the global region, 7 asynchronous ones, 4 teleports
made asynchronous, 2 changes of time and weather moved to the global region, and no error. EssentialsX says once at the
start that it does not know Minecraft 26.3, and carries on.
Seeing what fails
The console says, once for each kind of error:
[LegacyTest] task #9 touched what its thread does not own, at LegacyTest.lambda$onEnable$7:78:
IllegalStateException: Thread failed main thread check: Cannot modify world asynchronously.
This plugin is not made for region threading: this part of it does not work on Prism.
The dashboard's Plugins page marks each such plugin Non-Folia and shows the tasks Prism moved for it, the teleports and commands it turned around, how many errors it had and the latest one.
Settings
In config/prism-server.yml:
plugins:
non-folia: true # false: Folia's behaviour, such plugins are not loaded
excluded: [Jobs] # plugins not made for Folia to keep out all the same, by name
A plugin that keeps failing is better replaced by a Folia version, or kept out with excluded.