3
0
Mirror von https://github.com/GeyserMC/Geyser.git synchronisiert 2024-12-26 08:10:11 +01:00

Show the help command even with command suggestions disabled

Dieser Commit ist enthalten in:
Camotoy 2024-08-22 13:16:07 -04:00
Ursprung 6801338ff9
Commit 2274377814
Es konnte kein GPG-Schlüssel zu dieser Signatur gefunden werden
GPG-Schlüssel-ID: 7EEFB66FE798081F

Datei anzeigen

@ -125,8 +125,9 @@ public class JavaCommandsTranslator extends PacketTranslator<ClientboundCommands
if (!session.getGeyser().getConfig().isCommandSuggestions()) { if (!session.getGeyser().getConfig().isCommandSuggestions()) {
session.getGeyser().getLogger().debug("Not sending translated command suggestions as they are disabled."); 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(); AvailableCommandsPacket emptyPacket = new AvailableCommandsPacket();
emptyPacket.getCommands().add(createFakeHelpCommand());
session.sendUpstreamPacket(emptyPacket); session.sendUpstreamPacket(emptyPacket);
return; return;
} }
@ -209,10 +210,7 @@ public class JavaCommandsTranslator extends PacketTranslator<ClientboundCommands
if (!helpAdded) { if (!helpAdded) {
// https://github.com/GeyserMC/Geyser/issues/2573 if Brigadier does not send the help command. // 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.add(createFakeHelpCommand());
CommandData data = new CommandData("help", "", flags, CommandPermission.ANY, aliases, Collections.emptyList(), new CommandOverloadData[0]);
commandData.add(data);
} }
// Add our commands to the AvailableCommandsPacket for the bedrock client // 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. * Stores the command description and parameter data for best optimizing the Bedrock commands packet.
*/ */