Flip velocity check to scan for newer Paper configurations first

The PaperConfig class file still exists in newer versions
This commit is contained in:
games647 committed 2022-07-08 16:43:02 +02:00
1 parent e89cb3293a
commit adfae507ac
2 files changed
+9 -8

No files matched your search

@@ -110,17 +110,17 @@ public class BungeeManager {
throws NoSuchFieldException, IllegalArgumentException, IllegalAccessException, ClassNotFoundException,
NoSuchMethodException, InvocationTargetException {
try {
if (isProxySupported("com.destroystokyo.paper.PaperConfig", "velocitySupport")) {
return true;
}
} catch (ClassNotFoundException classNotFoundException) {
// try again using the newer Paper configuration
Class<?> globalConfig = Class.forName("io.papermc.paper.configuration.GlobalConfiguration");
Object global = globalConfig.getDeclaredMethod("get").invoke(null);
Object proxiesConfiguration = global.getClass().getDeclaredField("proxies").get(global);
Object velocityConfig = proxiesConfiguration.getClass().getDeclaredField("velocity").get(proxiesConfiguration);
return velocityConfig.getClass().getDeclaredField("enabled").getBoolean(velocityConfig);
} catch (ClassNotFoundException classNotFoundException) {
// try again using the older Paper configuration, because the old class file still exists in newer versions
if (isProxySupported("com.destroystokyo.paper.PaperConfig", "velocitySupport")) {
return true;
}
}
return false;