Shade and repackage the adventure text library. I hate how it inflates the jar by 300kb
This commit is contained in:
		
							
								
								
									
										51
									
								
								pom.xml
									
									
									
									
									
								
							
							
						
						
									
										51
									
								
								pom.xml
									
									
									
									
									
								
							| @@ -57,6 +57,35 @@ | |||||||
|                     <mainClass>me.libraryaddict.disguise.utilities.watchers.CompileMethods</mainClass> |                     <mainClass>me.libraryaddict.disguise.utilities.watchers.CompileMethods</mainClass> | ||||||
|                 </configuration> |                 </configuration> | ||||||
|             </plugin> |             </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> | ||||||
|  |                     </execution> | ||||||
|  |                 </executions> | ||||||
|  |                 <configuration> | ||||||
|  |                     <minimizeJar>true</minimizeJar> | ||||||
|  |                     <artifactSet> | ||||||
|  |                         <includes> | ||||||
|  |                             <include>net.kyori:adventure-text-minimessage</include> | ||||||
|  |                             <include>net.kyori:adventure-text-serializer-gson</include> | ||||||
|  |                             <include>net.kyori:adventure-api</include> | ||||||
|  |                         </includes> | ||||||
|  |                     </artifactSet> | ||||||
|  |                     <relocations> | ||||||
|  |                         <relocation> | ||||||
|  |                             <pattern>net.kyori</pattern> | ||||||
|  |                             <shadedPattern>ld-shaded.net.kyori</shadedPattern> | ||||||
|  |                         </relocation> | ||||||
|  |                     </relocations> | ||||||
|  |                 </configuration> | ||||||
|  |             </plugin> | ||||||
|         </plugins> |         </plugins> | ||||||
|     </build> |     </build> | ||||||
|  |  | ||||||
| @@ -75,7 +104,9 @@ | |||||||
|         <junit.version>4.13.1</junit.version> |         <junit.version>4.13.1</junit.version> | ||||||
|         <paper-api.version>[1.16,]</paper-api.version> |         <paper-api.version>[1.16,]</paper-api.version> | ||||||
|         <bungeecord-chat.version>1.12-SNAPSHOT</bungeecord-chat.version> |         <bungeecord-chat.version>1.12-SNAPSHOT</bungeecord-chat.version> | ||||||
|         <adventure.version>4.1.0-SNAPSHOT</adventure.version> |         <adventure-minimessage.version>4.1.0-SNAPSHOT</adventure-minimessage.version> | ||||||
|  |         <adventure-api.version>4.7.0</adventure-api.version> | ||||||
|  |         <adventure-serializer.version>4.7.0</adventure-serializer.version> | ||||||
|     </properties> |     </properties> | ||||||
|  |  | ||||||
|     <dependencies> |     <dependencies> | ||||||
| @@ -133,7 +164,23 @@ | |||||||
|         <dependency> |         <dependency> | ||||||
|             <groupId>net.kyori</groupId> |             <groupId>net.kyori</groupId> | ||||||
|             <artifactId>adventure-text-minimessage</artifactId> |             <artifactId>adventure-text-minimessage</artifactId> | ||||||
|             <version>${adventure.version}</version> |             <version>${adventure-minimessage.version}</version> | ||||||
|  |             <scope>compile</scope> | ||||||
|  |             <optional>true</optional> | ||||||
|  |         </dependency> | ||||||
|  |         <dependency> | ||||||
|  |             <groupId>net.kyori</groupId> | ||||||
|  |             <artifactId>adventure-text-serializer-gson</artifactId> | ||||||
|  |             <version>${adventure-serializer.version}</version> | ||||||
|  |             <scope>compile</scope> | ||||||
|  |             <optional>true</optional> | ||||||
|  |         </dependency> | ||||||
|  |         <dependency> | ||||||
|  |             <groupId>net.kyori</groupId> | ||||||
|  |             <artifactId>adventure-api</artifactId> | ||||||
|  |             <version>${adventure-api.version}</version> | ||||||
|  |             <scope>compile</scope> | ||||||
|  |             <optional>true</optional> | ||||||
|         </dependency> |         </dependency> | ||||||
|     </dependencies> |     </dependencies> | ||||||
|  |  | ||||||
|   | |||||||
| @@ -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() { |     public static boolean hasAdventureTextSupport() { | ||||||
|         if (adventureTextSupport == null) { |         if (adventureTextSupport == null) { | ||||||
|             try { |             try { | ||||||
|   | |||||||
| @@ -10,7 +10,6 @@ import me.libraryaddict.disguise.utilities.reflection.NmsRemovedIn; | |||||||
| import me.libraryaddict.disguise.utilities.reflection.WatcherInfo; | import me.libraryaddict.disguise.utilities.reflection.WatcherInfo; | ||||||
| import me.libraryaddict.disguise.utilities.sounds.DisguiseSoundEnums; | import me.libraryaddict.disguise.utilities.sounds.DisguiseSoundEnums; | ||||||
| import me.libraryaddict.disguise.utilities.sounds.SoundGroup; | import me.libraryaddict.disguise.utilities.sounds.SoundGroup; | ||||||
| import org.apache.commons.lang.StringUtils; |  | ||||||
|  |  | ||||||
| import java.io.File; | import java.io.File; | ||||||
| import java.io.FileOutputStream; | import java.io.FileOutputStream; | ||||||
| @@ -69,7 +68,7 @@ public class CompileMethods { | |||||||
|         File soundsFile = new File("target/classes/ANTI_PIRACY_SECRET_FILE"); |         File soundsFile = new File("target/classes/ANTI_PIRACY_SECRET_FILE"); | ||||||
|  |  | ||||||
|         try (FileOutputStream fos = new FileOutputStream(soundsFile)) { |         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++) { |             for (int i = 0; i < array.length; i++) { | ||||||
|                 array[i] = (byte) (Byte.MAX_VALUE - array[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"); |         File methodsFile = new File("target/classes/ANTI_PIRACY_ENCRYPTION"); | ||||||
|  |  | ||||||
|         try (FileOutputStream fos = new FileOutputStream(methodsFile)) { |         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++) { |             for (int i = 0; i < array.length; i++) { | ||||||
|                 array[i] = (byte) (Byte.MAX_VALUE - array[i]); |                 array[i] = (byte) (Byte.MAX_VALUE - array[i]); | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user