#923 Add commands to run on unregister

This commit is contained in:
ljacqu
2017-04-29 19:08:10 +02:00
parent 578f63b944
commit d4c1370da6
8 changed files with 49 additions and 8 deletions
@@ -30,13 +30,18 @@ class CommandMigrationService implements MigrationService {
final CommandConfig commandConfig = CommandSettingsHolder.COMMANDS.getValue(resource);
final boolean didMoveCommands = transformOldCommands(commandConfig);
if (didMoveCommands) { // TODO ConfigMe/#29: Check that loaded file isn't completely empty
if (didMoveCommands || isFileEmpty(resource)) {
resource.setValue("", commandConfig);
return true;
}
return false;
}
private boolean isFileEmpty(PropertyResource resource) {
Object root = resource.getObject("");
return (root instanceof Map) && ((Map) root).isEmpty();
}
/**
* Adds command settings from their old location (in config.yml) to the given command configuration object.
*