1313import com .mojang .brigadier .tree .CommandNode ;
1414import net .fabricmc .fabric .api .client .command .v2 .ClientCommandRegistrationCallback ;
1515import net .fabricmc .fabric .api .client .command .v2 .FabricClientCommandSource ;
16- import net .fabricmc .loader .api .FabricLoader ;
17- import net .fabricmc .loader .api .ModContainer ;
1816import net .minecraft .command .argument .IdentifierArgumentType ;
1917import net .minecraft .text .Text ;
2018import net .minecraft .util .Identifier ;
2826import net .modfest .scatteredshards .client .screen .ShardCreatorGuiDescription ;
2927import net .modfest .scatteredshards .client .screen .ShardTabletGuiDescription ;
3028import net .modfest .scatteredshards .command .ShardCommand ;
29+ import net .modfest .scatteredshards .command .ShardCommandNodeHelper ;
3130
3231import java .util .Optional ;
3332import java .util .Set ;
@@ -95,19 +94,19 @@ public static int shards(CommandContext<FabricClientCommandSource> context) thro
9594 return Command .SINGLE_SUCCESS ;
9695 }
9796
98- public static CompletableFuture <Suggestions > suggestShardSets (CommandContext <FabricClientCommandSource > context , SuggestionsBuilder builder ) {
97+ private static CompletableFuture <Suggestions > suggestShardSets (CommandContext <FabricClientCommandSource > context , SuggestionsBuilder builder ) {
9998 for (Identifier id : ScatteredShardsAPI .getClientLibrary ().shardSets ().keySet ()) {
10099 builder .suggest (id .toString ());
101100 }
102101 return builder .buildFuture ();
103102 }
104103
105- public static CompletableFuture <Suggestions > suggestShards (CommandContext <FabricClientCommandSource > context , SuggestionsBuilder builder ) {
104+ private static CompletableFuture <Suggestions > suggestShards (CommandContext <FabricClientCommandSource > context , SuggestionsBuilder builder ) {
106105 ScatteredShardsAPI .getClientLibrary ().shards ().forEach ((id , shard ) -> builder .suggest (id .toString ()));
107106 return builder .buildFuture ();
108107 }
109108
110- public static CompletableFuture <Suggestions > suggestShardTypes (CommandContext <FabricClientCommandSource > context , SuggestionsBuilder builder ) {
109+ static CompletableFuture <Suggestions > suggestShardTypes (CommandContext <FabricClientCommandSource > context , SuggestionsBuilder builder ) {
111110 ScatteredShardsAPI .getClientLibrary ().shardTypes ().forEach ((id , shardSet ) -> {
112111 if (!id .equals (ShardType .MISSING_ID )) {
113112 builder .suggest (id .toString ());
@@ -116,22 +115,15 @@ public static CompletableFuture<Suggestions> suggestShardTypes(CommandContext<Fa
116115 return builder .buildFuture ();
117116 }
118117
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 ) {
127119 return LiteralArgumentBuilder .literal (name );
128120 }
129121
130- private static RequiredArgumentBuilder <FabricClientCommandSource , Identifier > identifierArgument (String name ) {
122+ static RequiredArgumentBuilder <FabricClientCommandSource , Identifier > identifierArgument (String name ) {
131123 return RequiredArgumentBuilder .argument (name , IdentifierArgumentType .identifier ());
132124 }
133125
134- private static RequiredArgumentBuilder <FabricClientCommandSource , String > stringArgument (String name ) {
126+ static RequiredArgumentBuilder <FabricClientCommandSource , String > stringArgument (String name ) {
135127 return RequiredArgumentBuilder .argument (name , StringArgumentType .string ());
136128 }
137129
@@ -151,7 +143,7 @@ public static void register() {
151143 CommandNode <FabricClientCommandSource > creator = literal ("creator" ).requires ((source ) -> source .hasPermissionLevel (2 )).build ();
152144 CommandNode <FabricClientCommandSource > creatorNew = literal ("new" ).build ();
153145 CommandNode <FabricClientCommandSource > modId = stringArgument ("mod_id" )
154- .suggests (ClientShardCommand ::suggestModIds )
146+ .suggests (ShardCommandNodeHelper ::suggestModIds )
155147 .build ();
156148 CommandNode <FabricClientCommandSource > shardType = identifierArgument ("shard_type" )
157149 .suggests (ClientShardCommand ::suggestShardTypes )
@@ -176,6 +168,8 @@ public static void register() {
176168 creator .addChild (creatorEdit );
177169 creatorEdit .addChild (shardId );
178170
171+ CreateInstantCommand .register (creator );
172+
179173 dispatcher .getRoot ().addChild (shardsCommand );
180174 });
181175 }
0 commit comments