mirror of
https://github.com/EssentialsX/Essentials.git
synced 2024-12-22 09:08:01 +01:00
Fix server state reflection provider mappings
This commit is contained in:
parent
b916488de2
commit
d04c933abe
@ -20,6 +20,7 @@ public final class ReflUtil {
|
||||
public static final NMSVersion V1_11_R1 = NMSVersion.fromString("v1_11_R1");
|
||||
public static final NMSVersion V1_17_R1 = NMSVersion.fromString("v1_17_R1");
|
||||
public static final NMSVersion V1_18_R1 = NMSVersion.fromString("v1_18_R1");
|
||||
public static final NMSVersion V1_19_R1 = NMSVersion.fromString("v1_19_R1");
|
||||
private static final Map<String, Class<?>> classCache = new HashMap<>();
|
||||
private static final Table<Class<?>, String, Method> methodCache = HashBasedTable.create();
|
||||
private static final Table<Class<?>, MethodParams, Method> methodParamCache = HashBasedTable.create();
|
||||
|
@ -14,11 +14,21 @@ public class ReflServerStateProvider implements ServerStateProvider {
|
||||
public ReflServerStateProvider() {
|
||||
Object serverObject = null;
|
||||
MethodHandle isRunning = null;
|
||||
|
||||
final String MDFIVEMAGICLETTER;
|
||||
if (ReflUtil.getNmsVersionObject().isHigherThanOrEqualTo(ReflUtil.V1_19_R1)) {
|
||||
MDFIVEMAGICLETTER = "u";
|
||||
} else if (ReflUtil.getNmsVersionObject().isHigherThanOrEqualTo(ReflUtil.V1_18_R1)) {
|
||||
MDFIVEMAGICLETTER = "v";
|
||||
} else {
|
||||
MDFIVEMAGICLETTER = "isRunning";
|
||||
}
|
||||
|
||||
final Class<?> nmsClass = ReflUtil.getNMSClass("MinecraftServer");
|
||||
try {
|
||||
serverObject = nmsClass.getMethod("getServer").invoke(null);
|
||||
isRunning = MethodHandles.lookup().findVirtual(nmsClass,
|
||||
ReflUtil.getNmsVersionObject().isHigherThanOrEqualTo(ReflUtil.V1_18_R1) ? "v" : "isRunning", //TODO jmp said he may make this better
|
||||
MDFIVEMAGICLETTER, //TODO jmp said he may make this better
|
||||
MethodType.methodType(boolean.class));
|
||||
} catch (final Exception e) {
|
||||
e.printStackTrace();
|
||||
|
Loading…
Reference in New Issue
Block a user