1
0
mirror of https://github.com/GeyserMC/Geyser.git synced 2025-12-31 04:36:33 +00:00

Another route of ensuring /help goes through to Bedrock

This commit is contained in:
Camotoy
2024-08-22 00:50:16 -04:00
parent b792f72ec7
commit 6801338ff9

View File

@@ -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