Skip to content

Add Folia support - #150

Open
CuukyOfficial wants to merge 10 commits into
masterfrom
folia-support
Open

CuukyOfficial wants to merge 10 commits into
masterfrom
folia-support

Conversation

@CuukyOfficial

@CuukyOfficial CuukyOfficial commented Oct 28, 2026 •

Copy link
Copy Markdown
Owner

Folia support

The plugin now loads and runs on Folia (folia-supported: true in plugin.yml and paper-plugin.yml) with unchanged behavior on Bukkit/Spigot/Paper.

Depends on CuukyOfficial/CFW#37. It has to be merged and released first, then cfw in gradle/libs.versions.toml has to be bumped. Until then the project does not compile against the published CFW.

Changes

  • Every BukkitScheduler/BukkitRunnable/BukkitTask usage was migrated to CFW's TaskScheduler/TaskRunnable/Task, accessed via the new Main.scheduler().
  • Players, entities, blocks and world settings are accessed by the thread that owns them (executeFor/executeAt/execute). On non-Folia servers this runs inline on the main thread as before.
  • Teleports go through SafeTeleport, which is asynchronous on Folia.
  • SpawnGenerator exposes a future; the game start continues once all spawns exist.
  • Shared state (VaroPlayer, VaroTeam, Spawn, backups, alerts, ...) uses thread-safe lists; SynchronizedArrayList iterates on a snapshot.
  • Border decreases, world spawn, chest filling, offline villagers, vanish, entity tracer, kick checks and admin commands were made region-aware.

Scoreboards and AutoSetup on Folia

  • Sidebar and nametags work: Folia blocks getNewScoreboard/setScoreboard, so CFW sends the scoreboard as packets (Mojang mapped servers, 1.20.5+).
  • /varo autosetup run works: terrain is scanned and edited per chunk by the owning region thread (ColumnScan, BlockEditor); spawn, portal and lobby generators expose futures. WorldEdit schematic lobbies depend on WorldEdit's own Folia support.
  • Teleports are asynchronous.
  • Not tested on Folia: Discord bot, backup restore/reset, finale, strikes, GUIs/menus.

Testing

Automated with a mineflayer bot (join, /varo spawns, /varo start incl. spawn generation, admin commands, death/kick, shutdown with a player online):

  • Folia 26.1.2 and Paper 26.1.2 (full flow incl. AutoSetup, /varo start, sidebar toggle, nametag teams with two players), Paper 1.21.11 (with forced packet scoreboards) and 1.12.2 on Java 8 (full flow incl. AutoSetup)
  • Folia/Paper 26.3 (startup)

Pre-existing problems that are unchanged by this PR: Paper 1.16.5/1.21.8 fail at startup in XSeries (GameRule.getKey()), and setNormalAttackSpeed throws an NPE on respawn after a death kick (seen on 1.12.2).

Several independent review passes (thread-safety, migration, Folia API conformance, design) were run; their findings are incorporated.

Stand

Scoreboards, nametags and AutoSetup work on every supported platform; full flow (AutoSetup, /varo start, sidebar toggle, nametag team, two bots) was tested on:

  • Folia 1.19.4, 1.20.1, 1.20.2, 1.20.4, 26.1
  • Spigot 1.8.8 (BuildTools), Paper 1.8.8, 1.12.2, 1.16.5, 1.21.8, 1.21.11, 26.1

No JVM arguments needed. Folia 1.20.6 and 26.3 start fine (the test bot cannot join those versions).
Reviews (architecture, thread safety) done and their findings implemented:

  • CFW: ScoreboardInstance is platform neutral (registerSideBar() is void, newInstance throws instead of returning null); Bukkit specifics (getSideBar, getScoreboard) moved to BukkitScoreboardInstance. Lost scoreboard packets (player without connection) are resent, unit tests with a fake PacketFactory, fail fast if the Folia scheduler API is unusable.
  • Varo: autosave serializes on the main/global thread and only writes files asynchronously, SynchronizedArrayList covers the remaining mutators (subList/listIterator are snapshots), platform forks moved to VaroUtils helpers, unit tests for SynchronizedArrayList.

Also: the Folia scheduler is compiled against folia-api in its own source set (no reflection; only FoliaPlatform is instantiated reflectively so other servers never load Folia classes); packet factories share their reflection helper (NMS access stays reflective, there is no API for scoreboard packets). Varo has a CI workflow (scripts/smoke-test.sh) that starts Folia 1.19.4-26.1 and Paper and checks that the plugin enables cleanly. Verified that game data survives kill -9 (autosave) and a regular stop: a started game with a team was restored after restart on Folia 26.1, Paper 1.21.11 and Spigot 1.8.8.

🤖 Generated with Claude Code

CuukyOfficial and others added 10 commits October 28, 2026 20:15
Migrate all scheduler usage to the CFW TaskScheduler, make player, entity,
block and world access region-aware and mark the plugin as Folia-supported.
Scoreboards/nametags and the AutoSetup are not available on Folia.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01APs98rPwpPZxMpjv4TcLiF
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01APs98rPwpPZxMpjv4TcLiF
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01APs98rPwpPZxMpjv4TcLiF
…ts on errors

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01APs98rPwpPZxMpjv4TcLiF
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01APs98rPwpPZxMpjv4TcLiF
Sidebar and nametags use CFW's packet based scoreboards on Folia. AutoSetup
scans and edits terrain per chunk via the owning region thread (BlockEditor,
ColumnScan). Removes the Folia startup warning.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01APs98rPwpPZxMpjv4TcLiF
paper-plugin.yml list format, VaroBootstrap overload for 1.19.x, XGameRule
fallback, null guards for players leaving during start sequences.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01APs98rPwpPZxMpjv4TcLiF
…volatile

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01APs98rPwpPZxMpjv4TcLiF
…ronizedArrayList, add platform helpers and tests

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01APs98rPwpPZxMpjv4TcLiF
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01APs98rPwpPZxMpjv4TcLiF
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

Successfully merging this pull request may close these issues.

1 participant