Add missing properties to commands.yml on start and reload

This commit is contained in:
ljacqu
2017-05-21 14:21:40 +02:00
parent 5c6af0330e
commit 5ca9112c12
3 changed files with 57 additions and 3 deletions
@@ -4,6 +4,7 @@ import ch.jalu.configme.migration.MigrationService;
import ch.jalu.configme.properties.Property;
import ch.jalu.configme.resource.PropertyResource;
import com.google.common.annotations.VisibleForTesting;
import com.google.common.collect.ImmutableList;
import fr.xephi.authme.ConsoleLogger;
import fr.xephi.authme.settings.SettingsMigrationService;
import fr.xephi.authme.util.RandomStringUtils;
@@ -19,6 +20,11 @@ import java.util.stream.Collectors;
*/
class CommandMigrationService implements MigrationService {
/** List of all properties in {@link CommandConfig}. */
@VisibleForTesting
static final List<String> COMMAND_CONFIG_PROPERTIES = ImmutableList.of(
"onJoin", "onLogin", "onSessionLogin", "onRegister", "onUnregister", "onLogout");
@Inject
private SettingsMigrationService settingsMigrationService;
@@ -38,8 +44,7 @@ class CommandMigrationService implements MigrationService {
}
private boolean isFileEmpty(PropertyResource resource) {
Object root = resource.getObject("");
return (root instanceof Map) && ((Map) root).isEmpty();
return COMMAND_CONFIG_PROPERTIES.stream().anyMatch(property -> resource.getObject(property) == null);
}
/**