🐛 Fix Bukkit alias command suggestions without Brigadier
This commit is contained in:
parent
e6af4e6caa
commit
dbdafed273
4 changed files with 35 additions and 26 deletions
|
|
@ -19,6 +19,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
||||||
|
|
||||||
### Fixed
|
### Fixed
|
||||||
- Use the correct default range for Double and Float parsers in the StandardParserRegistry
|
- Use the correct default range for Double and Float parsers in the StandardParserRegistry
|
||||||
|
- Fix Bukkit alias command suggestions without Brigadier
|
||||||
|
|
||||||
## [1.1.0] - 2020-10-24
|
## [1.1.0] - 2020-10-24
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -42,7 +42,7 @@ public class CommandSuggestionsTest {
|
||||||
@BeforeAll
|
@BeforeAll
|
||||||
static void setupManager() {
|
static void setupManager() {
|
||||||
manager = new TestCommandManager();
|
manager = new TestCommandManager();
|
||||||
manager.command(manager.commandBuilder("test").literal("one").build());
|
manager.command(manager.commandBuilder("test", "testalias").literal("one").build());
|
||||||
manager.command(manager.commandBuilder("test").literal("two").build());
|
manager.command(manager.commandBuilder("test").literal("two").build());
|
||||||
manager.command(manager.commandBuilder("test")
|
manager.command(manager.commandBuilder("test")
|
||||||
.literal("var")
|
.literal("var")
|
||||||
|
|
@ -92,6 +92,15 @@ public class CommandSuggestionsTest {
|
||||||
.argument(IntegerArgument.<TestCommandSender>newBuilder("num").withMin(5).withMax(100)));
|
.argument(IntegerArgument.<TestCommandSender>newBuilder("num").withMin(5).withMax(100)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void testRootAliases() {
|
||||||
|
final String input = "test ";
|
||||||
|
final List<String> suggestions = manager.suggest(new TestCommandSender(), input);
|
||||||
|
final String input2 = "testalias ";
|
||||||
|
final List<String> suggestions2 = manager.suggest(new TestCommandSender(), input2);
|
||||||
|
Assertions.assertEquals(suggestions, suggestions2);
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void testSimple() {
|
void testSimple() {
|
||||||
final String input = "test";
|
final String input = "test";
|
||||||
|
|
|
||||||
|
|
@ -88,6 +88,29 @@ public class BukkitPluginRegistrationHandler<C> implements CommandRegistrationHa
|
||||||
(CommandArgument<C, ?>) commandArgument,
|
(CommandArgument<C, ?>) commandArgument,
|
||||||
this.bukkitCommandManager
|
this.bukkitCommandManager
|
||||||
);
|
);
|
||||||
|
|
||||||
|
for (final String alias : aliases) {
|
||||||
|
this.recognizedAliases.add(getNamespacedLabel(alias));
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
this.registeredCommands.put(commandArgument, bukkitCommand);
|
this.registeredCommands.put(commandArgument, bukkitCommand);
|
||||||
if (!this.bukkitCommands.containsKey(label)) {
|
if (!this.bukkitCommands.containsKey(label)) {
|
||||||
this.recognizedAliases.add(label);
|
this.recognizedAliases.add(label);
|
||||||
|
|
@ -100,30 +123,6 @@ public class BukkitPluginRegistrationHandler<C> implements CommandRegistrationHa
|
||||||
);
|
);
|
||||||
this.registerExternal(label, command, bukkitCommand);
|
this.registerExternal(label, command, bukkitCommand);
|
||||||
|
|
||||||
if (this.bukkitCommandManager.getSplitAliases()) {
|
|
||||||
for (final String alias : aliases) {
|
|
||||||
if (!this.bukkitCommands.containsKey(alias)) {
|
|
||||||
@SuppressWarnings("unchecked") final BukkitCommand<C> aliasCommand = new BukkitCommand<>(
|
|
||||||
alias,
|
|
||||||
Collections.emptyList(),
|
|
||||||
(Command<C>) command,
|
|
||||||
(CommandArgument<C, ?>) commandArgument,
|
|
||||||
this.bukkitCommandManager
|
|
||||||
);
|
|
||||||
if (!this.bukkitCommands.containsKey(alias)) {
|
|
||||||
this.recognizedAliases.add(alias);
|
|
||||||
}
|
|
||||||
this.recognizedAliases.add(getNamespacedLabel(alias));
|
|
||||||
this.commandMap.register(
|
|
||||||
alias,
|
|
||||||
this.bukkitCommandManager.getOwningPlugin().getName().toLowerCase(),
|
|
||||||
bukkitCommand
|
|
||||||
);
|
|
||||||
this.registerExternal(alias, command, aliasCommand);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -642,7 +642,7 @@ public final class MinecraftHelp<C> {
|
||||||
* @param accent The color used for accents and symbols
|
* @param accent The color used for accents and symbols
|
||||||
* @return A new {@link HelpColors} instance
|
* @return A new {@link HelpColors} instance
|
||||||
*/
|
*/
|
||||||
public static HelpColors of(
|
public static @NonNull HelpColors of(
|
||||||
final @NonNull TextColor primary,
|
final @NonNull TextColor primary,
|
||||||
final @NonNull TextColor highlight,
|
final @NonNull TextColor highlight,
|
||||||
final @NonNull TextColor alternateHighlight,
|
final @NonNull TextColor alternateHighlight,
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue