mirror of
https://github.com/WiIIiam278/HuskSync.git
synced 2025-12-21 15:49:20 +00:00
Fix for a ConcurrentModificationException that can occur during the data save process
This commit is contained in:
@@ -172,7 +172,7 @@ public class BungeeRedisListener extends RedisListener {
|
|||||||
|
|
||||||
// When all the data has been received, save it
|
// When all the data has been received, save it
|
||||||
if (MPDBMigrator.migratedDataSent == MPDBMigrator.playersMigrated) {
|
if (MPDBMigrator.migratedDataSent == MPDBMigrator.playersMigrated) {
|
||||||
MPDBMigrator.loadIncomingData();
|
MPDBMigrator.loadIncomingData(MPDBMigrator.incomingPlayerData);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -198,15 +198,17 @@ public class MPDBMigrator {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Load all incoming decoded MPDB data to cache / SQL
|
* Loads all incoming decoded MPDB data to the cache and database
|
||||||
|
*
|
||||||
|
* @param dataToLoad HashMap of the {@link PlayerData} to player Usernames that will be loaded
|
||||||
*/
|
*/
|
||||||
public static void loadIncomingData() {
|
public static void loadIncomingData(HashMap<PlayerData, String> dataToLoad) {
|
||||||
ProxyServer.getInstance().getScheduler().runAsync(plugin, () -> {
|
ProxyServer.getInstance().getScheduler().runAsync(plugin, () -> {
|
||||||
int playersSaved = 0;
|
int playersSaved = 0;
|
||||||
plugin.getLogger().log(Level.INFO, "Saving data for " + playersMigrated + " players...");
|
plugin.getLogger().log(Level.INFO, "Saving data for " + playersMigrated + " players...");
|
||||||
|
|
||||||
for (PlayerData playerData : incomingPlayerData.keySet()) {
|
for (PlayerData playerData : dataToLoad.keySet()) {
|
||||||
String playerName = incomingPlayerData.get(playerData);
|
String playerName = dataToLoad.get(playerData);
|
||||||
|
|
||||||
// Add the player to the MySQL table
|
// Add the player to the MySQL table
|
||||||
DataManager.ensurePlayerExists(playerData.getPlayerUUID(), playerName);
|
DataManager.ensurePlayerExists(playerData.getPlayerUUID(), playerName);
|
||||||
|
|||||||
Reference in New Issue
Block a user