1.17.1 NBTAPI Shading Help!

Discussion in 'Spigot Plugin Development' started by Lollypoplove08, Nov 25, 2021.

  1. I am trying to make a plugin using NBTapi but I cant work out how to shade it in the pom.xml so the server owner doesnt need to add NBTapi plugin manually. Any help on getting this to work would be appriciated! :)
     
  2. this is my pom.xml atm:

    Code (Text):
    <?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>com.santapexie.santa_conwand</groupId>
        <artifactId>Condenser_Wand</artifactId>
        <version>0.1</version>
        <packaging>jar</packaging>

        <name>Condenser_Wand</name>

        <description>Adds a wand that condeses items in chests and your inventory!</description>
        <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-shade-plugin</artifactId>
                    <version>3.2.1</version>
                    <executions>
                        <execution>
                            <id>shade</id>
                            <phase>package</phase>
                            <goals>
                                <goal>shade</goal>
                            </goals>
                        </execution>
                    </executions>
                    <configuration>
                        <relocations>
                            <relocation>
                                <pattern>de.tr7zw.changeme.nbtapi</pattern>
                                <shadedPattern>com.santapexie.santa_conwand.nbtapi</shadedPattern>
                            </relocation>
                        </relocations>
                    </configuration>
                </plugin>
                <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>
                                <outputFile>D:\Documents\Coding\Plugins\Testing Server\plugins\CondenserWand-${project.version}.jar</outputFile>
                            </configuration>
                        </execution>
                    </executions>
                </plugin>
            </plugins>

            <resources>
                <resource>
                    <directory>src/main/resources</directory>
                    <filtering>true</filtering>
                </resource>
            </resources>
        </build>

        <repositories>
            <repository>
                <id>spigotmc-repo</id>
                <url>https://hub.spigotmc.org/nexus/content/repositories/snapshots/</url>
            </repository>
            <repository>
                <id>sonatype</id>
                <url>https://oss.sonatype.org/content/groups/public/</url>
            </repository>
        </repositories>

        <dependencies>
            <dependency>
                <groupId>org.spigotmc</groupId>
                <artifactId>spigot-api</artifactId>
                <version>1.17.1-R0.1-SNAPSHOT</version>
                <scope>provided</scope>
            </dependency>
            <dependency>
                <groupId>com.santapexie.santa_conwand</groupId>
                <artifactId>item-nbt-api</artifactId>
                <version>2.6.0</version>
                <scope>compile</scope>
            </dependency>
        </dependencies>
    </project>
     
     
  3. What is wrong with that file? i get this error:
    Cannot resolve com.santapexie.santa_conwand:item-nbt-api:2.6.0
     
  4. I have done that and (i posted my pom.xml above) I get this error now even tho it looks fine. Do i need to put the NBTapi jar in a folder or smth. Thanks!

     
  5. First of all, you have the shade plugin twice.
    If Maven cannot resolve an artifact it means that it is neither in the repositories that you specified, nor in your local repository. To solve this, you have to either specify a remote repository in which the artifact can be found, or install the artifact into your local repository. I assume you'd do the latter, since the dependency is something that you created.