Commands completion list not updated when a root command is unregistered
I've tried to register user-defined commands, but, when I try to un-register and re-register them (reloading the config), the tab completions don't get updated when the commands in the config change, despite they work correctly.
This happens only for player tab completions, and not console ones.
I've already tried with player.updateCommands(), but nothing changes.
Server Version: Paper 1.15.2
Command registration:
public static void registerBook(IBook book)
{
if(!book.getOpenCommands().isEmpty())
{
CommandReplacements replacements = commandManager.getCommandReplacements();
replacements.addReplacement("openbook", String.join("|", book.getOpenCommands()));
replacements.addReplacement("interactivebooks.open", "interactivebooks.open." + book.getId());
CommandOpenBook command = new CommandOpenBook(book);
commandManager.registerCommand(command);
book.setCommandExecutor(command);
}
books.put(book.getId(), book);
}
Command un-register:
public static void unregisterBook(String id)
{
IBook book = getBook(id);
if(book.getCommandExecutor() != null)
commandManager.unregisterCommand(book.getCommandExecutor());
books.remove(id);
}
CommandOpenBook class:
@CommandAlias("%openbook")
@CommandPermission("%interactivebooks.open")
public final class CommandOpenBook extends BaseCommand {
private final IBook book;
public CommandOpenBook(IBook book)
{
super();
this.book = book;
}
@Default
@CatchUnknown
public void onCommand(Player player)
{
book.open(player);
}
}
Relogging doesn't update it either.
I assume the list that the server sends to the client is simply not updated when commands are unregistered.
I've noticed that registering commands well after server start results in similar behaviour, in that the new command is usable but the client does not new about the new command, and says that it's invalid.
Paper 108 (1.16.1) co.aikar:acf-bukkit:0.5.0-SNAPSHOT
Relogging doesn't update it either. I assume the list that the server sends to the client is simply not updated when commands are unregistered. I've noticed that registering commands well after server start results in similar behaviour, in that the new command is usable but the client does not new about the new command, and says that it's invalid.
Paper 108 (1.16.1) co.aikar:acf-bukkit:0.5.0-SNAPSHOT
With built in Minecraft commands, when you reload the permissions (for example with /op - /deop commands), the command completions are automatically updated, even without a player rejoin.
Yeah neither Permissible#recalculatePermissions(); nor manually opping/deopping the player gets around the issue. Attempting to add the command /test, then using either method I mentioned, the client still does not know about the /test command.
calling updateCommands is needed afterwards. Can you paste how you did it with update commands?
though i really suggest keeping a single command registered and calling it as a subcommand with the data from the book.
Commands are for the entire server, but it feels like your turning commands on and off for a book, but that's not going to be per player.