Search code examples
javaspigot

Why can't i import NMS in Spigot?


import net.minecraft.server;

gives me the error:

Cannot resolve symbol 'minecraft'

How do i fix this? The version of spigot api i am using is

spigot-api-1.14.4-R0.1-20191205.000449-89-shaded.jar

When i tried to import net.minecraft.server, it couldnt find it. Do i have a dependency issue?


Solution

  • Spigot does not include NMS with its maven packages. The legal way to do what you are after is to download BuildTools and run it via:

    java -jar BuildTools.jar --rev 1.14.4
    

    This command will not only build Spigot but also install the resulting artifacts to your local maven repository. Then, you can include your dependency as follows:

    <dependency>
      <groupId>org.spigotmc</groupId>
      <artifactId>spigot-server</artifactId>
      <version>1.14.4-R0.1</version>
    </dependency>
    

    Note that you have to change spigot-api to spigot-server which is the artifact that also includes NMS.