🐛 Fix registration of command aliases on Bukkit when using Brigadier
This commit is contained in:
parent
fc1a613463
commit
2f0ded5be6
3 changed files with 19 additions and 21 deletions
|
|
@ -22,6 +22,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||
### Fixed
|
||||
- Use the correct default range for Double and Float parsers in the StandardParserRegistry
|
||||
- Fix Bukkit alias command suggestions without Brigadier
|
||||
- Fix Bukkit command alias registration when using Brigadier
|
||||
|
||||
## [1.1.0] - 2020-10-24
|
||||
|
||||
|
|
|
|||
|
|
@ -36,7 +36,6 @@ import org.checkerframework.checker.nullness.qual.NonNull;
|
|||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
|
@ -77,52 +76,51 @@ public class BukkitPluginRegistrationHandler<C> implements CommandRegistrationHa
|
|||
return false;
|
||||
}
|
||||
final String label = commandArgument.getName();
|
||||
final String namespacedLabel = this.getNamespacedLabel(label);
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
final List<String> aliases = new ArrayList<>(((StaticArgument<C>) commandArgument).getAlternativeAliases());
|
||||
|
||||
@SuppressWarnings("unchecked") final BukkitCommand<C> bukkitCommand = new BukkitCommand<>(
|
||||
label,
|
||||
(this.bukkitCommandManager.getSplitAliases() ? Collections.emptyList() : aliases),
|
||||
aliases,
|
||||
(Command<C>) command,
|
||||
(CommandArgument<C, ?>) commandArgument,
|
||||
this.bukkitCommandManager
|
||||
);
|
||||
|
||||
for (final String alias : aliases) {
|
||||
this.recognizedAliases.add(getNamespacedLabel(alias));
|
||||
final String namespacedAlias = this.getNamespacedLabel(alias);
|
||||
|
||||
this.recognizedAliases.add(namespacedAlias);
|
||||
if (!this.bukkitCommands.containsKey(alias)) {
|
||||
this.recognizedAliases.add(alias);
|
||||
}
|
||||
|
||||
if (this.bukkitCommandManager.getSplitAliases()) {
|
||||
@SuppressWarnings("unchecked") final BukkitCommand<C> aliasCommand = new BukkitCommand<>(
|
||||
alias,
|
||||
Collections.emptyList(),
|
||||
(Command<C>) command,
|
||||
(CommandArgument<C, ?>) commandArgument,
|
||||
this.bukkitCommandManager
|
||||
);
|
||||
this.commandMap.register(
|
||||
alias,
|
||||
this.bukkitCommandManager.getOwningPlugin().getName().toLowerCase(),
|
||||
bukkitCommand
|
||||
);
|
||||
this.registerExternal(alias, command, aliasCommand);
|
||||
if (this.bukkitCommands.containsKey(alias)) {
|
||||
this.registerExternal(namespacedAlias, command, bukkitCommand);
|
||||
} else {
|
||||
this.registerExternal(namespacedAlias, command, bukkitCommand);
|
||||
this.registerExternal(alias, command, bukkitCommand);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
this.registeredCommands.put(commandArgument, bukkitCommand);
|
||||
if (!this.bukkitCommands.containsKey(label)) {
|
||||
this.recognizedAliases.add(label);
|
||||
this.registerExternal(label, command, bukkitCommand);
|
||||
}
|
||||
this.recognizedAliases.add(getNamespacedLabel(label));
|
||||
this.recognizedAliases.add(this.getNamespacedLabel(label));
|
||||
this.registerExternal(namespacedLabel, command, bukkitCommand);
|
||||
|
||||
this.commandMap.register(
|
||||
label,
|
||||
this.bukkitCommandManager.getOwningPlugin().getName().toLowerCase(),
|
||||
bukkitCommand
|
||||
);
|
||||
this.registerExternal(label, command, bukkitCommand);
|
||||
|
||||
this.registeredCommands.put(commandArgument, bukkitCommand);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -68,7 +68,6 @@ class CloudCommodoreManager<C> extends BukkitPluginRegistrationHandler<C> {
|
|||
final @NonNull BukkitCommand<C> bukkitCommand
|
||||
) {
|
||||
this.registerWithCommodore(label, command);
|
||||
this.registerWithCommodore(String.format("%s:%s", bukkitCommand.getPlugin().getName(), label).toLowerCase(), command);
|
||||
}
|
||||
|
||||
protected @NonNull CloudBrigadierManager brigadierManager() {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue