@@ -158,28 +158,29 @@ public void registerCommands(@NotNull Object instance) {
158
158
* @param instance of the method above
159
159
*/
160
160
private void registerCommand (Command command , Method method , Object instance ) {
161
- if (command .name ().contains ("." )) {
161
+ final String cmdName = command .name ();
162
+
163
+ if (cmdName .contains ("." )) {
162
164
subCommands .put (command , me .despical .commons .util .Collections .mapEntry (method , instance ));
163
165
} else {
164
166
commands .put (command , me .despical .commons .util .Collections .mapEntry (method , instance ));
165
- }
166
167
167
- try {
168
- final Constructor <PluginCommand > constructor = PluginCommand .class .getDeclaredConstructor (String .class , Plugin .class );
169
- constructor .setAccessible (true );
170
-
171
- final String splittedCommand = command . name (). split ( " \\ ." )[ 0 ] ;
172
- final PluginCommand pluginCommand = constructor . newInstance ( splittedCommand , plugin );
173
- pluginCommand .setTabCompleter (this );
174
- pluginCommand .setExecutor ( this );
175
- pluginCommand .setUsage ( command .usage ());
176
- pluginCommand .setPermission (command .permission ());
177
- pluginCommand .setDescription ( command .desc ( ));
178
- pluginCommand . setAliases ( Arrays . asList ( command . aliases ()));
179
-
180
- commandMap . register ( splittedCommand , pluginCommand );
181
- } catch ( Exception exception ) {
182
- exception . printStackTrace ();
168
+ try {
169
+ final Constructor <PluginCommand > constructor = PluginCommand .class .getDeclaredConstructor (String .class , Plugin .class );
170
+ constructor .setAccessible (true );
171
+
172
+ final PluginCommand pluginCommand = constructor . newInstance ( cmdName , plugin ) ;
173
+ pluginCommand . setTabCompleter ( this );
174
+ pluginCommand .setExecutor (this );
175
+ pluginCommand .setUsage ( command . usage () );
176
+ pluginCommand .setPermission (! command .permission (). isEmpty () ? null : command . permission ());
177
+ pluginCommand .setDescription (command .desc ());
178
+ pluginCommand .setAliases ( Arrays . asList ( command .aliases () ));
179
+
180
+ commandMap . register ( cmdName , pluginCommand );
181
+ } catch ( Exception exception ) {
182
+ exception . printStackTrace ();
183
+ }
183
184
}
184
185
}
185
186
0 commit comments