fix running in versions without version.json
All checks were successful
Publish to snapshot maven / build (push) Successful in 23s

This commit is contained in:
moehreag 2024-06-08 03:04:20 +02:00
parent acc021ffa0
commit 85c94881cf
2 changed files with 6 additions and 4 deletions

View file

@ -36,8 +36,6 @@ dependencies {
api(libs.annotations) api(libs.annotations)
} }
java { java {
sourceCompatibility = JavaVersion.VERSION_21 sourceCompatibility = JavaVersion.VERSION_21
targetCompatibility = JavaVersion.VERSION_21 targetCompatibility = JavaVersion.VERSION_21
@ -84,4 +82,4 @@ publishing {
} }
} }
} }
} }

View file

@ -175,7 +175,11 @@ public class Minecraft implements FrogPlugin {
if (Files.exists(fs.getPath(n)) && n.contains(FrogLoaderImpl.getInstance().getEnv().getIdentifier())) { if (Files.exists(fs.getPath(n)) && n.contains(FrogLoaderImpl.getInstance().getEnv().getIdentifier())) {
LOGGER.info("Found game: {}", jar); LOGGER.info("Found game: {}", jar);
foundMainClass = n.substring(0, n.length() - 6).replace("/", "."); foundMainClass = n.substring(0, n.length() - 6).replace("/", ".");
version = FrogLoaderImpl.getInstance().getGson().fromJson(Files.readString(fs.getPath("version.json")), JsonObject.class).get("id").getAsString(); try {
version = FrogLoaderImpl.getInstance().getGson().fromJson(Files.readString(fs.getPath("version.json")), JsonObject.class).get("id").getAsString();
} catch (Exception e){
version = FrogLoaderImpl.getInstance().getArgument("version");
}
return true; return true;
} }
} }