Skip to content

支持 Folia#1059

Open
StarWishsama wants to merge 200 commits into
devfrom
feature/folia
Open

支持 Folia#1059
StarWishsama wants to merge 200 commits into
devfrom
feature/folia

Conversation

@StarWishsama

@StarWishsama StarWishsama commented May 5, 2025

Copy link
Copy Markdown
Member
  • 迁移至 Folia Scheduler
  • 为部分模块添加多线程支持
    • 为 TickerTask 引入异步调度器并行运行任务
    • sub region slimefun ticker (由于 Folia 没有显式获取所有 Region 的方法,故取消)
  • Fix feature/folia分支部分多方快结构无法使用 #1082
  • 正确处理传送
  • 新增 Ticker 线程池配置,便于用户根据服务器情况调优
  • Folia 不支持的事件替代方案(重生、登录、...)
  • [API] concurrent safe 标记*
  • 线程池管理
  • 合并到 Insider 通道

*: BlockTicker#isConcurrentSafe() 用于标记当前机器 Ticker 是并发安全的,Slimefun 默认认为附属的机器是并发不安全的,并移至异步单线程处理这些机器。

ybw0014 and others added 30 commits October 19, 2023 12:07
Bumps me.clip:placeholderapi from 2.11.3 to 2.11.4.

