Bump Protocol version to fix command suggestions

Fix assert that occurs on Bedrock after typing /
This commit is contained in:
davchoo 2022-05-29 18:56:54 -04:00
parent cbba0d3a75
commit f79a3ef2f7
No known key found for this signature in database
GPG key ID: A0168C8E45799B7D
2 changed files with 9 additions and 3 deletions

View file

@ -121,7 +121,7 @@
<dependency> <dependency>
<groupId>com.github.CloudburstMC.Protocol</groupId> <groupId>com.github.CloudburstMC.Protocol</groupId>
<artifactId>bedrock-beta</artifactId> <artifactId>bedrock-beta</artifactId>
<version>49323e0</version> <version>51d4fce</version>
<scope>compile</scope> <scope>compile</scope>
<exclusions> <exclusions>
<exclusion> <exclusion>

View file

@ -248,7 +248,7 @@ public class JavaCommandsTranslator extends PacketTranslator<ClientboundCommands
/** /**
* 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.
*/ */
private static record BedrockCommandInfo(String description, CommandParamData[][] paramData) { private record BedrockCommandInfo(String description, CommandParamData[][] paramData) {
} }
@Getter @Getter
@ -317,15 +317,21 @@ public class JavaCommandsTranslator extends PacketTranslator<ClientboundCommands
Object mappedType = mapCommandType(session, paramNode); Object mappedType = mapCommandType(session, paramNode);
CommandEnumData enumData = null; CommandEnumData enumData = null;
CommandParam type = null; CommandParam type = null;
boolean optional = this.paramNode.isExecutable();
if (mappedType instanceof String[]) { if (mappedType instanceof String[]) {
enumData = new CommandEnumData(paramNode.getParser().name().toLowerCase(), (String[]) mappedType, false); enumData = new CommandEnumData(paramNode.getParser().name().toLowerCase(), (String[]) mappedType, false);
} else { } else {
type = (CommandParam) mappedType; type = (CommandParam) mappedType;
// Bedrock throws a fit if an optional message comes after a string or target
// Example vanilla commands: ban-ip, ban, and kick
if (optional && type == CommandParam.MESSAGE && (paramData.getType() == CommandParam.STRING || paramData.getType() == CommandParam.TARGET)) {
optional = false;
}
} }
// IF enumData != null: // IF enumData != null:
// In game, this will show up like <paramNode.getName(): enumData.getName()> // In game, this will show up like <paramNode.getName(): enumData.getName()>
// So if paramNode.getName() == "value" and enumData.getName() == "bool": <value: bool> // So if paramNode.getName() == "value" and enumData.getName() == "bool": <value: bool>
children.add(new ParamInfo(paramNode, new CommandParamData(paramNode.getName(), this.paramNode.isExecutable(), enumData, type, null, Collections.emptyList()))); children.add(new ParamInfo(paramNode, new CommandParamData(paramNode.getName(), optional, enumData, type, null, Collections.emptyList())));
} }
} }