Cleanup after UUID Ignore List PR (#3227)

Most of these are edge case fixes, but still fixes nonetheless!
This commit is contained in:
Josh Roy 2020-05-04 09:32:49 -04:00 committed by GitHub
parent fd136384a1
commit 81d3900ef6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 1 deletions

View File

@ -43,9 +43,13 @@ public class EssentialsUpgrade {
}
public void convertIgnoreList() {
Pattern pattern = Pattern.compile("^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$");
if (doneFile.getBoolean("updateUsersIgnoreListUUID", false)) {
return;
}
LOGGER.info("Attempting to migrate ignore list to UUIDs");
final File userdataFolder = new File(ess.getDataFolder(), "userdata");
if (!userdataFolder.exists() || !userdataFolder.isDirectory()) {
return;
@ -65,6 +69,10 @@ public class EssentialsUpgrade {
if (name == null) {
continue;
}
if (pattern.matcher(name.trim()).matches()) {
LOGGER.info("Detected already migrated ignore list!");
return;
}
User user = ess.getOfflineUser(name);
if (user != null && user.getBase() != null) {
migratedIgnores.add(user.getBase().getUniqueId().toString());
@ -81,6 +89,7 @@ public class EssentialsUpgrade {
}
doneFile.setProperty("updateUsersIgnoreListUUID", true);
doneFile.save();
LOGGER.info("Done converting ignore list.");
}
public void convertKits() {

View File

@ -21,7 +21,7 @@ public class Commandignore extends EssentialsCommand {
StringBuilder sb = new StringBuilder();
for (UUID uuid : user._getIgnoredPlayers()) {
User curUser = ess.getUser(uuid);
if (curUser != null && curUser.getName() != null && !curUser.getName().trim().equals("")) {
if (curUser != null && curUser.getName() != null && !curUser.getName().trim().isEmpty()) {
sb.append(curUser.getName()).append(" ");
}
}