mirror of
https://github.com/TuxCoding/FastLogin.git
synced 2025-07-30 10:47:33 +02:00
Detect enabled Velocity support in server
This commit is contained in:
committed by
games647
parent
cb29c5e226
commit
15fee92937
@ -88,9 +88,9 @@ public class BungeeManager {
|
|||||||
|
|
||||||
public void initialize() {
|
public void initialize() {
|
||||||
try {
|
try {
|
||||||
enabled = detectBungeeCord();
|
enabled = detectProxy();
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
plugin.getLog().warn("Cannot check bungeecord support. Fallback to non-bungee mode", ex);
|
plugin.getLog().warn("Cannot check proxy support. Fallback to non-proxy mode", ex);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (enabled) {
|
if (enabled) {
|
||||||
@ -99,18 +99,22 @@ public class BungeeManager {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean detectBungeeCord() throws Exception {
|
private boolean isProxySupported(String className, String fieldName) throws Exception {
|
||||||
try {
|
try {
|
||||||
enabled = Class.forName("org.spigotmc.SpigotConfig").getDeclaredField("bungee").getBoolean(null);
|
return Class.forName(className).getDeclaredField(fieldName).getBoolean(null);
|
||||||
return enabled;
|
|
||||||
} catch (ClassNotFoundException notFoundEx) {
|
} catch (ClassNotFoundException notFoundEx) {
|
||||||
//ignore server has no bungee support
|
//ignore server has no proxy support
|
||||||
return false;
|
return false;
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
throw ex;
|
throw ex;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private boolean detectProxy() throws Exception {
|
||||||
|
return isProxySupported("org.spigotmc.SpigotConfig", "bungee")
|
||||||
|
|| isProxySupported("com.destroystokyo.paper.PaperConfig", "velocitySupport");
|
||||||
|
}
|
||||||
|
|
||||||
private void registerPluginChannels() {
|
private void registerPluginChannels() {
|
||||||
Server server = Bukkit.getServer();
|
Server server = Bukkit.getServer();
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user