Refactor command queue handling to prevent duplicate execution on Folia. Introduced atomic flag to track command check progress and updated comments for clarity.#126
Open
sluhtie wants to merge 1 commit intotebexio:2.3.0-devfrom
Conversation
…ia. Introduced atomic flag to track command check progress and updated comments for clarity.
R00tB33rMan
approved these changes
Feb 4, 2026
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.
Summary
This PR fixes an issue on Folia where purchase commands could be executed twice when the player is online. The root cause was a redundant call to
checkCommandQueue(true)during Folia plugin enable, combined with missing protection against overlapping command-queue checks.In favour of #125
Changes
1) Folia: remove redundant command queue check on startup
File:
folia/src/main/java/io/tebex/plugin/TebexFoliaPlugin.javaplatform.checkCommandQueue(true)call at the end ofonEnable().initStore()aftergetServerInformation()succeeds, matching the existing Bukkit behavior (where theonEnable()call is commented out).checkCommandQueueshould not be invoked fromonEnable()on Folia.Why:
On Folia,
onEnable()could initiate a queue check concurrently with the store initialization flow, resulting in duplicate processing and command execution.2) SDK: guard against concurrent command queue checks
File:
sdk/src/main/java/io/tebex/sdk/platform/BasePluginPlatform.javaIntroduced
AtomicBoolean commandCheckInProgressto prevent parallel executions ofcheckCommandQueue().At the beginning of
checkCommandQueue():compareAndSet(false, true)fails), the check is skipped.In the
whenCompletecallback ofgetDuePlayers():try/finally.finally,commandCheckInProgress.set(false)ensures the next run is allowed.Why:
Even with the Folia startup fix, overlapping checks can still occur (e.g., scheduler timings, network delays, async completions). This guard ensures command processing remains idempotent with respect to scheduling and avoids double execution due to concurrency.
Result
checkCommandQueue()is protected from overlapping runs across all platforms.Testing
Verified on Folia
1.21.11that:Verified both purchase flows: