Skip to content

Conversation

Copy link

Copilot AI commented Nov 2, 2025

Addresses performance feedback on #13: the settings API availability check was being called inside a coroutine for every online player, causing redundant checks and unnecessary coroutine launches.

Changes

  • Move plugin.hasSettingsApi() check outside the forEachPlayer loop
  • Cache result in hasSettingsApi variable to use across all player iterations

Before

forEachPlayer {
    plugin.launch {
        if (plugin.hasSettingsApi()) {  // Called N times
            if (settingsService.hasSoundsEnabled(it.uniqueId)) {
                it.playSound(...)
            }
        }
    }
}

After

val hasSettingsApi = plugin.hasSettingsApi()  // Called once

forEachPlayer {
    plugin.launch {
        if (hasSettingsApi) {
            if (settingsService.hasSoundsEnabled(it.uniqueId)) {
                it.playSound(...)
            }
        }
    }
}

Reduces check from O(N) to O(1) where N is the number of online players.


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

…tter performance

Co-authored-by: TheBjoRedCraft <143264463+TheBjoRedCraft@users.noreply.github.com>
Copy link
Author

Copilot AI commented Nov 2, 2025

Just as a heads up, I was blocked by some firewall rules while working on your feedback. Expand below for details.

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • repo.slne.dev
    • Triggering command: /usr/lib/jvm/temurin-17-jdk-amd64/bin/java --add-opens=java.base/java.lang=ALL-UNNAMED --add-opens=java.base/java.lang.invoke=ALL-UNNAMED --add-opens=java.base/java.util=ALL-UNNAMED --add-opens=java.prefs/java.util.prefs=ALL-UNNAMED --add-exports=jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED --add-exports=jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED --add-opens=java.base/java.util=ALL-UNNAMED --add-opens=java.prefs/java.util.prefs=ALL-UNNAMED --add-opens=java.base/java.nio.charset=ALL-UNNAMED --add-opens=java.base/java.net=ALL-UNNAMED --add-opens=java.base/java.util.concurrent.atomic=ALL-UNNAMED --add-opens=java.xml/javax.xml.namespace=ALL-UNNAMED -XX:MaxMetaspaceSize=384m -XX:&#43;HeapDumpOnOutOfMemoryError -Xms256m -Xmx512m -Dfile.encoding=UTF-8 -Duser.country -Duser.language=en -Duser.variant -cp /home/REDACTED/.gradle/wrapper/dists/gradle-8.14.3-bin/cv11ve7ro1n3o1j4so8xd9n66/gradle-8.14.3/lib/gradle-daemon-main-8.14.3.jar -javaagent:/home/REDACTED/.gradle/wrapper/dists/gradle-8.14.3-bin/cv11ve7ro1n3o1j4so8xd9n66/gradle-8.14.3/lib/agents/gradle-instrumentation-agent-8.14.3.jar org.gradle.launcher.daemon.bootstrap.GradleDaemon 8.14.3 (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

Copilot AI changed the title [WIP] Update surf settings feature implementation based on feedback Optimize settings API check in SpecialItemListener to avoid redundant calls Nov 2, 2025
Copilot AI requested a review from TheBjoRedCraft November 2, 2025 01:31
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.

2 participants