Compare commits

...
13 Commits
Author SHA1 Message Date
tr7zw eec2c0980e tag 2.15.3 2025-10-11 17:05:48 +02:00
tr7zw 3ddf3e53dc Add 1.21.10 support 2025-10-04 20:09:20 +02:00
tr7zw 70d5ab12eb Add 1.21.9 spigot support 2025-09-30 19:25:28 +02:00
tr7zw a63e9ba8f4 Add 1.21.9 Paper support, Fix Gameprofile reading/writing 2025-09-30 19:14:54 +02:00
tr7zw d8a59d6383 Merge pull request #335 from tr7zw/dependabot/maven/org.apache.maven.plugins-maven-shade-plugin-3.6.1
Bump org.apache.maven.plugins:maven-shade-plugin from 3.6.0 to 3.6.1
2025-09-28 11:53:27 +02:00
tr7zw 943c7d23d6 Merge pull request #336 from tr7zw/dependabot/maven/org.codehaus.mojo-license-maven-plugin-2.7.0
Bump org.codehaus.mojo:license-maven-plugin from 2.6.0 to 2.7.0
2025-09-28 11:53:18 +02:00
tr7zw 6c70ce2ccc Merge pull request #337 from tr7zw/dependabot/maven/org.apache.maven.plugins-maven-compiler-plugin-3.14.1
Bump org.apache.maven.plugins:maven-compiler-plugin from 3.14.0 to 3.14.1
2025-09-28 11:53:09 +02:00
tr7zw c1b7854fbb Merge pull request #338 from tr7zw/dependabot/maven/org.apache.maven.plugins-maven-javadoc-plugin-3.12.0
Bump org.apache.maven.plugins:maven-javadoc-plugin from 3.11.3 to 3.12.0
2025-09-28 11:52:59 +02:00
tr7zw f9f1c204b6 Start 2.15.3-SNAPSHOT 2025-09-28 11:52:38 +02:00
dependabot[bot] 789f1fea96 Bump org.apache.maven.plugins:maven-javadoc-plugin from 3.11.3 to 3.12.0
Bumps [org.apache.maven.plugins:maven-javadoc-plugin](https://github.com/apache/maven-javadoc-plugin) from 3.11.3 to 3.12.0.
- [Release notes](https://github.com/apache/maven-javadoc-plugin/releases)
- [Commits](https://github.com/apache/maven-javadoc-plugin/compare/maven-javadoc-plugin-3.11.3...maven-javadoc-plugin-3.12.0)

---
updated-dependencies:
- dependency-name: org.apache.maven.plugins:maven-javadoc-plugin
  dependency-version: 3.12.0
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-09-22 23:02:47 +00:00
dependabot[bot] 0e40144f09 Bump org.apache.maven.plugins:maven-compiler-plugin
Bumps [org.apache.maven.plugins:maven-compiler-plugin](https://github.com/apache/maven-compiler-plugin) from 3.14.0 to 3.14.1.
- [Release notes](https://github.com/apache/maven-compiler-plugin/releases)
- [Commits](https://github.com/apache/maven-compiler-plugin/compare/maven-compiler-plugin-3.14.0...maven-compiler-plugin-3.14.1)

---
updated-dependencies:
- dependency-name: org.apache.maven.plugins:maven-compiler-plugin
  dependency-version: 3.14.1
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-09-22 23:02:10 +00:00
dependabot[bot] 1c6315e014 Bump org.codehaus.mojo:license-maven-plugin from 2.6.0 to 2.7.0
Bumps [org.codehaus.mojo:license-maven-plugin](https://github.com/mojohaus/license-maven-plugin) from 2.6.0 to 2.7.0.
- [Release notes](https://github.com/mojohaus/license-maven-plugin/releases)
- [Commits](https://github.com/mojohaus/license-maven-plugin/compare/2.6.0...2.7.0)

---
updated-dependencies:
- dependency-name: org.codehaus.mojo:license-maven-plugin
  dependency-version: 2.7.0
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-09-22 23:02:05 +00:00
dependabot[bot] 91f345adf2 Bump org.apache.maven.plugins:maven-shade-plugin from 3.6.0 to 3.6.1
Bumps [org.apache.maven.plugins:maven-shade-plugin](https://github.com/apache/maven-shade-plugin) from 3.6.0 to 3.6.1.
- [Release notes](https://github.com/apache/maven-shade-plugin/releases)
- [Commits](https://github.com/apache/maven-shade-plugin/compare/maven-shade-plugin-3.6.0...v3.6.1)

---
updated-dependencies:
- dependency-name: org.apache.maven.plugins:maven-shade-plugin
  dependency-version: 3.6.1
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-09-15 23:09:04 +00:00
13 changed files with 194 additions and 37 deletions

No files matched your search

+2 -2
View File
@@ -5,7 +5,7 @@
<parent>
<groupId>de.tr7zw</groupId>
<artifactId>item-nbt-parent</artifactId>
<version>2.15.2</version>
<version>2.15.3</version>
</parent>
<artifactId>item-nbt-api</artifactId>
@@ -38,7 +38,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>3.6.0</version>
<version>3.6.1</version>
<configuration>
<relocations>
<relocation>
@@ -31,6 +31,7 @@ public class DataFixerUtil {
public static final int VERSION1_21R3 = 4189;
public static final int VERSION1_21R4 = 4323;
public static final int VERSION1_21R5 = 4435;
public static final int VERSION1_21R6 = 4554;
// There was a mixup between version numbers and revisions, kept for compatibility, use the above revision numbers
@Deprecated
public static final int VERSION1_12_2 = 1343;
@@ -92,7 +93,9 @@ public class DataFixerUtil {
* @return
*/
public static int getCurrentVersion() {
if (MinecraftVersion.isAtLeastVersion(MinecraftVersion.MC1_21_R5)) {
if (MinecraftVersion.isAtLeastVersion(MinecraftVersion.MC1_21_R6)) {
return VERSION1_21R6;
}else if (MinecraftVersion.isAtLeastVersion(MinecraftVersion.MC1_21_R5)) {
return VERSION1_21R5;
} else if (MinecraftVersion.isAtLeastVersion(MinecraftVersion.MC1_21_R4)) {
return VERSION1_21R4;
@@ -1,12 +1,16 @@
package de.tr7zw.changeme.nbtapi.utils;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.UUID;
import javax.annotation.Nullable;
import com.mojang.authlib.GameProfile;
import com.mojang.authlib.properties.PropertyMap;
import de.tr7zw.changeme.nbtapi.NBTType;
import de.tr7zw.changeme.nbtapi.NbtApiException;
import de.tr7zw.changeme.nbtapi.iface.ReadWriteNBT;
import de.tr7zw.changeme.nbtapi.iface.ReadWriteNBTCompoundList;
import de.tr7zw.changeme.nbtapi.iface.ReadableNBT;
@@ -14,15 +18,42 @@ import de.tr7zw.changeme.nbtapi.iface.ReadableNBTList;
public class GameprofileUtil {
private static Method GET_NAME = null;
private static Method GET_ID = null;
private static Method GET_VALUE = null;
private static Method GET_SIGNATURE = null;
private static Method GET_PROPERTY_NAME = null;
private static Method GET_PROPERTIES = null;
static {
if(MinecraftVersion.isAtLeastVersion(MinecraftVersion.MC1_21_R6)) {
try {
GET_NAME = GameProfile.class.getDeclaredMethod("name");
GET_ID = GameProfile.class.getDeclaredMethod("id");
GET_VALUE = com.mojang.authlib.properties.Property.class.getDeclaredMethod("value");
GET_SIGNATURE = com.mojang.authlib.properties.Property.class.getDeclaredMethod("signature");
GET_PROPERTY_NAME = com.mojang.authlib.properties.Property.class.getDeclaredMethod("name");
GET_PROPERTIES = GameProfile.class.getDeclaredMethod("properties");
} catch (NoSuchMethodException e) {
e.printStackTrace();
}
}
}
@Nullable
public static GameProfile readGameProfile(ReadableNBT arg) {
String string = null;
UUID uUID = null;
if (arg.hasTag("Name") && arg.getType("Name") == NBTType.NBTTagString) {
string = arg.getString("Name");
} else if (arg.hasTag("name") && arg.getType("name") == NBTType.NBTTagString) {
string = arg.getString("name");
}
if (arg.hasTag("Id") && arg.getType("Id") == NBTType.NBTTagIntArray && arg.getIntArray("Id").length == 4) {
uUID = arg.getUUID("Id");
} else if (arg.hasTag("id") && arg.getType("id") == NBTType.NBTTagIntArray
&& arg.getIntArray("id").length == 4) {
uUID = arg.getUUID("id");
}
try {
GameProfile gameProfile = new GameProfile(uUID, string);
@@ -43,6 +74,21 @@ public class GameprofileUtil {
}
}
}
} else if (arg.getType("properties") == NBTType.NBTTagList) { // 1.20.5+
ReadableNBTList<ReadWriteNBT> listTag = arg.getCompoundList("properties");
for (int i = 0; i < listTag.size(); ++i) {
ReadableNBT compoundTag2 = listTag.get(i);
String string2 = compoundTag2.getString("name");
String string3 = compoundTag2.getString("value");
if (compoundTag2.hasTag("signature")
&& compoundTag2.getType("signature") == NBTType.NBTTagString) {
gameProfile.getProperties().put(string2, new com.mojang.authlib.properties.Property(string2,
string3, compoundTag2.getString("signature")));
} else {
gameProfile.getProperties().put(string2,
new com.mojang.authlib.properties.Property(string2, string3));
}
}
}
return gameProfile;
} catch (Throwable var11) {
@@ -51,26 +97,115 @@ public class GameprofileUtil {
}
public static ReadWriteNBT writeGameProfile(ReadWriteNBT arg, GameProfile gameProfile) {
if (!(gameProfile.getName() == null || gameProfile.getName().isEmpty())) {
arg.setString("Name", gameProfile.getName());
String name = getName(gameProfile);
if (!(name == null || name.isEmpty())) {
String nameKey = MinecraftVersion.isAtLeastVersion(MinecraftVersion.MC1_20_R4) ? "name" : "Name";
arg.setString(nameKey, getName(gameProfile));
}
if (gameProfile.getId() != null) {
arg.setUUID("Id", gameProfile.getId());
UUID id = getId(gameProfile);
if (id != null) {
String idKey = MinecraftVersion.isAtLeastVersion(MinecraftVersion.MC1_20_R4) ? "id" : "Id";
arg.setUUID(idKey, id);
}
if (!gameProfile.getProperties().isEmpty()) {
ReadWriteNBT compoundTag = arg.getOrCreateCompound("Properties");
for (String string : gameProfile.getProperties().keySet()) {
ReadWriteNBTCompoundList list = compoundTag.getCompoundList(string);
for (com.mojang.authlib.properties.Property property : gameProfile.getProperties().get(string)) {
ReadWriteNBT tag = list.addCompound();
tag.setString("Value", property.getValue());
if (property.hasSignature()) {
tag.setString("Signature", property.getSignature());
PropertyMap properties = getProperties(gameProfile);
if (!properties.isEmpty()) {
if(MinecraftVersion.isAtLeastVersion(MinecraftVersion.MC1_20_R4)) {
ReadWriteNBTCompoundList list = arg.getCompoundList("properties");
for (com.mojang.authlib.properties.Property property : properties.values()) {
ReadWriteNBT tag = list.addCompound();
tag.setString("name", getPropertyName(property));
tag.setString("value", getValue(property));
if (property.hasSignature()) {
tag.setString("signature", getSignature(property));
}
}
} else {
ReadWriteNBT compoundTag = arg.getOrCreateCompound("Properties");
for (String string : gameProfile.getProperties().keySet()) {
ReadWriteNBTCompoundList list = compoundTag.getCompoundList(string);
for (com.mojang.authlib.properties.Property property : properties.get(string)) {
ReadWriteNBT tag = list.addCompound();
tag.setString("Value", getValue(property));
if (property.hasSignature()) {
tag.setString("Signature", getSignature(property));
}
}
}
}
}
return arg;
}
private static String getName(GameProfile profile) {
if(MinecraftVersion.isAtLeastVersion(MinecraftVersion.MC1_21_R6)) {
try {
return GET_NAME.invoke(profile).toString();
} catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException e) {
throw new NbtApiException("Failed to get GameProfile name via reflection", e);
}
} else {
return profile.getName();
}
}
private static UUID getId(GameProfile profile) {
if(MinecraftVersion.isAtLeastVersion(MinecraftVersion.MC1_21_R6)) {
try {
return (UUID) GET_ID.invoke(profile);
} catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException e) {
throw new NbtApiException("Failed to get GameProfile id via reflection", e);
}
} else {
return profile.getId();
}
}
private static String getValue(com.mojang.authlib.properties.Property property) {
if(MinecraftVersion.isAtLeastVersion(MinecraftVersion.MC1_21_R6)) {
try {
return GET_VALUE.invoke(property).toString();
} catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException e) {
throw new NbtApiException("Failed to get Property value via reflection", e);
}
} else {
return property.getValue();
}
}
private static String getSignature(com.mojang.authlib.properties.Property property) {
if(MinecraftVersion.isAtLeastVersion(MinecraftVersion.MC1_21_R6)) {
try {
return GET_SIGNATURE.invoke(property).toString();
} catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException e) {
throw new NbtApiException("Failed to get Property signature via reflection", e);
}
} else {
return property.getSignature();
}
}
private static String getPropertyName(com.mojang.authlib.properties.Property property) {
if(MinecraftVersion.isAtLeastVersion(MinecraftVersion.MC1_21_R6)) {
try {
return GET_PROPERTY_NAME.invoke(property).toString();
} catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException e) {
throw new NbtApiException("Failed to get Property name via reflection", e);
}
} else {
return property.getName();
}
}
private static PropertyMap getProperties(GameProfile profile) {
if(MinecraftVersion.isAtLeastVersion(MinecraftVersion.MC1_21_R6)) {
try {
return (PropertyMap) GET_PROPERTIES.invoke(profile);
} catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException e) {
throw new NbtApiException("Failed to get GameProfile properties via reflection", e);
}
} else {
return profile.getProperties();
}
}
}
@@ -31,7 +31,7 @@ public enum MinecraftVersion {
MC1_16_R3(1163), MC1_17_R1(1171), MC1_18_R1(1181, true), MC1_18_R2(1182, true), MC1_19_R1(1191, true),
MC1_19_R2(1192, true), MC1_19_R3(1193, true), MC1_20_R1(1201, true), MC1_20_R2(1202, true), MC1_20_R3(1203, true),
MC1_20_R4(1204, true), MC1_21_R1(1211, true), MC1_21_R2(1212, true), MC1_21_R3(1213, true), MC1_21_R4(1214, true),
MC1_21_R5(1215, true);
MC1_21_R5(1215, true), MC1_21_R6(1216, true);
private static MinecraftVersion version;
private static Boolean hasGsonSupport;
@@ -48,7 +48,7 @@ public enum MinecraftVersion {
private static Logger logger = Logger.getLogger("NBTAPI");
// NBT-API Version
protected static final String VERSION = "2.15.2";
protected static final String VERSION = "2.15.3";
private final int versionId;
private final boolean mojangMapping;
@@ -73,6 +73,8 @@ public enum MinecraftVersion {
this.put("1.21.6", MC1_21_R5);
this.put("1.21.7", MC1_21_R5);
this.put("1.21.8", MC1_21_R5);
this.put("1.21.9", MC1_21_R6);
this.put("1.21.10", MC1_21_R6);
}
};
@@ -284,9 +284,27 @@ public class MojangToMapping {
};
@SuppressWarnings("serial")
private static Map<String, String> MC1_21R6 = new HashMap<String, String>() {
{
putAll(MC1_21R5);
put("net.minecraft.server.MinecraftServer#registryAccess()", "bg");
put("net.minecraft.world.entity.Entity#load(net.minecraft.world.level.storage.ValueInput)", "d");
put("net.minecraft.world.entity.Entity#getEncodeId()", "bW");
put("net.minecraft.world.item.component.CustomData#copyTag()", "b");
put("net.minecraft.world.level.block.entity.BlockEntity#getBlockState()", "o");
put("net.minecraft.util.datafix.fixes.References#ITEM_STACK", "v");
}
};
public static Map<String, String> getMapping() {
switch (MinecraftVersion.getVersion()) {
case MC1_21_R6:
return MC1_21R6;
case MC1_21_R5:
return MC1_21R5;
case MC1_21_R4:
+3 -3
View File
@@ -4,7 +4,7 @@
<parent>
<groupId>de.tr7zw</groupId>
<artifactId>item-nbt-parent</artifactId>
<version>2.15.2</version>
<version>2.15.3</version>
</parent>
<artifactId>item-nbt-api-plugin</artifactId>
<packaging>jar</packaging>
@@ -12,7 +12,7 @@
<dependency>
<groupId>de.tr7zw</groupId>
<artifactId>item-nbt-api</artifactId>
<version>2.15.2</version>
<version>2.15.3</version>
<scope>compile</scope>
</dependency>
<dependency>
@@ -40,7 +40,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>3.6.0</version>
<version>3.6.1</version>
<configuration>
<createDependencyReducedPom>true</createDependencyReducedPom>
<relocations>
@@ -15,9 +15,8 @@ public class GameprofileTest implements Test {
UUID uuid = UUID.randomUUID();
GameProfile profile = new GameProfile(uuid, "random");
ReadWriteNBT nbt = NBT.gameProfileToNBT(profile);
profile = null;
profile = NBT.gameProfileFromNBT(nbt);
if (profile == null || !profile.getId().equals(uuid)) {
GameProfile profile2 = NBT.gameProfileFromNBT(nbt);
if (profile == null || !profile.equals(profile2)) {
throw new NbtApiException("Error when converting a GameProfile from/to NBT!");
}
}
+2 -2
View File
@@ -4,7 +4,7 @@
<parent>
<groupId>de.tr7zw</groupId>
<artifactId>item-nbt-parent</artifactId>
<version>2.15.2</version>
<version>2.15.3</version>
</parent>
<artifactId>mappings-parser</artifactId>
<packaging>jar</packaging>
@@ -12,7 +12,7 @@
<dependency>
<groupId>de.tr7zw</groupId>
<artifactId>item-nbt-api</artifactId>
<version>2.15.2</version>
<version>2.15.3</version>
<scope>compile</scope>
</dependency>
</dependencies>
@@ -24,7 +24,7 @@ public class MappingsParser {
public static StringBuilder builder = new StringBuilder();
public static void main(String[] args) throws IOException {
File input = new File("minecraft_server.1.21.6.txt");
File input = new File("minecraft_server.1.21.9.txt");
List<String> lines = Files.readAllLines(input.toPath());
Map<String, ClassWrapper> classes = new HashMap<>();
+2 -2
View File
@@ -5,7 +5,7 @@
<parent>
<groupId>de.tr7zw</groupId>
<artifactId>item-nbt-parent</artifactId>
<version>2.15.2</version>
<version>2.15.3</version>
</parent>
<artifactId>nbt-data-api</artifactId>
@@ -14,7 +14,7 @@
<dependency>
<groupId>de.tr7zw</groupId>
<artifactId>item-nbt-api</artifactId>
<version>2.15.2</version>
<version>2.15.3</version>
<scope>compile</scope>
</dependency>
</dependencies>
+2 -2
View File
@@ -4,7 +4,7 @@
<parent>
<groupId>de.tr7zw</groupId>
<artifactId>item-nbt-parent</artifactId>
<version>2.15.2</version>
<version>2.15.3</version>
</parent>
<artifactId>nbt-injector</artifactId>
<packaging>jar</packaging>
@@ -12,7 +12,7 @@
<dependency>
<groupId>de.tr7zw</groupId>
<artifactId>item-nbt-api</artifactId>
<version>2.15.2</version>
<version>2.15.3</version>
<scope>compile</scope>
</dependency>
<dependency>
+4 -4
View File
@@ -3,7 +3,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>de.tr7zw</groupId>
<artifactId>item-nbt-parent</artifactId>
<version>2.15.2</version>
<version>2.15.3</version>
<packaging>pom</packaging>
<inceptionYear>2015</inceptionYear>
<organization>
@@ -88,7 +88,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.14.0</version>
<version>3.14.1</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
@@ -110,7 +110,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>3.11.3</version>
<version>3.12.0</version>
<configuration>
<source>8</source>
</configuration>
@@ -139,7 +139,7 @@
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>license-maven-plugin</artifactId>
<version>2.6.0</version>
<version>2.7.0</version>
<configuration>
<licenseName>mit</licenseName>
<licenseFile>LICENSE</licenseFile>
+2 -2
View File
@@ -112,7 +112,7 @@ Just use the Plugin as Maven dependency and remember to add "NBTAPI" as dependen
<dependency>
<groupId>de.tr7zw</groupId>
<artifactId>item-nbt-api-plugin</artifactId>
<version>2.15.2</version>
<version>2.15.3</version>
</dependency>
[/CODE]
[/SPOILER]
@@ -122,7 +122,7 @@ Using this method the API gets copied into your plugin. Server owners don't have
<dependency>
<groupId>de.tr7zw</groupId>
<artifactId>item-nbt-api</artifactId>
<version>2.15.2</version>
<version>2.15.3</version>
</dependency>
...
<plugins>