---
updated-dependencies:
- dependency-name: me.clip:placeholderapi
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Bumps [com.rudikershaw.gitbuildhook:git-build-hook-maven-plugin](https://github.com/rudikershaw/git-build-hook) from 3.1.0 to 3.4.1.
- [Release notes](https://github.com/rudikershaw/git-build-hook/releases)
- [Commits](rudikershaw/git-build-hook@3.1.0...3.4.1)

---
updated-dependencies:
- dependency-name: com.rudikershaw.gitbuildhook:git-build-hook-maven-plugin
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Bumps [com.gmail.nossr50.mcMMO:mcMMO](https://github.com/mcMMO-Dev/mcMMO) from 2.1.223 to 2.1.225.
- [Release notes](https://github.com/mcMMO-Dev/mcMMO/releases)
- [Changelog](https://github.com/mcMMO-Dev/mcMMO/blob/master/Changelog.txt)
- [Commits](https://github.com/mcMMO-Dev/mcMMO/commits)

---
updated-dependencies:
- dependency-name: com.gmail.nossr50.mcMMO:mcMMO
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Bumps com.sk89q.worldedit:worldedit-core from 7.2.15 to 7.2.17.

---
updated-dependencies:
- dependency-name: com.sk89q.worldedit:worldedit-core
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Bumps [com.zaxxer:HikariCP](https://github.com/brettwooldridge/HikariCP) from 5.0.1 to 5.1.0.
- [Changelog](https://github.com/brettwooldridge/HikariCP/blob/dev/CHANGES)
- [Commits](brettwooldridge/HikariCP@HikariCP-5.0.1...HikariCP-5.1.0)

---
updated-dependencies:
- dependency-name: com.zaxxer:HikariCP
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Bumps me.clip:placeholderapi from 2.11.4 to 2.11.5.

---
updated-dependencies:
- dependency-name: me.clip:placeholderapi
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
* e2e testing initial

* Setup matrix

* Download tester

* Jeff's changes

* capitalized Chosen

* Update dependency org.apache.maven.plugins:maven-shade-plugin to v3.5.1

* fix breaking sf block with not unlocked item duping contents (Slimefun#3976)

* [CI skip] Update actions/setup-java action to v3.13.0

* [CI skip] Update dependency me.clip:placeholderapi to v2.11.4

* [CI skip] Update actions/checkout action to v4

* [CI skip] Update dependency com.github.LoneDev6:itemsadder-api to v3.5.0c-r5

* [CI skip] Update dependency org.apache.maven.plugins:maven-javadoc-plugin to v3.6.0

* [CI skip] Update dependency org.sonarsource.scanner.maven:sonar-maven-plugin to v3.10.0.2594

* [CI skip] Update dependency com.sk89q.worldedit:worldedit-core to v7.2.16

* [CI skip] Update dependency com.sk89q.worldedit:worldedit-bukkit to v7.2.16

* [CI skip] Update dependency com.gmail.nossr50.mcMMO:mcMMO to v2.1.224

* [CI skip] Update dependency org.mockito:mockito-core to v5.6.0

* updated dough version (Slimefun#3991)

* [CI skip] Update dependency com.github.LoneDev6:itemsadder-api to v3.6.1

* [CI skip] Update dependency com.sk89q.worldedit:worldedit-core to v7.2.17

* [CI skip] Update dependency com.sk89q.worldedit:worldedit-bukkit to v7.2.17

* [CI skip] Update dependency com.gmail.nossr50.mcMMO:mcMMO to v2.1.225

* [CI skip] Update dependency org.jacoco:jacoco-maven-plugin to v0.8.11

* [CI skip] Update actions/checkout action to v4.1.1

* [CI skip] Update thollander/actions-comment-pull-request action to v2.4.3

* [CI skip] Update dependency org.apache.maven.plugins:maven-surefire-plugin to v3.2.1

* [CI skip] Update dependency me.clip:placeholderapi to v2.11.5

* Update .github/workflows/e2e-testing.yml

* Update .github/workflows/e2e-testing.yml

* Update .github/workflows/e2e-testing.yml

* Update .github/workflows/e2e-testing.yml

* Add MultiBlockCraftEvent (Updated version of Slimefun#3439) (Slimefun#3928)

* fix taking damage on head collision while wearing elytra cap (Slimefun#3760)

* Remove Lore Check from Slimefun Guide (Slimefun#3969)

* don't consume bookbinder inputs if the output is worse than the input (Slimefun#3925)

Co-authored-by: Jeroen <j.teriele1@students.uu.nl>

* Update .github/workflows/e2e-testing.yml

* Update .github/workflows/e2e-testing.yml

* fix heads showing as steve (Slimefun#4027)

* fix: clean up issues after merging

* chore(style): apply code style

---------

Co-authored-by: Jeffrey <jeffrey@kosse.me>
Co-authored-by: Daniel Walsh <walshydev@gmail.com>
Co-authored-by: iTwins <teriele.jeroen@gmail.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: Jeroen <48769316+iTwins@users.noreply.github.com>
Co-authored-by: TheBusyBiscuit <TheBusyBiscuit@users.noreply.github.com>
Co-authored-by: J3fftw <44972470+J3fftw1@users.noreply.github.com>
Co-authored-by: JustAHuman-xD <65748158+JustAHuman-xD@users.noreply.github.com>
Co-authored-by: Jeroen <j.teriele1@students.uu.nl>
Co-authored-by: Alessio Colombo <37039432+Sfiguz7@users.noreply.github.com>
* feat: use e2e test
Bumps [net.guizhanss:GuizhanLib-common](https://github.com/ybw0014/GuizhanLib) from 1.5.0 to 1.6.1.
- [Release notes](https://github.com/ybw0014/GuizhanLib/releases)
- [Changelog](https://github.com/ybw0014/GuizhanLib/blob/master/CHANGELOG.md)
- [Commits](https://github.com/ybw0014/GuizhanLib/commits)

---
updated-dependencies:
- dependency-name: net.guizhanss:GuizhanLib-common
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Bumps [net.guizhanss:GuizhanLib-updater](https://github.com/ybw0014/GuizhanLib) from 1.5.0 to 1.6.1.
- [Release notes](https://github.com/ybw0014/GuizhanLib/releases)
- [Changelog](https://github.com/ybw0014/GuizhanLib/blob/master/CHANGELOG.md)
- [Commits](https://github.com/ybw0014/GuizhanLib/commits)

---
updated-dependencies:
- dependency-name: net.guizhanss:GuizhanLib-updater
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

Copilot AI commented Feb 27, 2026

Copy link
Copy Markdown

@StarWishsama I've opened a new pull request, #1193, to work on those changes. Once the pull request is ready, I'll request review from you.

Copilot AI and others added 3 commits February 27, 2026 07:49
…o prevent race condition

Co-authored-by: StarWishsama <25561848+StarWishsama@users.noreply.github.com>
…-again

Fix race condition in SoulboundListener Folia task scheduling
Copilot AI review requested due to automatic review settings March 3, 2026 03:22

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 61 out of 61 changed files in this pull request and generated 5 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines 21 to 23
public void schedule(long delay) {
setID(Bukkit.getScheduler().scheduleSyncDelayedTask(Slimefun.instance(), this, delay));
setTask(Slimefun.getPlatformScheduler().runLaterAsync(this, delay));
}

Copilot AI Mar 3, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

schedule(...) uses runLaterAsync(this, delay), but implementations mutate Player state (inventory/velocity/effects). On Folia this can run off the entity thread and cause region/entity-thread violations. Use runAtEntityLater(p, ...) (and similarly an entity-bound repeating scheduler) for these tasks.

Copilot uses AI. Check for mistakes.
Comment on lines +82 to +86
() -> {
if (p.getHealth() > 0) {
returnSoulboundItems(p);

WrappedTask returnTask = returnTasks.remove(uuid);

Copilot AI Mar 3, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This Folia fallback schedules only a single delayed check and only completes when p.getHealth() > 0. If the player respawns later than this delay, items may never be returned and the returnTasks entry is never removed (blocking future scheduling). Use a repeating entity-bound task that retries until the player is alive/valid, and always remove the map entry when the task finishes.

Copilot uses AI. Check for mistakes.
Comment on lines +71 to 73
throw new IllegalArgumentException(
"Location or entity must be provided when executing sync task on Folia!");
}

Copilot AI Mar 3, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On Folia, the no-context overload now throws if neither a Location nor Entity is provided. There are still call sites using runSyncMethod(Callable) without context (e.g. DebugFishListener), which will now crash at runtime. Consider keeping the no-context overload safe (run inline when already on a region thread, otherwise require callers to pass Location/Entity), and/or deprecate it and update remaining call sites.

Copilot uses AI. Check for mistakes.
Comment on lines +64 to +68
return;
}

try {
menu.lock(false);

Copilot AI Mar 3, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This pattern is still vulnerable to a race: another thread can acquire the menu lock between menu.locked() and menu.lock(false), causing the ticker thread to block unexpectedly now that lock() is a blocking ReentrantLock. Prefer a tryLock-style API (return immediately when locked) or make lock(false) itself non-blocking.

Copilot uses AI. Check for mistakes.
Comment on lines +102 to +106
this.asyncTickerService = new SlimefunPoolExecutor(
"Slimefun-Ticker-Pool",
initSize - 1,
maxSize - 1,
1,

Copilot AI Mar 3, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The executor is created with initSize - 1 / maxSize - 1, but the config keys are named as thread counts (init-size, max-size). This off-by-one mapping is surprising for operators and easy to misconfigure. Either pass the config values directly, or rename/update the config docs/defaults to reflect the - 1 semantics.

Copilot uses AI. Check for mistakes.
StarWishsama and others added 21 commits March 31, 2026 10:40
# Conflicts:
#	README.md
# Conflicts:
#	.github/workflows/pr-checker.yml
#	pom.xml
#	src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/elevator/ElevatorPlate.java
#	src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/multiblocks/AutomatedPanningMachine.java
#	src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/multiblocks/miner/MiningTask.java
Optimize universal block detection to avoid expensive NBT lookups
# Conflicts:
#	src/main/java/com/xzavier0722/mc/plugin/slimefun4/storage/util/StorageCacheUtils.java
23a5b33d0be4982fba6bd03273547a09ce40b96e
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Ticker 多线程问题