99import net .fabricmc .fabric .api .command .v2 .CommandRegistrationCallback ;
1010import net .fabricmc .fabric .api .event .lifecycle .v1 .ServerLifecycleEvents ;
1111import net .fabricmc .loader .api .FabricLoader ;
12- import net .minecraft .server . command . CommandManager ;
13- import net .minecraft .server . command . ServerCommandSource ;
14- import net .minecraft .server . network .ServerPlayerEntity ;
15- import net .minecraft .text . Text ;
12+ import net .minecraft .commands . CommandSourceStack ;
13+ import net .minecraft .commands . Commands ;
14+ import net .minecraft .network .chat . Component ;
15+ import net .minecraft .server . level . ServerPlayer ;
1616import org .slf4j .LoggerFactory ;
1717
1818import java .io .IOException ;
@@ -38,30 +38,30 @@ public void onInitializeServer() {
3838 core .init (this );
3939
4040 CommandRegistrationCallback .EVENT .register ((dispatcher , registryAccess , environment ) ->
41- dispatcher .register (CommandManager .literal ("auth" )
42- .then (CommandManager .argument ("token" , StringArgumentType .string ())
41+ dispatcher .register (Commands .literal ("auth" )
42+ .then (Commands .argument ("token" , StringArgumentType .string ())
4343 .executes (ctx -> {
44- ServerCommandSource source = ctx .getSource ();
45- ServerPlayerEntity player ;
44+ CommandSourceStack source = ctx .getSource ();
45+ ServerPlayer player ;
4646 try {
47- player = source .getPlayerOrThrow ();
47+ player = source .getPlayerOrException ();
4848 } catch (Exception e ) {
49- source .sendFeedback (() -> Text .literal ("This command can only be used by players" ), false );
49+ source .sendSuccess (() -> Component .literal ("This command can only be used by players" ), false );
5050 return 0 ;
5151 }
5252 String token = StringArgumentType .getString (ctx , "token" );
5353 try {
54- String msg = core .handleAuthCommand (player .getUuid (), player .getName ().getString (), token );
54+ String msg = core .handleAuthCommand (player .getUUID (), player .getName ().getString (), token );
5555 if (msg != null ) {
56- source .sendFeedback (() -> Text .literal (msg ), false );
56+ source .sendSuccess (() -> Component .literal (msg ), false );
5757 return 1 ;
5858 } else {
59- source .sendFeedback (() -> Text .literal ("Verification failed, check that you typed the authentication token correctly" ), false );
59+ source .sendSuccess (() -> Component .literal ("Verification failed, check that you typed the authentication token correctly" ), false );
6060 return 0 ;
6161 }
6262 } catch (SQLException e ) {
6363 getLogger ().severe ("Failed to verify player session: " + e .getMessage ());
64- source .sendFeedback (() -> Text .literal ("Something went wrong" ), false );
64+ source .sendSuccess (() -> Component .literal ("Something went wrong" ), false );
6565 return 0 ;
6666 }
6767 })
0 commit comments