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

Don't use -1 if provided by ProtocolDetectorService on Bungee #1064

Dieser Commit ist enthalten in:
Myles 2018-11-01 22:41:56 +00:00
Ursprung b9750be745
Commit e6922eae46

Datei anzeigen

@ -58,19 +58,22 @@ public class ProtocolDetectorService implements Runnable {
@Override @Override
public void done(ServerPing serverPing, Throwable throwable) { public void done(ServerPing serverPing, Throwable throwable) {
if (throwable == null && serverPing != null && serverPing.getVersion() != null) { if (throwable == null && serverPing != null && serverPing.getVersion() != null) {
detectedProtocolIds.put(key, serverPing.getVersion().getProtocol()); // Ensure protocol is positive, some services will return -1
if (((BungeeConfigAPI) Via.getConfig()).isBungeePingSave()) { if (serverPing.getVersion().getProtocol() > 0) {
Map<String, Integer> servers = ((BungeeConfigAPI) Via.getConfig()).getBungeeServerProtocols(); detectedProtocolIds.put(key, serverPing.getVersion().getProtocol());
Integer protocol = servers.get(key); if (((BungeeConfigAPI) Via.getConfig()).isBungeePingSave()) {
if (protocol != null && protocol == serverPing.getVersion().getProtocol()) { Map<String, Integer> servers = ((BungeeConfigAPI) Via.getConfig()).getBungeeServerProtocols();
return; Integer protocol = servers.get(key);
if (protocol != null && protocol == serverPing.getVersion().getProtocol()) {
return;
}
// Ensure we're the only ones writing to the config
synchronized (Via.getPlatform().getConfigurationProvider()) {
servers.put(key, serverPing.getVersion().getProtocol());
}
// Save
Via.getPlatform().getConfigurationProvider().saveConfig();
} }
// Ensure we're the only ones writing to the config
synchronized (Via.getPlatform().getConfigurationProvider()) {
servers.put(key, serverPing.getVersion().getProtocol());
}
// Save
Via.getPlatform().getConfigurationProvider().saveConfig();
} }
} }
} }