Skip to content

Commit a5f6c89

Browse files
committed
Detect enabled Velocity support in server
1 parent 5612ca7 commit a5f6c89

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

bukkit/src/main/java/com/github/games647/fastlogin/bukkit/BungeeManager.java

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -88,9 +88,9 @@ public boolean isEnabled() {
8888

8989
public void initialize() {
9090
try {
91-
enabled = detectBungeeCord();
91+
enabled = detectProxy();
9292
} catch (Exception ex) {
93-
plugin.getLog().warn("Cannot check bungeecord support. Fallback to non-bungee mode", ex);
93+
plugin.getLog().warn("Cannot check proxy support. Fallback to non-proxy mode", ex);
9494
}
9595

9696
if (enabled) {
@@ -99,18 +99,22 @@ public void initialize() {
9999
}
100100
}
101101

102-
private boolean detectBungeeCord() throws Exception {
102+
private boolean isProxySupported(String className, String fieldName) throws Exception {
103103
try {
104-
enabled = Class.forName("org.spigotmc.SpigotConfig").getDeclaredField("bungee").getBoolean(null);
105-
return enabled;
104+
return Class.forName(className).getDeclaredField(fieldName).getBoolean(null);
106105
} catch (ClassNotFoundException notFoundEx) {
107-
//ignore server has no bungee support
106+
//ignore server has no proxy support
108107
return false;
109108
} catch (Exception ex) {
110109
throw ex;
111110
}
112111
}
113112

113+
private boolean detectProxy() throws Exception {
114+
return isProxySupported("org.spigotmc.SpigotConfig", "bungee")
115+
|| isProxySupported("com.destroystokyo.paper.PaperConfig", "velocitySupport");
116+
}
117+
114118
private void registerPluginChannels() {
115119
Server server = Bukkit.getServer();
116120

0 commit comments

Comments
 (0)