Improves tab-completions for salvage-able and reforge-able items settings

This commit is contained in:
Kristian Knarvik 2024-05-04 14:25:08 +02:00
parent f9463f58d1
commit 8b8890c408
2 changed files with 10 additions and 3 deletions

View File

@ -120,8 +120,9 @@ public class BlackSmithConfigTabCompleter implements TabCompleter {
*/ */
private List<String> getCompletions(@NotNull BlacksmithSetting blacksmithSetting, private List<String> getCompletions(@NotNull BlacksmithSetting blacksmithSetting,
@NotNull String commandValue) { @NotNull String commandValue) {
if (blacksmithSetting == BlacksmithSetting.ENCHANTMENT_BLOCK_LIST) { if (blacksmithSetting == BlacksmithSetting.ENCHANTMENT_BLOCK_LIST ||
return TabCompletionHelper.getStringList(getTabCompletions(SettingValueType.ENCHANTMENT), blacksmithSetting == BlacksmithSetting.REFORGE_ABLE_ITEMS) {
return TabCompletionHelper.getStringList(getTabCompletions(blacksmithSetting.getValueType()),
commandValue, TabCompletionHelper::filterMatchingContains); commandValue, TabCompletionHelper::filterMatchingContains);
} }

View File

@ -2,6 +2,7 @@ package net.knarcraft.blacksmith.command.scrapper;
import net.knarcraft.blacksmith.config.Setting; import net.knarcraft.blacksmith.config.Setting;
import net.knarcraft.blacksmith.config.scrapper.ScrapperSetting; import net.knarcraft.blacksmith.config.scrapper.ScrapperSetting;
import net.knarcraft.knarlib.util.TabCompletionHelper;
import org.bukkit.command.Command; import org.bukkit.command.Command;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
import org.bukkit.command.TabCompleter; import org.bukkit.command.TabCompleter;
@ -70,9 +71,14 @@ public class ScrapperConfigTabCompleter implements TabCompleter {
} }
Setting scrapperSetting = ScrapperSetting.getSetting(commandName); Setting scrapperSetting = ScrapperSetting.getSetting(commandName);
if (scrapperSetting != null) { if (scrapperSetting != null) {
if (scrapperSetting == ScrapperSetting.SALVAGE_ABLE_ITEMS) {
return TabCompletionHelper.getStringList(getTabCompletions(scrapperSetting.getValueType()),
commandValue, TabCompletionHelper::filterMatchingContains);
}
return filterMatchingContains(getTabCompletions(scrapperSetting.getValueType()), commandValue); return filterMatchingContains(getTabCompletions(scrapperSetting.getValueType()), commandValue);
} else { } else {
return null; return new ArrayList<>();
} }
} }