Save if uuid conversion is complete

This commit is contained in:
TfT_02 2014-07-17 22:39:21 +02:00
parent ed95cfcbfc
commit 83c8d3cdb9

View File

@ -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<String> 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;
}
}