Display Java supported versions as list in dumps

This commit is contained in:
Camotoy 2021-12-10 16:27:23 -05:00
parent 1885a75d3c
commit 9d09a7e418
No known key found for this signature in database
GPG key ID: 7EEFB66FE798081F
4 changed files with 30 additions and 10 deletions

View file

@ -62,9 +62,16 @@ public class VersionCommand extends GeyserCommand {
} else {
bedrockVersions = MinecraftProtocol.SUPPORTED_BEDROCK_CODECS.get(0).getMinecraftVersion();
}
String javaVersions;
List<String> supportedJavaVersions = MinecraftProtocol.getJavaVersions();
if (supportedJavaVersions.size() > 1) {
javaVersions = supportedJavaVersions.get(0) + " - " + supportedJavaVersions.get(supportedJavaVersions.size() - 1);
} else {
javaVersions = supportedJavaVersions.get(0);
}
sender.sendMessage(GeyserLocale.getPlayerLocaleString("geyser.commands.version.version", sender.getLocale(),
GeyserImpl.NAME, GeyserImpl.VERSION, MinecraftProtocol.getJavaVersion(), bedrockVersions));
GeyserImpl.NAME, GeyserImpl.VERSION, javaVersions, bedrockVersions));
// Disable update checking in dev mode and for players in Geyser Standalone
if (GeyserImpl.getInstance().productionEnvironment() && !(!sender.isConsole() && geyser.getPlatformType() == PlatformType.STANDALONE)) {

View file

@ -207,14 +207,14 @@ public class DumpInfo {
private final List<String> bedrockVersions;
private final List<Integer> bedrockProtocols;
private final int defaultBedrockProtocol;
private final String javaVersion;
private final List<String> javaVersions;
private final int javaProtocol;
MCInfo() {
this.bedrockVersions = MinecraftProtocol.SUPPORTED_BEDROCK_CODECS.stream().map(BedrockPacketCodec::getMinecraftVersion).toList();
this.bedrockProtocols = MinecraftProtocol.SUPPORTED_BEDROCK_CODECS.stream().map(BedrockPacketCodec::getProtocolVersion).toList();
this.defaultBedrockProtocol = MinecraftProtocol.DEFAULT_BEDROCK_CODEC.getProtocolVersion();
this.javaVersion = MinecraftProtocol.getJavaVersion();
this.javaVersions = MinecraftProtocol.getJavaVersions();
this.javaProtocol = MinecraftProtocol.getJavaProtocolVersion();
}
}

View file

@ -33,6 +33,7 @@ import com.nukkitx.protocol.bedrock.v471.Bedrock_v471;
import com.nukkitx.protocol.bedrock.v475.Bedrock_v475;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.StringJoiner;
@ -86,12 +87,12 @@ public final class MinecraftProtocol {
}
/**
* Gets the supported Minecraft: Java Edition version name.
* Gets the supported Minecraft: Java Edition version names.
*
* @return the supported Minecraft: Java Edition version name
* @return the supported Minecraft: Java Edition version names
*/
public static String getJavaVersion() {
return "1.18 - 1.18.1";
public static List<String> getJavaVersions() {
return Arrays.asList("1.18", "1.18.1");
}
/**
@ -104,9 +105,9 @@ public final class MinecraftProtocol {
}
/**
* @return a string showing all supported versions for this Geyser instance
* @return a string showing all supported Bedrock versions for this Geyser instance
*/
public static String getAllSupportedVersions() {
public static String getAllSupportedBedrockVersions() {
StringJoiner joiner = new StringJoiner(", ");
for (BedrockPacketCodec packetCodec : SUPPORTED_BEDROCK_CODECS) {
joiner.add(packetCodec.getMinecraftVersion());
@ -115,6 +116,18 @@ public final class MinecraftProtocol {
return joiner.toString();
}
/**
* @return a string showing all supported Java versions for this Geyser instance
*/
public static String getAllSupportedJavaVersions() {
StringJoiner joiner = new StringJoiner(", ");
for (String version : getJavaVersions()) {
joiner.add(version);
}
return joiner.toString();
}
private MinecraftProtocol() {
}
}

View file

@ -70,7 +70,7 @@ public class UpstreamPacketHandler extends LoggingPacketHandler {
BedrockPacketCodec packetCodec = MinecraftProtocol.getBedrockCodec(loginPacket.getProtocolVersion());
if (packetCodec == null) {
String supportedVersions = MinecraftProtocol.getAllSupportedVersions();
String supportedVersions = MinecraftProtocol.getAllSupportedBedrockVersions();
if (loginPacket.getProtocolVersion() > MinecraftProtocol.DEFAULT_BEDROCK_CODEC.getProtocolVersion()) {
// Too early to determine session locale
session.getGeyser().getLogger().info(GeyserLocale.getLocaleStringLog("geyser.network.outdated.server", supportedVersions));