Solved Error: package org.bukkit.craftbukkit.v1_15_R1.inventory does not exist

Discussion in 'Spigot Plugin Help' started by MMularr, Feb 20, 2020.

  1. How do you properly reference a CraftBukkit library? I tried to use a CraftBukkit library and got this:

    Error:(8,49) java: package org.bukkit.craftbukkit.v1_15_R1.inventory does not exist

    I'm using intelliJ and I went to project structure and added the craftbukkit jar to my Libraries section and add the import statement at the top of my class to reference it but it's not recognizing it when I try to compile. I'm guessing I have to reference it in my pom.xml but I'm not sure how it works. This is what I have in it now.

    <dependencies>
    <dependency>
    <groupId>org.spigotmc</groupId>
    <artifactId>spigot-api</artifactId>
    <version>1.15.2-R0.1-SNAPSHOT</version>
    <scope>provided</scope>
    </dependency>
    </dependencies>

    I'm really new and don't know what a Maven is please help.

    EDIT: WOW OK THAT TOOK A WHILE
    following method 2 from http://roufid.com/3-ways-to-add-local-jar-to-maven-project/
    I added

    <dependency>
    <groupId>org.bukkitmc</groupId>
    <artifactId>craftbukkitapi</artifactId>
    <version>1.15.2</version>
    <scope>system</scope>
    <systemPath>${basedir}/local-maven-repo/craftbukkit-1.15.2.jar</systemPath>
    </dependency>

    to my pom.xml <dependencies>
    not sure if groupId or artifactId are actually important but what was definitely important was setting the <systemPath> to the craftbukkit.jar and setting <scope> to system.

    AND NOW IT WORKS
     
    #1 MMularr, Feb 20, 2020
    Last edited: Feb 20, 2020
  2. You want to access NMS classes..? If so you don't need craftbukkit, go to project structure -> libraries -> and add the spigot server jar, the same one your server would use, that will give you access to relevant classes.
     
  3. use buildtools to build the jar, then import spigot instead of spigot-api artifactId. also anything relating to developing plugins should go in plugin development, for future reference.

    /e just read your last sentence xd
    maven is a dependency manager that aims to assist the java compiler in easily managing dependencies for large scale projects. it has many useful tools for smaller projects as well. you have the right go about it, just run buildtools to compile the spigot server locally, and then change the artifactid to spigot to import the spigot server instead of the api.

    also.. if you dont know what maven is or how to use it and youre trying to tackle NMS.. you may want to rethink what youre doing.
     
  4. thanks I did a bunch of googling and found out how to reference local dependencies in the pom.xml using its system path