Skip to content

Commit 7fe6fac

Browse files
committed
Don't generate a help topic for the namespaced version
This should be reverted if we think we should
1 parent 51b5d1e commit 7fe6fac

File tree

1 file changed

+15
-0
lines changed
  • commandapi-platforms/commandapi-bukkit/commandapi-bukkit-core/src/main/java/dev/jorel/commandapi

1 file changed

+15
-0
lines changed

commandapi-platforms/commandapi-bukkit/commandapi-bukkit-core/src/main/java/dev/jorel/commandapi/CommandAPIBukkit.java

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -354,10 +354,16 @@ private String[] getUsageList(RegisteredCommand currentCommand) {
354354

355355
void updateHelpForCommands(List<RegisteredCommand> commands) {
356356
Map<String, HelpTopic> helpTopicsToAdd = new HashMap<>();
357+
List<String> namespacedCommandNames = new ArrayList<>();
357358

358359
for (RegisteredCommand command : commands) {
359360
// Don't override the plugin help topic
360361
String commandPrefix = generateCommandHelpPrefix(command.commandName());
362+
363+
// Namespaced commands shouldn't have a namespace, we should save the namespaced command name
364+
commandPrefix = commandPrefix.substring(1); // Get rid of the '/' for the namespaced command
365+
namespacedCommandNames.add("/" + command.namespace() + ":" + commandPrefix); // Bukkit it stupid, it registers commands with a '/' in the help map
366+
361367
StringBuilder aliasSb = new StringBuilder();
362368
final String shortDescription;
363369

@@ -418,13 +424,22 @@ void updateHelpForCommands(List<RegisteredCommand> commands) {
418424
// Don't override the plugin help topic
419425
commandPrefix = generateCommandHelpPrefix(alias);
420426
helpTopic = generateHelpTopic(commandPrefix, shortDescription, currentAliasSb.toString().trim(), permission);
427+
428+
// Namespaced commands shouldn't have a namespace, we should save the namespaced command name
429+
commandPrefix = commandPrefix.substring(1); // Get rid of the '/' for the namespaced command
430+
namespacedCommandNames.add("/" + command.namespace() + ":" + commandPrefix); // Bukkit it stupid, it registers commands with a '/' in the help map
421431
}
422432
helpTopicsToAdd.put(commandPrefix, helpTopic);
423433
}
424434
}
425435

426436
// We have to use helpTopics.put (instead of .addTopic) because we're overwriting an existing help topic, not adding a new help topic
427437
getHelpMap().putAll(helpTopicsToAdd);
438+
439+
// We also have to remove help topics for namespaced command names
440+
for (String namespacedCommandName : namespacedCommandNames) {
441+
getHelpMap().remove(namespacedCommandName);
442+
}
428443
}
429444

430445
private void fixNamespaces() {

0 commit comments

Comments
 (0)