From 3a2aa05137525becc7c01a9789d068d765696d6b Mon Sep 17 00:00:00 2001 From: ljacqu Date: Sun, 4 Sep 2016 16:00:04 +0200 Subject: [PATCH] Fix settings migration using boolean from old property #927 - ConfigMe's PropertyResource#getString only returns a String if the value is indeed a string, whereas Bukkit's FileConfiguration#getString will return whatever the value is as a string -> not a good idea to use PropertyResource#getString to get an old boolean property's value if it is still present --- .../fr/xephi/authme/settings/SettingsMigrationService.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/main/java/fr/xephi/authme/settings/SettingsMigrationService.java b/src/main/java/fr/xephi/authme/settings/SettingsMigrationService.java index ce6877d2..b47ce8e1 100644 --- a/src/main/java/fr/xephi/authme/settings/SettingsMigrationService.java +++ b/src/main/java/fr/xephi/authme/settings/SettingsMigrationService.java @@ -4,6 +4,7 @@ import com.github.authme.configme.knownproperties.PropertyEntry; import com.github.authme.configme.migration.PlainMigrationService; import com.github.authme.configme.properties.Property; import com.github.authme.configme.resource.PropertyResource; +import com.google.common.base.Objects; import fr.xephi.authme.ConsoleLogger; import fr.xephi.authme.output.LogLevel; import fr.xephi.authme.settings.properties.PluginSettings; @@ -145,7 +146,8 @@ public class SettingsMigrationService extends PlainMigrationService { final Property newProperty = PluginSettings.LOG_LEVEL; if (!newProperty.isPresent(resource) && resource.contains(oldPath)) { ConsoleLogger.info("Moving '" + oldPath + "' to '" + newProperty.getPath() + "'"); - LogLevel level = Boolean.valueOf(resource.getString(oldPath)) ? LogLevel.INFO : LogLevel.FINE; + boolean oldValue = Objects.firstNonNull(resource.getBoolean(oldPath), false); + LogLevel level = oldValue ? LogLevel.INFO : LogLevel.FINE; resource.setValue(newProperty.getPath(), level.name()); return true; }