Skip to content

Commit 6bc23cf

Browse files
committed
Empty permissions and multiple command registrations fixed
1 parent 5bc666c commit 6bc23cf

File tree

3 files changed

+22
-21
lines changed

3 files changed

+22
-21
lines changed

.github/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ To add this project as a dependency to your project, add the following to your p
3939
<dependency>
4040
<groupId>com.github.Despical</groupId>
4141
<artifactId>CommandFramework</artifactId>
42-
<version>1.1.8</version>
42+
<version>1.1.9</version>
4343
<scope>compile</scope>
4444
</dependency>
4545
```
@@ -52,7 +52,7 @@ repositories {
5252
```
5353
```
5454
dependencies {
55-
compileOnly group: "com.github.Despical", name: "CommandFramework", version: "1.1.8";
55+
compileOnly group: "com.github.Despical", name: "CommandFramework", version: "1.1.9";
5656
}
5757
```
5858

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<modelVersion>4.0.0</modelVersion>
44
<groupId>me.despical</groupId>
55
<artifactId>command-framework</artifactId>
6-
<version>1.1.8</version>
6+
<version>1.1.9</version>
77

88
<properties>
99
<java.version>8</java.version>

src/main/java/me/despical/commandframework/CommandFramework.java

Lines changed: 19 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -158,28 +158,29 @@ public void registerCommands(@NotNull Object instance) {
158158
* @param instance of the method above
159159
*/
160160
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(".")) {
162164
subCommands.put(command, me.despical.commons.util.Collections.mapEntry(method, instance));
163165
} else {
164166
commands.put(command, me.despical.commons.util.Collections.mapEntry(method, instance));
165-
}
166167

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+
}
183184
}
184185
}
185186

0 commit comments

Comments
 (0)