Skip to content

dev#106

Merged
Aliorpse merged 6 commits intomainfrom
dev
Jan 31, 2026
Merged

dev#106
Aliorpse merged 6 commits intomainfrom
dev

Conversation

@Aliorpse
Copy link
Owner

No description provided.

@sourcery-ai
Copy link

sourcery-ai bot commented Jan 31, 2026

Reviewer's Guide

Refines project and module documentation, clarifies contribution workflow, and introduces platform-specific browser detection to adjust MSMP WebSocket authentication headers for browser vs non-browser environments.

Sequence diagram for MSMP WebSocket connection header selection

sequenceDiagram
    participant MsmpLifecycleManager
    participant WebSocketClient
    participant WebSocketServer

    MsmpLifecycleManager->>WebSocketClient: webSocketSession(target, config)
    alt isBrowser true
        WebSocketClient-->>WebSocketServer: CONNECT with header SecWebSocketProtocol: minecraft-v1,token
    else isBrowser false
        WebSocketClient-->>WebSocketServer: CONNECT with header Authorization: Authorization token
    end
    WebSocketServer-->>WebSocketClient: WebSocketSession established or failure
    WebSocketClient-->>MsmpLifecycleManager: Boolean connectionResult
Loading

Class diagram for platform browser detection and MSMP lifecycle usage

classDiagram
    class MsmpLifecycleManager {
        -target String
        -token String
        -config MsmpClientConfig
        +connectSession() Boolean
    }

    class PlatformEnvironment {
        <<interface>>
        +isBrowser Boolean
    }

    class CommonPlatform {
        +isBrowser Boolean
    }

    class JsPlatform {
        +isBrowser Boolean
    }

    class WasmJsPlatform {
        +isBrowser Boolean
    }

    class JvmPlatform {
        +isBrowser Boolean
    }

    class NativePlatform {
        +isBrowser Boolean
    }

    MsmpLifecycleManager ..> PlatformEnvironment : uses

    PlatformEnvironment <|.. CommonPlatform
    PlatformEnvironment <|.. JsPlatform
    PlatformEnvironment <|.. WasmJsPlatform
    PlatformEnvironment <|.. JvmPlatform
    PlatformEnvironment <|.. NativePlatform
Loading

File-Level Changes

Change Details Files
Add platform-specific browser detection utility and use it to send different WebSocket authentication headers for browser and non-browser MSMP clients.
  • Introduce expect/actual isBrowser flag in common, JS, WasmJS, JVM, and Native source sets.
  • Implement browser detection on JS and WasmJS using a window/document presence check, returning false on JVM and Native.
  • Modify MsmpLifecycleManager to send Sec-WebSocket-Protocol with a combined protocol/token value when running in browser environments, and an Authorization header otherwise, while preserving connection timeout configuration.
mcutils-msmp/src/commonMain/kotlin/tech/aliorpse/mcutils/internal/util/Platform.kt
mcutils-msmp/src/jsMain/kotlin/tech/aliorpse/mcutils/internal/util/Platform.js.kt
mcutils-msmp/src/wasmJsMain/kotlin/tech/aliorpse/mcutils/internal/util/Platform.wasmJs.kt
mcutils-msmp/src/jvmMain/kotlin/tech/aliorpse/mcutils/internal/util/Platform.jvm.kt
mcutils-msmp/src/nativeMain/kotlin/tech/aliorpse/mcutils/internal/util/Platform.native.kt
mcutils-msmp/src/commonMain/kotlin/tech/aliorpse/mcutils/internal/MsmpLifecycleManager.kt
Improve top-level and module README documentation for clearer usage and platform support information.
  • Update main README to describe mcutils as a Kotlin Multiplatform library, enumerate supported platforms, tweak module documentation wording, and add a Contributing section pointing to CONTRIBUTING.md.
  • Simplify module dependency snippets in msmp, player, rcon, and server-status READMEs by removing the explicit $version placeholder from coordinates.
  • Clarify MSMP README examples by rephrasing client.await comments and explaining event subscription behavior across reconnections.
README.md
mcutils-msmp/README.md
mcutils-player/README.md
mcutils-rcon/README.md
mcutils-server-status/README.md
Streamline and clarify contributing guidelines.
  • Rewrite CONTRIBUTING.md pull request section as a numbered list describing issue discussion, branching, ABI validation flags/tasks, and PR title/target branch expectations.
  • Clarify the purpose of the Pfull-build flag (disabling full build for faster dev builds) and collapse PR guidelines into a single step for creating PRs to main with proper titles.
CONTRIBUTING.md

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

Copy link

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

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

Hey - I've found 3 issues

Prompt for AI Agents
Please address the comments from this code review:

## Individual Comments

### Comment 1
<location> `mcutils-msmp/src/commonMain/kotlin/tech/aliorpse/mcutils/internal/MsmpLifecycleManager.kt:150` </location>
<code_context>
+            if (isBrowser) {
+                header(HttpHeaders.SecWebSocketProtocol, "minecraft-v1,$token")
+            } else {
+                header(HttpHeaders.Authorization, "Authorization $token")
+            }
             timeout { connectTimeoutMillis = config.connectTimeout }
</code_context>

<issue_to_address>
**issue (bug_risk):** Non-browser branch appears to send an `Authorization` header with a non-standard value instead of `Bearer`.

This changes the non-browser path from sending `Bearer $token` to sending `Authorization $token` as the `Authorization` header value, which is non-standard and will likely break existing clients expecting a Bearer token. If you want to preserve prior behavior, this should remain `Bearer $token` (or another explicit scheme) so servers continue to accept these requests.
</issue_to_address>

### Comment 2
<location> `README.md:13-15` </location>
<code_context>
+
+* **Kotlin/JVM**
+* **Kotlin/JS, WasmJS** on
+  * nodejs
+  * browser *(except modules depends on ktor-network, see [build.gradle.kts](build.gradle.kts) for more details)*
+* **Kotlin/Native** on
+  * linuxX64 (X64/Arm64)
</code_context>

<issue_to_address>
**suggestion (typo):** Fix capitalization of "Node.js" and adjust grammar in the browser note.

Consider updating the entries to:
- `* Node.js`
- `* browsers *(except modules that depend on ktor-network, see [build.gradle.kts](build.gradle.kts) for more details)*`

```suggestion
* **Kotlin/JS, WasmJS** on
  * Node.js
  * browsers *(except modules that depend on ktor-network, see [build.gradle.kts](build.gradle.kts) for more details)*
```
</issue_to_address>

### Comment 3
<location> `CONTRIBUTING.md:11` </location>
<code_context>
+2. Fork the repository and create a new branch named like `feat/my-feature`, code in it.
+3. add `Pfull-build=true` to abi-validating related tasks, for full build is disabled to boost dev build speed.
+4. run `./gradlew checkLegacyAbi` to check your changes. If including a breaking change, run `./gradlew updateLegacyAbi`.
+5. When creating PR, use a concise, descriptive PR title with prefixes like `feat:` or `fix:`. Please pull to `main` branch.
+
+
</code_context>

<issue_to_address>
**suggestion (typo):** Adjust phrasing around PR creation and targeting the main branch.

For clearer grammar, consider: "5. When creating a PR, use a concise, descriptive PR title with prefixes like `feat:` or `fix:`. Please open the PR against the `main` branch."
</issue_to_address>

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

@Aliorpse Aliorpse self-assigned this Jan 31, 2026
@Aliorpse Aliorpse merged commit eec457a into main Jan 31, 2026
2 checks passed
@Aliorpse Aliorpse deleted the dev branch January 31, 2026 14:57
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