mirror of
https://github.com/TotalFreedomMC/TF-EssentialsX.git
synced 2024-07-01 02:09:26 +00:00
Fix reflection mappings for the ServerStateProvider in 1.18
This commit is contained in:
parent
b6ba1768a1
commit
7a1e50d10f
|
@ -19,6 +19,7 @@ public final class ReflUtil {
|
||||||
public static final NMSVersion V1_12_R1 = NMSVersion.fromString("v1_12_R1");
|
public static final NMSVersion V1_12_R1 = NMSVersion.fromString("v1_12_R1");
|
||||||
public static final NMSVersion V1_11_R1 = NMSVersion.fromString("v1_11_R1");
|
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_17_R1 = NMSVersion.fromString("v1_17_R1");
|
||||||
|
public static final NMSVersion V1_18_R1 = NMSVersion.fromString("v1_18_R1");
|
||||||
private static final Map<String, Class<?>> classCache = new HashMap<>();
|
private static final Map<String, Class<?>> classCache = new HashMap<>();
|
||||||
private static final Table<Class<?>, String, Method> methodCache = HashBasedTable.create();
|
private static final Table<Class<?>, String, Method> methodCache = HashBasedTable.create();
|
||||||
private static final Table<Class<?>, MethodParams, Method> methodParamCache = HashBasedTable.create();
|
private static final Table<Class<?>, MethodParams, Method> methodParamCache = HashBasedTable.create();
|
||||||
|
|
|
@ -17,7 +17,9 @@ public class ReflServerStateProvider implements ServerStateProvider {
|
||||||
final Class<?> nmsClass = ReflUtil.getNMSClass("MinecraftServer");
|
final Class<?> nmsClass = ReflUtil.getNMSClass("MinecraftServer");
|
||||||
try {
|
try {
|
||||||
serverObject = nmsClass.getMethod("getServer").invoke(null);
|
serverObject = nmsClass.getMethod("getServer").invoke(null);
|
||||||
isRunning = MethodHandles.lookup().findVirtual(nmsClass, "isRunning", MethodType.methodType(boolean.class));
|
isRunning = MethodHandles.lookup().findVirtual(nmsClass,
|
||||||
|
ReflUtil.getNmsVersionObject().isHigherThanOrEqualTo(ReflUtil.V1_18_R1) ? "v" : "isRunning", //TODO jmp said he may make this better
|
||||||
|
MethodType.methodType(boolean.class));
|
||||||
} catch (final Exception e) {
|
} catch (final Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue