mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2024-11-26 07:06:45 +01:00
Save if uuid conversion is complete
This commit is contained in:
parent
ed95cfcbfc
commit
83c8d3cdb9
@ -7,21 +7,24 @@ import org.bukkit.scheduler.BukkitRunnable;
|
|||||||
import com.gmail.nossr50.mcMMO;
|
import com.gmail.nossr50.mcMMO;
|
||||||
import com.gmail.nossr50.config.HiddenConfig;
|
import com.gmail.nossr50.config.HiddenConfig;
|
||||||
import com.gmail.nossr50.database.DatabaseManager;
|
import com.gmail.nossr50.database.DatabaseManager;
|
||||||
|
import com.gmail.nossr50.datatypes.database.UpgradeType;
|
||||||
import com.gmail.nossr50.datatypes.player.PlayerProfile;
|
import com.gmail.nossr50.datatypes.player.PlayerProfile;
|
||||||
import com.gmail.nossr50.util.Misc;
|
import com.gmail.nossr50.util.Misc;
|
||||||
|
|
||||||
public class UUIDUpdateAsyncTask extends BukkitRunnable {
|
public class UUIDUpdateAsyncTask extends BukkitRunnable {
|
||||||
private mcMMO plugin;
|
private mcMMO plugin;
|
||||||
private static final int MAX_LOOKUP = HiddenConfig.getInstance().getUUIDConvertAmount();
|
private static final int MAX_LOOKUP = HiddenConfig.getInstance().getUUIDConvertAmount();
|
||||||
|
private boolean conversionNeeded;
|
||||||
|
|
||||||
private DatabaseManager databaseManager;
|
private DatabaseManager databaseManager;
|
||||||
private List<String> userNames;
|
private List<String> userNames;
|
||||||
private int size;
|
private int size;
|
||||||
int checkedUsers;
|
private int checkedUsers;
|
||||||
long startMillis;
|
private long startMillis;
|
||||||
|
|
||||||
public UUIDUpdateAsyncTask(mcMMO plugin) {
|
public UUIDUpdateAsyncTask(mcMMO plugin) {
|
||||||
this.plugin = plugin;
|
this.plugin = plugin;
|
||||||
|
this.conversionNeeded = !mcMMO.getUpgradeManager().shouldUpgrade(UpgradeType.ADD_UUIDS);
|
||||||
|
|
||||||
this.databaseManager = mcMMO.getDatabaseManager();
|
this.databaseManager = mcMMO.getDatabaseManager();
|
||||||
this.userNames = databaseManager.getStoredUsers();
|
this.userNames = databaseManager.getStoredUsers();
|
||||||
@ -35,7 +38,7 @@ public class UUIDUpdateAsyncTask extends BukkitRunnable {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
if (!conversionNeeded()) {
|
if (!conversionNeeded) {
|
||||||
plugin.debug("No need to update database with UUIDs");
|
plugin.debug("No need to update database with UUIDs");
|
||||||
this.cancel();
|
this.cancel();
|
||||||
return;
|
return;
|
||||||
@ -51,6 +54,8 @@ public class UUIDUpdateAsyncTask extends BukkitRunnable {
|
|||||||
userNamesSection = userNames.subList(0, size);
|
userNamesSection = userNames.subList(0, size);
|
||||||
size = 0;
|
size = 0;
|
||||||
this.cancel();
|
this.cancel();
|
||||||
|
mcMMO.getUpgradeManager().setUpgradeCompleted(UpgradeType.ADD_UUIDS);
|
||||||
|
plugin.debug("Database updated with UUIDs!");
|
||||||
}
|
}
|
||||||
|
|
||||||
for (String userName : userNamesSection) {
|
for (String userName : userNamesSection) {
|
||||||
@ -67,10 +72,4 @@ public class UUIDUpdateAsyncTask extends BukkitRunnable {
|
|||||||
|
|
||||||
Misc.printProgress(checkedUsers, DatabaseManager.progressInterval, startMillis);
|
Misc.printProgress(checkedUsers, DatabaseManager.progressInterval, startMillis);
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean conversionNeeded() {
|
|
||||||
plugin.debug("Checking if conversion is needed...");
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user