@@ -45,15 +45,21 @@ void setRegistry(CommandFramework commandFramework) {
45
45
46
46
@ Override
47
47
public boolean onCommand (@ NotNull CommandSender sender , @ NotNull org .bukkit .command .Command cmd , @ NotNull String label , String [] args ) {
48
- final Map .Entry <Command , Map .Entry <Method , Object >> entry = registry .getCommandMatcher ().getAssociatedCommand (cmd .getName (), args );
48
+ Map .Entry <Command , Map .Entry <Method , Object >> entry = registry .getCommandMatcher ().getAssociatedCommand (cmd .getName (), args );
49
49
50
50
if (entry == null ) return false ;
51
51
52
- final Command command = entry .getKey ();
53
- final String permission = command .permission ();
54
- final String [] splitted = command .name ().split ("\\ ." );
55
- final String [] newArgs = Arrays .copyOfRange (args , splitted .length - 1 , args .length );
56
- final CommandArguments arguments = new CommandArguments (sender , cmd , command , label , newArgs );
52
+ Method method = entry .getValue ().getKey ();
53
+
54
+ if (method == null ) {
55
+ return false ;
56
+ }
57
+
58
+ Command command = entry .getKey ();
59
+ String permission = command .permission ();
60
+ String [] split = command .name ().split ("\\ ." );
61
+ String [] newArgs = Arrays .copyOfRange (args , split .length - 1 , args .length );
62
+ CommandArguments arguments = new CommandArguments (sender , cmd , command , label , newArgs );
57
63
58
64
if (command .onlyOp () && !sender .isOp ()) {
59
65
arguments .sendMessage (Message .MUST_HAVE_OP );
@@ -83,8 +89,7 @@ public boolean onCommand(@NotNull CommandSender sender, @NotNull org.bukkit.comm
83
89
return arguments .sendMessage (Message .LONG_ARG_SIZE );
84
90
}
85
91
86
- final Method method = entry .getValue ().getKey ();
87
- final CommandFramework commandFramework = CommandFramework .getInstance ();
92
+ CommandFramework commandFramework = CommandFramework .getInstance ();
88
93
89
94
if (commandFramework .checkConfirmation (sender , command , method )) {
90
95
return true ;
@@ -94,7 +99,7 @@ public boolean onCommand(@NotNull CommandSender sender, @NotNull org.bukkit.comm
94
99
return true ;
95
100
}
96
101
97
- final boolean parseOptions = method .getAnnotationsByType (Option .class ).length + method .getAnnotationsByType (Flag .class ).length > 0 ;
102
+ boolean parseOptions = method .getAnnotationsByType (Option .class ).length + method .getAnnotationsByType (Flag .class ).length > 0 ;
98
103
99
104
if (parseOptions ) {
100
105
OptionParser optionParser = new OptionParser (newArgs , method );
@@ -103,9 +108,9 @@ public boolean onCommand(@NotNull CommandSender sender, @NotNull org.bukkit.comm
103
108
arguments .setParsedFlags (optionParser .parseFlags ());
104
109
}
105
110
106
- final Runnable invocation = () -> {
111
+ Runnable invocation = () -> {
107
112
try {
108
- final Object instance = entry .getValue ().getValue ();
113
+ Object instance = entry .getValue ().getValue ();
109
114
110
115
method .invoke (instance , parameterHandler .getParameterArray (method , arguments ));
111
116
} catch (Exception exception ) {
@@ -118,7 +123,7 @@ public boolean onCommand(@NotNull CommandSender sender, @NotNull org.bukkit.comm
118
123
};
119
124
120
125
if (command .async ()) {
121
- final Plugin plugin = commandFramework .plugin ;
126
+ Plugin plugin = commandFramework .plugin ;
122
127
123
128
plugin .getServer ().getScheduler ().runTaskAsynchronously (plugin , invocation );
124
129
} else {
@@ -130,22 +135,22 @@ public boolean onCommand(@NotNull CommandSender sender, @NotNull org.bukkit.comm
130
135
131
136
@ Override
132
137
public List <String > onTabComplete (@ NotNull CommandSender sender , @ NotNull org .bukkit .command .Command cmd , @ NotNull String label , String [] args ) {
133
- final Map .Entry <Completer , Map .Entry <Method , Object >> entry = this .registry .getCommandMatcher ().getAssociatedCompleter (cmd .getName (), args );
138
+ Map .Entry <Completer , Map .Entry <Method , Object >> entry = this .registry .getCommandMatcher ().getAssociatedCompleter (cmd .getName (), args );
134
139
135
140
if (entry == null )
136
141
return null ;
137
142
138
- final String permission = entry .getKey ().permission ();
143
+ String permission = entry .getKey ().permission ();
139
144
140
145
if (!permission .isEmpty () && !sender .hasPermission (permission ))
141
146
return null ;
142
147
143
148
try {
144
- final Method method = entry .getValue ().getKey ();
145
- final Object instance = entry .getValue ().getValue ();
146
- final String [] splitName = entry .getKey ().name ().split ("\\ ." );
147
- final String [] newArgs = Arrays .copyOfRange (args , splitName .length - 1 , args .length );
148
- final Object completer = method .invoke (instance , parameterHandler .getParameterArray (method , new CommandArguments (sender , cmd , null , label , newArgs )));
149
+ Method method = entry .getValue ().getKey ();
150
+ Object instance = entry .getValue ().getValue ();
151
+ String [] splitName = entry .getKey ().name ().split ("\\ ." );
152
+ String [] newArgs = Arrays .copyOfRange (args , splitName .length - 1 , args .length );
153
+ Object completer = method .invoke (instance , parameterHandler .getParameterArray (method , new CommandArguments (sender , cmd , null , label , newArgs )));
149
154
150
155
return (List <String >) completer ;
151
156
} catch (Exception exception ) {
0 commit comments