1
1
package com .aqupd .namebros ;
2
2
3
- import com .mojang .brigadier .StringReader ;
4
- import com .mojang .brigadier .builder .ArgumentBuilder ;
5
- import com .mojang .brigadier .builder .LiteralArgumentBuilder ;
6
3
import me .lucko .fabric .api .permissions .v0 .Permissions ;
7
4
import net .fabricmc .api .ModInitializer ;
8
5
import net .fabricmc .fabric .api .command .v2 .CommandRegistrationCallback ;
12
9
import org .slf4j .Logger ;
13
10
import org .slf4j .LoggerFactory ;
14
11
15
- import static net .minecraft .server .command .CommandManager .*;
12
+ import static net .minecraft .server .command .CommandManager .argument ;
13
+ import static net .minecraft .server .command .CommandManager .literal ;
16
14
17
15
public class Main implements ModInitializer {
18
16
@@ -23,37 +21,36 @@ public void onInitialize() {
23
21
Config conf = Config .INSTANCE ;
24
22
conf .load ();
25
23
26
- CommandRegistrationCallback .EVENT .register (((dispatcher , registryAccess , environment ) -> {
27
- dispatcher .register (literal ("namebros" ).requires (source -> Permissions .check (source , "namebros.command.use" , 3 ))
28
- .then (literal ("addblacklist" ).then (argument ("Entity name" , EntitySummonArgumentType .entitySummon ()).suggests (SuggestionProviders .SUMMONABLE_ENTITIES ).executes (ctx -> {
29
- String eName = EntitySummonArgumentType .getEntitySummon (ctx , "Entity name" ).toString ();
30
- if (conf .addBlacklist (eName )) ctx .getSource ().sendMessage (Text .literal ("Added entity \" " + eName + "\" to the blacklist" ));
31
- else ctx .getSource ().sendMessage (Text .literal ("Entity \" " + eName + "\" already blacklisted" ));
32
- return 1 ;
33
- })))
34
- .then (literal ("removeblacklist" ).then (argument ("Entity name" , EntitySummonArgumentType .entitySummon ()).suggests (SuggestionProviders .SUMMONABLE_ENTITIES ).executes (ctx -> {
35
- String eName = EntitySummonArgumentType .getEntitySummon (ctx , "Entity name" ).toString ();
36
- if (conf .removeBlackList (eName )) ctx .getSource ().sendMessage (Text .literal ("Removed entity \" " + eName + "\" from the blacklist" ));
37
- else ctx .getSource ().sendMessage (Text .literal ("Entity \" " + eName + "\" not blacklisted" ));
38
- return 1 ;
39
- })))
40
- .then (literal ("debug" ).executes (ctx -> {
41
- conf .toggleDebug ();
42
- ctx .getSource ().sendMessage (Text .literal ("Debug mode is: " + (conf .isDebug ()?"ON" :"OFF" )));
43
- return 1 ;
44
- }))
45
- .then (literal ("enable" ).executes (ctx -> {
46
- conf .toggleEnable ();
47
- ctx .getSource ().sendMessage (Text .literal ("Mod is " + (conf .enabled ()?"enabled" :"disabled" )));
48
- return 1 ;
49
- }))
50
- .then (literal ("reload" ).executes (ctx -> {
51
- conf .load ();
52
- ctx .getSource ().sendMessage (Text .literal ("Reloaded config files" ));
53
- return 1 ;
54
- }))
55
- );
56
- }));
24
+ CommandRegistrationCallback .EVENT .register (((dispatcher , registryAccess , environment ) -> dispatcher
25
+ .register (literal ("namebros" ).requires (source -> Permissions .check (source , "namebros.command.use" , 3 ))
26
+ .then (literal ("addblacklist" ).then (argument ("Entity name" , EntitySummonArgumentType .entitySummon ()).suggests (SuggestionProviders .SUMMONABLE_ENTITIES ).executes (ctx -> {
27
+ String eName = EntitySummonArgumentType .getEntitySummon (ctx , "Entity name" ).toString ();
28
+ if (conf .addBlacklist (eName )) ctx .getSource ().sendMessage (Text .literal ("Added entity \" " + eName + "\" to the blacklist" ));
29
+ else ctx .getSource ().sendMessage (Text .literal ("Entity \" " + eName + "\" already blacklisted" ));
30
+ return 1 ;
31
+ })))
32
+ .then (literal ("removeblacklist" ).then (argument ("Entity name" , EntitySummonArgumentType .entitySummon ()).suggests (SuggestionProviders .SUMMONABLE_ENTITIES ).executes (ctx -> {
33
+ String eName = EntitySummonArgumentType .getEntitySummon (ctx , "Entity name" ).toString ();
34
+ if (conf .removeBlackList (eName )) ctx .getSource ().sendMessage (Text .literal ("Removed entity \" " + eName + "\" from the blacklist" ));
35
+ else ctx .getSource ().sendMessage (Text .literal ("Entity \" " + eName + "\" not blacklisted" ));
36
+ return 1 ;
37
+ })))
38
+ .then (literal ("debug" ).executes (ctx -> {
39
+ conf .toggleDebug ();
40
+ ctx .getSource ().sendMessage (Text .literal ("Debug mode is: " + (conf .isDebug ()?"ON" :"OFF" )));
41
+ return 1 ;
42
+ }))
43
+ .then (literal ("enable" ).executes (ctx -> {
44
+ conf .toggleEnable ();
45
+ ctx .getSource ().sendMessage (Text .literal ("Mod is " + (conf .enabled ()?"enabled" :"disabled" )));
46
+ return 1 ;
47
+ }))
48
+ .then (literal ("reload" ).executes (ctx -> {
49
+ conf .load ();
50
+ ctx .getSource ().sendMessage (Text .literal ("Reloaded config files" ));
51
+ return 1 ;
52
+ }))
53
+ )));
57
54
LOGGER .info ("Mod initialized" );
58
55
}
59
56
}
0 commit comments