Skip to content

Commit

Permalink
Display Java supported versions as list in dumps
Browse files Browse the repository at this point in the history
  • Loading branch information
Camotoy committed Dec 10, 2021
1 parent 1885a75 commit 9d09a7e
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,16 @@ public void execute(GeyserSession session, CommandSender sender, String[] args)
} 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)) {
Expand Down
4 changes: 2 additions & 2 deletions core/src/main/java/org/geysermc/geyser/dump/DumpInfo.java
Original file line number Diff line number Diff line change
Expand Up @@ -207,14 +207,14 @@ public static class MCInfo {
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();
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
import com.nukkitx.protocol.bedrock.v475.Bedrock_v475;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.StringJoiner;

Expand Down Expand Up @@ -86,12 +87,12 @@ public static PacketCodec getJavaCodec() {
}

/**
* 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");
}

/**
Expand All @@ -104,9 +105,9 @@ public static int getJavaProtocolVersion() {
}

/**
* @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());
Expand All @@ -115,6 +116,18 @@ public static String getAllSupportedVersions() {
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() {
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ public boolean handle(LoginPacket loginPacket) {

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));
Expand Down

0 comments on commit 9d09a7e

Please sign in to comment.