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

@ -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) {