3
0
Mirror von https://github.com/GeyserMC/Geyser.git synchronisiert 2024-09-28 06:01:10 +02:00

Another route of ensuring /help goes through to Bedrock

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

Datei anzeigen

@ -88,6 +88,7 @@ public class JavaCommandsTranslator extends PacketTranslator<ClientboundCommands
if (a == null || b == null) return false;
if ("help".equals(a.name()) && !"help".equals(b.name())) {
// Merging this causes Bedrock to fallback to its own help command
// Tested on Paper 1.20.4 with Essentials and Bedrock 1.21
// https://github.com/GeyserMC/Geyser/issues/2573
return false;
}
@ -182,6 +183,8 @@ public class JavaCommandsTranslator extends PacketTranslator<ClientboundCommands
// The command flags, set to NOT_CHEAT so known commands can be used while achievements are enabled.
Set<CommandData.Flag> flags = Set.of(CommandData.Flag.NOT_CHEAT);
boolean helpAdded = false;
// Loop through all the found commands
for (Map.Entry<BedrockCommandInfo, Set<String>> entry : commands.entrySet()) {
String commandName = entry.getValue().iterator().next(); // We know this has a value
@ -198,6 +201,18 @@ public class JavaCommandsTranslator extends PacketTranslator<ClientboundCommands
// Build the completed command and add it to the final list
CommandData data = new CommandData(commandName, entry.getKey().description(), flags, CommandPermission.ANY, aliases, Collections.emptyList(), entry.getKey().paramData());
commandData.add(data);
if (commandName.equals("help")) {
helpAdded = true;
}
}
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);
}
// Add our commands to the AvailableCommandsPacket for the bedrock client