3
0
Mirror von https://github.com/ViaVersion/ViaVersion.git synchronisiert 2024-12-26 00:00:28 +01:00

Fix ServerConnection #198

Dieser Commit ist enthalten in:
Myles 2016-03-12 20:48:04 +00:00
Ursprung 4f133366e1
Commit 44a044848f

Datei anzeigen

@ -29,7 +29,6 @@ import us.myles.ViaVersion.util.ListWrapper;
import us.myles.ViaVersion.util.ReflectionUtil;
import java.io.File;
import java.io.IOException;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.util.List;
@ -39,7 +38,6 @@ import java.util.concurrent.Callable;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.Future;
import java.util.concurrent.TimeUnit;
import java.util.logging.Level;
public class ViaVersionPlugin extends JavaPlugin implements ViaVersionAPI {
@ -123,12 +121,9 @@ public class ViaVersionPlugin extends JavaPlugin implements ViaVersionAPI {
try {
Class<?> serverClazz = ReflectionUtil.nms("MinecraftServer");
Object server = ReflectionUtil.invokeStatic(serverClazz, "getServer");
Object connection = serverClazz.getDeclaredMethod("getServerConnection").invoke(server);
if (connection == null) {
System.out.println("connection is null!!");
//try others
Object connection = null;
for (Method m : serverClazz.getDeclaredMethods()) {
if (m.getReturnType() != null && !m.getName().equals("getServerConnection")) {
if (m.getReturnType() != null) {
if (m.getReturnType().getSimpleName().equals("ServerConnection")) {
if (m.getParameterTypes().length == 0) {
connection = m.invoke(server);
@ -137,10 +132,9 @@ public class ViaVersionPlugin extends JavaPlugin implements ViaVersionAPI {
}
}
if (connection == null) {
getLogger().warning("We failed to find the ServerConnection? :(");
getLogger().warning("We failed to find the ServerConnection? :( What server are you running?");
return;
}
}
if (connection != null) {
for (Field field : connection.getClass().getDeclaredFields()) {
field.setAccessible(true);