Skip to content

Commit

Permalink
#20240808.0
Browse files Browse the repository at this point in the history
  • Loading branch information
LemonCaramel committed Aug 8, 2024
1 parent 9ec7f28 commit b5c89ca
Showing 1 changed file with 27 additions and 4 deletions.
31 changes: 27 additions & 4 deletions patches/0003-Add-Brigadier-Command-API.patch
Original file line number Diff line number Diff line change
Expand Up @@ -702,10 +702,10 @@ index 0000000000000000000000000000000000000000..abf12ad7215553b85709c39bad0292b0
+}
diff --git a/src/main/java/moe/caramel/daydream/brigadier/BrigadierCommand.java b/src/main/java/moe/caramel/daydream/brigadier/BrigadierCommand.java
new file mode 100644
index 0000000000000000000000000000000000000000..56338bbfca08443b8899f4a6fc93aa44222011c9
index 0000000000000000000000000000000000000000..d03177b2304f6d1d3af9c7958b961bd6654ad295
--- /dev/null
+++ b/src/main/java/moe/caramel/daydream/brigadier/BrigadierCommand.java
@@ -0,0 +1,230 @@
@@ -0,0 +1,253 @@
+package moe.caramel.daydream.brigadier;
+
+import com.mojang.brigadier.CommandDispatcher;
Expand All @@ -727,6 +727,7 @@ index 0000000000000000000000000000000000000000..56338bbfca08443b8899f4a6fc93aa44
+import java.util.List;
+import java.util.Map;
+import java.util.concurrent.CompletableFuture;
+import java.util.function.BiConsumer;
+import java.util.function.Consumer;
+import java.util.function.Supplier;
+
Expand Down Expand Up @@ -864,9 +865,20 @@ index 0000000000000000000000000000000000000000..56338bbfca08443b8899f4a6fc93aa44
+ */
+ @NotNull
+ public static SuggestionProvider<CommandSourceStack> suggest(final @NotNull Consumer<Collection<String>> strings) {
+ return suggest((source, list) -> strings.accept(list));
+ }
+
+ /**
+ * (동적) 명령어 제안을 생성합니다.
+ *
+ * @param strings 제안 목록
+ * @return 생성된 제안 프로바이더
+ */
+ @NotNull
+ public static SuggestionProvider<CommandSourceStack> suggest(final @NotNull BiConsumer<CommandSourceStack, Collection<String>> strings) {
+ return (c, b) -> {
+ final List<String> list = new ArrayList<>();
+ strings.accept(list);
+ strings.accept(c.getSource(), list);
+ return suggest(b, list);
+ };
+ }
Expand All @@ -890,9 +902,20 @@ index 0000000000000000000000000000000000000000..56338bbfca08443b8899f4a6fc93aa44
+ */
+ @NotNull
+ public static SuggestionProvider<CommandSourceStack> hoverSuggest(final @NotNull Consumer<Map<String, Component>> suggestions) {
+ return hoverSuggest((source, map) -> suggestions.accept(map));
+ }
+
+ /**
+ * (동적) 툴팁이 포함된 명령어 제안을 생성합니다.
+ *
+ * @param suggestions 툴팁이 포함된 제안 목록
+ * @return 생성된 제안 프로바이더
+ */
+ @NotNull
+ public static SuggestionProvider<CommandSourceStack> hoverSuggest(final @NotNull BiConsumer<CommandSourceStack, Map<String, Component>> suggestions) {
+ return (c, b) -> {
+ final Map<String, Component> map = new HashMap<>();
+ suggestions.accept(map);
+ suggestions.accept(c.getSource(), map);
+ return suggest(b, map);
+ };
+ }
Expand Down

0 comments on commit b5c89ca

Please sign in to comment.