Show the help command even with command suggestions disabled

This commit is contained in:
Camotoy 2024-08-22 13:16:07 -04:00
parent 6801338ff9
commit 2274377814
No known key found for this signature in database
GPG key ID: 7EEFB66FE798081F

View file

@ -125,8 +125,9 @@ public class JavaCommandsTranslator extends PacketTranslator<ClientboundCommands
if (!session.getGeyser().getConfig().isCommandSuggestions()) {
session.getGeyser().getLogger().debug("Not sending translated command suggestions as they are disabled.");
// Send an empty packet so Bedrock doesn't override /help with its own, built-in help command.
// Send a mostly empty packet so Bedrock doesn't override /help with its own, built-in help command.
AvailableCommandsPacket emptyPacket = new AvailableCommandsPacket();
emptyPacket.getCommands().add(createFakeHelpCommand());
session.sendUpstreamPacket(emptyPacket);
return;
}
@ -209,10 +210,7 @@ public class JavaCommandsTranslator extends PacketTranslator<ClientboundCommands
if (!helpAdded) {
// https://github.com/GeyserMC/Geyser/issues/2573 if Brigadier does not send the help command.
CommandEnumData aliases = new CommandEnumData("helpAliases", Map.of("help", EnumSet.of(CommandEnumConstraint.ALLOW_ALIASES)), false);
CommandData data = new CommandData("help", "", flags, CommandPermission.ANY, aliases, Collections.emptyList(), new CommandOverloadData[0]);
commandData.add(data);
commandData.add(createFakeHelpCommand());
}
// Add our commands to the AvailableCommandsPacket for the bedrock client
@ -301,6 +299,11 @@ public class JavaCommandsTranslator extends PacketTranslator<ClientboundCommands
};
}
private CommandData createFakeHelpCommand() {
CommandEnumData aliases = new CommandEnumData("helpAliases", Map.of("help", EnumSet.of(CommandEnumConstraint.ALLOW_ALIASES)), false);
return new CommandData("help", "", Set.of(CommandData.Flag.NOT_CHEAT), CommandPermission.ANY, aliases, Collections.emptyList(), new CommandOverloadData[0]);
}
/**
* Stores the command description and parameter data for best optimizing the Bedrock commands packet.
*/