package io.gitlab.jfronny.inceptum.launcher.model.inceptum; import io.gitlab.jfronny.gson.compile.annotations.GSerializable; import io.gitlab.jfronny.inceptum.common.GsonPreset; import java.util.List; import java.util.Objects; @GSerializable(configure = GsonPreset.Config.class) public class InstanceMeta { public String instanceVersion = "1.0"; public String gameVersion; public String java; public Long minMem; public Long maxMem; public Long lastLaunched; public Arguments arguments; public void setVersion(String version) { this.gameVersion = version; } @Override public boolean equals(Object obj) { if (obj == this) return true; if (obj == null || obj.getClass() != this.getClass()) return false; var that = (InstanceMeta) obj; return Objects.equals(this.gameVersion, that.gameVersion) && Objects.equals(this.java, that.java) && Objects.equals(this.minMem, that.minMem) && Objects.equals(this.maxMem, that.maxMem) && Objects.equals(this.lastLaunched, that.lastLaunched) && Objects.equals(this.arguments, that.arguments); } @Override public int hashCode() { return Objects.hash(gameVersion, java, minMem, maxMem, lastLaunched, arguments); } public void checkArguments() { arguments = arguments == null ? Arguments.EMPTY : arguments.checked(); } @GSerializable(configure = GsonPreset.Config.class) public record Arguments(List jvm, List client, List server) { public static final Arguments EMPTY = new Arguments(List.of(), List.of(), List.of()); public Arguments checked() { return new Arguments( jvm == null ? List.of() : jvm, client == null ? List.of() : client, server == null ? List.of() : server ); } public Arguments withJvm(List jvm) { return new Arguments(jvm, client, server); } public Arguments withClient(List client) { return new Arguments(jvm, client, server); } public Arguments withServer(List server) { return new Arguments(jvm, client, server); } } }