Using NMS in Paper

Hello,

I’m using Paper to develop minecraft plugins in intellij. I’ve installed it using the intellij Minecraft plugin.
However, I cannot use any NMS stuff because the net.minecraft… package simply doesn’t exist.
This is the Maven code in the pom.xml file:

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
     xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<groupId>de.grana</groupId>
<artifactId>FirstNations</artifactId>
<version>1.0</version>
<packaging>jar</packaging>

<name>FirstNations</name>

<properties>
    <java.version>1.8</java.version>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>

<build>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>3.8.1</version>
            <configuration>
                <source>${java.version}</source>
                <target>${java.version}</target>
            </configuration>
        </plugin>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-shade-plugin</artifactId>
            <version>3.2.4</version>
            <executions>
                <execution>
                    <phase>package</phase>
                    <goals>
                        <goal>shade</goal>
                    </goals>
                    <configuration>
                        <createDependencyReducedPom>false</createDependencyReducedPom>
                    </configuration>
                </execution>
            </executions>
        </plugin>
    </plugins>
    <resources>
        <resource>
            <directory>src/main/resources</directory>
            <filtering>true</filtering>
        </resource>
    </resources>
</build>

<repositories>
    <repository>
        <id>papermc-repo</id>
        <url>https://papermc.io/repo/repository/maven-public/</url>
    </repository>
    <repository>
        <id>sonatype</id>
        <url>https://oss.sonatype.org/content/groups/public/</url>
    </repository>
</repositories>

<dependencies>
    <dependency>
        <groupId>com.destroystokyo.paper</groupId>
        <artifactId>paper-api</artifactId>
        <version>1.16.4-R0.1-SNAPSHOT</version>
        <scope>provided</scope>
    </dependency>
</dependencies>

What is the best way to add support for NMS?

Well that is because you are only including the api as a dependency. (Hence the paper-api in your dependencies).

Since the server code cannot be hosted online, you have to clone the repository from github and run ./paper install to install the nms code into your local m2 repository. Then remove the -api part of the dependencies and remove the repository from pom.xml and re-import your maven project.

1 Like

Thank you for your answer! How does this work on a Windows computer? I have successfully executed ./paper install in the Linux subsystem, but it’s not installed in my local Windows m2 repository. How would that work?

With 1.16.4 you can use this command:
java -Dpaperclip.install=true -jar paperclip.jar

Where do I run that command? Where is the paperclip.jar?

It’s just the normal download from https://papermc.io/downloads

Thanks for your help, but I’m just getting errors after errors. It did get imported into my local m2 repository, but now there are problems with the dependencies in intellij.

Just use the scripts, ./paper p and then mvn clean install, the paperclip install stuff only works once you’ve installed the stuff locally for the current version

The command mvn clean install doesn’t work. I’m getting that error:

Did you run “./paper patch” first?

Yep, I’ve tried ./paper patch, ./paper p and ./paper install. All of those finished without any errors.

EDIT: I ran these commands in linux, then I copied the new Paper folder into windows to run that mvn command.

that’s why you’re getting the error, the scripts install stuff like the minecraft-server jar that it’s complaining about

Where are the scripts installing those things into? I’m moving the whole Paper folder from Linux to Windows, so if it gets installed into that folder, shouldn’t it be fine?

the minecraft-server jar is installed to the local maven repo

Ahh okay. Well I also ran java -Dpaperclip.install=true -jar paperclip.jar which worked just fine, so it should be in my local maven repo by now, right? So how do I make it work in intellij? Changing spigot-api to spigot and removing the repository gives me a bunch of weird errors, for example this: https://papermc.io/forums/uploads/default/original/2X/3/3034307b56bb4f507eee65e0936ba69a96d36f2f.png

<dependency>
<groupId>com.destroystokyo.paper</groupId>
<artifactId>paper</artifactId>
<version>1.16.4-R0.1-SNAPSHOT</version>
<scope>provided</scope>

When I run that command, it fails with Error: Could not find or load main class .install=true

-D"…"=true or something, pretty sure some OS was misparsing that flag

Sounds like you wrongly copied/pasted it, probably added space after paperclip and before .install=true.

Double check your command or try: java "-Dpaperclip.install=true" -jar paperclip.jar