From fd797908848801c9aa143a58847f459a057a6c61 Mon Sep 17 00:00:00 2001 From: trainphreak Date: Mon, 24 Oct 2016 09:51:17 -0700 Subject: [PATCH 1/3] Fix padding and trim excess digits for ShortArrayTag.toString() and ByteArrayTag.toString() Fix ShortArrayTag.clone() returning the original array instead of the clone --- .../java/com/flowpowered/nbt/ByteArrayTag.java | 4 +++- .../java/com/flowpowered/nbt/ShortArrayTag.java | 17 ++++++++++++++--- 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/src/main/java/com/flowpowered/nbt/ByteArrayTag.java b/src/main/java/com/flowpowered/nbt/ByteArrayTag.java index 1c2d1bf..10bed06 100644 --- a/src/main/java/com/flowpowered/nbt/ByteArrayTag.java +++ b/src/main/java/com/flowpowered/nbt/ByteArrayTag.java @@ -55,7 +55,9 @@ public String toString() { StringBuilder hex = new StringBuilder(); for (byte b : value) { String hexDigits = Integer.toHexString(b).toUpperCase(); - if (hexDigits.length() == 1) { + if (hexDigits.length() > 2) + hexDigits = hexDigits.substring(hexDigits.length() - 2); + else if (hexDigits.length() == 1) { hex.append("0"); } hex.append(hexDigits).append(" "); diff --git a/src/main/java/com/flowpowered/nbt/ShortArrayTag.java b/src/main/java/com/flowpowered/nbt/ShortArrayTag.java index 37f32d9..3175a60 100644 --- a/src/main/java/com/flowpowered/nbt/ShortArrayTag.java +++ b/src/main/java/com/flowpowered/nbt/ShortArrayTag.java @@ -52,8 +52,19 @@ public String toString() { StringBuilder hex = new StringBuilder(); for (short s : value) { String hexDigits = Integer.toHexString(s).toUpperCase(); - if (hexDigits.length() == 1) { - hex.append("0"); + switch (hexDigits.length()) { + case 8: + case 7: + case 6: + case 5: + hexDigits = hexDigits.substring(hexDigits.length() - 4); + break; + case 1: + hex.append("0"); + case 2: + hex.append("0"); + case 3: + hex.append("0"); } hex.append(hexDigits).append(" "); } @@ -89,7 +100,7 @@ private short[] cloneArray(short[] shortArray) { int length = shortArray.length; short[] newArray = new short[length]; System.arraycopy(shortArray, 0, newArray, 0, length); - return shortArray; + return newArray; } } } From b67006075f7d1c0970429fbbfba6cdda32580d40 Mon Sep 17 00:00:00 2001 From: trainphreak Date: Wed, 21 Dec 2016 14:22:07 -0800 Subject: [PATCH 2/3] Escaped a single-quote that should have been escaped when the file was first created (not my fault) --- build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.gradle b/build.gradle index 54cac53..1e6f45d 100644 --- a/build.gradle +++ b/build.gradle @@ -17,7 +17,7 @@ version = '1.0.1-SNAPSHOT' ext.packaging = 'jar' ext.inceptionYear = '2011' ext.url = 'https://flowpowered.com/nbt' -ext.description = 'Named Binary Tag (NBT) library for Java based on Graham Edgecombe's JNBT library.' +ext.description = 'Named Binary Tag (NBT) library for Java based on Graham Edgecombe\'s JNBT library.' // Organization information ext.organization = 'Flow Powered' From 38dbba4ed27f8c790e9733ed47dccdb30947e205 Mon Sep 17 00:00:00 2001 From: trainphreak Date: Sat, 9 Dec 2017 15:44:47 -0500 Subject: [PATCH 3/3] Clarified the license file is for com.flowpowered only. --- build.gradle | 2 +- LICENSE.txt => flownbt-LICENSE.txt | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) rename LICENSE.txt => flownbt-LICENSE.txt (92%) diff --git a/build.gradle b/build.gradle index 1e6f45d..13ac464 100644 --- a/build.gradle +++ b/build.gradle @@ -64,7 +64,7 @@ dependencies { processResources { // Include in final JAR from(rootProject.rootDir) { - include 'LICENSE.txt' + include 'flownbt-LICENSE.txt' } } diff --git a/LICENSE.txt b/flownbt-LICENSE.txt similarity index 92% rename from LICENSE.txt rename to flownbt-LICENSE.txt index 1a63677..a08d8d3 100644 --- a/LICENSE.txt +++ b/flownbt-LICENSE.txt @@ -1,3 +1,5 @@ +This license document applies to the com.flowpowered package and its subpackages. + The MIT License (MIT) Permission is hereby granted, free of charge, to any person obtaining a copy of