Skip to content

Commit e73172c

Browse files
committed
Added an option to change the fallback prefix of the commands (Fixes #15)
1 parent 1db29ea commit e73172c

File tree

3 files changed

+14
-1
lines changed

3 files changed

+14
-1
lines changed

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,9 @@ protected void registerCommand(Command command, Method method, Object instance)
173173
pluginCommand.setPermission(command.permission().isEmpty() ? null : command.permission());
174174
pluginCommand.setDescription(command.desc());
175175

176-
commandMap.register(cmdName, pluginCommand);
176+
String fallBackPrefix = command.fallBackPrefix().isEmpty() ? commandFramework.plugin.getName() : command.fallBackPrefix();
177+
178+
commandMap.register(fallBackPrefix, pluginCommand);
177179
} catch (Exception exception) {
178180
Utils.handleExceptions(exception);
179181
}

src/main/java/me/despical/commandframework/annotations/Command.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,12 @@
4444
*/
4545
String name();
4646

47+
/**
48+
* @return a prefix which is prepended to the command with a ':'
49+
* one or more times to make the command unique.
50+
*/
51+
String fallBackPrefix() default "";
52+
4753
/**
4854
* The permission that sender has to have to execute command.
4955
*

src/main/java/me/despical/commandframework/utils/Utils.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,11 @@ public String name() {
158158
return commandName;
159159
}
160160

161+
@Override
162+
public String fallBackPrefix() {
163+
return command.fallBackPrefix();
164+
}
165+
161166
@Override
162167
public String permission() {
163168
return command.permission();

0 commit comments

Comments
 (0)