feat: reflection here so save the day
This commit is contained in:
parent
4c2135ac32
commit
c7154510de
4 changed files with 28 additions and 184 deletions
|
@ -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) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue