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:
Ursprung
4f133366e1
Commit
44a044848f
@ -29,7 +29,6 @@ import us.myles.ViaVersion.util.ListWrapper;
|
|||||||
import us.myles.ViaVersion.util.ReflectionUtil;
|
import us.myles.ViaVersion.util.ReflectionUtil;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
|
||||||
import java.lang.reflect.Field;
|
import java.lang.reflect.Field;
|
||||||
import java.lang.reflect.Method;
|
import java.lang.reflect.Method;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@ -39,7 +38,6 @@ import java.util.concurrent.Callable;
|
|||||||
import java.util.concurrent.ConcurrentHashMap;
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
import java.util.concurrent.Future;
|
import java.util.concurrent.Future;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
import java.util.logging.Level;
|
|
||||||
|
|
||||||
public class ViaVersionPlugin extends JavaPlugin implements ViaVersionAPI {
|
public class ViaVersionPlugin extends JavaPlugin implements ViaVersionAPI {
|
||||||
|
|
||||||
@ -99,7 +97,7 @@ public class ViaVersionPlugin extends JavaPlugin implements ViaVersionAPI {
|
|||||||
|
|
||||||
public void generateConfig() {
|
public void generateConfig() {
|
||||||
File file = new File(getDataFolder(), "config.yml");
|
File file = new File(getDataFolder(), "config.yml");
|
||||||
if(file.exists()) {
|
if (file.exists()) {
|
||||||
// Update config options
|
// Update config options
|
||||||
Configuration oldConfig = new Configuration(file);
|
Configuration oldConfig = new Configuration(file);
|
||||||
oldConfig.reload(false); // Load current options from config
|
oldConfig.reload(false); // Load current options from config
|
||||||
@ -107,9 +105,9 @@ public class ViaVersionPlugin extends JavaPlugin implements ViaVersionAPI {
|
|||||||
saveDefaultConfig(); // Generate new config
|
saveDefaultConfig(); // Generate new config
|
||||||
Configuration newConfig = new Configuration(file);
|
Configuration newConfig = new Configuration(file);
|
||||||
newConfig.reload(true); // Load default options
|
newConfig.reload(true); // Load default options
|
||||||
for(String key : oldConfig.getKeys(false)) {
|
for (String key : oldConfig.getKeys(false)) {
|
||||||
// Set option in new config if exists
|
// Set option in new config if exists
|
||||||
if(newConfig.contains(key)) {
|
if (newConfig.contains(key)) {
|
||||||
newConfig.set(key, oldConfig.get(key));
|
newConfig.set(key, oldConfig.get(key));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -123,23 +121,19 @@ public class ViaVersionPlugin extends JavaPlugin implements ViaVersionAPI {
|
|||||||
try {
|
try {
|
||||||
Class<?> serverClazz = ReflectionUtil.nms("MinecraftServer");
|
Class<?> serverClazz = ReflectionUtil.nms("MinecraftServer");
|
||||||
Object server = ReflectionUtil.invokeStatic(serverClazz, "getServer");
|
Object server = ReflectionUtil.invokeStatic(serverClazz, "getServer");
|
||||||
Object connection = serverClazz.getDeclaredMethod("getServerConnection").invoke(server);
|
Object connection = null;
|
||||||
if (connection == null) {
|
for (Method m : serverClazz.getDeclaredMethods()) {
|
||||||
System.out.println("connection is null!!");
|
if (m.getReturnType() != null) {
|
||||||
//try others
|
if (m.getReturnType().getSimpleName().equals("ServerConnection")) {
|
||||||
for (Method m : serverClazz.getDeclaredMethods()) {
|
if (m.getParameterTypes().length == 0) {
|
||||||
if (m.getReturnType() != null && !m.getName().equals("getServerConnection")) {
|
connection = m.invoke(server);
|
||||||
if (m.getReturnType().getSimpleName().equals("ServerConnection")) {
|
|
||||||
if (m.getParameterTypes().length == 0) {
|
|
||||||
connection = m.invoke(server);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (connection == null) {
|
}
|
||||||
getLogger().warning("We failed to find the ServerConnection? :(");
|
if (connection == null) {
|
||||||
return;
|
getLogger().warning("We failed to find the ServerConnection? :( What server are you running?");
|
||||||
}
|
return;
|
||||||
}
|
}
|
||||||
if (connection != null) {
|
if (connection != null) {
|
||||||
for (Field field : connection.getClass().getDeclaredFields()) {
|
for (Field field : connection.getClass().getDeclaredFields()) {
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren