NBT-API

NBT-API

98.9k Downloads

Encoding itemstack error [NullPointerException]

JoaoGabrielCostaa opened this issue ยท 9 comments

commented

Hi, i'm trying to encode a itemstack to string with your api but its causing error:

Error (Pastebin): https://pastebin.com/rWiF3H7V

My code (Pastebin): https://pastebin.com/NPMEdkVN

I'm using the latest version of maven and realocation:

My pom.xml:

`

<modelVersion>4.0.0</modelVersion>
<groupId>com.atlasplugins.atlasshop</groupId>
<artifactId>AtlasShopV2</artifactId>
<version>0.0.1-SNAPSHOT</version>


<repositories>
	<repository>
		<id>spigotmc-repo</id>
		<url>https://hub.spigotmc.org/nexus/content/repositories/snapshots/</url>
	</repository>
	<repository>
		<id>mojang</id>
		<name>Mojang's Repository</name>
		<url>https://libraries.minecraft.net/</url>
	</repository>
	<repository>
		<id>jitpack.io</id>
		<url>https://jitpack.io</url>
	</repository>
	<repository>
		<id>jcenter</id>
		<name>jcenter-bintray</name>
		<url>https://jcenter.bintray.com</url>
	</repository>
	<repository>
		<id>codemc-repo</id>
		<url>https://repo.codemc.io/repository/maven-public/</url>
	</repository>
	<repository>
		<id>dmulloy2-repo</id>
		<url>https://repo.dmulloy2.net/nexus/repository/public/</url>
	</repository>
	<repository>
		<id>everything</id>
		<url>http://repo.citizensnpcs.co/</url>
	</repository>
</repositories>

<properties>
	<maven.compiler.source>1.8</maven.compiler.source>
	<maven.compiler.target>1.8</maven.compiler.target>
</properties>

<dependencies>

	<dependency>
		<groupId>net.citizensnpcs</groupId>
		<artifactId>citizensapi</artifactId>
		<version>2.0.18-SNAPSHOT</version>
		<type>jar</type>
		<scope>provided</scope>
	</dependency>

	<dependency>
		<groupId>de.tr7zw</groupId>
		<artifactId>item-nbt-api-plugin</artifactId>
		<version>2.7.1</version>
	</dependency>

	<dependency>
		<groupId>xyz.xenondevs</groupId>
		<artifactId>particle</artifactId>
		<version>1.5.1</version>
	</dependency>

	<dependency>
		<groupId>com.github.cryptomorin</groupId>
		<artifactId>XSeries</artifactId>
		<version>7.5.4</version>
	</dependency>

	<dependency>
		<groupId>AtlasLicense</groupId>
		<artifactId>AtlasLicense</artifactId>
		<version>1.8.8-R0.1</version>
		<scope>system</scope>
		<systemPath>E:/dependencies/AtlasLicense.jar</systemPath>
	</dependency>

	<dependency>
		<groupId>PlayerPoints</groupId>
		<artifactId>PlayerPoints</artifactId>
		<version>1.0.0</version>
		<scope>system</scope>
		<systemPath>E:/dependencies/PlayerPoints.jar</systemPath>
	</dependency>

	<dependency>
		<groupId>mCore</groupId>
		<artifactId>mCore</artifactId>
		<version>1.0.0</version>
		<scope>system</scope>
		<systemPath>E:/dependencies/mCore.jar</systemPath>
	</dependency>

	<dependency>
		<groupId>org.projectlombok</groupId>
		<artifactId>lombok</artifactId>
		<version>1.18.16</version>
		<scope>provided</scope>
	</dependency>

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

	<dependency>
		<groupId>com.zaxxer</groupId>
		<artifactId>HikariCP-java9ea</artifactId>
		<version>2.6.1</version>
		<scope>compile</scope>
	</dependency>

	<dependency>
		<groupId>org.slf4j</groupId>
		<artifactId>slf4j-simple</artifactId>
		<version>1.7.26</version>
		<scope>compile</scope>
	</dependency>

	<dependency>
		<groupId>com.github.MilkBowl</groupId>
		<artifactId>VaultAPI</artifactId>
		<version>1.7</version>
		<scope>provided</scope>
	</dependency>

	<dependency>
		<groupId>com.mojang</groupId>
		<artifactId>authlib</artifactId>
		<version>1.5.21</version>
		<scope>provided</scope>
	</dependency>

</dependencies>
<distributionManagement>
	<repository>
		<id>sinndev-repo</id>
		<name>Releases</name>
		<url>http://repo.sinndev.com/content/repositories/releases/</url>
	</repository>
	<snapshotRepository>
		<id>sinndev-repo</id>
		<name>Snapshots</name>
		<url>http://repo.sinndev.com/content/repositories/snapshots/</url>
	</snapshotRepository>
</distributionManagement>
<build>
	<plugins>
		<plugin>
			<groupId>org.apache.maven.plugins</groupId>
			<artifactId>maven-shade-plugin</artifactId>
			<version>3.2.1</version>
			<configuration>
				<annotationProcessorPaths>
					<path>
						<groupId>org.projectlombok</groupId>
						<artifactId>lombok</artifactId>
						<version>1.18.16</version>
					</path>
				</annotationProcessorPaths>
				<relocations>
					<relocation>
						<pattern>de.tr7zw</pattern>
						<shadedPattern>com.atlasplugins.atlasshop.de.tr7zw</shadedPattern>
					</relocation>
					<relocation>
						<pattern>com.cryptomorin.xseries</pattern>
						<shadedPattern>com.atlasplugins.atlasshop.com.cryptomorin.xseries</shadedPattern>
					</relocation>
					<relocation>
						<pattern>xyz.upperlevel.spigot.book</pattern>
						<shadedPattern>com.atlasplugins.atlasshop.xyz.upperlevel.spigot.book</shadedPattern>
					</relocation>
				</relocations>
				<outputFile>C:\Users\Gabriel\Desktop\ed5c71e40522b1faa204e242c6d984ed.jar</outputFile>
			</configuration>
			<executions>
				<execution>
					<phase>package</phase>
					<goals>
						<goal>shade</goal>
					</goals>
				</execution>
			</executions>
		</plugin>
	</plugins>
</build>

`

