1010import java .util .Collections ;
1111import java .util .List ;
1212
13+ import com .mojang .brigadier .CommandDispatcher ;
14+ import net .fabricmc .fabric .api .client .command .v2 .FabricClientCommandSource ;
1315import org .lwjgl .glfw .GLFW ;
1416
1517import com .coflnet .gui .RenderUtils ;
@@ -167,49 +169,8 @@ public void onInitializeClient() {
167169 });
168170
169171 ClientCommandRegistrationCallback .EVENT .register ((dispatcher , registryAccess ) -> {
170- dispatcher .register (ClientCommandManager .literal ("cofl" )
171- .then (ClientCommandManager .argument ("args" , StringArgumentType .greedyString ())
172- .suggests ((context , builder ) -> {
173- String input = context .getInput ();
174- String [] inputArgs = input .split (" " );
175-
176- String [] suggestions = {"start" , "stop" , "report" , "online" , "delay" , "blacklist" , "bl" , "whitelist" , "wl" ,
177- "mute" , "blocked" , "chat" , "c" , "nickname" , "nick" , "profit" , "worstflips" , "bestflips" ,
178- "leaderboard" , "lb" , "loserboard" , "buyspeedboard" , "trades" , "flips" , "set" , "s" ,
179- "purchase" , "buy" , "transactions" , "balance" , "help" , "h" , "logout" , "backup" , "restore" ,
180- "captcha" , "importtfm" , "replayactive" , "reminder" , "filters" , "emoji" , "addremindertime" ,
181- "lore" , "fact" , "flip" , "preapi" , "transfercoins" , "ping" , "setgui" , "bazaar" , "bz" ,
182- "switchregion" , "craftbreakdown" , "cheapattrib" , "ca" , "attributeupgrade" , "au" , "ownconfigs" ,
183- "configs" , "config" , "licenses" , "license" , "verify" , "unverify" , "attributeflip" , "forge" ,
184- "crafts" , "craft" , "upgradeplan" , "updatecurrentconfig" , "settimezone" , "cheapmuseum" , "cm" ,
185- "replayflips" , "lowball" , "ahtax" , "sethotkey" };
186-
187-
188- // Check if the command is "s" or "set" and suggest specific subcommands
189- if (inputArgs .length >= 2 && (inputArgs [1 ].equals ("s" ) || inputArgs [1 ].equals ("set" ))) {
190- suggestions = new String [] {"lbin" , "finders" , "onlyBin" , "whitelistAftermain" , "DisableFlips" ,
191- "DebugMode" , "blockHighCompetition" , "minProfit" , "minProfitPercent" , "minVolume" , "maxCost" ,
192- "modjustProfit" , "modsoundOnFlip" , "modshortNumbers" , "modshortNames" , "modblockTenSecMsg" ,
193- "modformat" , "modblockedFormat" , "modchat" , "modcountdown" , "modhideNoBestFlip" , "modtimerX" ,
194- "modtimerY" , "modtimerSeconds" , "modtimerScale" , "modtimerPrefix" , "modtimerPrecision" ,
195- "modblockedMsg" , "modmaxPercentOfPurse" , "modnoBedDelay" , "modstreamerMode" , "modautoStartFlipper" ,
196- "modnormalSoldFlips" , "modtempBlacklistSpam" , "moddataOnlyMode" , "modahListHours" , "modquickSell" ,
197- "modmaxItemsInInventory" , "moddisableSpamProtection" , "showcost" , "showestProfit" , "showlbin" ,
198- "showslbin" , "showmedPrice" , "showseller" , "showvolume" , "showextraFields" , "showprofitPercent" ,
199- "showprofit" , "showsellerOpenBtn" , "showlore" , "showhideSold" , "showhideManipulated" ,
200- "privacyExtendDescriptions" , "privacyAutoStart" , "loreHighlightFilterMatch" ,
201- "loreMinProfitForHighlight" , "loreDisableHighlighting" };
202- }
203- for (String suggestion : suggestions ) {
204- builder .suggest (suggestion );
205- }
206- return builder .buildFuture ();
207- })
208- .executes (context -> {
209- String [] args = context .getArgument ("args" , String .class ).split (" " );
210- CoflSkyCommand .processCommand (args , username );
211- return 1 ;
212- })));
172+ registerDefaultCommands (dispatcher , "cofl" );
173+ registerDefaultCommands (dispatcher , "cl" );
213174 dispatcher .register (ClientCommandManager .literal ("fc" )
214175 .then (ClientCommandManager .argument ("args" , StringArgumentType .greedyString ())
215176 .suggests ((context , builder ) -> {
@@ -221,8 +182,14 @@ public void onInitializeClient() {
221182 ":fyou:" , ":angwyflip:" , ":snipe:" , ":preapi:" , ":tm:" , ":r:" , ":c:" , ":crown:" , ":fire:" ,
222183 ":sword:" , ":shield:" , ":cross:" , ":star1:" , ":star2:" , ":star3:" , ":star4:" , ":rich:" , ":boop:" ,
223184 ":yay:" , ":gg:" };
185+ String input = context .getInput ();
186+ String [] inputParts = input .split (" " );
187+ String currentWord = inputParts .length > 0 ? inputParts [inputParts .length - 1 ] : "" ;
188+
224189 for (String suggestion : suggestions ) {
225- builder .suggest (suggestion , new TooltipMessage ("Will be replaced with the emoji" ));
190+ if (suggestion .toLowerCase ().startsWith (currentWord .toLowerCase ())) {
191+ builder .suggest (suggestion , new TooltipMessage ("Will be replaced with the emoji" ));
192+ }
226193 }
227194 return builder .buildFuture ();
228195 })
@@ -330,6 +297,55 @@ public void onInitializeClient() {
330297 });
331298 }
332299
300+ private void registerDefaultCommands (CommandDispatcher <FabricClientCommandSource > dispatcher , String name ) {
301+ dispatcher .register (ClientCommandManager .literal (name )
302+ .then (ClientCommandManager .argument ("args" , StringArgumentType .greedyString ())
303+ .suggests ((context , builder ) -> {
304+ String input = context .getInput ();
305+ String [] inputArgs = input .split (" " );;
306+ String currentWord = inputArgs .length > 0 ? inputArgs [inputArgs .length - 1 ] : "" ;
307+
308+ String [] suggestions = {"start" , "stop" , "vps" , "report" , "online" , "delay" , "blacklist" , "bl" , "whitelist" , "wl" ,
309+ "mute" , "blocked" , "chat" , "c" , "nickname" , "nick" , "profit" , "worstflips" , "bestflips" ,
310+ "leaderboard" , "lb" , "loserboard" , "buyspeedboard" , "trades" , "flips" , "set" , "s" ,
311+ "purchase" , "buy" , "transactions" , "balance" , "help" , "h" , "logout" , "backup" , "restore" ,
312+ "captcha" , "importtfm" , "replayactive" , "reminder" , "filters" , "emoji" , "addremindertime" ,
313+ "lore" , "fact" , "flip" , "preapi" , "transfercoins" , "ping" , "setgui" , "bazaar" , "bz" ,
314+ "switchregion" , "craftbreakdown" , "cheapattrib" , "ca" , "attributeupgrade" , "au" , "ownconfigs" ,
315+ "configs" , "config" , "licenses" , "license" , "verify" , "unverify" , "attributeflip" , "forge" ,
316+ "crafts" , "craft" , "upgradeplan" , "updatecurrentconfig" , "settimezone" , "cheapmuseum" , "cm" ,
317+ "replayflips" , "lowball" , "ahtax" , "sethotkey" };
318+
319+
320+ // Check if the command is "s" or "set" and suggest specific subcommands
321+ if (inputArgs .length == 2 && (inputArgs [1 ].equals ("s" ) || inputArgs [1 ].equals ("set" ))) {
322+ suggestions = new String [] {"lbin" , "finders" , "onlyBin" , "whitelistAftermain" , "DisableFlips" ,
323+ "DebugMode" , "blockHighCompetition" , "minProfit" , "minProfitPercent" , "minVolume" , "maxCost" ,
324+ "modjustProfit" , "modsoundOnFlip" , "modshortNumbers" , "modshortNames" , "modblockTenSecMsg" ,
325+ "modformat" , "modblockedFormat" , "modchat" , "modcountdown" , "modhideNoBestFlip" , "modtimerX" ,
326+ "modtimerY" , "modtimerSeconds" , "modtimerScale" , "modtimerPrefix" , "modtimerPrecision" ,
327+ "modblockedMsg" , "modmaxPercentOfPurse" , "modnoBedDelay" , "modstreamerMode" , "modautoStartFlipper" ,
328+ "modnormalSoldFlips" , "modtempBlacklistSpam" , "moddataOnlyMode" , "modahListHours" , "modquickSell" ,
329+ "modmaxItemsInInventory" , "moddisableSpamProtection" , "showcost" , "showestProfit" , "showlbin" ,
330+ "showslbin" , "showmedPrice" , "showseller" , "showvolume" , "showextraFields" , "showprofitPercent" ,
331+ "showprofit" , "showsellerOpenBtn" , "showlore" , "showhideSold" , "showhideManipulated" ,
332+ "privacyExtendDescriptions" , "privacyAutoStart" , "loreHighlightFilterMatch" ,
333+ "loreMinProfitForHighlight" , "loreDisableHighlighting" };
334+ } else if (inputArgs .length > 1 )
335+ return builder .buildFuture ();
336+ for (String suggestion : suggestions ) {
337+ if (suggestion .toLowerCase ().startsWith (currentWord .toLowerCase ()))
338+ builder .suggest (suggestion );
339+ }
340+ return builder .buildFuture ();
341+ })
342+ .executes (context -> {
343+ String [] args = context .getArgument ("args" , String .class ).split (" " );
344+ CoflSkyCommand .processCommand (args , username );
345+ return 1 ;
346+ })));
347+ }
348+
333349 private void handleGetHoveredItem (MinecraftClient client ) {
334350 uploadItem (client .player .getInventory ().getStack (client .player .getInventory ().getSelectedSlot ()));
335351 }
0 commit comments