From 8b8890c408909a2cb74f19547608fa934dd1cfd0 Mon Sep 17 00:00:00 2001 From: EpicKnarvik97 Date: Sat, 4 May 2024 14:25:08 +0200 Subject: [PATCH] Improves tab-completions for salvage-able and reforge-able items settings --- .../command/blacksmith/BlackSmithConfigTabCompleter.java | 5 +++-- .../command/scrapper/ScrapperConfigTabCompleter.java | 8 +++++++- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/src/main/java/net/knarcraft/blacksmith/command/blacksmith/BlackSmithConfigTabCompleter.java b/src/main/java/net/knarcraft/blacksmith/command/blacksmith/BlackSmithConfigTabCompleter.java index 19087b6..35ec8a0 100644 --- a/src/main/java/net/knarcraft/blacksmith/command/blacksmith/BlackSmithConfigTabCompleter.java +++ b/src/main/java/net/knarcraft/blacksmith/command/blacksmith/BlackSmithConfigTabCompleter.java @@ -120,8 +120,9 @@ public class BlackSmithConfigTabCompleter implements TabCompleter { */ private List getCompletions(@NotNull BlacksmithSetting blacksmithSetting, @NotNull String commandValue) { - if (blacksmithSetting == BlacksmithSetting.ENCHANTMENT_BLOCK_LIST) { - return TabCompletionHelper.getStringList(getTabCompletions(SettingValueType.ENCHANTMENT), + if (blacksmithSetting == BlacksmithSetting.ENCHANTMENT_BLOCK_LIST || + blacksmithSetting == BlacksmithSetting.REFORGE_ABLE_ITEMS) { + return TabCompletionHelper.getStringList(getTabCompletions(blacksmithSetting.getValueType()), commandValue, TabCompletionHelper::filterMatchingContains); } diff --git a/src/main/java/net/knarcraft/blacksmith/command/scrapper/ScrapperConfigTabCompleter.java b/src/main/java/net/knarcraft/blacksmith/command/scrapper/ScrapperConfigTabCompleter.java index 9876700..8007d3e 100644 --- a/src/main/java/net/knarcraft/blacksmith/command/scrapper/ScrapperConfigTabCompleter.java +++ b/src/main/java/net/knarcraft/blacksmith/command/scrapper/ScrapperConfigTabCompleter.java @@ -2,6 +2,7 @@ package net.knarcraft.blacksmith.command.scrapper; import net.knarcraft.blacksmith.config.Setting; import net.knarcraft.blacksmith.config.scrapper.ScrapperSetting; +import net.knarcraft.knarlib.util.TabCompletionHelper; import org.bukkit.command.Command; import org.bukkit.command.CommandSender; import org.bukkit.command.TabCompleter; @@ -70,9 +71,14 @@ public class ScrapperConfigTabCompleter implements TabCompleter { } Setting scrapperSetting = ScrapperSetting.getSetting(commandName); if (scrapperSetting != null) { + if (scrapperSetting == ScrapperSetting.SALVAGE_ABLE_ITEMS) { + return TabCompletionHelper.getStringList(getTabCompletions(scrapperSetting.getValueType()), + commandValue, TabCompletionHelper::filterMatchingContains); + } + return filterMatchingContains(getTabCompletions(scrapperSetting.getValueType()), commandValue); } else { - return null; + return new ArrayList<>(); } }