commented

com.atlasplugins.atlasshop.de.tr7zw.nbtapi.utils.MinecraftVersion.init(MinecraftVersion.java:114)

if (!disablePackageWarning && MinecraftVersion.class.getPackage().getName().equals(defaultPackage)) {
you shouldn't be able to get a NPE there?
What kind of server are you running (Version and Fork)? Also make sure you use version 2.7.1

commented

com.atlasplugins.atlasshop.de.tr7zw.nbtapi.utils.MinecraftVersion.init(MinecraftVersion.java:114)

if (!disablePackageWarning && MinecraftVersion.class.getPackage().getName().equals(defaultPackage)) {

you shouldn't be able to get a NPE there?
What kind of server are you running (Version and Fork)? Also make sure you use version 2.7.1

I'm using 2.7.1

<dependency> <groupId>de.tr7zw</groupId> <artifactId>item-nbt-api-plugin</artifactId> <version>2.7.1</version> </dependency>

commented

And what kind of server are you running? Apparently 1.8.8, but what kind of Fork?

commented

And what kind of server are you running? Apparently 1.8.8, but what kind of Fork?

This server is running CraftBukkit version git-Spigot-79a30d7-acbc348 (MC: 1.12.2) (Implementing API version 1.12.2-R0.1-SNAPSHOT)

commented

Also do not shade the plugin! https://github.com/tr7zw/Item-NBT-API/wiki/Using-Maven item-nbt-api-plugin vs item-nbt-api!

commented

Also do not shade the plugin! https://github.com/tr7zw/Item-NBT-API/wiki/Using-Maven item-nbt-api-plugin vs item-nbt-api!

But also if i shade only item-nbt-api the server owner needs to install the Item-NBT-API.jar in plugins folder, no?

commented

Also do not shade the plugin! https://github.com/tr7zw/Item-NBT-API/wiki/Using-Maven item-nbt-api-plugin vs item-nbt-api!

Ok, now i'm shading the ITEM-NBT-API , not ITEM-NBT-API-PLUGIN

and i'm getting the same error: https://pastebin.com/rUiKFGEK

commented

Did you get it fixed? Also no, the -plugin is a preshaded version of the api that contains other stuff like a selfcheck/plugin.yml that you don't want in your jar.

commented

yes i fixed it, my custom classloader was not loading the packages, thanks for your attention