From 20d032682805eab6951dfda1368cf5d0f5cb1080 Mon Sep 17 00:00:00 2001
From: jhqwqmc <2110242767@qq.com>
Date: Sun, 16 Mar 2025 18:53:37 +0800
Subject: [PATCH 01/10] =?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
---
bukkit-loader/src/main/resources/commands.yml | 14 +++++
.../src/main/resources/translations/en.yml | 3 +-
.../src/main/resources/translations/es.yml | 1 +
.../src/main/resources/translations/zh_cn.yml | 1 +
.../src/main/resources/translations/zh_tw.yml | 1 +
.../plugin/command/BukkitCommandManager.java | 2 +
.../feature/ItemRecipeBrowserCommand.java | 58 ++++++++++++++++++
.../feature/ItemUsageBrowserCommand.java | 59 +++++++++++++++++++
.../plugin/user/BukkitServerPlayer.java | 5 ++
.../core/entity/player/Player.java | 2 +
.../gui/category/ItemBrowserManager.java | 6 ++
.../gui/category/ItemBrowserManagerImpl.java | 34 +++++++++--
.../core/plugin/locale/MessageConstants.java | 1 +
gradle.properties | 4 +-
14 files changed, 182 insertions(+), 9 deletions(-)
create mode 100644 bukkit/src/main/java/net/momirealms/craftengine/bukkit/plugin/command/feature/ItemRecipeBrowserCommand.java
create mode 100644 bukkit/src/main/java/net/momirealms/craftengine/bukkit/plugin/command/feature/ItemUsageBrowserCommand.java
diff --git a/bukkit-loader/src/main/resources/commands.yml b/bukkit-loader/src/main/resources/commands.yml
index 02e9b64c1..fb536fccc 100644
--- a/bukkit-loader/src/main/resources/commands.yml
+++ b/bukkit-loader/src/main/resources/commands.yml
@@ -38,6 +38,20 @@ item_browser:
- /ce item browser
- /ce
+item_recipe_browser:
+ enable: true
+ permission: ce.command.item_recipe_browser
+ usage:
+ - /craftengine item recipe
+ - /ce item recipe
+
+item_usage_browser:
+ enable: true
+ permission: ce.command.item_usage_browser
+ usage:
+ - /craftengine item usage
+ - /ce item usage
+
# Debug commands
debug_set_block:
enable: true
diff --git a/bukkit-loader/src/main/resources/translations/en.yml b/bukkit-loader/src/main/resources/translations/en.yml
index a0e77f1fa..ba6ea921f 100644
--- a/bukkit-loader/src/main/resources/translations/en.yml
+++ b/bukkit-loader/src/main/resources/translations/en.yml
@@ -48,4 +48,5 @@ command.item.get.success: "Got "
command.item.get.failure.not_exist: "'>"
command.item.give.success.single: "':'':''>"
command.item.give.success.multiple: "':'':''>"
-command.item.give.failure.not_exist: "'>"
\ No newline at end of file
+command.item.give.failure.not_exist: "'>"
+command.item.usage.browser.recipe.no_found: "No usage found for this item"
\ No newline at end of file
diff --git a/bukkit-loader/src/main/resources/translations/es.yml b/bukkit-loader/src/main/resources/translations/es.yml
index 4517db462..7c4d9cbe3 100644
--- a/bukkit-loader/src/main/resources/translations/es.yml
+++ b/bukkit-loader/src/main/resources/translations/es.yml
@@ -49,3 +49,4 @@ command.item.get.failure.not_exist: "':'':''>"
command.item.give.success.multiple: "':'':''>"
command.item.give.failure.not_exist: "'>"
+command.item.usage.browser.recipe.no_found: "No usage found for this item"
\ No newline at end of file
diff --git a/bukkit-loader/src/main/resources/translations/zh_cn.yml b/bukkit-loader/src/main/resources/translations/zh_cn.yml
index 1375301c7..5af0fef1b 100644
--- a/bukkit-loader/src/main/resources/translations/zh_cn.yml
+++ b/bukkit-loader/src/main/resources/translations/zh_cn.yml
@@ -49,3 +49,4 @@ command.item.get.failure.not_exist: "':'':''>"
command.item.give.success.multiple: "':'':''>"
command.item.give.failure.not_exist: "'>"
+command.item.usage.browser.recipe.no_found: "找不到此物品的用法"
\ No newline at end of file
diff --git a/bukkit-loader/src/main/resources/translations/zh_tw.yml b/bukkit-loader/src/main/resources/translations/zh_tw.yml
index d38e5b80c..26f5aec3b 100644
--- a/bukkit-loader/src/main/resources/translations/zh_tw.yml
+++ b/bukkit-loader/src/main/resources/translations/zh_tw.yml
@@ -49,3 +49,4 @@ command.item.get.failure.not_exist: "':'':''>"
command.item.give.success.multiple: "':'':''>"
command.item.give.failure.not_exist: "'>"
+command.item.usage.browser.recipe.no_found: "找不到此物品的用法"
\ No newline at end of file
diff --git a/bukkit/src/main/java/net/momirealms/craftengine/bukkit/plugin/command/BukkitCommandManager.java b/bukkit/src/main/java/net/momirealms/craftengine/bukkit/plugin/command/BukkitCommandManager.java
index 9553c3c45..54d5523cd 100644
--- a/bukkit/src/main/java/net/momirealms/craftengine/bukkit/plugin/command/BukkitCommandManager.java
+++ b/bukkit/src/main/java/net/momirealms/craftengine/bukkit/plugin/command/BukkitCommandManager.java
@@ -32,6 +32,8 @@ public class BukkitCommandManager extends AbstractCommandManager
new GetItemCommand(this, plugin),
new GiveItemCommand(this, plugin),
new ItemBrowserCommand(this, plugin),
+ new ItemRecipeBrowserCommand(this, plugin),
+ new ItemUsageBrowserCommand(this, plugin),
new TestCommand(this, plugin),
new DebugGetBlockStateRegistryIdCommand(this, plugin),
new DebugGetBlockInternalIdCommand(this, plugin),
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
new file mode 100644
index 000000000..3389898fe
--- /dev/null
+++ b/bukkit/src/main/java/net/momirealms/craftengine/bukkit/plugin/command/feature/ItemRecipeBrowserCommand.java
@@ -0,0 +1,58 @@
+package net.momirealms.craftengine.bukkit.plugin.command.feature;
+
+import net.momirealms.craftengine.bukkit.plugin.command.BukkitCommandFeature;
+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.util.Key;
+import org.bukkit.NamespacedKey;
+import org.bukkit.command.CommandSender;
+import org.bukkit.entity.Player;
+import org.checkerframework.checker.nullness.qual.NonNull;
+import org.incendo.cloud.Command;
+import org.incendo.cloud.CommandManager;
+import org.incendo.cloud.bukkit.parser.NamespacedKeyParser;
+import org.incendo.cloud.context.CommandContext;
+import org.incendo.cloud.context.CommandInput;
+import org.incendo.cloud.suggestion.Suggestion;
+import org.incendo.cloud.suggestion.SuggestionProvider;
+
+import java.util.List;
+import java.util.concurrent.CompletableFuture;
+
+public class ItemRecipeBrowserCommand extends BukkitCommandFeature {
+
+ public ItemRecipeBrowserCommand(CraftEngineCommandManager commandManager, CraftEngine plugin) {
+ super(commandManager, plugin);
+ }
+
+ @Override
+ public Command.Builder extends CommandSender> assembleCommand(CommandManager manager, Command.Builder builder) {
+ return builder
+ .senderType(Player.class)
+ .required("id", NamespacedKeyParser.namespacedKeyComponent().suggestionProvider(new SuggestionProvider<>() {
+ @Override
+ public @NonNull CompletableFuture extends @NonNull Iterable extends @NonNull Suggestion>> suggestionsFuture(@NonNull CommandContext