Autocompletion

1

Step 1

Create a new file in your namespace folder called build.gradle.kts. For example ItemsAdder/contents/test/build.gradle.kts.

You can add repositories and dependencies, but they must be available on the server, otherwise they won't work!

In this case I added Paper and ItemsAdder as dependencies of my script, to get the autocompletion working.

plugins {
    java
}

sourceSets {
    main {
        java {
            setSrcDirs(listOf("."))
        }
    }
}

repositories {
    mavenCentral()
    maven("https://repo.papermc.io/repository/maven-public/")
    maven("https://maven.devs.beer/")
}

dependencies {
    compileOnly("io.papermc.paper:paper-api:1.20.1-R0.1-SNAPSHOT")
    compileOnly("dev.lone:api-itemsadder:4.0.10")
}
2

Step 2

Make sure to install VSCode. Install also the Gradle for Java extension.

3

Step 3

Change your server launch arguments and add -Xdebug -Xnoagent -Djava.compiler=NONE -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=55213.

Change the port 55213 to a new unused port debug port, which is different from the server port.

Example: java -Xdebug -Xnoagent -Djava.compiler=NONE -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=55213 -jar server.jar nogui.

4

Step 4

Create a new file .vscode\launch.json (do not forget the dot at the very start!).

Change the port 55213 to your own debug port, which is different from the server port.

{
  "version": "0.2.0",
  "configurations": [
    {
      "type": "java",
      "name": "Attach to Minecraft Server",
      "request": "attach",
      "hostName": "localhost",
      "port": 55213
    }
  ]
}
5

Step 5

Create a new file .vscode\settings.json (do not forget the dot at the very start!).

{
  "java.autobuild.enabled": false
}

Last updated

Was this helpful?