Folia support: migrate Bukkit scheduler usage to SchedulerUtils#12
Open
GenOpenDiesel wants to merge 1 commit into
Open
Folia support: migrate Bukkit scheduler usage to SchedulerUtils#12GenOpenDiesel wants to merge 1 commit into
GenOpenDiesel wants to merge 1 commit into
Conversation
ItemTag declared folia-supported but still scheduled tasks through the global BukkitScheduler / BukkitRunnable, which throws on Folia (and left a `//TODO folia fix` in Usable). - Replace all one-shot runTaskLater / BukkitRunnable delayed tasks with ItemEdit's Folia-aware SchedulerUtils, scoped to the relevant player so they run on that entity's region thread (Usable, EquipmentFlag, RenamableOld, WearPermission, EffectsResurrectListener, Effects, DelayedAction, activity DelayedActionType). - EquipmentChangeListener: SlotCheck no longer extends BukkitRunnable; it implements Runnable and exposes schedule() backed by SchedulerUtils. - Equipment poll timer: keep the BukkitRunnable timer off Folia; on Folia self-reschedule via SchedulerUtils and fan each player check out to its own region thread. Back equips/clickDrop with thread-safe collections on Folia (mirrors ActionHandler). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
plugin.ymlalready declaresfolia-supported: true, but the plugin still scheduled work through the globalBukkitScheduler/BukkitRunnable, which throws on Folia. There was even a leftover//TODO folia fixinUsable. On Foliareload()would also blow up becauseEquipmentChangeListenerBasestarted arunTaskTimeron the global scheduler.What
Migrated every scheduler call to ItemEdit's Folia-aware
SchedulerUtils, scoping each task to the player it acts on so it runs on that entity's region thread.One-shot delayed tasks (
runTaskLater/BukkitRunnable):customflags/Usable(removes the//TODO folia fix)customflags/EquipmentFlagcustomflags/RenamableOldcommand/itemtag/WearPermissioncommand/itemtag/EffectsResurrectListenercommand/itemtag/Effects(respawn + milk-bucket consume)actions/DelayedActionactivity/action/DelayedActionTypeEquipment change listener:
SlotCheckno longer extendsBukkitRunnable— it implementsRunnableand exposesschedule()backed bySchedulerUtils.runLater(plugin, player, 1L, this). Allnew SlotCheck(...).runTaskLater(...)call sites (Base +EquipmentChangeListener+UpTo1_13+UpTo1_8) now call.schedule().BukkitRunnabletimer off Folia (unchanged behaviour, includingmax_checked_players_per_tickspreading). On Folia it self-reschedules throughSchedulerUtilsand fans each player's check out to that player's own region thread.equips/clickDropare backed by thread-safe collections on Folia (mirrors the existingActionHandlerConcurrentHashMaphandling), since they are now touched from per-player region threads.Notes
SchedulerUtilsships with ItemEdit (already acompiledependency).mvn packageagainst spigot-api 1.21.x. I don't have a Folia server to runtime-test the equipment-poll path, so that part would benefit from a check on a live Folia instance.🤖 Generated with Claude Code