Add ensureGlobalTickThread method for validation#374
Merged
Conversation
…al tick thread validation
Contributor
There was a problem hiding this comment.
Pull request overview
Adds an explicit “global tick thread” validation hook to the Paper TickThreadGuard API, with NMS-backed implementations for the supported versions, to improve thread-safety checks and diagnostics.
Changes:
- Extended
TickThreadGuardwithensureGlobalTickThread(reason: String)and updated the published API surface. - Implemented
ensureGlobalTickThreadfor NMSv1_21_11andv26_1. - Bumped the project version to
3.23.0.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| surf-api-paper/surf-api-paper/src/main/kotlin/dev/slne/surf/api/paper/region/TickThreadGuard.kt | Adds the new ensureGlobalTickThread method to the public interface/companion delegation. |
| surf-api-paper/surf-api-paper/api/surf-api-paper.api | Updates the API dump to reflect the new method on the interface and companion. |
| surf-api-paper/surf-api-paper-nms/surf-api-paper-nms-v26-1/src/main/kotlin/dev/slne/surf/api/paper/server/nms/v26_1/region/V26_1TickThreadGuard.kt | Implements ensureGlobalTickThread for v26.1 and updates tick-thread checks. |
| surf-api-paper/surf-api-paper-nms/surf-api-paper-nms-v1-21-11/src/main/kotlin/dev/slne/surf/api/paper/server/nms/v1_21_11/region/V1_21_11TickThreadGuard.kt | Implements ensureGlobalTickThread for v1.21.11. |
| gradle.properties | Version bump to 3.23.0. |
Comment on lines
19
to
23
| override fun ensureTickThread(world: World, pos: Position, reason: String) { | ||
| TickThread.ensureTickThread("") | ||
|
|
||
| TickThread.ensureTickThread(world.toNms(), pos.chunkX, pos.chunkZ, reason) | ||
| } |
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.
This pull request introduces a new method,
ensureGlobalTickThread, to theTickThreadGuardinterface and implements it for both thev1_21_11andv26_1NMS versions. This addition allows for explicit checks to ensure code is running on the global tick thread, improving thread safety and error reporting. The project version is also updated.API changes
ensureGlobalTickThread(reason: String)method to theTickThreadGuardinterface and its companion, updating the API contract and documentation. [1] [2] [3]Implementation updates
ensureGlobalTickThreadmethod in bothV1_21_11TickThreadGuardandV26_1TickThreadGuard, throwing anIllegalStateExceptionif not on the global tick thread. [1] [2]serverextension to support the global tick thread check in both NMS guard classes. [1] [2]Versioning
3.22.0to3.23.0ingradle.properties.