ru.cwcode.tkach.config.commands.ConfigArg Maven / Gradle / Ivy
The newest version!
package ru.cwcode.tkach.config.commands;
import ru.cwcode.commands.Argument;
import ru.cwcode.commands.api.Sender;
import ru.cwcode.tkach.config.base.Config;
import ru.cwcode.tkach.config.base.manager.ConfigManager;
import java.util.Collection;
import java.util.Set;
import java.util.function.Predicate;
import static ru.cwcode.tkach.config.server.ServerPlatform.l10n;
public class ConfigArg> extends Argument {
private final Predicate predicate;
ConfigManager configManager;
public ConfigArg(Predicate predicate, ConfigManager configManager) {
this.predicate = predicate;
this.configManager = configManager;
}
@Override
public boolean valid(String raw) {
return getReloadableConfigNames().contains(raw);
}
@Override
public Collection completions(Sender sender) {
return getReloadableConfigNames();
}
@Override
public String argumentName() {
return l10n.get("config.argument.name");
}
private Set getReloadableConfigNames() {
return configManager.getConfigNames(predicate);
}
}