File tree Expand file tree Collapse file tree 9 files changed +43
-7
lines changed
src/main/java/dev/loat/command Expand file tree Collapse file tree 9 files changed +43
-7
lines changed Original file line number Diff line number Diff line change @@ -32,11 +32,9 @@ public static void register() {
3232 .then (Commands .literal (Abort .COMMAND ).executes (Abort ::execute ))
3333 .then (Commands .literal (List .COMMAND ).executes (List ::execute ))
3434 .then (Commands .literal (Info .COMMAND )
35- .then (Commands .argument (Info .ARGUMENT , StringArgumentType .string ()).suggests (new BackupFiles ()).executes (Restore ::execute ))
35+ .then (Commands .argument (Info .ARGUMENT , StringArgumentType .string ()).suggests (new BackupFiles ()).executes (Info ::execute ))
3636 )
3737 .then (Commands .literal (Cleanup .COMMAND ).executes (Cleanup ::execute ))
3838 ));
3939 }
4040}
41-
42-
Original file line number Diff line number Diff line change 11package dev .loat .command .sub_command ;
22
33import com .mojang .brigadier .context .CommandContext ;
4+
5+ import dev .loat .logging .Logger ;
46import net .minecraft .commands .CommandSourceStack ;
57import net .minecraft .network .chat .Component ;
8+ import net .minecraft .world .entity .player .Player ;
69
710
811public final class Abort {
912 public static final String COMMAND = "abort" ;
1013
1114 public static int execute (CommandContext <CommandSourceStack > context ) {
15+ String playerName ;
16+
17+ if (context .getSource ().getEntity () instanceof Player ) {
18+ playerName = context .getSource ().getPlayer ().getName ().getString ();
19+ } else {
20+ playerName = "Console" ;
21+ }
22+
23+ Logger .info ("[%s] Aborting current action" .formatted (playerName ));
24+
1225 context .getSource ().sendSuccess (() -> Component .literal ("/backup abort" ), false );
1326 return 1 ;
1427 }
Original file line number Diff line number Diff line change 11package dev .loat .command .sub_command ;
22
33import com .mojang .brigadier .context .CommandContext ;
4+
5+ import dev .loat .logging .Logger ;
46import net .minecraft .commands .CommandSourceStack ;
57import net .minecraft .network .chat .Component ;
68
@@ -9,6 +11,8 @@ public final class Cleanup {
911 public static final String COMMAND = "cleanup" ;
1012
1113 public static int execute (CommandContext <CommandSourceStack > context ) {
14+ Logger .info ("Running cleanup process" );
15+
1216 context .getSource ().sendSuccess (() -> Component .literal ("/backup cleanup" ), false );
1317 return 1 ;
1418 }
Original file line number Diff line number Diff line change @@ -16,13 +16,14 @@ public final class Create extends Command {
1616 @ SuppressWarnings ("null" )
1717 public static int execute (CommandContext <CommandSourceStack > context ) {
1818 String comment ;
19+ String playerName = context .getSource ().getPlayer ().getName ().getString ();
1920
2021 if (Create .hasArgument (context , Create .ARGUMENT )) {
2122 comment = StringArgumentType .getString (context , Create .ARGUMENT );
22- Logger .info ("Creating new backup with comment \" %s\" " .formatted (comment ));
23+ Logger .info ("[%s] Creating new backup with comment \" %s\" " .formatted (playerName , comment ));
2324 } else {
2425 comment = "" ;
25- Logger .info ("Creating new backup" );
26+ Logger .info ("[%s] Creating new backup" . formatted ( playerName ) );
2627 }
2728
2829 context .getSource ().sendSuccess (() -> Component .literal ("/backup create \" %s\" " .formatted (comment )), false );
Original file line number Diff line number Diff line change 11package dev .loat .command .sub_command ;
22
33import com .mojang .brigadier .context .CommandContext ;
4+
5+ import dev .loat .logging .Logger ;
46import net .minecraft .commands .CommandSourceStack ;
57import net .minecraft .network .chat .Component ;
68
@@ -9,6 +11,8 @@ public final class Help {
911 public static final String COMMAND = "help" ;
1012
1113 public static int execute (CommandContext <CommandSourceStack > context ) {
14+ Logger .info ("Getting help" );
15+
1216 context .getSource ().sendSuccess (() -> Component .literal ("/backup help" ), false );
1317 return 1 ;
1418 }
Original file line number Diff line number Diff line change 11package dev .loat .command .sub_command ;
22
3+ import com .mojang .brigadier .arguments .StringArgumentType ;
34import com .mojang .brigadier .context .CommandContext ;
5+
6+ import dev .loat .logging .Logger ;
47import net .minecraft .commands .CommandSourceStack ;
58import net .minecraft .network .chat .Component ;
69
@@ -9,8 +12,13 @@ public final class Info {
912 public static final String COMMAND = "info" ;
1013 public static final String ARGUMENT = "name" ;
1114
15+ @ SuppressWarnings ("null" )
1216 public static int execute (CommandContext <CommandSourceStack > context ) {
13- context .getSource ().sendSuccess (() -> Component .literal ("/backup info" ), false );
17+ String name = StringArgumentType .getString (context , Info .ARGUMENT );
18+
19+ Logger .info ("Getting info about existing backup \" %s\" " .formatted (name ));
20+
21+ context .getSource ().sendSuccess (() -> Component .literal ("/backup info \" %s\" " .formatted (name )), false );
1422 return 1 ;
1523 }
1624}
Original file line number Diff line number Diff line change 11package dev .loat .command .sub_command ;
22
33import com .mojang .brigadier .context .CommandContext ;
4+
5+ import dev .loat .logging .Logger ;
46import net .minecraft .commands .CommandSourceStack ;
57import net .minecraft .network .chat .Component ;
68
@@ -9,6 +11,8 @@ public final class List {
911 public static final String COMMAND = "list" ;
1012
1113 public static int execute (CommandContext <CommandSourceStack > context ) {
14+ Logger .info ("Listing all backups" );
15+
1216 context .getSource ().sendSuccess (() -> Component .literal ("/backup list" ), false );
1317 return 1 ;
1418 }
Original file line number Diff line number Diff line change 11package dev .loat .command .sub_command ;
22
33import com .mojang .brigadier .context .CommandContext ;
4+
5+ import dev .loat .logging .Logger ;
46import net .minecraft .commands .CommandSourceStack ;
57import net .minecraft .network .chat .Component ;
68
@@ -9,6 +11,8 @@ public final class Reload {
911 public static final String COMMAND = "reload" ;
1012
1113 public static int execute (CommandContext <CommandSourceStack > context ) {
14+ Logger .info ("Reloading config" );
15+
1216 context .getSource ().sendSuccess (() -> Component .literal ("/backup reload" ), false );
1317 return 1 ;
1418 }
Original file line number Diff line number Diff line change @@ -29,7 +29,7 @@ public static int execute(CommandContext<CommandSourceStack> context) {
2929
3030 Logger .info ("Restoring existing backup \" %s\" " .formatted (name ));
3131
32- context .getSource ().sendSuccess (() -> Component .literal ("/backup create \" %s\" " .formatted (name )), false );
32+ context .getSource ().sendSuccess (() -> Component .literal ("/backup restore \" %s\" " .formatted (name )), false );
3333 return 1 ;
3434 }
3535}
You can’t perform that action at this time.
0 commit comments