Skip to content

Refactor to Guice dependency injection - #23

Draft
DinoMarlir with Copilot wants to merge 4 commits into
devfrom
copilot/refactor-project-with-dependency-injection
Draft

Refactor to Guice dependency injection#23
DinoMarlir with Copilot wants to merge 4 commits into
devfrom
copilot/refactor-project-with-dependency-injection

Conversation

Copilot AI commented Jan 11, 2026

Copy link
Copy Markdown

Replaces static singleton pattern with Google Guice DI framework.

Changes

Core Architecture

  • Added Guice 7.0.0 dependency to build and plugin loader
  • Created SMPClaimModule with provider methods for singleton dependencies
  • Removed companion object from SMPClaim - now uses Injector to resolve instances

Command Classes

  • Converted from Kotlin object to @Singleton class with constructor injection
  • ClaimCommand, UnclaimCommand, AccessCommand, ChunkInfoCommand now receive IDataHandler via constructor

Listeners & Config

  • Listeners receives IDataHandler and @Named("listenerConfig") Config via constructor
  • ConfigManager accepts plugin instance as constructor parameter

Before:

object ClaimCommand {
    fun register() {
        command("claim") {
            if (SMPClaim.dataHandler.addClaimedChunk(...)) {
                // ...
            }
        }
    }
}

After:

@Singleton
class ClaimCommand @Inject constructor(
    private val dataHandler: IDataHandler
) {
    fun register() {
        command("claim") {
            if (dataHandler.addClaimedChunk(...)) {
                // ...
            }
        }
    }
}

All static references eliminated. Dependencies are now explicit, testable, and follow standard DI patterns.

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.papermc.io
    • Triggering command: /usr/lib/jvm/temurin-17-jdk-amd64/bin/java /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=ALL-UNNAMED --add-opens=java.base/java.util.concurrent.atomic=ALL-UNNAMED --add-opens=java.xml/javax.xml.namespace=ALL-UNNAMED --add-opens=java.base/java.time=ALL-UNNAMED -XX:MaxMetaspaceSize=384m -XX:+HeapDumpOnOutOfMemoryError -Xms256m -Xmx512m -Dfile.encoding=UTF-8 (dns block)
    • Triggering command: /usr/lib/jvm/temurin-21-jdk-amd64/bin/java /usr/lib/jvm/temurin-21-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=ALL-UNNAMED --add-opens=java.base/java.util.concurrent.atomic=ALL-UNNAMED --add-opens=java.xml/javax.xml.namespace=ALL-UNNAMED --add-opens=java.base/java.time=ALL-UNNAMED -XX:MaxMetaspaceSize=384m -XX:+HeapDumpOnOutOfMemoryError -Xms256m -Xmx512m -Dfile.encoding=UTF-8 (dns block)

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

Original prompt

I want to refractor this project. I want to use dependency injection (e.g. Guice).


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Copilot AI and others added 3 commits January 11, 2026 14:14
Co-authored-by: DinoMarlir <72864666+DinoMarlir@users.noreply.github.com>
Co-authored-by: DinoMarlir <72864666+DinoMarlir@users.noreply.github.com>
Co-authored-by: DinoMarlir <72864666+DinoMarlir@users.noreply.github.com>
Copilot AI changed the title [WIP] Refactor project to use dependency injection with Guice Refactor to Guice dependency injection Jan 11, 2026
Copilot AI requested a review from DinoMarlir January 11, 2026 14:23
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