From 83c8d3cdb9aff445ae04c8a346856df8d43a7056 Mon Sep 17 00:00:00 2001 From: TfT_02 Date: Thu, 17 Jul 2014 22:39:21 +0200 Subject: [PATCH] Save if uuid conversion is complete --- .../runnables/database/UUIDUpdateAsyncTask.java | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/src/main/java/com/gmail/nossr50/runnables/database/UUIDUpdateAsyncTask.java b/src/main/java/com/gmail/nossr50/runnables/database/UUIDUpdateAsyncTask.java index 264e00b47..92b420373 100644 --- a/src/main/java/com/gmail/nossr50/runnables/database/UUIDUpdateAsyncTask.java +++ b/src/main/java/com/gmail/nossr50/runnables/database/UUIDUpdateAsyncTask.java @@ -7,21 +7,24 @@ import org.bukkit.scheduler.BukkitRunnable; import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.config.HiddenConfig; import com.gmail.nossr50.database.DatabaseManager; +import com.gmail.nossr50.datatypes.database.UpgradeType; import com.gmail.nossr50.datatypes.player.PlayerProfile; import com.gmail.nossr50.util.Misc; public class UUIDUpdateAsyncTask extends BukkitRunnable { private mcMMO plugin; private static final int MAX_LOOKUP = HiddenConfig.getInstance().getUUIDConvertAmount(); + private boolean conversionNeeded; private DatabaseManager databaseManager; private List userNames; private int size; - int checkedUsers; - long startMillis; + private int checkedUsers; + private long startMillis; public UUIDUpdateAsyncTask(mcMMO plugin) { this.plugin = plugin; + this.conversionNeeded = !mcMMO.getUpgradeManager().shouldUpgrade(UpgradeType.ADD_UUIDS); this.databaseManager = mcMMO.getDatabaseManager(); this.userNames = databaseManager.getStoredUsers(); @@ -35,7 +38,7 @@ public class UUIDUpdateAsyncTask extends BukkitRunnable { @Override public void run() { - if (!conversionNeeded()) { + if (!conversionNeeded) { plugin.debug("No need to update database with UUIDs"); this.cancel(); return; @@ -51,6 +54,8 @@ public class UUIDUpdateAsyncTask extends BukkitRunnable { userNamesSection = userNames.subList(0, size); size = 0; this.cancel(); + mcMMO.getUpgradeManager().setUpgradeCompleted(UpgradeType.ADD_UUIDS); + plugin.debug("Database updated with UUIDs!"); } for (String userName : userNamesSection) { @@ -67,10 +72,4 @@ public class UUIDUpdateAsyncTask extends BukkitRunnable { Misc.printProgress(checkedUsers, DatabaseManager.progressInterval, startMillis); } - - private boolean conversionNeeded() { - plugin.debug("Checking if conversion is needed..."); - - return true; - } }