Add missing properties to commands.yml on start and reload
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user