Return if the proxy is disabling

feat/data-edit-commands
William 3 years ago
parent cf6b81200b
commit d4dbb5fe7d

@ -31,6 +31,7 @@ public final class HuskSyncBungeeCord extends Plugin {
private static final int METRICS_ID = 13141;
private static HuskSyncBungeeCord instance;
public static HuskSyncBungeeCord getInstance() {
return instance;
}
@ -38,12 +39,16 @@ public final class HuskSyncBungeeCord extends Plugin {
// Whether the plugin is ready to accept redis messages
public static boolean readyForRedis = false;
// Whether the plugin is in the process of disabling and should skip responding to handshake confirmations
public static boolean isDisabling = false;
/**
Set of all the {@link Server}s that have completed the synchronisation handshake with HuskSync on the proxy
* Set of all the {@link Server}s that have completed the synchronisation handshake with HuskSync on the proxy
*/
public static HashSet<Server> synchronisedServers;
private static HashMap<String, Database> clusterDatabases;
public static Connection getConnection(String clusterId) throws SQLException {
return clusterDatabases.get(clusterId).getConnection();
}
@ -78,6 +83,7 @@ public final class HuskSyncBungeeCord extends Plugin {
}
// Initialize the database
clusterDatabases = new HashMap<>();
for (Settings.SynchronisationCluster cluster : Settings.clusters) {
Database clusterDatabase = switch (Settings.dataStorageType) {
case SQLITE -> new SQLite(this, cluster);
@ -134,6 +140,7 @@ public final class HuskSyncBungeeCord extends Plugin {
@Override
public void onDisable() {
// Plugin shutdown logic
isDisabling = true;
// Send terminating handshake message
for (Server server : synchronisedServers) {
@ -159,5 +166,7 @@ public final class HuskSyncBungeeCord extends Plugin {
/**
* A record representing a server synchronised on the network and whether it has MySqlPlayerDataBridge installed
*/
public record Server(UUID serverUUID, boolean hasMySqlPlayerDataBridge, String huskSyncVersion, String serverBrand, String clusterId) { }
public record Server(UUID serverUUID, boolean hasMySqlPlayerDataBridge, String huskSyncVersion, String serverBrand,
String clusterId) {
}
}

@ -131,6 +131,7 @@ public class BungeeRedisListener extends RedisListener {
}
case CONNECTION_HANDSHAKE -> {
// Reply to a Bukkit server's connection handshake to complete the process
if (HuskSyncBungeeCord.isDisabling) return; // Return if the Proxy is disabling
final UUID serverUUID = UUID.fromString(message.getMessageDataElements()[0]);
final boolean hasMySqlPlayerDataBridge = Boolean.parseBoolean(message.getMessageDataElements()[1]);
final String bukkitBrand = message.getMessageDataElements()[2];

Loading…
Cancel
Save