mirror of
https://github.com/TotalFreedomMC/TF-EssentialsX.git
synced 2025-02-14 21:22:09 +00:00
parent
63dd5f3f64
commit
02e6b5f1b3
1 changed files with 4 additions and 3 deletions
|
@ -20,12 +20,13 @@ public class ServerState {
|
||||||
MethodHandle nmsIsRunningHandle = null;
|
MethodHandle nmsIsRunningHandle = null;
|
||||||
Object nmsServerObject = null;
|
Object nmsServerObject = null;
|
||||||
try {
|
try {
|
||||||
|
//noinspection JavaLangInvokeHandleSignature - We don't compile against Paper
|
||||||
isStoppingHandle = MethodHandles.lookup().findStatic(Bukkit.class, "isStopping", MethodType.methodType(boolean.class));
|
isStoppingHandle = MethodHandles.lookup().findStatic(Bukkit.class, "isStopping", MethodType.methodType(boolean.class));
|
||||||
} catch (Throwable e) {
|
} catch (Throwable e) {
|
||||||
try {
|
try {
|
||||||
Class<?> nmsClass = ReflUtil.getNMSClass("MinecraftServer");
|
Class<?> nmsClass = ReflUtil.getNMSClass("MinecraftServer");
|
||||||
if (nmsClass != null) {
|
if (nmsClass != null) {
|
||||||
nmsServerObject = ReflUtil.getMethodCached(nmsClass, "getServer").invoke(null);
|
nmsServerObject = nmsClass.getMethod("getServer").invoke(null);
|
||||||
nmsIsRunningHandle = MethodHandles.lookup().findVirtual(nmsClass, "isRunning", MethodType.methodType(boolean.class));
|
nmsIsRunningHandle = MethodHandles.lookup().findVirtual(nmsClass, "isRunning", MethodType.methodType(boolean.class));
|
||||||
nmsHasStoppedHandle = MethodHandles.lookup().findVirtual(nmsClass, "hasStopped", MethodType.methodType(boolean.class));
|
nmsHasStoppedHandle = MethodHandles.lookup().findVirtual(nmsClass, "hasStopped", MethodType.methodType(boolean.class));
|
||||||
}
|
}
|
||||||
|
@ -49,13 +50,13 @@ public class ServerState {
|
||||||
} else if (nmsServer != null) {
|
} else if (nmsServer != null) {
|
||||||
if (nmsHasStopped != null) {
|
if (nmsHasStopped != null) {
|
||||||
try {
|
try {
|
||||||
stopping = (boolean) nmsHasStopped.invokeExact(nmsServer);
|
stopping = (boolean) nmsHasStopped.invoke(nmsServer);
|
||||||
} catch (Throwable t) {
|
} catch (Throwable t) {
|
||||||
t.printStackTrace();
|
t.printStackTrace();
|
||||||
}
|
}
|
||||||
} else if (nmsIsRunning != null) {
|
} else if (nmsIsRunning != null) {
|
||||||
try {
|
try {
|
||||||
stopping = (boolean) nmsIsRunning.invokeExact(nmsServer);
|
stopping = !(boolean) nmsIsRunning.invoke(nmsServer);
|
||||||
} catch (Throwable t) {
|
} catch (Throwable t) {
|
||||||
t.printStackTrace();
|
t.printStackTrace();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue