From 381ab971b6ce7f8026b2ef5b635908f0d5e02181 Mon Sep 17 00:00:00 2001 From: libraryaddict Date: Mon, 14 Jun 2021 12:05:58 +1200 Subject: [PATCH] Shade and repackage the adventure text library. I hate how it inflates the jar by 300kb --- pom.xml | 51 ++++++++++++++++++- .../disguise/utilities/DisguiseUtilities.java | 5 ++ .../utilities/watchers/CompileMethods.java | 5 +- 3 files changed, 56 insertions(+), 5 deletions(-) diff --git a/pom.xml b/pom.xml index b17f87c8..5d6700f3 100644 --- a/pom.xml +++ b/pom.xml @@ -57,6 +57,35 @@ me.libraryaddict.disguise.utilities.watchers.CompileMethods + + org.apache.maven.plugins + maven-shade-plugin + 3.2.4 + + + package + + shade + + + + + true + + + net.kyori:adventure-text-minimessage + net.kyori:adventure-text-serializer-gson + net.kyori:adventure-api + + + + + net.kyori + ld-shaded.net.kyori + + + + @@ -75,7 +104,9 @@ 4.13.1 [1.16,] 1.12-SNAPSHOT - 4.1.0-SNAPSHOT + 4.1.0-SNAPSHOT + 4.7.0 + 4.7.0 @@ -133,7 +164,23 @@ net.kyori adventure-text-minimessage - ${adventure.version} + ${adventure-minimessage.version} + compile + true + + + net.kyori + adventure-text-serializer-gson + ${adventure-serializer.version} + compile + true + + + net.kyori + adventure-api + ${adventure-api.version} + compile + true diff --git a/src/main/java/me/libraryaddict/disguise/utilities/DisguiseUtilities.java b/src/main/java/me/libraryaddict/disguise/utilities/DisguiseUtilities.java index b35d1ee5..b160a8b9 100644 --- a/src/main/java/me/libraryaddict/disguise/utilities/DisguiseUtilities.java +++ b/src/main/java/me/libraryaddict/disguise/utilities/DisguiseUtilities.java @@ -219,6 +219,11 @@ public class DisguiseUtilities { } } + /** + * This should return true every single time, except for when ProtocolLib isn't updated for AdventureComponentConverter + * + * The reason being is that we shade the adventure text library in the plugin + */ public static boolean hasAdventureTextSupport() { if (adventureTextSupport == null) { try { diff --git a/src/main/java/me/libraryaddict/disguise/utilities/watchers/CompileMethods.java b/src/main/java/me/libraryaddict/disguise/utilities/watchers/CompileMethods.java index 325ee62e..2e7d285d 100644 --- a/src/main/java/me/libraryaddict/disguise/utilities/watchers/CompileMethods.java +++ b/src/main/java/me/libraryaddict/disguise/utilities/watchers/CompileMethods.java @@ -10,7 +10,6 @@ import me.libraryaddict.disguise.utilities.reflection.NmsRemovedIn; import me.libraryaddict.disguise.utilities.reflection.WatcherInfo; import me.libraryaddict.disguise.utilities.sounds.DisguiseSoundEnums; import me.libraryaddict.disguise.utilities.sounds.SoundGroup; -import org.apache.commons.lang.StringUtils; import java.io.File; import java.io.FileOutputStream; @@ -69,7 +68,7 @@ public class CompileMethods { File soundsFile = new File("target/classes/ANTI_PIRACY_SECRET_FILE"); try (FileOutputStream fos = new FileOutputStream(soundsFile)) { - byte[] array = StringUtils.join(list, "\n").getBytes(StandardCharsets.UTF_8); + byte[] array = String.join("\n", list).getBytes(StandardCharsets.UTF_8); for (int i = 0; i < array.length; i++) { array[i] = (byte) (Byte.MAX_VALUE - array[i]); @@ -160,7 +159,7 @@ public class CompileMethods { File methodsFile = new File("target/classes/ANTI_PIRACY_ENCRYPTION"); try (FileOutputStream fos = new FileOutputStream(methodsFile)) { - byte[] array = StringUtils.join(methods, "\n").getBytes(StandardCharsets.UTF_8); + byte[] array = String.join("\n", methods).getBytes(StandardCharsets.UTF_8); for (int i = 0; i < array.length; i++) { array[i] = (byte) (Byte.MAX_VALUE - array[i]);