Improve version detection on borge and fabric

This commit is contained in:
Lukas Rieger (Blue) 2022-08-03 23:13:00 +02:00
parent aa5395622c
commit db05bc89b0
No known key found for this signature in database
GPG Key ID: 2D09EC5ED2687FF2
4 changed files with 19 additions and 4 deletions

View File

@ -38,7 +38,7 @@ public class MinecraftVersion implements Comparable<MinecraftVersion> {
private static final Pattern VERSION_REGEX = Pattern.compile("(?:(?<major>\\d+)\\.(?<minor>\\d+))(?:\\.(?<patch>\\d+))?(?:\\-(?:pre|rc)\\d+)?");
public static final MinecraftVersion LATEST_SUPPORTED = new MinecraftVersion(1, 19, 0);
public static final MinecraftVersion LATEST_SUPPORTED = new MinecraftVersion(1, 19, 1);
public static final MinecraftVersion EARLIEST_SUPPORTED = new MinecraftVersion(1, 13);
private final int major, minor, patch;

View File

@ -41,6 +41,7 @@ import net.fabricmc.api.ModInitializer;
import net.fabricmc.fabric.api.command.v2.CommandRegistrationCallback;
import net.fabricmc.fabric.api.event.lifecycle.v1.ServerLifecycleEvents;
import net.fabricmc.fabric.api.event.lifecycle.v1.ServerTickEvents;
import net.minecraft.SharedConstants;
import net.minecraft.server.MinecraftServer;
import net.minecraft.server.network.ServerPlayerEntity;
import net.minecraft.util.Identifier;
@ -124,7 +125,11 @@ public class FabricMod implements ModInitializer, ServerInterface {
@Override
public MinecraftVersion getMinecraftVersion() {
return new MinecraftVersion(1, 19);
try {
return MinecraftVersion.of(SharedConstants.getGameVersion().getReleaseTarget());
} catch (IllegalArgumentException ex) {
return MinecraftVersion.LATEST_SUPPORTED;
}
}
@Override

View File

@ -35,6 +35,7 @@ import de.bluecolored.bluemap.common.serverinterface.ServerWorld;
import de.bluecolored.bluemap.core.BlueMap;
import de.bluecolored.bluemap.core.MinecraftVersion;
import de.bluecolored.bluemap.core.logger.Logger;
import net.minecraft.SharedConstants;
import net.minecraft.core.Registry;
import net.minecraft.resources.ResourceKey;
import net.minecraft.resources.ResourceLocation;
@ -140,7 +141,11 @@ public class ForgeMod implements ServerInterface {
@Override
public MinecraftVersion getMinecraftVersion() {
return new MinecraftVersion(1, 19, 1);
try {
return MinecraftVersion.of(SharedConstants.getCurrentVersion().getReleaseTarget());
} catch (IllegalArgumentException ex) {
return MinecraftVersion.LATEST_SUPPORTED;
}
}
@Override

View File

@ -35,6 +35,7 @@ import de.bluecolored.bluemap.common.serverinterface.ServerWorld;
import de.bluecolored.bluemap.core.BlueMap;
import de.bluecolored.bluemap.core.MinecraftVersion;
import de.bluecolored.bluemap.core.logger.Logger;
import net.minecraft.SharedConstants;
import net.minecraft.core.Registry;
import net.minecraft.resources.ResourceKey;
import net.minecraft.resources.ResourceLocation;
@ -140,7 +141,11 @@ public class ForgeMod implements ServerInterface {
@Override
public MinecraftVersion getMinecraftVersion() {
return new MinecraftVersion(1, 19, 0);
try {
return MinecraftVersion.of(SharedConstants.getCurrentVersion().getReleaseTarget());
} catch (IllegalArgumentException ex) {
return new MinecraftVersion(1, 19, 1);
}
}
@Override