3
3
import com .mojang .brigadier .CommandDispatcher ;
4
4
import com .mojang .brigadier .builder .LiteralArgumentBuilder ;
5
5
import com .mojang .brigadier .tree .LiteralCommandNode ;
6
- import com .thepinkhacker .decree .Decree ;
7
6
import com .thepinkhacker .decree .data .command .CommandConfig ;
8
7
import com .thepinkhacker .decree .registry .DecreeRegistries ;
9
- import net .minecraft .registry .Registry ;
10
8
import net .minecraft .registry .RegistryKey ;
11
9
import net .minecraft .server .command .CommandManager ;
12
10
import net .minecraft .server .command .ServerCommandSource ;
13
11
14
- import java .util .Optional ;
15
12
import java .util .function .Function ;
16
13
17
14
public class DecreeUtils {
18
15
public static LiteralCommandNode <ServerCommandSource > register (
19
16
CommandDispatcher <ServerCommandSource > dispatcher ,
20
17
RegistryKey <CommandConfig > key ,
21
18
Function <LiteralArgumentBuilder <ServerCommandSource >, LiteralArgumentBuilder <ServerCommandSource >> command
22
- ) {
23
- return register (dispatcher , key , 0 , command );
24
- }
25
-
26
- public static LiteralCommandNode <ServerCommandSource > register (
27
- CommandDispatcher <ServerCommandSource > dispatcher ,
28
- RegistryKey <CommandConfig > key ,
29
- int permissionLevel ,
30
- Function <LiteralArgumentBuilder <ServerCommandSource >, LiteralArgumentBuilder <ServerCommandSource >> command
31
19
) {
32
20
// TODO: Check for collisions
33
21
LiteralArgumentBuilder <ServerCommandSource > builtCommand = command .apply (CommandManager .literal (key .getValue ().getPath ()));
@@ -37,39 +25,6 @@ public static LiteralCommandNode<ServerCommandSource> register(
37
25
dispatcher .register (builtCommand );
38
26
}
39
27
40
- if (permissionLevel == 0 ) {
41
- for (String alias : config .aliases ) {
42
- createAlias (dispatcher , builtCommand .getLiteral (), alias );
43
- }
44
- } else {
45
- for (String alias : config .aliases ) {
46
- createAlias (dispatcher , builtCommand .getLiteral (), alias , permissionLevel );
47
- }
48
- }
49
-
50
28
return dispatcher .register (CommandManager .literal (config .prefix .prefix ).then (builtCommand ));
51
29
}
52
-
53
- // TODO: Fix issue with blank aliases
54
- public static void createAlias (CommandDispatcher <ServerCommandSource > dispatcher , String original , String alias ) {
55
- dispatcher .register (CommandManager .literal (alias ).redirect (dispatcher .getRoot ().getChild (original )));
56
- }
57
-
58
- public static void createAlias (CommandDispatcher <ServerCommandSource > dispatcher , String original , String alias , int permissionLevel ) {
59
- dispatcher .register (CommandManager .literal (alias )
60
- .redirect (dispatcher .getRoot ().getChild (original ))
61
- .requires (source -> source .hasPermissionLevel (permissionLevel ))
62
- );
63
- }
64
-
65
- public static void createAlias (CommandDispatcher <ServerCommandSource > dispatcher , LiteralCommandNode <ServerCommandSource > original , String alias ) {
66
- dispatcher .register (CommandManager .literal (alias ).redirect (original ));
67
- }
68
-
69
- public static void createAlias (CommandDispatcher <ServerCommandSource > dispatcher , LiteralCommandNode <ServerCommandSource > original , String alias , int permissionLevel ) {
70
- dispatcher .register (CommandManager .literal (alias )
71
- .redirect (original )
72
- .requires (source -> source .hasPermissionLevel (permissionLevel ))
73
- );
74
- }
75
30
}
0 commit comments