Adds some unfinished changes for improving blacksmith commands
This commit is contained in:
@ -3,6 +3,7 @@ package net.knarcraft.blacksmith.command;
|
||||
import net.knarcraft.blacksmith.config.GlobalSetting;
|
||||
import net.knarcraft.blacksmith.config.NPCSetting;
|
||||
import net.knarcraft.blacksmith.util.TabCompleteValuesHelper;
|
||||
import net.knarcraft.blacksmith.util.TabCompletionHelper;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.command.TabCompleter;
|
||||
@ -34,9 +35,9 @@ public class BlackSmithConfigTabCompleter implements TabCompleter {
|
||||
for (GlobalSetting globalSetting : GlobalSetting.values()) {
|
||||
availableCommands.add(globalSetting.getCommandName());
|
||||
}
|
||||
return availableCommands;
|
||||
return TabCompletionHelper.filterMatchingContains(availableCommands, args[0]);
|
||||
} else if (args.length == 2) {
|
||||
return tabCompleteCommandValues(args[0]);
|
||||
return tabCompleteCommandValues(args[0], args[1]);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
@ -44,18 +45,24 @@ public class BlackSmithConfigTabCompleter implements TabCompleter {
|
||||
/**
|
||||
* Tab completes the values available for the given command
|
||||
*
|
||||
* @param commandName <p>The name of the used command</p>
|
||||
* @param commandName <p>The name of the used command</p>
|
||||
* @param commandValue <p>The command value used to filter tab-completions</p>
|
||||
* @return <p>Some valid options for the command's argument</p>
|
||||
*/
|
||||
private List<String> tabCompleteCommandValues(String commandName) {
|
||||
private List<String> tabCompleteCommandValues(String commandName, String commandValue) {
|
||||
if (commandName.equalsIgnoreCase("reload")) {
|
||||
return new ArrayList<>();
|
||||
}
|
||||
for (GlobalSetting globalSetting : GlobalSetting.values()) {
|
||||
if (globalSetting.getCommandName().equalsIgnoreCase(commandName)) {
|
||||
return TabCompleteValuesHelper.getTabCompletions(globalSetting.getValueType());
|
||||
return TabCompletionHelper.filterMatchingContains(TabCompleteValuesHelper.getTabCompletions(
|
||||
globalSetting.getValueType()), commandValue);
|
||||
}
|
||||
}
|
||||
for (NPCSetting npcSetting : NPCSetting.values()) {
|
||||
if (npcSetting.getCommandName().equalsIgnoreCase(commandName)) {
|
||||
return TabCompleteValuesHelper.getTabCompletions(npcSetting.getValueType());
|
||||
return TabCompletionHelper.filterMatchingContains(TabCompleteValuesHelper.getTabCompletions(
|
||||
npcSetting.getValueType()), commandValue);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
|
Reference in New Issue
Block a user