Skip to content
This repository was archived by the owner on Dec 10, 2025. It is now read-only.

Conversation

@TheBjoRedCraft
Copy link
Member

fixes #117

@twisti-dev twisti-dev added this pull request to the merge queue Nov 20, 2025
Merged via the queue into master with commit 2c187c7 Nov 20, 2025
5 checks passed
@github-project-automation github-project-automation bot moved this from Backlog to Done in surf-cloud Nov 20, 2025
@TheBjoRedCraft TheBjoRedCraft deleted the fix/fix-playtime-command branch November 20, 2025 18:30
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR updates the playtime command to properly handle asynchronous player retrieval by changing the player argument type from OfflineCloudPlayer? to Deferred<OfflineCloudPlayer?>, fixing issue #117. The change aligns with how the offlineCloudPlayerArgument actually returns deferred values that must be awaited in a coroutine context.

Key Changes

  • Updated player argument type to Deferred<OfflineCloudPlayer?> with proper async handling using await()
  • Added coroutine scope with plugin.launch to handle the deferred player retrieval
  • Included translation consistency fix changing "Total" to "Gesamt" to match German localization

Comment on lines +28 to +30
plugin.launch {
player.await()?.let { sendPlaytime(sender, it) }
}
Copy link

Copilot AI Nov 20, 2025

Choose a reason for hiding this comment

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

The sendPlaytime function already calls plugin.launch internally (line 35), so wrapping this call in another plugin.launch creates unnecessary nested coroutine scopes.

Consider removing the outer plugin.launch and calling sendPlaytime directly within a suspend function, similar to how LastSeenCommand handles this pattern:

anyExecutor { sender, args ->
    val player: Deferred<OfflineCloudPlayer?> by args
    
    plugin.launch {
        val awaited = player.await() ?: return@launch
        sendPlaytime(sender, awaited)
    }
}

Or refactor sendPlaytime to be a regular function that doesn't launch its own coroutine, allowing the caller to control the coroutine scope.

Copilot uses AI. Check for mistakes.
@github-actions
Copy link

Qodana for JVM

535 new problems were found

Inspection name Severity Problems
Unused symbol 🔶 Warning 426
Unresolved reference in KDoc 🔶 Warning 27
Unused import directive 🔶 Warning 27
Redundant nullable return type 🔶 Warning 6
Leaking 'this' in constructor 🔶 Warning 4
Redundant 'suspend' modifier 🔶 Warning 4
Constant conditions 🔶 Warning 3
Control flow with empty body 🔶 Warning 2
Possibly blocking call in non-blocking context 🔶 Warning 1
Incorrect formatting ◽️ Notice 16
Function or property has platform type ◽️ Notice 7
Leaking 'this' in constructor ◽️ Notice 5
@Deprecated annotation without 'replaceWith' argument ◽️ Notice 4
Condition of 'if' expression is constant ◽️ Notice 1
Convert 'object' to 'data object' ◽️ Notice 1
Redundant empty initializer block ◽️ Notice 1

☁️ View the detailed Qodana report

Contact Qodana team

Contact us at qodana-support@jetbrains.com

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

Class Cast Exeption in Playtime Command

3 participants