13
13
import com .mojang .brigadier .tree .CommandNode ;
14
14
import net .fabricmc .fabric .api .client .command .v2 .ClientCommandRegistrationCallback ;
15
15
import net .fabricmc .fabric .api .client .command .v2 .FabricClientCommandSource ;
16
- import net .fabricmc .loader .api .FabricLoader ;
17
- import net .fabricmc .loader .api .ModContainer ;
18
16
import net .minecraft .command .argument .IdentifierArgumentType ;
19
17
import net .minecraft .text .Text ;
20
18
import net .minecraft .util .Identifier ;
28
26
import net .modfest .scatteredshards .client .screen .ShardCreatorGuiDescription ;
29
27
import net .modfest .scatteredshards .client .screen .ShardTabletGuiDescription ;
30
28
import net .modfest .scatteredshards .command .ShardCommand ;
29
+ import net .modfest .scatteredshards .command .ShardCommandNodeHelper ;
31
30
32
31
import java .util .Optional ;
33
32
import java .util .Set ;
@@ -95,19 +94,19 @@ public static int shards(CommandContext<FabricClientCommandSource> context) thro
95
94
return Command .SINGLE_SUCCESS ;
96
95
}
97
96
98
- public static CompletableFuture <Suggestions > suggestShardSets (CommandContext <FabricClientCommandSource > context , SuggestionsBuilder builder ) {
97
+ private static CompletableFuture <Suggestions > suggestShardSets (CommandContext <FabricClientCommandSource > context , SuggestionsBuilder builder ) {
99
98
for (Identifier id : ScatteredShardsAPI .getClientLibrary ().shardSets ().keySet ()) {
100
99
builder .suggest (id .toString ());
101
100
}
102
101
return builder .buildFuture ();
103
102
}
104
103
105
- public static CompletableFuture <Suggestions > suggestShards (CommandContext <FabricClientCommandSource > context , SuggestionsBuilder builder ) {
104
+ private static CompletableFuture <Suggestions > suggestShards (CommandContext <FabricClientCommandSource > context , SuggestionsBuilder builder ) {
106
105
ScatteredShardsAPI .getClientLibrary ().shards ().forEach ((id , shard ) -> builder .suggest (id .toString ()));
107
106
return builder .buildFuture ();
108
107
}
109
108
110
- public static CompletableFuture <Suggestions > suggestShardTypes (CommandContext <FabricClientCommandSource > context , SuggestionsBuilder builder ) {
109
+ static CompletableFuture <Suggestions > suggestShardTypes (CommandContext <FabricClientCommandSource > context , SuggestionsBuilder builder ) {
111
110
ScatteredShardsAPI .getClientLibrary ().shardTypes ().forEach ((id , shardSet ) -> {
112
111
if (!id .equals (ShardType .MISSING_ID )) {
113
112
builder .suggest (id .toString ());
@@ -116,22 +115,15 @@ public static CompletableFuture<Suggestions> suggestShardTypes(CommandContext<Fa
116
115
return builder .buildFuture ();
117
116
}
118
117
119
- public static CompletableFuture <Suggestions > suggestModIds (CommandContext <FabricClientCommandSource > context , SuggestionsBuilder builder ) {
120
- for (ModContainer mod : FabricLoader .getInstance ().getAllMods ()) {
121
- builder .suggest (mod .getMetadata ().getId ());
122
- }
123
- return builder .buildFuture ();
124
- }
125
-
126
- private static LiteralArgumentBuilder <FabricClientCommandSource > literal (String name ) {
118
+ static LiteralArgumentBuilder <FabricClientCommandSource > literal (String name ) {
127
119
return LiteralArgumentBuilder .literal (name );
128
120
}
129
121
130
- private static RequiredArgumentBuilder <FabricClientCommandSource , Identifier > identifierArgument (String name ) {
122
+ static RequiredArgumentBuilder <FabricClientCommandSource , Identifier > identifierArgument (String name ) {
131
123
return RequiredArgumentBuilder .argument (name , IdentifierArgumentType .identifier ());
132
124
}
133
125
134
- private static RequiredArgumentBuilder <FabricClientCommandSource , String > stringArgument (String name ) {
126
+ static RequiredArgumentBuilder <FabricClientCommandSource , String > stringArgument (String name ) {
135
127
return RequiredArgumentBuilder .argument (name , StringArgumentType .string ());
136
128
}
137
129
@@ -151,7 +143,7 @@ public static void register() {
151
143
CommandNode <FabricClientCommandSource > creator = literal ("creator" ).requires ((source ) -> source .hasPermissionLevel (2 )).build ();
152
144
CommandNode <FabricClientCommandSource > creatorNew = literal ("new" ).build ();
153
145
CommandNode <FabricClientCommandSource > modId = stringArgument ("mod_id" )
154
- .suggests (ClientShardCommand ::suggestModIds )
146
+ .suggests (ShardCommandNodeHelper ::suggestModIds )
155
147
.build ();
156
148
CommandNode <FabricClientCommandSource > shardType = identifierArgument ("shard_type" )
157
149
.suggests (ClientShardCommand ::suggestShardTypes )
@@ -176,6 +168,8 @@ public static void register() {
176
168
creator .addChild (creatorEdit );
177
169
creatorEdit .addChild (shardId );
178
170
171
+ CreateInstantCommand .register (creator );
172
+
179
173
dispatcher .getRoot ().addChild (shardsCommand );
180
174
});
181
175
}
0 commit comments