Mirror von
https://github.com/GeyserMC/Geyser.git
synchronisiert 2024-11-16 04:50:07 +01:00
Another route of ensuring /help goes through to Bedrock
Dieser Commit ist enthalten in:
Ursprung
b792f72ec7
Commit
6801338ff9
@ -88,6 +88,7 @@ public class JavaCommandsTranslator extends PacketTranslator<ClientboundCommands
|
|||||||
if (a == null || b == null) return false;
|
if (a == null || b == null) return false;
|
||||||
if ("help".equals(a.name()) && !"help".equals(b.name())) {
|
if ("help".equals(a.name()) && !"help".equals(b.name())) {
|
||||||
// Merging this causes Bedrock to fallback to its own help command
|
// 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
|
// https://github.com/GeyserMC/Geyser/issues/2573
|
||||||
return false;
|
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.
|
// 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);
|
Set<CommandData.Flag> flags = Set.of(CommandData.Flag.NOT_CHEAT);
|
||||||
|
|
||||||
|
boolean helpAdded = false;
|
||||||
|
|
||||||
// Loop through all the found commands
|
// Loop through all the found commands
|
||||||
for (Map.Entry<BedrockCommandInfo, Set<String>> entry : commands.entrySet()) {
|
for (Map.Entry<BedrockCommandInfo, Set<String>> entry : commands.entrySet()) {
|
||||||
String commandName = entry.getValue().iterator().next(); // We know this has a value
|
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
|
// 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 data = new CommandData(commandName, entry.getKey().description(), flags, CommandPermission.ANY, aliases, Collections.emptyList(), entry.getKey().paramData());
|
||||||
commandData.add(data);
|
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
|
// Add our commands to the AvailableCommandsPacket for the bedrock client
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren