11package top .mcfpp .mod .breakpoint .command ;
22
33import com .google .common .collect .Queues ;
4- import com .mojang .brigadier .CommandDispatcher ;
4+ import com .mojang .brigadier .arguments . IntegerArgumentType ;
55import net .fabricmc .fabric .api .command .v2 .CommandRegistrationCallback ;
66import net .minecraft .command .CommandExecutionContext ;
7- import net .minecraft .command .CommandRegistryAccess ;
8- import net .minecraft .server .command .CommandManager .RegistrationEnvironment ;
97import net .minecraft .server .command .CommandManager ;
108import net .minecraft .server .command .ServerCommandSource ;
119import net .minecraft .text .Text ;
12- import org .spongepowered . asm . launch . MixinBootstrap ;
10+ import org .jetbrains . annotations . NotNull ;
1311import top .mcfpp .mod .breakpoint .DatapackBreakpoint ;
12+
1413import java .util .Deque ;
15- import java .util .Locale ;
1614
1715public class BreakPointCommand {
1816
@@ -25,31 +23,30 @@ public class BreakPointCommand {
2523 public static void onInitialize () {
2624 CommandRegistrationCallback .EVENT .register ((dispatcher , registryAccess , environment ) -> {
2725 dispatcher .register (CommandManager .literal ("breakpoint" )
28- .requires (source -> source .hasPermissionLevel (2 ))
29- .executes (context -> {
30- context .getSource ().sendFeedback (() -> Text .literal ("已触发断点" ), false );
31- breakPoint (context .getSource ());
32- return 1 ;
33- })
34- .then (CommandManager .literal ("step" )
35- .executes (context -> {
36- context .getSource ().sendFeedback (() -> Text .literal ("已触发单步" ), false );
37- step (1 , context .getSource ());
38- return 1 ;
39- })
40- )
41- .then (CommandManager .literal ("move" )
42- .executes (context -> {
43- context .getSource ().sendFeedback (() -> Text .literal ("已恢复断点" ), false );
44- moveOn (context .getSource ());
45- return 1 ;
46- })
47- )
26+ .requires (source -> source .hasPermissionLevel (2 ))
27+ .executes (context -> {
28+ context .getSource ().sendFeedback (() -> Text .literal ("已触发断点" ), false );
29+ breakPoint (context .getSource ());
30+ return 1 ;
31+ })
32+ .then (CommandManager .literal ("step" )
33+ .executes (context -> {
34+ step (1 , context .getSource ());
35+ return 1 ;
36+ })
37+ )
38+ .then (CommandManager .literal ("move" )
39+ .executes (context -> {
40+ context .getSource ().sendFeedback (() -> Text .literal ("已恢复断点" ), false );
41+ moveOn (context .getSource ());
42+ return 1 ;
43+ })
44+ )
4845 );
4946 });
5047 }
5148
52- private static void breakPoint (ServerCommandSource source ) {
49+ private static void breakPoint (@ NotNull ServerCommandSource source ) {
5350 source .getServer ().getTickManager ().setFrozen (true );
5451 isDebugging = true ;
5552 }
@@ -66,7 +63,6 @@ private static void step(int steps, ServerCommandSource source) {
6663 while (moveSteps > 0 ) {
6764 context = storedCommandExecutionContext .peekFirst ();
6865 if (context != null ) {
69- LOGGER .info ("before mod invokes run()" );
7066 var cls = context .getClass ();
7167 var method = cls .getDeclaredMethod ("onStep" );
7268 method .setAccessible (true );
@@ -93,7 +89,7 @@ private static void step(int steps, ServerCommandSource source) {
9389 }
9490 }
9591
96- private static void moveOn (ServerCommandSource source ) {
92+ private static void moveOn (@ NotNull ServerCommandSource source ) {
9793 source .getServer ().getTickManager ().setFrozen (false );
9894 isDebugging = false ;
9995 moveSteps = 0 ;
0 commit comments