Adds tons of changes to messages
This commit is contained in:
@ -2,8 +2,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 net.knarcraft.blacksmith.config.SettingValueType;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.command.TabCompleter;
|
||||
@ -13,6 +12,9 @@ import org.jetbrains.annotations.Nullable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import static net.knarcraft.blacksmith.util.TabCompleteValuesHelper.getTabCompletions;
|
||||
import static net.knarcraft.blacksmith.util.TabCompletionHelper.filterMatchingContains;
|
||||
|
||||
/**
|
||||
* The tab completer for the command used for changing global configuration options
|
||||
*/
|
||||
@ -35,7 +37,7 @@ public class BlackSmithConfigTabCompleter implements TabCompleter {
|
||||
for (GlobalSetting globalSetting : GlobalSetting.values()) {
|
||||
availableCommands.add(globalSetting.getCommandName());
|
||||
}
|
||||
return TabCompletionHelper.filterMatchingContains(availableCommands, args[0]);
|
||||
return filterMatchingContains(availableCommands, args[0]);
|
||||
} else if (args.length == 2) {
|
||||
return tabCompleteCommandValues(args[0], args[1]);
|
||||
}
|
||||
@ -55,17 +57,33 @@ public class BlackSmithConfigTabCompleter implements TabCompleter {
|
||||
}
|
||||
for (GlobalSetting globalSetting : GlobalSetting.values()) {
|
||||
if (globalSetting.getCommandName().equalsIgnoreCase(commandName)) {
|
||||
return TabCompletionHelper.filterMatchingContains(TabCompleteValuesHelper.getTabCompletions(
|
||||
globalSetting.getValueType()), commandValue);
|
||||
return getCompletions(globalSetting, commandValue);
|
||||
}
|
||||
}
|
||||
for (NPCSetting npcSetting : NPCSetting.values()) {
|
||||
if (npcSetting.getCommandName().equalsIgnoreCase(commandName)) {
|
||||
return TabCompletionHelper.filterMatchingContains(TabCompleteValuesHelper.getTabCompletions(
|
||||
return filterMatchingContains(getTabCompletions(
|
||||
npcSetting.getValueType()), commandValue);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets tab-completions for the given global setting and filters on the command value
|
||||
*
|
||||
* @param globalSetting <p>The global setting to get tab-completions for</p>
|
||||
* @param commandValue <p>The command value used to filter between available tab-completions</p>
|
||||
* @return <p>The available tab-completions</p>
|
||||
*/
|
||||
private List<String> getCompletions(GlobalSetting globalSetting, String commandValue) {
|
||||
List<String> returnValues = filterMatchingContains(getTabCompletions(globalSetting.getValueType()), commandValue);
|
||||
if (globalSetting == GlobalSetting.BASE_PRICE || globalSetting == GlobalSetting.PRICE_PER_DURABILITY_POINT) {
|
||||
returnValues.addAll(filterMatchingContains(getTabCompletions(SettingValueType.MATERIAL), commandValue));
|
||||
} else if (globalSetting == GlobalSetting.ENCHANTMENT_COST) {
|
||||
returnValues.addAll(filterMatchingContains(getTabCompletions(SettingValueType.ENCHANTMENT), commandValue));
|
||||
}
|
||||
return returnValues;
|
||||
}
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user