From 2053ce5fb761bdc70d9d14ebd2dee2fa6404d561 Mon Sep 17 00:00:00 2001 From: jhqwqmc <2110242767@qq.com> Date: Sun, 16 Mar 2025 19:08:02 +0800 Subject: [PATCH] =?UTF-8?q?feat(core):=20=E6=B7=BB=E5=8A=A0=E6=9F=A5?= =?UTF-8?q?=E7=9C=8B=E7=89=A9=E5=93=81=E9=85=8D=E6=96=B9=E5=92=8C=E7=94=A8?= =?UTF-8?q?=E6=B3=95=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../plugin/command/feature/ItemRecipeBrowserCommand.java | 4 ++++ .../momirealms/craftengine/core/plugin/command/FlagKeys.java | 2 ++ 2 files changed, 6 insertions(+) diff --git a/bukkit/src/main/java/net/momirealms/craftengine/bukkit/plugin/command/feature/ItemRecipeBrowserCommand.java b/bukkit/src/main/java/net/momirealms/craftengine/bukkit/plugin/command/feature/ItemRecipeBrowserCommand.java index d0dbd2a38..eca22e414 100644 --- a/bukkit/src/main/java/net/momirealms/craftengine/bukkit/plugin/command/feature/ItemRecipeBrowserCommand.java +++ b/bukkit/src/main/java/net/momirealms/craftengine/bukkit/plugin/command/feature/ItemRecipeBrowserCommand.java @@ -5,6 +5,7 @@ import net.momirealms.craftengine.bukkit.plugin.user.BukkitServerPlayer; import net.momirealms.craftengine.core.item.recipe.Recipe; import net.momirealms.craftengine.core.plugin.CraftEngine; import net.momirealms.craftengine.core.plugin.command.CraftEngineCommandManager; +import net.momirealms.craftengine.core.plugin.command.FlagKeys; import net.momirealms.craftengine.core.plugin.locale.MessageConstants; import net.momirealms.craftengine.core.util.Key; import org.bukkit.NamespacedKey; @@ -32,6 +33,7 @@ public class ItemRecipeBrowserCommand extends BukkitCommandFeature assembleCommand(CommandManager manager, Command.Builder builder) { return builder .senderType(Player.class) + .flag(FlagKeys.BROWSE_FLAG) .required("id", NamespacedKeyParser.namespacedKeyComponent().suggestionProvider(new SuggestionProvider<>() { @Override public @NonNull CompletableFuture> suggestionsFuture(@NonNull CommandContext context, @NonNull CommandInput input) { @@ -46,6 +48,8 @@ public class ItemRecipeBrowserCommand extends BukkitCommandFeature> inRecipes = plugin().recipeManager().getRecipeByResult(itemId); if (!inRecipes.isEmpty()) { plugin().itemBrowserManager().openRecipePage(serverPlayer, null, inRecipes, 0, 0); + } else if (context.flags().hasFlag(FlagKeys.BROWSE)) { + plugin().itemBrowserManager().openNoRecipePage(serverPlayer, itemId, null, 0); } else { handleFeedback(context, MessageConstants.COMMAND_ITEM_RECIPE_BROWSER_RECIPE_NO_FOUND); } diff --git a/core/src/main/java/net/momirealms/craftengine/core/plugin/command/FlagKeys.java b/core/src/main/java/net/momirealms/craftengine/core/plugin/command/FlagKeys.java index 5cde8bd5c..6f55a828a 100644 --- a/core/src/main/java/net/momirealms/craftengine/core/plugin/command/FlagKeys.java +++ b/core/src/main/java/net/momirealms/craftengine/core/plugin/command/FlagKeys.java @@ -7,4 +7,6 @@ public final class FlagKeys { public static final CommandFlag SILENT_FLAG = CommandFlag.builder("silent").withAliases("s").build(); public static final String TO_INVENTORY = "to-inventory"; public static final CommandFlag TO_INVENTORY_FLAG = CommandFlag.builder("to-inventory").build(); + public static final String BROWSE = "browse"; + public static final CommandFlag BROWSE_FLAG = CommandFlag.builder("browse").withAliases("b").build(); }