feat: reflection here so save the day

This commit is contained in:
aro 2023-01-21 12:38:20 +01:00
parent 4c2135ac32
commit c7154510de
4 changed files with 28 additions and 184 deletions

View file

@ -36,10 +36,6 @@
<id>spigot-repo</id>
<url>https://hub.spigotmc.org/nexus/content/groups/public/</url>
</repository>
<repository>
<id>dmulloy2-repo</id>
<url>https://repo.dmulloy2.net/repository/public/</url>
</repository>
<repository>
<id>codemc-snapshots</id>
<url>https://repo.codemc.io/repository/maven-snapshots/</url>
@ -115,12 +111,6 @@
<artifactId>yamlconfig</artifactId>
<version>1.1.1</version>
</dependency>
<!-- ProtocolLib -->
<dependency>
<groupId>com.comphenix.protocol</groupId>
<artifactId>ProtocolLib</artifactId>
<version>5.0.0-SNAPSHOT</version>
</dependency>
</dependencies>
<build>

View file

@ -6,17 +6,12 @@ import java.lang.reflect.InvocationTargetException;
public class InternalsProvider {
private static Internals internals;
private static boolean protocolLib = true;
static {
try {
final String packageName = Internals.class.getPackage().getName();
final String bukkitVersion = Bukkit.getServer().getClass().getPackage().getName().split("\\.")[3];
String fullClassName = packageName + "." + bukkitVersion;
if (protocolLib) {
System.out.println("USING PROTOCOLLIB HACK");
fullClassName += "_P";
}
internals = (Internals) Class.forName(fullClassName).getConstructors()[0].newInstance();
} catch (InvocationTargetException | ClassNotFoundException | InstantiationException | IllegalAccessException |
ClassCastException exception) {