2020
2121package top .byteeeee .quickcommand .helpers ;
2222
23+ import com .mojang .brigadier .suggestion .SuggestionProvider ;
24+
25+ import net .fabricmc .fabric .api .client .command .v1 .FabricClientCommandSource ;
26+ import net .minecraft .command .CommandSource ;
2327import net .minecraft .entity .player .PlayerEntity ;
24- import net .minecraft .server .network . ServerPlayerEntity ;
28+ import net .minecraft .server .command . ServerCommandSource ;
2529import net .minecraft .text .MutableText ;
2630import net .minecraft .util .Formatting ;
2731
3438
3539public class QuickCommandCommandHelper {
3640 private static final Translator translator = new Translator ("command" );
41+ public static final SuggestionProvider <ServerCommandSource > SERVER_LANGUAGE_SUGGESTION = (context , builder ) -> CommandSource .suggestMatching (new String []{"en_us" , "zh_cn" }, builder );
42+ public static final SuggestionProvider <FabricClientCommandSource > CLIENT_LANGUAGE_SUGGESTION = (context , builder ) -> CommandSource .suggestMatching (new String []{"en_us" , "zh_cn" }, builder );
3743 public static final Map <String , String > QUICK_COMMAND_MAP = new LinkedHashMap <>();
3844 private static final String MSG_HEAD = EnvironmentHelper .isServer () ? "§b<ServerQuickCommand>§r " : "§b<QuickCommand>§r " ;
3945 public static boolean awaitingConfirmation = false ;
@@ -108,6 +114,7 @@ public static int showListWithRun(PlayerEntity player) {
108114 ).formatted (Formatting .AQUA , Formatting .BOLD ),
109115 false
110116 );
117+
111118 player .sendMessage (
112119 translator .tr ("setLanguageTitle" ).formatted (Formatting .LIGHT_PURPLE )
113120 .append (Messenger .endl ())
@@ -116,6 +123,7 @@ public static int showListWithRun(PlayerEntity player) {
116123 .append (QuickCommandButton .setEnglishButton ())
117124 .append (Messenger .endl ()), false
118125 );
126+
119127 player .sendMessage (translator .tr ("commandListTitle" ).formatted (Formatting .LIGHT_PURPLE ), false );
120128 if (QUICK_COMMAND_MAP .isEmpty ()) {
121129 player .sendMessage (Messenger .s ("··· ··· ···" ).formatted (Formatting .AQUA ), false );
@@ -139,6 +147,7 @@ public static int showListWithRun(PlayerEntity player) {
139147 player .sendMessage (message , false );
140148 counter ++;
141149 }
150+
142151 final String displayCommandInListMsgLine = "-----------------------------" ;
143152 player .sendMessage (
144153 Messenger .s (displayCommandInListMsgLine ).formatted (Formatting .DARK_AQUA )
@@ -151,6 +160,7 @@ public static int showListWithRun(PlayerEntity player) {
151160 .append (Messenger .endl ()),
152161 false
153162 );
163+
154164 player .sendMessage (
155165 translator .tr ("easyOperation" ).formatted (Formatting .LIGHT_PURPLE ).append (Messenger .endl ())
156166 .append (QuickCommandButton .addCommandButton ()).append (Messenger .endl ())
@@ -208,7 +218,7 @@ public static void saveToJson() {
208218 QuickCommandConfig .saveToJson (QUICK_COMMAND_MAP );
209219 }
210220
211- public static int setLanguage (ServerPlayerEntity player , String language ) {
221+ public static int setLanguage (PlayerEntity player , String language ) {
212222 List <String > availableLanguages = Arrays .asList ("zh_cn" , "en_us" );
213223 if (!availableLanguages .contains (language )) {
214224 return 0 ;
0 commit comments