22
33import com .github .simulatan .meteornotificationsaddon .notifications .Notification ;
44import com .github .simulatan .meteornotificationsaddon .notifications .NotificationsManager ;
5+ import com .mojang .brigadier .LiteralMessage ;
56import com .mojang .brigadier .StringReader ;
67import com .mojang .brigadier .arguments .ArgumentType ;
78import com .mojang .brigadier .builder .LiteralArgumentBuilder ;
1314import meteordevelopment .meteorclient .systems .commands .Command ;
1415import meteordevelopment .meteorclient .utils .player .ChatUtils ;
1516import net .minecraft .command .CommandSource ;
16- import net .minecraft .text .LiteralText ;
1717
1818import java .awt .*;
1919import java .util .Arrays ;
2626
2727public class NotificationsCommand extends Command {
2828
29- public NotificationsCommand () {
30- super ("notifications" , "Sends a dummy notification" );
31- }
29+ public NotificationsCommand () {
30+ super ("notifications" , "Sends a dummy notification" );
31+ }
3232
33- @ Override
34- public void build (LiteralArgumentBuilder <CommandSource > builder ) {
35- builder .then (argument ("mode" , new NotificationsArgumentType ()).executes (context -> {
36- NotificationCommandType arg = context .getArgument ("mode" , NotificationCommandType .class );
37- if (arg == NotificationCommandType .SEND ) {
38- NotificationsManager .add (new Notification ("hey, this is a test!" , "very cool indeed yes" , new Color ((int ) (Math .random () * 0x1000000 ))));
39- ChatUtils .info ("Notifications" , "Successfully triggered notification!" );
40- } else if (arg == NotificationCommandType .CLEAR ) {
41- NotificationsManager .clearNotifications ();
42- ChatUtils .warning ("Notifications" , "Successfully cleared notifications!" );
43- }
44- return SINGLE_SUCCESS ;
45- }));
46- }
33+ @ Override
34+ public void build (LiteralArgumentBuilder <CommandSource > builder ) {
35+ builder .then (argument ("mode" , new NotificationsArgumentType ()).executes (context -> {
36+ NotificationCommandType arg = context .getArgument ("mode" , NotificationCommandType .class );
37+ if (arg == NotificationCommandType .SEND ) {
38+ NotificationsManager .add (new Notification ("hey, this is a test!" , "very cool indeed yes" , new Color ((int ) (Math .random () * 0x1000000 ))));
39+ ChatUtils .info ("Notifications" , "Successfully triggered notification!" );
40+ } else if (arg == NotificationCommandType .CLEAR ) {
41+ NotificationsManager .clearNotifications ();
42+ ChatUtils .warning ("Notifications" , "Successfully cleared notifications!" );
43+ }
44+ return SINGLE_SUCCESS ;
45+ }));
46+ }
4747
48- private enum NotificationCommandType {
49- SEND ,
50- CLEAR ;
48+ private enum NotificationCommandType {
49+ SEND ,
50+ CLEAR
5151 }
5252
53- private static class NotificationsArgumentType implements ArgumentType <NotificationCommandType > {
53+ private static class NotificationsArgumentType implements ArgumentType <NotificationCommandType > {
5454
55- private static final DynamicCommandExceptionType NO_SUCH_MODULE = new DynamicCommandExceptionType (o -> new LiteralText ("Type " + o + " doesn't exist." ));
55+ private static final DynamicCommandExceptionType NO_SUCH_MODULE = new DynamicCommandExceptionType (o -> new LiteralMessage ("Type " + o + " doesn't exist." ));
5656
57- @ Override
58- public NotificationCommandType parse (StringReader reader ) throws CommandSyntaxException {
59- String argument = reader .readString ();
60- try {
61- return NotificationCommandType .valueOf (argument .toUpperCase ());
62- } catch (Exception ignored ){
63- throw NO_SUCH_MODULE .create (argument );
64- }
65- }
57+ @ Override
58+ public NotificationCommandType parse (StringReader reader ) throws CommandSyntaxException {
59+ String argument = reader .readString ();
60+ try {
61+ return NotificationCommandType .valueOf (argument .toUpperCase ());
62+ } catch (Exception ignored ) {
63+ throw NO_SUCH_MODULE .create (argument );
64+ }
65+ }
6666
67- @ Override
68- public <S > CompletableFuture <Suggestions > listSuggestions (CommandContext <S > context , SuggestionsBuilder builder ) {
69- return CommandSource .suggestMatching (Arrays .stream (NotificationCommandType .values ()).map (NotificationCommandType ::name ), builder );
70- }
67+ @ Override
68+ public <S > CompletableFuture <Suggestions > listSuggestions (CommandContext <S > context , SuggestionsBuilder builder ) {
69+ return CommandSource .suggestMatching (Arrays .stream (NotificationCommandType .values ()).map (NotificationCommandType ::name ), builder );
70+ }
7171
72- private static final List <String > EXAMPLES = Arrays .stream (NotificationCommandType .values ()).map (Enum ::name ).collect (Collectors .toList ());
72+ private static final List <String > EXAMPLES = Arrays .stream (NotificationCommandType .values ()).map (Enum ::name ).collect (Collectors .toList ());
7373
74- @ Override
75- public Collection <String > getExamples () {
76- return EXAMPLES ;
77- }
78- }
79- }
74+ @ Override
75+ public Collection <String > getExamples () {
76+ return EXAMPLES ;
77+ }
78+ }
79+ }
0 commit comments