From 787833f7323557ea6bac44c668e3916e4cc06f0b Mon Sep 17 00:00:00 2001 From: JFronny Date: Mon, 3 Jun 2024 14:40:44 +0200 Subject: [PATCH] chore: update to jfCommons 1.7 --- build.gradle.kts | 12 +- .../kotlin/inceptum.gson-compile.gradle.kts | 7 +- .../gitlab/jfronny/inceptum/common/GList.java | 33 ++++++ .../jfronny/inceptum/common/GsonPreset.java | 62 +++++++++-- .../inceptum/common/InceptumConfig.java | 10 +- .../InceptumEnvironmentInitializer.java | 11 +- .../gitlab/jfronny/inceptum/common/Net.java | 27 +++++ .../jfronny/inceptum/common/Updater.java | 9 +- .../gitlab/jfronny/inceptum/common/Utils.java | 4 +- .../common/model/inceptum/UpdateMetadata.java | 4 +- .../common/model/inceptum/WrapperConfig.java | 4 +- common/src/main/java/module-info.java | 9 +- gradle/libs.versions.toml | 15 +-- .../inceptum/cli/BaseInstanceCommand.java | 3 +- .../inceptum/cli/commands/ImportCommand.java | 2 +- launcher-dist/build.gradle.kts | 3 +- launcher-gtk/build.gradle.kts | 2 - .../gitlab/jfronny/inceptum/gtk/util/Log.kt | 4 +- launcher-gtk/src/main/kotlin/module-info.java | 2 +- .../jfronny/inceptum/imgui/GuiMain.java | 8 +- .../inceptum/launcher/api/CurseforgeApi.java | 19 ++-- .../inceptum/launcher/api/FabricMetaApi.java | 12 +- .../jfronny/inceptum/launcher/api/McApi.java | 12 +- .../inceptum/launcher/api/ModrinthApi.java | 20 ++-- .../launcher/api/account/AccountManager.java | 11 +- .../api/account/MicrosoftAccount.java | 4 +- .../api/account/MicrosoftAuthAPI.java | 27 ++--- .../gson/MicrosoftAccountAdapter.java | 15 ++- .../launcher/gson/MicrosoftAccountMeta.java | 4 +- .../gson/MinecraftArgumentAdapter.java | 21 ++-- .../launcher/gson/ModMetaSourcesAdapter.java | 14 +-- .../launcher/gson/ModSourceAdapter.java | 104 ++++++++++-------- .../inceptum/launcher/gson/RulesAdapter.java | 14 +-- .../model/curseforge/CurseforgeFile.java | 12 +- .../model/curseforge/CurseforgeMod.java | 16 +-- .../curseforge/CurseforgeModpackManifest.java | 10 +- .../response/FingerprintMatchesResponse.java | 8 +- .../response/GetModDescriptionResponse.java | 4 +- .../response/GetModFileResponse.java | 4 +- .../curseforge/response/GetModResponse.java | 4 +- .../curseforge/response/SearchResponse.java | 6 +- .../model/fabric/FabricLoaderVersion.java | 4 +- .../launcher/model/fabric/FabricModJson.java | 4 +- .../model/fabric/FabricVersionLoaderInfo.java | 14 +-- .../model/fabric/IntermediaryVersion.java | 4 +- .../launcher/model/inceptum/InstanceMeta.java | 12 +- .../launcher/model/inceptum/ModMeta.java | 9 +- .../model/microsoft/Entitlements.java | 6 +- .../launcher/model/microsoft/Profile.java | 8 +- .../model/microsoft/request/LoginRequest.java | 4 +- .../microsoft/request/XblTokenRequest.java | 9 +- .../microsoft/request/XstsTokenRequest.java | 9 +- .../microsoft/response/LoginResponse.java | 7 +- .../response/OauthTokenResponse.java | 9 +- .../response/XboxLiveAuthResponse.java | 11 +- .../model/modrinth/ModrinthHashes.java | 4 +- .../modrinth/ModrinthModpackManifest.java | 13 +-- .../model/modrinth/ModrinthProject.java | 10 +- .../model/modrinth/ModrinthSearchResult.java | 6 +- .../model/modrinth/ModrinthVersion.java | 8 +- .../launcher/model/mojang/AssetIndex.java | 6 +- .../launcher/model/mojang/JvmFileInfo.java | 8 +- .../launcher/model/mojang/JvmInfo.java | 13 +-- .../model/mojang/MinecraftArgument.java | 4 +- .../model/mojang/MojangFileDownload.java | 4 +- .../inceptum/launcher/model/mojang/Rules.java | 4 +- .../launcher/model/mojang/VersionInfo.java | 21 ++-- .../launcher/model/mojang/VersionsList.java | 6 +- .../model/mojang/VersionsListInfo.java | 4 +- .../launcher/model/multimc/MMCPackMeta.java | 6 +- .../system/exporter/CurseForgeExporter.java | 5 +- .../system/exporter/ModrinthExporter.java | 5 +- .../system/exporter/MultiMCExporter.java | 3 +- .../system/importer/CurseForgeImporter.java | 5 +- .../launcher/system/importer/Importer.java | 3 +- .../system/importer/ModrinthImporter.java | 3 +- .../system/importer/MultiMCImporter.java | 3 +- .../launcher/system/instance/Instance.java | 3 +- .../system/instance/InstanceList.java | 3 +- .../launcher/system/instance/ModManager.java | 3 +- .../system/mds/threaded/FileScanTask.java | 14 +-- .../launcher/system/mds/threaded/MdsMod.java | 3 +- .../system/setup/steps/RunMdsStep.java | 3 +- .../system/setup/steps/WriteMetadataStep.java | 3 +- .../launcher/system/source/ModSource.java | 4 +- .../system/source/ModrinthModSource.java | 6 +- .../inceptum/launcher/util/FileBackedRef.java | 10 ++ launcher/src/main/java/module-info.java | 3 +- .../jfronny/inceptum/wrapper/Wrapper.java | 2 +- 89 files changed, 498 insertions(+), 385 deletions(-) create mode 100644 common/src/main/java/io/gitlab/jfronny/inceptum/common/GList.java diff --git a/build.gradle.kts b/build.gradle.kts index e14ae91..06c6bf3 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -9,16 +9,6 @@ allprojects { group = "io.gitlab.jfronny.inceptum" } -// common -val jfCommonsVersion by extra(libs.versions.jf.commons.get()) -val gsonCompileVersion by extra(libs.versions.gson.compile.get()) -val jbAnnotationsVersion by extra(libs.versions.annotations.get()) -// launcher-imgui -val lwjglVersion by extra(libs.versions.lwjgl.get()) -val imguiVersion by extra(libs.versions.imgui.get()) -// launcher-gtk -val javagiVersion by extra(libs.versions.javagi.get()) - val flavorProp: String by extra(prop("flavor", "custom")) if (!setOf("custom", "maven", "fat", "windows", "linux", "macos").contains(flavorProp)) throw IllegalStateException("Unsupported flavor: $flavorProp") val flavor: String by extra(if (flavorProp != "custom") flavorProp else OS.TYPE.codename) @@ -28,6 +18,8 @@ val isRelease by extra(project.hasProperty("release")) val buildTime by extra(System.currentTimeMillis()) val wrapperVersion by extra(1) +val lwjglVersion = libs.versions.lwjgl.get() +val imguiVersion = libs.versions.imgui.get() tasks.register("exportMetadata") { doLast { projectDir.resolve("version.json").writeText( diff --git a/buildSrc/src/main/kotlin/inceptum.gson-compile.gradle.kts b/buildSrc/src/main/kotlin/inceptum.gson-compile.gradle.kts index c64ba68..a627ecc 100644 --- a/buildSrc/src/main/kotlin/inceptum.gson-compile.gradle.kts +++ b/buildSrc/src/main/kotlin/inceptum.gson-compile.gradle.kts @@ -4,11 +4,10 @@ plugins { val libs = extensions.getByType().named("libs") dependencies { - api(libs.findLibrary("gson-compile-core").orElseThrow()) - compileOnly(libs.findLibrary("gson-compile-annotations").orElseThrow()) - annotationProcessor(libs.findLibrary("gson-compile-processor").orElseThrow()) + compileOnly(libs.findLibrary("commons-serialize-generator-annotations").orElseThrow()) + annotationProcessor(libs.findLibrary("commons-serialize-generator").orElseThrow()) } tasks.withType { - options.compilerArgs.add("-AgsonCompileNoReflect") + options.compilerArgs.addAll(listOf("-AserializeProcessorNoReflect")) } \ No newline at end of file diff --git a/common/src/main/java/io/gitlab/jfronny/inceptum/common/GList.java b/common/src/main/java/io/gitlab/jfronny/inceptum/common/GList.java new file mode 100644 index 0000000..f1e5cc2 --- /dev/null +++ b/common/src/main/java/io/gitlab/jfronny/inceptum/common/GList.java @@ -0,0 +1,33 @@ +package io.gitlab.jfronny.inceptum.common; + +import io.gitlab.jfronny.commons.serialize.SerializeReader; +import io.gitlab.jfronny.commons.serialize.Token; +import io.gitlab.jfronny.commons.serialize.json.JsonWriter; +import io.gitlab.jfronny.commons.throwable.ThrowingBiConsumer; +import io.gitlab.jfronny.commons.throwable.ThrowingFunction; + +import java.io.IOException; +import java.util.LinkedList; +import java.util.List; + +public class GList { + public static > List read(Reader reader, ThrowingFunction read) throws TEx { + if (reader.isLenient() && reader.peek() != Token.BEGIN_ARRAY) return List.of(read.apply(reader)); + reader.beginArray(); + List res = new LinkedList<>(); + while (reader.hasNext()) { + if (reader.peek() == Token.NULL) { + reader.nextNull(); + res.add(null); + } else res.add(read.apply(reader)); + } + reader.endArray(); + return res; + } + + public static void write(JsonWriter writer, List list, ThrowingBiConsumer write) throws IOException { + writer.beginArray(); + for (T t : list) write.accept(t, writer); + writer.endArray(); + } +} diff --git a/common/src/main/java/io/gitlab/jfronny/inceptum/common/GsonPreset.java b/common/src/main/java/io/gitlab/jfronny/inceptum/common/GsonPreset.java index 087ca64..e4e53e5 100644 --- a/common/src/main/java/io/gitlab/jfronny/inceptum/common/GsonPreset.java +++ b/common/src/main/java/io/gitlab/jfronny/inceptum/common/GsonPreset.java @@ -1,34 +1,76 @@ package io.gitlab.jfronny.inceptum.common; -import io.gitlab.jfronny.gson.stream.JsonReader; -import io.gitlab.jfronny.gson.stream.JsonWriter; +import io.gitlab.jfronny.commons.serialize.SerializeReader; +import io.gitlab.jfronny.commons.serialize.SerializeWriter; +import io.gitlab.jfronny.commons.serialize.json.JsonReader; +import io.gitlab.jfronny.commons.serialize.json.JsonTransport; +import io.gitlab.jfronny.commons.serialize.json.JsonWriter; + +import java.io.IOException; +import java.io.Reader; +import java.io.Writer; public class GsonPreset { - public static class Config { - public static void configure(JsonReader reader) { + public static Config CONFIG = new Config(); + public static Api API = new Api(); + + public static class Config extends JsonTransport { + public static > void configure(Reader reader) { reader.setSerializeSpecialFloatingPointValues(true); reader.setLenient(true); } - public static void configure(JsonWriter writer) { + public static > void configure(Writer writer) { writer.setSerializeNulls(true); writer.setSerializeSpecialFloatingPointValues(true); writer.setLenient(true); - writer.setIndent(" "); - writer.setOmitQuotes(true); + if (writer instanceof JsonWriter jw) { + jw.setIndent(" "); + jw.setOmitQuotes(true); + jw.setNewline("\n"); + jw.setCommentUnexpectedNames(true); + } + } + + @Override + public JsonWriter createWriter(Writer target) throws IOException { + JsonWriter jw = super.createWriter(target); + configure(jw); + return jw; + } + + @Override + public JsonReader createReader(Reader source) { + JsonReader jr = super.createReader(source); + configure(jr); + return jr; } } - public static class Api { - public static void configure(JsonReader reader) { + public static class Api extends JsonTransport { + public static > void configure(Reader reader) { reader.setSerializeSpecialFloatingPointValues(true); reader.setLenient(true); } - public static void configure(JsonWriter writer) { + public static > void configure(Writer writer) { writer.setSerializeNulls(false); writer.setSerializeSpecialFloatingPointValues(true); writer.setLenient(false); } + + @Override + public JsonWriter createWriter(Writer target) throws IOException { + JsonWriter jw = super.createWriter(target); + configure(jw); + return jw; + } + + @Override + public JsonReader createReader(Reader source) { + JsonReader jr = super.createReader(source); + configure(jr); + return jr; + } } } diff --git a/common/src/main/java/io/gitlab/jfronny/inceptum/common/InceptumConfig.java b/common/src/main/java/io/gitlab/jfronny/inceptum/common/InceptumConfig.java index 1828378..e690a6e 100644 --- a/common/src/main/java/io/gitlab/jfronny/inceptum/common/InceptumConfig.java +++ b/common/src/main/java/io/gitlab/jfronny/inceptum/common/InceptumConfig.java @@ -1,14 +1,14 @@ package io.gitlab.jfronny.inceptum.common; -import io.gitlab.jfronny.gson.compile.annotations.GComment; -import io.gitlab.jfronny.gson.compile.annotations.GSerializable; +import io.gitlab.jfronny.commons.serialize.generator.annotations.GComment; +import io.gitlab.jfronny.commons.serialize.generator.annotations.GSerializable; import io.gitlab.jfronny.inceptum.common.model.inceptum.UpdateChannel; import java.io.IOException; import java.nio.file.Files; import java.nio.file.Path; -@GSerializable(configure = GsonPreset.Config.class, isStatic = true) +@GSerializable(isStatic = true) public class InceptumConfig { @GComment("Whether to show snapshots in the version selector for new instances") public static boolean snapshots = false; @@ -41,12 +41,12 @@ public class InceptumConfig { saveConfig(); } } - GC_InceptumConfig.read(MetaHolder.CONFIG_PATH); + GC_InceptumConfig.deserialize(MetaHolder.CONFIG_PATH, GsonPreset.CONFIG); } public static void saveConfig() { try { - GC_InceptumConfig.write(MetaHolder.CONFIG_PATH); + GC_InceptumConfig.serialize(MetaHolder.CONFIG_PATH, GsonPreset.CONFIG); } catch (IOException e) { Utils.LOGGER.error("Could not save config", e); } diff --git a/common/src/main/java/io/gitlab/jfronny/inceptum/common/InceptumEnvironmentInitializer.java b/common/src/main/java/io/gitlab/jfronny/inceptum/common/InceptumEnvironmentInitializer.java index b7ecf0a..238dbd2 100644 --- a/common/src/main/java/io/gitlab/jfronny/inceptum/common/InceptumEnvironmentInitializer.java +++ b/common/src/main/java/io/gitlab/jfronny/inceptum/common/InceptumEnvironmentInitializer.java @@ -1,19 +1,20 @@ package io.gitlab.jfronny.inceptum.common; import io.gitlab.jfronny.commons.http.client.HttpClient; -import io.gitlab.jfronny.commons.logging.Logger; -import io.gitlab.jfronny.commons.logging.StdoutLogger; +import io.gitlab.jfronny.commons.logger.HotswapLoggerFinder; +import io.gitlab.jfronny.commons.logger.StdoutLogger; +import io.gitlab.jfronny.commons.logger.SystemLoggerPlus; import java.io.IOException; public class InceptumEnvironmentInitializer { public static void initialize() throws IOException { - Logger.registerFactory(InceptumEnvironmentInitializer::defaultFactory); + HotswapLoggerFinder.updateAllStrategies(InceptumEnvironmentInitializer::defaultFactory); HttpClient.setUserAgent("jfmods/inceptum/" + BuildMetadata.VERSION); InceptumConfig.load(); } - public static Logger defaultFactory(String name) { - return StdoutLogger.fancy(name); + public static SystemLoggerPlus defaultFactory(String name, Module module, System.Logger.Level level) { + return StdoutLogger.fancy(name, module, level); } } diff --git a/common/src/main/java/io/gitlab/jfronny/inceptum/common/Net.java b/common/src/main/java/io/gitlab/jfronny/inceptum/common/Net.java index 2ea0132..b178624 100644 --- a/common/src/main/java/io/gitlab/jfronny/inceptum/common/Net.java +++ b/common/src/main/java/io/gitlab/jfronny/inceptum/common/Net.java @@ -2,6 +2,9 @@ package io.gitlab.jfronny.inceptum.common; import io.gitlab.jfronny.commons.http.client.HttpClient; import io.gitlab.jfronny.commons.io.HashUtils; +import io.gitlab.jfronny.commons.serialize.json.JsonReader; +import io.gitlab.jfronny.commons.serialize.json.JsonTransport; +import io.gitlab.jfronny.commons.throwable.ThrowingBiFunction; import io.gitlab.jfronny.commons.throwable.ThrowingFunction; import io.gitlab.jfronny.commons.throwable.ThrowingSupplier; @@ -34,22 +37,42 @@ public class Net { return downloadObject(url, func, true); } + public static T downloadJObject(String url, ThrowingFunction func) throws IOException { + return downloadJObject(url, func, true); + } + public static T downloadObject(String url, ThrowingFunction func, boolean cache) throws IOException { return downloadObject(url, () -> HttpClient.get(url).sendString(), func, cache); } + public static T downloadJObject(String url, ThrowingFunction func, boolean cache) throws IOException { + return downloadJObject(url, () -> HttpClient.get(url).sendString(), func, cache); + } + public static T downloadObject(String url, ThrowingFunction func, String apiKey) throws IOException { return downloadObject(url, () -> downloadStringAuthenticated(url, apiKey), func, true); } + public static T downloadJObject(String url, ThrowingFunction func, String apiKey) throws IOException { + return downloadJObject(url, () -> downloadStringAuthenticated(url, apiKey), func, true); + } + public static T downloadObject(String url, String sha1, ThrowingFunction func) throws IOException { return downloadObject(url, sha1, func, true); } + public static T downloadJObject(String url, String sha1, ThrowingFunction func) throws IOException { + return downloadJObject(url, sha1, func, true); + } + public static T downloadObject(String url, String sha1, ThrowingFunction func, boolean cache) throws IOException { return downloadObject(url, () -> downloadString(url, sha1), func, cache); } + public static T downloadJObject(String url, String sha1, ThrowingFunction func, boolean cache) throws IOException { + return downloadJObject(url, () -> downloadString(url, sha1), func, cache); + } + private static T downloadObject(String url, ThrowingSupplier sourceString, ThrowingFunction func, boolean cache) throws IOException { try { ThrowingSupplier builder = () -> func.apply(sourceString.get()); @@ -59,6 +82,10 @@ public class Net { } } + public static T downloadJObject(String url, ThrowingSupplier sourceString, ThrowingFunction func, boolean cache) throws IOException { + return downloadObject(url, sourceString, s -> func.apply(GsonPreset.API.createReader(s)), cache); + } + public static String buildUrl(String host, String url, Map params) { StringBuilder res = new StringBuilder(host); if (res.toString().endsWith("/")) res = new StringBuilder(res.substring(0, res.length() - 1)); diff --git a/common/src/main/java/io/gitlab/jfronny/inceptum/common/Updater.java b/common/src/main/java/io/gitlab/jfronny/inceptum/common/Updater.java index 87d63db..c3b3204 100644 --- a/common/src/main/java/io/gitlab/jfronny/inceptum/common/Updater.java +++ b/common/src/main/java/io/gitlab/jfronny/inceptum/common/Updater.java @@ -1,6 +1,7 @@ package io.gitlab.jfronny.inceptum.common; import io.gitlab.jfronny.commons.OSUtils; +import io.gitlab.jfronny.commons.serialize.json.JsonTransport; import io.gitlab.jfronny.inceptum.common.api.MavenApi; import io.gitlab.jfronny.inceptum.common.model.inceptum.*; import io.gitlab.jfronny.inceptum.common.model.maven.*; @@ -53,7 +54,7 @@ public class Updater { config.natives().put(Utils.getCurrentFlavor(), natives); } - GC_WrapperConfig.write(config, MetaHolder.WRAPPER_CONFIG_PATH); + GC_WrapperConfig.serialize(config, MetaHolder.WRAPPER_CONFIG_PATH, GsonPreset.CONFIG); if (relaunch) { Runtime.getRuntime().addShutdownHook(new Thread(() -> { @@ -94,7 +95,7 @@ public class Updater { } } - if (configChanged) GC_WrapperConfig.write(wrapperConfig, MetaHolder.WRAPPER_CONFIG_PATH); + if (configChanged) GC_WrapperConfig.serialize(wrapperConfig, MetaHolder.WRAPPER_CONFIG_PATH, GsonPreset.CONFIG); return buildClasspath(Stream.concat(libs.stream(), natives.stream())).toList(); } @@ -141,10 +142,10 @@ public class Updater { public static @Nullable UpdateMetadata check(UpdateChannel channel, boolean versionCompare, boolean checkEnv, Consumer channelInvalid) throws UpdateCheckException { try { - UpdateMetadata experimental = Net.downloadObject(ARTIFACTS_URL + "version.json", json -> GC_UpdateMetadata.read(json)); + UpdateMetadata experimental = Net.downloadObject(ARTIFACTS_URL + "version.json", json -> GC_UpdateMetadata.deserialize(json, GsonPreset.API)); UpdateMetadata stable = null; try { - stable = Net.downloadObject(STABLE_URL + "version.json", json -> GC_UpdateMetadata.read(json)); + stable = Net.downloadObject(STABLE_URL + "version.json", json -> GC_UpdateMetadata.deserialize(json, GsonPreset.API)); } catch (Throwable ignored) {} if (stable == null && channel == UpdateChannel.Stable) { channel = UpdateChannel.CI; diff --git a/common/src/main/java/io/gitlab/jfronny/inceptum/common/Utils.java b/common/src/main/java/io/gitlab/jfronny/inceptum/common/Utils.java index 6cacc99..2b11648 100644 --- a/common/src/main/java/io/gitlab/jfronny/inceptum/common/Utils.java +++ b/common/src/main/java/io/gitlab/jfronny/inceptum/common/Utils.java @@ -2,7 +2,7 @@ package io.gitlab.jfronny.inceptum.common; import io.gitlab.jfronny.commons.OSUtils; import io.gitlab.jfronny.commons.io.JFiles; -import io.gitlab.jfronny.commons.logging.Logger; +import io.gitlab.jfronny.commons.logger.SystemLoggerPlus; import java.awt.*; import java.io.File; @@ -19,7 +19,7 @@ public class Utils { public static final int CACHE_SIZE = 128; public static final Pattern NEW_LINE = Pattern.compile("[\r\n]+"); public static final Pattern VALID_FILENAME = Pattern.compile("[a-zA-Z0-9_\\-.][a-zA-Z0-9 _\\-.]*[a-zA-Z0-9_\\-.]"); - public static final Logger LOGGER = Logger.forName("Inceptum"); + public static final SystemLoggerPlus LOGGER = SystemLoggerPlus.forName("Inceptum"); private static ClassLoader SYSTEM_LOADER = ClassLoader.getSystemClassLoader(); public static void openWebBrowser(URI uri) { diff --git a/common/src/main/java/io/gitlab/jfronny/inceptum/common/model/inceptum/UpdateMetadata.java b/common/src/main/java/io/gitlab/jfronny/inceptum/common/model/inceptum/UpdateMetadata.java index c563c0b..f2a2ee7 100644 --- a/common/src/main/java/io/gitlab/jfronny/inceptum/common/model/inceptum/UpdateMetadata.java +++ b/common/src/main/java/io/gitlab/jfronny/inceptum/common/model/inceptum/UpdateMetadata.java @@ -1,12 +1,12 @@ package io.gitlab.jfronny.inceptum.common.model.inceptum; -import io.gitlab.jfronny.gson.compile.annotations.GSerializable; +import io.gitlab.jfronny.commons.serialize.generator.annotations.GSerializable; import io.gitlab.jfronny.inceptum.common.GsonPreset; import java.util.Map; import java.util.Set; -@GSerializable(configure = GsonPreset.Api.class) +@GSerializable public record UpdateMetadata(int wrapperVersion, String version, long buildTime, diff --git a/common/src/main/java/io/gitlab/jfronny/inceptum/common/model/inceptum/WrapperConfig.java b/common/src/main/java/io/gitlab/jfronny/inceptum/common/model/inceptum/WrapperConfig.java index 00759a0..ca2aa1a 100644 --- a/common/src/main/java/io/gitlab/jfronny/inceptum/common/model/inceptum/WrapperConfig.java +++ b/common/src/main/java/io/gitlab/jfronny/inceptum/common/model/inceptum/WrapperConfig.java @@ -1,11 +1,11 @@ package io.gitlab.jfronny.inceptum.common.model.inceptum; -import io.gitlab.jfronny.gson.compile.annotations.GSerializable; +import io.gitlab.jfronny.commons.serialize.generator.annotations.GSerializable; import io.gitlab.jfronny.inceptum.common.GsonPreset; import java.util.Map; import java.util.Set; -@GSerializable(configure = GsonPreset.Config.class) +@GSerializable public record WrapperConfig(Set libraries, Set repositories, Map> natives) { } diff --git a/common/src/main/java/module-info.java b/common/src/main/java/module-info.java index c859b1b..295edd9 100644 --- a/common/src/main/java/module-info.java +++ b/common/src/main/java/module-info.java @@ -7,12 +7,11 @@ module io.gitlab.jfronny.inceptum.common { requires transitive java.desktop; requires java.xml; requires transitive io.gitlab.jfronny.commons; - requires transitive io.gitlab.jfronny.commons.gson; requires transitive io.gitlab.jfronny.commons.http.client; requires transitive io.gitlab.jfronny.commons.io; - requires transitive io.gitlab.jfronny.commons.logging; - requires transitive io.gitlab.jfronny.gson; - requires transitive io.gitlab.jfronny.gson.compile.core; + requires transitive io.gitlab.jfronny.commons.logger; + requires transitive io.gitlab.jfronny.commons.serialize.json; requires static org.jetbrains.annotations; - requires static io.gitlab.jfronny.gson.compile.annotations; + requires static io.gitlab.jfronny.commons.serialize.generator.annotations; + requires io.gitlab.jfronny.commons.serialize; } \ No newline at end of file diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index c7a21ed..c8def95 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -1,6 +1,5 @@ [versions] -jf-commons = "1.5-SNAPSHOT" -gson-compile = "1.4-SNAPSHOT" +jf-commons = "1.7-SNAPSHOT" annotations = "24.0.1" lwjgl = "3.3.2" imgui = "1.86.10" @@ -36,12 +35,10 @@ commons = { module = "io.gitlab.jfronny:commons", version.ref = "jf-commons" } commons-http-client = { module = "io.gitlab.jfronny:commons-http-client", version.ref = "jf-commons" } commons-http-server = { module = "io.gitlab.jfronny:commons-http-server", version.ref = "jf-commons" } commons-io = { module = "io.gitlab.jfronny:commons-io", version.ref = "jf-commons" } -commons-logging = { module = "io.gitlab.jfronny:commons-logging", version.ref = "jf-commons" } -commons-serialize-gson = { module = "io.gitlab.jfronny:commons-serialize-gson", version.ref = "jf-commons" } - -gson-compile-core = { module = "io.gitlab.jfronny.gson:gson-compile-core", version.ref = "gson-compile" } -gson-compile-annotations = { module = "io.gitlab.jfronny.gson:gson-compile-annotations", version.ref = "gson-compile" } -gson-compile-processor = { module = "io.gitlab.jfronny.gson:gson-compile-processor", version.ref = "gson-compile" } +commons-logger = { module = "io.gitlab.jfronny:commons-logger", version.ref = "jf-commons" } +commons-serialize-json = { module = "io.gitlab.jfronny:commons-serialize-json", version.ref = "jf-commons" } +commons-serialize-generator-annotations = { module = "io.gitlab.jfronny:commons-serialize-generator-annotations", version.ref = "jf-commons" } +commons-serialize-generator = { module = "io.gitlab.jfronny:commons-serialize-generator", version.ref = "jf-commons" } annotations = { module = "org.jetbrains:annotations", version.ref = "annotations" } @@ -49,4 +46,4 @@ annotations = { module = "org.jetbrains:annotations", version.ref = "annotations lwjgl = ["lwjgl-core", "lwjgl-glfw", "lwjgl-opengl", "lwjgl-tinyfd"] lwjgl-natives = ["lwjgl-core-natives", "lwjgl-glfw-natives", "lwjgl-opengl-natives", "lwjgl-tinyfd-natives"] javagi = ["javagi-glib", "javagi-gtk", "javagi-adw"] -commons = ["commons", "commons-http-client", "commons-io", "commons-logging", "commons-serialize-gson"] \ No newline at end of file +commons = ["commons", "commons-http-client", "commons-io", "commons-logger", "commons-serialize-json"] \ No newline at end of file diff --git a/launcher-cli/src/main/java/io/gitlab/jfronny/inceptum/cli/BaseInstanceCommand.java b/launcher-cli/src/main/java/io/gitlab/jfronny/inceptum/cli/BaseInstanceCommand.java index 7d7472f..90f3d04 100644 --- a/launcher-cli/src/main/java/io/gitlab/jfronny/inceptum/cli/BaseInstanceCommand.java +++ b/launcher-cli/src/main/java/io/gitlab/jfronny/inceptum/cli/BaseInstanceCommand.java @@ -1,5 +1,6 @@ package io.gitlab.jfronny.inceptum.cli; +import io.gitlab.jfronny.inceptum.common.GsonPreset; import io.gitlab.jfronny.inceptum.common.MetaHolder; import io.gitlab.jfronny.inceptum.common.Utils; import io.gitlab.jfronny.inceptum.launcher.model.inceptum.GC_InstanceMeta; @@ -36,7 +37,7 @@ public abstract class BaseInstanceCommand extends Command { Instance instance; Path normalPath = Path.of(args.get(0)); if (Files.exists(normalPath.resolve(Instance.CONFIG_NAME))) { - instance = new Instance(normalPath, GC_InstanceMeta.read(normalPath.resolve(Instance.CONFIG_NAME))); + instance = new Instance(normalPath, GC_InstanceMeta.deserialize(normalPath.resolve(Instance.CONFIG_NAME), GsonPreset.CONFIG)); } else { Path instancePath = MetaHolder.INSTANCE_DIR.resolve(args.get(0)).normalize(); if (!instancePath.startsWith(MetaHolder.INSTANCE_DIR)) { diff --git a/launcher-cli/src/main/java/io/gitlab/jfronny/inceptum/cli/commands/ImportCommand.java b/launcher-cli/src/main/java/io/gitlab/jfronny/inceptum/cli/commands/ImportCommand.java index 6e515ce..e458609 100644 --- a/launcher-cli/src/main/java/io/gitlab/jfronny/inceptum/cli/commands/ImportCommand.java +++ b/launcher-cli/src/main/java/io/gitlab/jfronny/inceptum/cli/commands/ImportCommand.java @@ -1,6 +1,6 @@ package io.gitlab.jfronny.inceptum.cli.commands; -import io.gitlab.jfronny.commons.logging.OutputColors; +import io.gitlab.jfronny.commons.logger.OutputColors; import io.gitlab.jfronny.inceptum.cli.Command; import io.gitlab.jfronny.inceptum.cli.CommandArgs; import io.gitlab.jfronny.inceptum.launcher.system.importer.Importers; diff --git a/launcher-dist/build.gradle.kts b/launcher-dist/build.gradle.kts index 235ac20..11bec2f 100644 --- a/launcher-dist/build.gradle.kts +++ b/launcher-dist/build.gradle.kts @@ -24,7 +24,8 @@ tasks.shadowJar { archiveBaseName.set("Inceptum") exclude("about.html") exclude("plugin.properties") - exclude("META-INF/**") +// exclude("META-INF/**") + mergeServiceFiles() } (components["java"] as AdhocComponentWithVariants).withVariantsFromConfiguration(configurations["shadowRuntimeElements"]) { diff --git a/launcher-gtk/build.gradle.kts b/launcher-gtk/build.gradle.kts index 4932a0a..8bdb807 100644 --- a/launcher-gtk/build.gradle.kts +++ b/launcher-gtk/build.gradle.kts @@ -16,8 +16,6 @@ samWithReceiver { } dependencies { - val javagiVersion: String by rootProject.extra - implementation(libs.bundles.javagi) implementation(projects.launcher) } diff --git a/launcher-gtk/src/main/kotlin/io/gitlab/jfronny/inceptum/gtk/util/Log.kt b/launcher-gtk/src/main/kotlin/io/gitlab/jfronny/inceptum/gtk/util/Log.kt index a987cd9..e9832bf 100644 --- a/launcher-gtk/src/main/kotlin/io/gitlab/jfronny/inceptum/gtk/util/Log.kt +++ b/launcher-gtk/src/main/kotlin/io/gitlab/jfronny/inceptum/gtk/util/Log.kt @@ -1,6 +1,6 @@ package io.gitlab.jfronny.inceptum.gtk.util -import io.gitlab.jfronny.commons.logging.Logger +import io.gitlab.jfronny.commons.logger.SystemLoggerPlus import io.gitlab.jfronny.inceptum.common.Utils -object Log : Logger by Utils.LOGGER \ No newline at end of file +object Log : SystemLoggerPlus by Utils.LOGGER \ No newline at end of file diff --git a/launcher-gtk/src/main/kotlin/module-info.java b/launcher-gtk/src/main/kotlin/module-info.java index aaee171..9264b8e 100644 --- a/launcher-gtk/src/main/kotlin/module-info.java +++ b/launcher-gtk/src/main/kotlin/module-info.java @@ -10,6 +10,6 @@ module io.gitlab.jfronny.inceptum.launcher.gtk { // Should theoretically already be included transitively through inceptum.launcher and inceptum.common requires io.gitlab.jfronny.commons; requires io.gitlab.jfronny.commons.io; - requires io.gitlab.jfronny.commons.logging; + requires io.gitlab.jfronny.commons.logger; requires java.desktop; } \ No newline at end of file diff --git a/launcher-imgui/src/main/java/io/gitlab/jfronny/inceptum/imgui/GuiMain.java b/launcher-imgui/src/main/java/io/gitlab/jfronny/inceptum/imgui/GuiMain.java index bb404c5..8bd938d 100644 --- a/launcher-imgui/src/main/java/io/gitlab/jfronny/inceptum/imgui/GuiMain.java +++ b/launcher-imgui/src/main/java/io/gitlab/jfronny/inceptum/imgui/GuiMain.java @@ -5,7 +5,9 @@ import imgui.ImGuiIO; import imgui.flag.ImGuiConfigFlags; import imgui.gl3.ImGuiImplGl3; import imgui.glfw.ImGuiImplGlfw; -import io.gitlab.jfronny.commons.logging.*; +import io.gitlab.jfronny.commons.logger.CompoundLogger; +import io.gitlab.jfronny.commons.logger.HotswapLoggerFinder; +import io.gitlab.jfronny.commons.logger.MemoryLogger; import io.gitlab.jfronny.inceptum.common.*; import io.gitlab.jfronny.inceptum.common.model.inceptum.UpdateMetadata; import io.gitlab.jfronny.inceptum.imgui.window.MainWindow; @@ -32,7 +34,7 @@ import java.nio.file.Paths; import java.util.*; public class GuiMain { - public static final MemoryLogger MEMLOG = new MemoryLogger("Inceptum"); + public static final MemoryLogger MEMLOG = new MemoryLogger("Inceptum", System.Logger.Level.INFO); public static final Set WINDOWS = new LinkedHashSet<>(); private static final ImGuiImplGlfw imGuiGlfw = new ImGuiImplGlfw(); private static final ImGuiImplGl3 imGuiGl3 = new ImGuiImplGl3(); @@ -54,7 +56,7 @@ public class GuiMain { } public static void showGui() { - Logger.registerFactory(name -> new CompoundLogger(name, InceptumEnvironmentInitializer.defaultFactory(name), MEMLOG)); + HotswapLoggerFinder.updateAllStrategies((name, module, level) -> new CompoundLogger(name, new System.Logger[] { InceptumEnvironmentInitializer.defaultFactory(name, module, level), MEMLOG })); UpdateMetadata update = null; Updater.UpdateCheckException updateCheckFail = null; try { diff --git a/launcher/src/main/java/io/gitlab/jfronny/inceptum/launcher/api/CurseforgeApi.java b/launcher/src/main/java/io/gitlab/jfronny/inceptum/launcher/api/CurseforgeApi.java index 3409967..128d716 100644 --- a/launcher/src/main/java/io/gitlab/jfronny/inceptum/launcher/api/CurseforgeApi.java +++ b/launcher/src/main/java/io/gitlab/jfronny/inceptum/launcher/api/CurseforgeApi.java @@ -1,6 +1,7 @@ package io.gitlab.jfronny.inceptum.launcher.api; import io.gitlab.jfronny.commons.http.client.HttpClient; +import io.gitlab.jfronny.inceptum.common.GsonPreset; import io.gitlab.jfronny.inceptum.common.Net; import io.gitlab.jfronny.inceptum.launcher.model.curseforge.CurseforgeFile; import io.gitlab.jfronny.inceptum.launcher.model.curseforge.CurseforgeMod; @@ -27,7 +28,7 @@ public class CurseforgeApi { private static final int pageSize = 20; public static List search(String gameVersion, String query, int page, String sort) throws IOException { - return Net.downloadObject(Net.buildUrl(API_URL, "mods/search", Map.of( + return Net.downloadJObject(Net.buildUrl(API_URL, "mods/search", Map.of( "gameId", "432", // minecraft "modLoaderType", "4", // fabric "classId", "6", // mods @@ -38,27 +39,27 @@ public class CurseforgeApi { "gameVersion", gameVersion, "pageSize", Integer.toString(pageSize), "index", Integer.toString(page * pageSize) - )), GC_SearchResponse::read, API_KEY).data(); + )), GC_SearchResponse::deserialize, API_KEY).data(); } public static CurseforgeMod getMod(String slug) throws IOException { - SearchResponse response = Net.downloadObject(Net.buildUrl(API_URL, "mods/search", Map.of( + SearchResponse response = Net.downloadJObject(Net.buildUrl(API_URL, "mods/search", Map.of( "gameId", "432", "classId", "6", "slug", slug - )), GC_SearchResponse::read, API_KEY); + )), GC_SearchResponse::deserialize, API_KEY); if (response.pagination().totalCount() != 1) { throw new FileNotFoundException("Could not find mod with slug \"" + slug + "\""); } - return checkDistribution(response.data().get(0)); + return checkDistribution(response.data().getFirst()); } public static CurseforgeMod getMod(int id) throws IOException { - return checkDistribution(Net.downloadObject(API_URL + "mods/" + id, GC_GetModResponse::read, API_KEY).data()); + return checkDistribution(Net.downloadJObject(API_URL + "mods/" + id, GC_GetModResponse::deserialize, API_KEY).data()); } public static String getDescription(int id) throws IOException { - return Net.downloadObject(API_URL + "mods/" + id + "/description", GC_GetModDescriptionResponse::read, API_KEY).data(); + return Net.downloadJObject(API_URL + "mods/" + id + "/description", GC_GetModDescriptionResponse::deserialize, API_KEY).data(); } private static CurseforgeMod checkDistribution(CurseforgeMod mod) { @@ -70,12 +71,12 @@ public class CurseforgeApi { } public static CurseforgeFile getFile(int modId, int fileId) throws IOException { - return Net.downloadObject(API_URL + "mods/" + modId + "/files/" + fileId, GC_GetModFileResponse::read, API_KEY).data(); + return Net.downloadJObject(API_URL + "mods/" + modId + "/files/" + fileId, GC_GetModFileResponse::deserialize, API_KEY).data(); } public static FingerprintMatchesResponse.Result checkFingerprint(long hash) throws IOException, URISyntaxException { try (Reader r = HttpClient.post(API_URL + "fingerprints").bodyJson("{\"fingerprints\":[" + hash + "]}").sendReader()) { - return GC_FingerprintMatchesResponse.read(r).data(); + return GC_FingerprintMatchesResponse.deserialize(r, GsonPreset.API).data(); } } diff --git a/launcher/src/main/java/io/gitlab/jfronny/inceptum/launcher/api/FabricMetaApi.java b/launcher/src/main/java/io/gitlab/jfronny/inceptum/launcher/api/FabricMetaApi.java index 069bd31..eb6bde8 100644 --- a/launcher/src/main/java/io/gitlab/jfronny/inceptum/launcher/api/FabricMetaApi.java +++ b/launcher/src/main/java/io/gitlab/jfronny/inceptum/launcher/api/FabricMetaApi.java @@ -1,8 +1,8 @@ package io.gitlab.jfronny.inceptum.launcher.api; import io.gitlab.jfronny.commons.io.cache.MemoryOperationResultCache; -import io.gitlab.jfronny.gson.compile.util.GList; -import io.gitlab.jfronny.gson.stream.JsonReader; +import io.gitlab.jfronny.commons.serialize.json.JsonReader; +import io.gitlab.jfronny.inceptum.common.GList; import io.gitlab.jfronny.inceptum.common.Net; import io.gitlab.jfronny.inceptum.common.Utils; import io.gitlab.jfronny.inceptum.common.model.maven.ArtifactMeta; @@ -23,10 +23,8 @@ public class FabricMetaApi { public static List getLoaderVersions(VersionsListInfo version) { try { return LOADER_VERSIONS_CACHE.get(version, () -> { - return Net.downloadObject(META_URL + "v2/versions/loader/" + version.id, s -> { - try (JsonReader r = new JsonReader(new StringReader(s))) { - return GList.read(r, GC_FabricVersionLoaderInfo::read); - } + return Net.downloadJObject(META_URL + "v2/versions/loader/" + version.id, s -> { + return GList.read(s, GC_FabricVersionLoaderInfo::deserialize); }); }); } catch (IOException e) { @@ -35,7 +33,7 @@ public class FabricMetaApi { } public static FabricVersionLoaderInfo getLoaderVersion(String gameVersion, String fabricVersion) throws IOException { - return Net.downloadObject(META_URL + "v2/versions/loader/" + gameVersion + "/" + fabricVersion, GC_FabricVersionLoaderInfo.WithMeta::read); + return Net.downloadJObject(META_URL + "v2/versions/loader/" + gameVersion + "/" + fabricVersion, GC_FabricVersionLoaderInfo.WithMeta::deserialize); } public static VersionInfo addFabric(VersionInfo version, String fabricVersion, FabricVersionInfoType type) throws IOException { diff --git a/launcher/src/main/java/io/gitlab/jfronny/inceptum/launcher/api/McApi.java b/launcher/src/main/java/io/gitlab/jfronny/inceptum/launcher/api/McApi.java index fda511d..df086a7 100644 --- a/launcher/src/main/java/io/gitlab/jfronny/inceptum/launcher/api/McApi.java +++ b/launcher/src/main/java/io/gitlab/jfronny/inceptum/launcher/api/McApi.java @@ -1,6 +1,7 @@ package io.gitlab.jfronny.inceptum.launcher.api; import io.gitlab.jfronny.commons.OSUtils; +import io.gitlab.jfronny.inceptum.common.GsonPreset; import io.gitlab.jfronny.inceptum.common.MetaHolder; import io.gitlab.jfronny.inceptum.common.Net; import io.gitlab.jfronny.inceptum.launcher.model.mojang.*; @@ -12,19 +13,20 @@ import java.nio.file.Path; import java.util.List; import java.util.Map; +import static io.gitlab.jfronny.inceptum.common.Net.downloadJObject; import static io.gitlab.jfronny.inceptum.common.Net.downloadObject; public class McApi { public static VersionsList getVersions() { try { - return downloadObject("https://launchermeta.mojang.com/mc/game/version_manifest_v2.json", GC_VersionsList::read); + return downloadJObject("https://launchermeta.mojang.com/mc/game/version_manifest_v2.json", GC_VersionsList::deserialize); } catch (IOException e) { throw new RuntimeException("Could not load version manifest", e); } } public static VersionInfo getVersionInfo(VersionsListInfo listInfo) throws IOException { - return downloadObject(listInfo.url, listInfo.sha1, GC_VersionInfo::read); + return downloadJObject(listInfo.url, listInfo.sha1, GC_VersionInfo::deserialize); } public static AssetIndex getAssetIndex(VersionInfo info) throws IOException, URISyntaxException { @@ -36,12 +38,12 @@ public class McApi { } catch (IOException | URISyntaxException e) { if (!Files.exists(file)) throw e; } - return GC_AssetIndex.read(file); + return GC_AssetIndex.deserialize(file, GsonPreset.API); } public static Map getJvm(String component, int majorVersion) throws IOException { // https://github.com/ATLauncher/ATLauncher/blob/master/src/main/java/com/atlauncher/constants/Constants.java#L123 - JvmInfo info = Net.downloadObject("https://launchermeta.mojang.com/v1/products/java-runtime/2ec0cc96c44e5a76b9c8b7c39df7210883d12871/all.json", GC_JvmInfo::read); + JvmInfo info = downloadJObject("https://launchermeta.mojang.com/v1/products/java-runtime/2ec0cc96c44e5a76b9c8b7c39df7210883d12871/all.json", GC_JvmInfo::deserialize); Map> vms = switch (OSUtils.TYPE) { case WINDOWS -> info.windowsX64(); case LINUX -> info.linux(); @@ -52,7 +54,7 @@ public class McApi { throw new IOException("Invalid component: " + component + " (available: " + String.join(", ", vms.keySet())); for (JvmInfo.Jvm jvm : vmList) { if (jvm.version().name().startsWith(Integer.toString(majorVersion))) { - return downloadObject(jvm.manifest().url, jvm.manifest().sha1, GC_JvmFileInfo::read).files(); + return downloadJObject(jvm.manifest().url, jvm.manifest().sha1, GC_JvmFileInfo::deserialize).files(); } } throw new IOException("JVM not found"); diff --git a/launcher/src/main/java/io/gitlab/jfronny/inceptum/launcher/api/ModrinthApi.java b/launcher/src/main/java/io/gitlab/jfronny/inceptum/launcher/api/ModrinthApi.java index 85ee4fc..c2f3f04 100644 --- a/launcher/src/main/java/io/gitlab/jfronny/inceptum/launcher/api/ModrinthApi.java +++ b/launcher/src/main/java/io/gitlab/jfronny/inceptum/launcher/api/ModrinthApi.java @@ -1,7 +1,7 @@ package io.gitlab.jfronny.inceptum.launcher.api; -import io.gitlab.jfronny.gson.compile.util.GList; -import io.gitlab.jfronny.gson.stream.JsonReader; +import io.gitlab.jfronny.commons.serialize.json.JsonReader; +import io.gitlab.jfronny.inceptum.common.GList; import io.gitlab.jfronny.inceptum.common.Net; import io.gitlab.jfronny.inceptum.launcher.model.modrinth.*; @@ -16,31 +16,27 @@ public class ModrinthApi { //TODO search by categories: facets:[["versions:$ver","versions:$ver"],["categories:$cat","categories:$cat"]] //TODO filter server/client-only mods public static ModrinthSearchResult search(String query, int page, String version, ModrinthProjectType type) throws IOException { - return Net.downloadObject(Net.buildUrl(API_HOST, "v2/search", Map.of( + return Net.downloadJObject(Net.buildUrl(API_HOST, "v2/search", Map.of( "query", query, "facets", "[[\"versions:" + version + "\"],[\"categories:fabric\"],[\"project_type:" + type + "\"]]", "index", "relevance", "offset", Integer.toString(page * ITEMS_PER_PAGE), "limit", Integer.toString(ITEMS_PER_PAGE) - )), GC_ModrinthSearchResult::read); + )), GC_ModrinthSearchResult::deserialize); } public static ModrinthProject getMod(String id) throws IOException { - return Net.downloadObject(API_HOST + "v2/project/" + id, GC_ModrinthProject::read); + return Net.downloadJObject(API_HOST + "v2/project/" + id, GC_ModrinthProject::deserialize); } public static List getVersions(String mod) throws IOException { - List versions = Net.downloadObject(API_HOST + "v2/project/" + mod + "/version", s -> { - try (JsonReader r = new JsonReader(new StringReader(s))) { - return GList.read(r, GC_ModrinthVersion::read); - } - }); + List versions = Net.downloadJObject(API_HOST + "v2/project/" + mod + "/version", s -> GList.read(s, GC_ModrinthVersion::deserialize)); versions.sort(Comparator.comparing(ModrinthVersion::date_published)); return versions; } public static ModrinthVersion getVersion(String id) throws IOException { - return Net.downloadObject(API_HOST + "v2/version/" + id, GC_ModrinthVersion::read); + return Net.downloadJObject(API_HOST + "v2/version/" + id, GC_ModrinthVersion::deserialize); } public static ModrinthLatest getLatestVersions(String mod, String gameVersion) throws IOException { @@ -60,6 +56,6 @@ public class ModrinthApi { } public static ModrinthVersion getVersionByHash(String sha1) throws IOException { - return Net.downloadObject(API_HOST + "v2/version_file/" + sha1 + "?algorithm=sha1", GC_ModrinthVersion::read); + return Net.downloadJObject(API_HOST + "v2/version_file/" + sha1 + "?algorithm=sha1", GC_ModrinthVersion::deserialize); } } diff --git a/launcher/src/main/java/io/gitlab/jfronny/inceptum/launcher/api/account/AccountManager.java b/launcher/src/main/java/io/gitlab/jfronny/inceptum/launcher/api/account/AccountManager.java index ff2c6d0..231ad19 100644 --- a/launcher/src/main/java/io/gitlab/jfronny/inceptum/launcher/api/account/AccountManager.java +++ b/launcher/src/main/java/io/gitlab/jfronny/inceptum/launcher/api/account/AccountManager.java @@ -1,8 +1,7 @@ package io.gitlab.jfronny.inceptum.launcher.api.account; -import io.gitlab.jfronny.gson.compile.util.GList; -import io.gitlab.jfronny.gson.stream.JsonReader; -import io.gitlab.jfronny.gson.stream.JsonWriter; +import io.gitlab.jfronny.commons.serialize.json.JsonReader; +import io.gitlab.jfronny.commons.serialize.json.JsonWriter; import io.gitlab.jfronny.inceptum.common.*; import io.gitlab.jfronny.inceptum.launcher.LauncherEnv; @@ -41,7 +40,7 @@ public class AccountManager { public static void saveAccounts() { try (JsonWriter w = new JsonWriter(Files.newBufferedWriter(MetaHolder.ACCOUNTS_PATH))) { GsonPreset.Config.configure(w); - GList.write(w, ACCOUNTS, GC_MicrosoftAccount::write); + GList.write(w, ACCOUNTS, GC_MicrosoftAccount::serialize); } catch (IOException e) { Utils.LOGGER.error("Could not save accounts", e); } @@ -52,7 +51,7 @@ public class AccountManager { if (Files.exists(MetaHolder.ACCOUNTS_PATH)) { try (JsonReader r = new JsonReader(Files.newBufferedReader(MetaHolder.ACCOUNTS_PATH))) { GsonPreset.Config.configure(r); - ACCOUNTS.addAll(GList.read(r, GC_MicrosoftAccount::read)); + ACCOUNTS.addAll(GList.read(r, GC_MicrosoftAccount::deserialize)); } catch (IOException e) { Utils.LOGGER.error("Could not load accounts", e); } @@ -79,7 +78,7 @@ public class AccountManager { if (ACCOUNTS.size() == 1) switchAccount(null); else - switchAccount(ACCOUNTS.get(0)); + switchAccount(ACCOUNTS.getFirst()); } ACCOUNTS.remove(account); saveAccounts(); diff --git a/launcher/src/main/java/io/gitlab/jfronny/inceptum/launcher/api/account/MicrosoftAccount.java b/launcher/src/main/java/io/gitlab/jfronny/inceptum/launcher/api/account/MicrosoftAccount.java index b997e08..903a1cd 100644 --- a/launcher/src/main/java/io/gitlab/jfronny/inceptum/launcher/api/account/MicrosoftAccount.java +++ b/launcher/src/main/java/io/gitlab/jfronny/inceptum/launcher/api/account/MicrosoftAccount.java @@ -1,6 +1,6 @@ package io.gitlab.jfronny.inceptum.launcher.api.account; -import io.gitlab.jfronny.gson.compile.annotations.GSerializable; +import io.gitlab.jfronny.commons.serialize.generator.annotations.GSerializable; import io.gitlab.jfronny.inceptum.common.GsonPreset; import io.gitlab.jfronny.inceptum.common.Utils; import io.gitlab.jfronny.inceptum.launcher.LauncherEnv; @@ -13,7 +13,7 @@ import java.io.IOException; import java.net.URISyntaxException; import java.util.*; -@GSerializable(with = MicrosoftAccountAdapter.class, configure = GsonPreset.Config.class) +@GSerializable(with = MicrosoftAccountAdapter.class) public class MicrosoftAccount { /** * The username/email/id of the account. diff --git a/launcher/src/main/java/io/gitlab/jfronny/inceptum/launcher/api/account/MicrosoftAuthAPI.java b/launcher/src/main/java/io/gitlab/jfronny/inceptum/launcher/api/account/MicrosoftAuthAPI.java index 8309761..11ef0c9 100644 --- a/launcher/src/main/java/io/gitlab/jfronny/inceptum/launcher/api/account/MicrosoftAuthAPI.java +++ b/launcher/src/main/java/io/gitlab/jfronny/inceptum/launcher/api/account/MicrosoftAuthAPI.java @@ -1,6 +1,7 @@ package io.gitlab.jfronny.inceptum.launcher.api.account; import io.gitlab.jfronny.commons.http.client.HttpClient; +import io.gitlab.jfronny.inceptum.common.GsonPreset; import io.gitlab.jfronny.inceptum.launcher.model.microsoft.*; import io.gitlab.jfronny.inceptum.launcher.model.microsoft.request.*; import io.gitlab.jfronny.inceptum.launcher.model.microsoft.response.*; @@ -38,7 +39,7 @@ public class MicrosoftAuthAPI { "redirect_uri", MICROSOFT_LOGIN_REDIRECT_URL, "scope", String.join(" ", MICROSOFT_LOGIN_SCOPES))) .sendReader()) { - return GC_OauthTokenResponse.read(r); + return GC_OauthTokenResponse.deserialize(r, GsonPreset.API); } } @@ -49,14 +50,14 @@ public class MicrosoftAuthAPI { "grant_type", "refresh_token", "redirect_uri", MICROSOFT_LOGIN_REDIRECT_URL)) .sendReader()) { - return GC_OauthTokenResponse.read(r); + return GC_OauthTokenResponse.deserialize(r, GsonPreset.API); } } public static XboxLiveAuthResponse getXBLToken(String accessToken) throws IOException, URISyntaxException { try (Reader r = HttpClient.post(MICROSOFT_XBL_AUTH_TOKEN_URL) .header("x-xbl-contract-version", "1") - .bodyJson(GC_XblTokenRequest.toJson(new XblTokenRequest( + .bodyJson(GsonPreset.API.write(writer -> GC_XblTokenRequest.serialize(new XblTokenRequest( new XblTokenRequest.Properties( "RPS", "user.auth.xboxlive.com", @@ -64,48 +65,48 @@ public class MicrosoftAuthAPI { ), "http://auth.xboxlive.com", "JWT" - ))) + ), writer))) .sendReader()) { - return GC_XboxLiveAuthResponse.read(r); + return GC_XboxLiveAuthResponse.deserialize(r, GsonPreset.API); } } public static XboxLiveAuthResponse getXstsToken(String xblToken) throws IOException, URISyntaxException { try (Reader r = HttpClient.post(MICROSOFT_XSTS_AUTH_TOKEN_URL) .header("x-xbl-contract-version", "1") - .bodyJson(GC_XstsTokenRequest.toJson(new XstsTokenRequest( + .bodyJson(GsonPreset.API.write(writer -> GC_XstsTokenRequest.serialize(new XstsTokenRequest( new XstsTokenRequest.Properties( "RETAIL", List.of(xblToken) ), "rp://api.minecraftservices.com/", "JWT" - ))) + ), writer))) .sendReader()) { - return GC_XboxLiveAuthResponse.read(r); + return GC_XboxLiveAuthResponse.deserialize(r, GsonPreset.API); } } public static LoginResponse loginToMinecraft(String xstsToken) throws IOException, URISyntaxException { try (Reader r = HttpClient.post(MICROSOFT_MINECRAFT_LOGIN_URL) - .bodyJson(GC_LoginRequest.toJson(new LoginRequest( + .bodyJson(GsonPreset.API.write(writer -> GC_LoginRequest.serialize(new LoginRequest( xstsToken, "PC_LAUNCHER" - ))) + ), writer))) .sendReader()) { - return GC_LoginResponse.read(r); + return GC_LoginResponse.deserialize(r, GsonPreset.API); } } public static Entitlements getEntitlements(String accessToken) throws IOException, URISyntaxException { try (Reader r = HttpClient.get(MICROSOFT_MINECRAFT_ENTITLEMENTS_URL + UUID.randomUUID()).bearer(accessToken).sendReader()) { - return GC_Entitlements.read(r); + return GC_Entitlements.deserialize(r, GsonPreset.API); } } public static Profile getMcProfile(String accessToken) throws IOException, URISyntaxException { try (Reader r = HttpClient.get(MICROSOFT_MINECRAFT_PROFILE_URL).bearer(accessToken).sendReader()) { - return GC_Profile.read(r); + return GC_Profile.deserialize(r, GsonPreset.API); } } } diff --git a/launcher/src/main/java/io/gitlab/jfronny/inceptum/launcher/gson/MicrosoftAccountAdapter.java b/launcher/src/main/java/io/gitlab/jfronny/inceptum/launcher/gson/MicrosoftAccountAdapter.java index c81ecc0..d907a0e 100644 --- a/launcher/src/main/java/io/gitlab/jfronny/inceptum/launcher/gson/MicrosoftAccountAdapter.java +++ b/launcher/src/main/java/io/gitlab/jfronny/inceptum/launcher/gson/MicrosoftAccountAdapter.java @@ -1,18 +1,17 @@ package io.gitlab.jfronny.inceptum.launcher.gson; -import io.gitlab.jfronny.gson.stream.JsonReader; -import io.gitlab.jfronny.gson.stream.JsonWriter; +import io.gitlab.jfronny.commons.serialize.MalformedDataException; +import io.gitlab.jfronny.commons.serialize.SerializeReader; +import io.gitlab.jfronny.commons.serialize.SerializeWriter; import io.gitlab.jfronny.inceptum.launcher.api.account.MicrosoftAccount; -import java.io.IOException; - public class MicrosoftAccountAdapter { - public static void write(MicrosoftAccount value, JsonWriter writer) throws IOException { - GC_MicrosoftAccountMeta.write(value == null ? null : value.toMeta(), writer); + public static > void serialize(MicrosoftAccount value, Writer writer) throws TEx, MalformedDataException { + GC_MicrosoftAccountMeta.serialize(value == null ? null : value.toMeta(), writer); } - public static MicrosoftAccount read(JsonReader reader) throws IOException { - MicrosoftAccountMeta meta = GC_MicrosoftAccountMeta.read(reader); + public static > MicrosoftAccount deserialize(Reader reader) throws TEx, MalformedDataException { + MicrosoftAccountMeta meta = GC_MicrosoftAccountMeta.deserialize(reader); return meta == null ? null : new MicrosoftAccount(meta); } } diff --git a/launcher/src/main/java/io/gitlab/jfronny/inceptum/launcher/gson/MicrosoftAccountMeta.java b/launcher/src/main/java/io/gitlab/jfronny/inceptum/launcher/gson/MicrosoftAccountMeta.java index 6c56e3c..8f5b8ab 100644 --- a/launcher/src/main/java/io/gitlab/jfronny/inceptum/launcher/gson/MicrosoftAccountMeta.java +++ b/launcher/src/main/java/io/gitlab/jfronny/inceptum/launcher/gson/MicrosoftAccountMeta.java @@ -1,12 +1,12 @@ package io.gitlab.jfronny.inceptum.launcher.gson; -import io.gitlab.jfronny.gson.compile.annotations.GSerializable; +import io.gitlab.jfronny.commons.serialize.generator.annotations.GSerializable; import io.gitlab.jfronny.inceptum.common.GsonPreset; import io.gitlab.jfronny.inceptum.launcher.model.microsoft.response.OauthTokenResponse; import io.gitlab.jfronny.inceptum.launcher.model.microsoft.response.XboxLiveAuthResponse; import java.util.Date; -@GSerializable(configure = GsonPreset.Api.class) +@GSerializable public record MicrosoftAccountMeta(String accountId, String minecraftUsername, String uuid, String accessToken, OauthTokenResponse oauthToken, XboxLiveAuthResponse xstsAuth, Date accessTokenExpiresAt, boolean mustLogin) { } diff --git a/launcher/src/main/java/io/gitlab/jfronny/inceptum/launcher/gson/MinecraftArgumentAdapter.java b/launcher/src/main/java/io/gitlab/jfronny/inceptum/launcher/gson/MinecraftArgumentAdapter.java index 3b5b115..6c58902 100644 --- a/launcher/src/main/java/io/gitlab/jfronny/inceptum/launcher/gson/MinecraftArgumentAdapter.java +++ b/launcher/src/main/java/io/gitlab/jfronny/inceptum/launcher/gson/MinecraftArgumentAdapter.java @@ -1,32 +1,33 @@ package io.gitlab.jfronny.inceptum.launcher.gson; -import io.gitlab.jfronny.gson.JsonParseException; -import io.gitlab.jfronny.gson.compile.util.GList; -import io.gitlab.jfronny.gson.stream.*; +import io.gitlab.jfronny.commons.serialize.MalformedDataException; +import io.gitlab.jfronny.commons.serialize.SerializeReader; +import io.gitlab.jfronny.commons.serialize.SerializeWriter; +import io.gitlab.jfronny.commons.serialize.Token; +import io.gitlab.jfronny.inceptum.common.GList; import io.gitlab.jfronny.inceptum.launcher.model.mojang.*; -import java.io.IOException; import java.util.List; import java.util.Set; public class MinecraftArgumentAdapter { - public static void write(MinecraftArgument rules, JsonWriter writer) throws IOException { + public static > void serialize(MinecraftArgument rules, Writer writer) throws TEx { throw new UnsupportedOperationException(); } - public static MinecraftArgument read(JsonReader reader) throws IOException { - if (reader.peek() == JsonToken.STRING) return new MinecraftArgument(Set.of(reader.nextString())); + public static > MinecraftArgument deserialize(Reader reader) throws TEx, MalformedDataException { + if (reader.peek() == Token.STRING) return new MinecraftArgument(Set.of(reader.nextString())); Rules rules = null; List value = null; reader.beginObject(); while (reader.hasNext()) { switch (reader.nextName()) { - case "rules" -> rules = GC_Rules.read(reader); - case "value" -> value = GList.read(reader, JsonReader::nextString); + case "rules" -> rules = GC_Rules.deserialize(reader); + case "value" -> value = GList.read(reader, Reader::nextString); } } reader.endObject(); - if (rules == null || value == null) throw new JsonParseException("Not a valid minecraft argument"); + if (rules == null || value == null) throw new MalformedDataException("Not a valid minecraft argument"); if (!rules.allow()) return new MinecraftArgument(Set.of()); return new MinecraftArgument(Set.copyOf(value)); } diff --git a/launcher/src/main/java/io/gitlab/jfronny/inceptum/launcher/gson/ModMetaSourcesAdapter.java b/launcher/src/main/java/io/gitlab/jfronny/inceptum/launcher/gson/ModMetaSourcesAdapter.java index 79f2914..c58efcd 100644 --- a/launcher/src/main/java/io/gitlab/jfronny/inceptum/launcher/gson/ModMetaSourcesAdapter.java +++ b/launcher/src/main/java/io/gitlab/jfronny/inceptum/launcher/gson/ModMetaSourcesAdapter.java @@ -1,26 +1,26 @@ package io.gitlab.jfronny.inceptum.launcher.gson; -import io.gitlab.jfronny.gson.stream.JsonReader; -import io.gitlab.jfronny.gson.stream.JsonWriter; +import io.gitlab.jfronny.commons.serialize.MalformedDataException; +import io.gitlab.jfronny.commons.serialize.SerializeReader; +import io.gitlab.jfronny.commons.serialize.SerializeWriter; import io.gitlab.jfronny.inceptum.launcher.model.inceptum.ModMeta.Sources; import io.gitlab.jfronny.inceptum.launcher.system.source.GC_ModSource; import io.gitlab.jfronny.inceptum.launcher.system.source.ModSource; -import java.io.IOException; import java.util.Optional; public class ModMetaSourcesAdapter { - public static void write(Sources value, JsonWriter writer) throws IOException { + public static > void serialize(Sources value, Writer writer) throws TEx, MalformedDataException { writer.beginArray(); - for (ModSource source : value.keySet()) GC_ModSource.write(source, writer); + for (ModSource source : value.keySet()) GC_ModSource.serialize(source, writer); writer.endArray(); } - public static Sources read(JsonReader reader) throws IOException { + public static > Sources deserialize(Reader reader) throws TEx, MalformedDataException { reader.beginArray(); Sources sources = new Sources(); while (reader.hasNext()) { - sources.put(GC_ModSource.read(reader), Optional.empty()); + sources.put(GC_ModSource.deserialize(reader), Optional.empty()); } reader.endArray(); return sources; diff --git a/launcher/src/main/java/io/gitlab/jfronny/inceptum/launcher/gson/ModSourceAdapter.java b/launcher/src/main/java/io/gitlab/jfronny/inceptum/launcher/gson/ModSourceAdapter.java index 871784b..a2d8abc 100644 --- a/launcher/src/main/java/io/gitlab/jfronny/inceptum/launcher/gson/ModSourceAdapter.java +++ b/launcher/src/main/java/io/gitlab/jfronny/inceptum/launcher/gson/ModSourceAdapter.java @@ -1,8 +1,8 @@ package io.gitlab.jfronny.inceptum.launcher.gson; -import io.gitlab.jfronny.gson.JsonParseException; -import io.gitlab.jfronny.gson.stream.JsonReader; -import io.gitlab.jfronny.gson.stream.JsonWriter; +import io.gitlab.jfronny.commons.serialize.MalformedDataException; +import io.gitlab.jfronny.commons.serialize.SerializeReader; +import io.gitlab.jfronny.commons.serialize.SerializeWriter; import io.gitlab.jfronny.inceptum.launcher.system.source.*; import java.io.IOException; @@ -10,34 +10,38 @@ import java.util.LinkedHashSet; import java.util.Set; public class ModSourceAdapter { - public static void write(ModSource src, JsonWriter writer) throws IOException { + public static > void serialize(ModSource src, Writer writer) throws TEx { writer.beginObject(); - if (src instanceof ModrinthModSource mo) { - writer.name("type").value("modrinth") + switch (src) { + case ModrinthModSource mo -> writer.name("type").value("modrinth") .name("id").value(mo.getVersionId()); - } else if (src instanceof DirectModSource di) { - writer.name("type").value("direct") - .name("fileName").value(di.getFileName()) - .name("url").value(di.url()) - .name("dependencies"); - writer.beginArray(); - for (ModSource dependency : di.dependencies()) { - write(dependency, writer); + case DirectModSource di -> { + writer.name("type").value("direct") + .name("fileName").value(di.getFileName()) + .name("url").value(di.url()) + .name("dependencies"); + writer.beginArray(); + for (ModSource dependency : di.dependencies()) { + serialize(dependency, writer); + } + writer.endArray(); } - writer.endArray(); - } else if (src instanceof CurseforgeModSource cu) { - writer.name("type").value("curseforge"); - if (cu.getShortName().matches("\\d+")) { - writer.name("projectId").value(cu.getProjectId()); - } else { - writer.name("project").value(cu.getShortName()); + case CurseforgeModSource cu -> { + writer.name("type").value("curseforge"); + if (cu.getShortName().matches("\\d+")) { + writer.name("projectId").value(cu.getProjectId()); + } else { + writer.name("project").value(cu.getShortName()); + } + writer.name("fileId").value(cu.getFileId()); } - writer.name("fileId").value(cu.getFileId()); - } else throw new RuntimeException("ModSources with the type " + src.getClass() + " are not supported"); + case null, default -> + throw new RuntimeException("ModSources with the type " + (src == null ? null : src.getClass()) + " are not supported"); + } writer.endObject(); } - public static ModSource read(JsonReader reader) throws IOException { + public static > ModSource deserialize(Reader reader) throws TEx, MalformedDataException { String type = null; String mr$id = null; @@ -63,34 +67,40 @@ public class ModSourceAdapter { case "dependencies" -> { direct$dependencies = new LinkedHashSet<>(); reader.beginArray(); - while (reader.hasNext()) direct$dependencies.add(read(reader)); + while (reader.hasNext()) direct$dependencies.add(deserialize(reader)); reader.endArray(); } } } reader.endObject(); - if (type == null) throw new JsonParseException("Expected ModSource to contain a type"); - return switch (type) { - case "modrinth" -> { - if (mr$id == null) throw new JsonParseException("Expected ModrinthModSource to contain a version ID"); - yield new ModrinthModSource(mr$id); - } - case "curseforge" -> { - if (cf$fileId == null) - throw new JsonParseException("Expected a fileId in this curseforge project"); - if (cf$projectId != null) yield new CurseforgeModSource(cf$projectId, cf$fileId); - else if (cf$project != null) yield new CurseforgeModSource(cf$project, cf$fileId); - else throw new JsonParseException("Expected a projectId in this curseforge project"); - } - case "direct" -> { - if (direct$fileName == null) throw new JsonParseException("Expected direct download to have a fileName"); - if (direct$url == null) throw new JsonParseException("Expected direct download to have a url"); - if (direct$dependencies == null) yield new DirectModSource(direct$fileName, direct$url, Set.of()); - else { - yield new DirectModSource(direct$fileName, direct$url, direct$dependencies); + if (type == null) throw new MalformedDataException("Expected ModSource to contain a type"); + try { + return switch (type) { + case "modrinth" -> { + if (mr$id == null) throw new MalformedDataException("Expected ModrinthModSource to contain a version ID"); + yield new ModrinthModSource(mr$id); } - } - default -> throw new JsonParseException("Unexpected ModSource type: " + type); - }; + case "curseforge" -> { + if (cf$fileId == null) + throw new MalformedDataException("Expected a fileId in this curseforge project"); + if (cf$projectId != null) yield new CurseforgeModSource(cf$projectId, cf$fileId); + else if (cf$project != null) yield new CurseforgeModSource(cf$project, cf$fileId); + else throw new MalformedDataException("Expected a projectId in this curseforge project"); + } + case "direct" -> { + if (direct$fileName == null) throw new MalformedDataException("Expected direct download to have a fileName"); + if (direct$url == null) throw new MalformedDataException("Expected direct download to have a url"); + if (direct$dependencies == null) yield new DirectModSource(direct$fileName, direct$url, Set.of()); + else { + yield new DirectModSource(direct$fileName, direct$url, direct$dependencies); + } + } + default -> throw new MalformedDataException("Unexpected ModSource type: " + type); + }; + } catch (MalformedDataException mde) { + throw mde; + } catch (IOException e) { + throw new MalformedDataException("Failed to read ModSource", e); + } } } diff --git a/launcher/src/main/java/io/gitlab/jfronny/inceptum/launcher/gson/RulesAdapter.java b/launcher/src/main/java/io/gitlab/jfronny/inceptum/launcher/gson/RulesAdapter.java index 9a02795..fad19a4 100644 --- a/launcher/src/main/java/io/gitlab/jfronny/inceptum/launcher/gson/RulesAdapter.java +++ b/launcher/src/main/java/io/gitlab/jfronny/inceptum/launcher/gson/RulesAdapter.java @@ -1,19 +1,17 @@ package io.gitlab.jfronny.inceptum.launcher.gson; import io.gitlab.jfronny.commons.OSUtils; -import io.gitlab.jfronny.gson.JsonParseException; -import io.gitlab.jfronny.gson.stream.JsonReader; -import io.gitlab.jfronny.gson.stream.JsonWriter; +import io.gitlab.jfronny.commons.serialize.MalformedDataException; +import io.gitlab.jfronny.commons.serialize.SerializeReader; +import io.gitlab.jfronny.commons.serialize.SerializeWriter; import io.gitlab.jfronny.inceptum.launcher.model.mojang.Rules; -import java.io.IOException; - public class RulesAdapter { - public static void write(Rules rules, JsonWriter writer) throws IOException { + public static > void serialize(Rules rules, Writer writer) throws TEx { throw new UnsupportedOperationException(); } - public static Rules read(JsonReader reader) throws IOException { + public static > Rules deserialize(Reader reader) throws TEx, MalformedDataException { boolean valid = true; reader.beginArray(); while (reader.hasNext()) { @@ -48,7 +46,7 @@ public class RulesAdapter { } reader.endObject(); if (actionType == null || (!actionType.equals("allow") && !actionType.equals("disallow"))) { - throw new JsonParseException("Unexpected action in argument: " + actionType); + throw new MalformedDataException("Unexpected action in argument: " + actionType); } if (hasFeatures) valid = false; if (osName != null && !OSUtils.TYPE.getMojName().equals(osName)) valid = false; diff --git a/launcher/src/main/java/io/gitlab/jfronny/inceptum/launcher/model/curseforge/CurseforgeFile.java b/launcher/src/main/java/io/gitlab/jfronny/inceptum/launcher/model/curseforge/CurseforgeFile.java index 7397ceb..b3cc5c2 100644 --- a/launcher/src/main/java/io/gitlab/jfronny/inceptum/launcher/model/curseforge/CurseforgeFile.java +++ b/launcher/src/main/java/io/gitlab/jfronny/inceptum/launcher/model/curseforge/CurseforgeFile.java @@ -1,12 +1,12 @@ package io.gitlab.jfronny.inceptum.launcher.model.curseforge; -import io.gitlab.jfronny.gson.compile.annotations.GSerializable; +import io.gitlab.jfronny.commons.serialize.generator.annotations.GSerializable; import io.gitlab.jfronny.inceptum.common.GsonPreset; import java.util.Date; import java.util.List; -@GSerializable(configure = GsonPreset.Api.class) +@GSerializable public record CurseforgeFile( int id, int gameId, @@ -52,11 +52,11 @@ public record CurseforgeFile( /* Possible algorithms: 1=Sha1 2=Md5*/ - @GSerializable(configure = GsonPreset.Api.class) + @GSerializable public record Hash(String value, int algo) { } - @GSerializable(configure = GsonPreset.Api.class) + @GSerializable public record GameVersion(String gameVersionName, String gameVersionPadded, String gameVersion, @@ -71,11 +71,11 @@ public record CurseforgeFile( 4=Tool 5=Incompatible 6=Include*/ - @GSerializable(configure = GsonPreset.Api.class) + @GSerializable public record Dependency(int modId, int relationType) { } - @GSerializable(configure = GsonPreset.Api.class) + @GSerializable public record Module(String name, long fingerprint) { } } diff --git a/launcher/src/main/java/io/gitlab/jfronny/inceptum/launcher/model/curseforge/CurseforgeMod.java b/launcher/src/main/java/io/gitlab/jfronny/inceptum/launcher/model/curseforge/CurseforgeMod.java index ff083f5..44372c6 100644 --- a/launcher/src/main/java/io/gitlab/jfronny/inceptum/launcher/model/curseforge/CurseforgeMod.java +++ b/launcher/src/main/java/io/gitlab/jfronny/inceptum/launcher/model/curseforge/CurseforgeMod.java @@ -1,12 +1,12 @@ package io.gitlab.jfronny.inceptum.launcher.model.curseforge; -import io.gitlab.jfronny.gson.compile.annotations.GSerializable; +import io.gitlab.jfronny.commons.serialize.generator.annotations.GSerializable; import io.gitlab.jfronny.inceptum.common.GsonPreset; import java.util.Date; import java.util.List; -@GSerializable(configure = GsonPreset.Api.class) +@GSerializable public record CurseforgeMod( int id, int gameId, @@ -45,11 +45,11 @@ public record CurseforgeMod( boolean isAvailable, int thumbsUpCount ) { - @GSerializable(configure = GsonPreset.Api.class) + @GSerializable public record Links(String websiteUrl, String wikiUrl, String issuesUrl, String sourcesUrl) { } - @GSerializable(configure = GsonPreset.Api.class) + @GSerializable public record Category(int id, int gameId, String name, @@ -62,11 +62,11 @@ public record CurseforgeMod( int primaryCategoryId) { } - @GSerializable(configure = GsonPreset.Api.class) + @GSerializable public record Author(int id, String name, String url) { } - @GSerializable(configure = GsonPreset.Api.class) + @GSerializable public record Logo(int id, int modId, String title, @@ -75,7 +75,7 @@ public record CurseforgeMod( String url) { } - @GSerializable(configure = GsonPreset.Api.class) + @GSerializable public record Screenshot(int id, int modId, String title, @@ -84,7 +84,7 @@ public record CurseforgeMod( String url) { } - @GSerializable(configure = GsonPreset.Api.class) + @GSerializable public record LatestFileIndex(String gameVersion, int fileId, String filename, diff --git a/launcher/src/main/java/io/gitlab/jfronny/inceptum/launcher/model/curseforge/CurseforgeModpackManifest.java b/launcher/src/main/java/io/gitlab/jfronny/inceptum/launcher/model/curseforge/CurseforgeModpackManifest.java index 9c7fa6e..9e98a64 100644 --- a/launcher/src/main/java/io/gitlab/jfronny/inceptum/launcher/model/curseforge/CurseforgeModpackManifest.java +++ b/launcher/src/main/java/io/gitlab/jfronny/inceptum/launcher/model/curseforge/CurseforgeModpackManifest.java @@ -1,11 +1,11 @@ package io.gitlab.jfronny.inceptum.launcher.model.curseforge; -import io.gitlab.jfronny.gson.compile.annotations.GSerializable; +import io.gitlab.jfronny.commons.serialize.generator.annotations.GSerializable; import io.gitlab.jfronny.inceptum.common.GsonPreset; import java.util.Set; -@GSerializable(configure = GsonPreset.Api.class) +@GSerializable public record CurseforgeModpackManifest(Minecraft minecraft, String manifestType, int manifestVersion, @@ -14,14 +14,14 @@ public record CurseforgeModpackManifest(Minecraft minecraft, String author, Set files, String overrides) { - @GSerializable(configure = GsonPreset.Api.class) + @GSerializable public record Minecraft(String version, Set modLoaders) { - @GSerializable(configure = GsonPreset.Api.class) + @GSerializable public record ModLoader(String id, boolean primary) { } } - @GSerializable(configure = GsonPreset.Api.class) + @GSerializable public record File(int projectID, int fileID, boolean required) { } } diff --git a/launcher/src/main/java/io/gitlab/jfronny/inceptum/launcher/model/curseforge/response/FingerprintMatchesResponse.java b/launcher/src/main/java/io/gitlab/jfronny/inceptum/launcher/model/curseforge/response/FingerprintMatchesResponse.java index 18837f3..2166005 100644 --- a/launcher/src/main/java/io/gitlab/jfronny/inceptum/launcher/model/curseforge/response/FingerprintMatchesResponse.java +++ b/launcher/src/main/java/io/gitlab/jfronny/inceptum/launcher/model/curseforge/response/FingerprintMatchesResponse.java @@ -1,21 +1,21 @@ package io.gitlab.jfronny.inceptum.launcher.model.curseforge.response; -import io.gitlab.jfronny.gson.compile.annotations.GSerializable; +import io.gitlab.jfronny.commons.serialize.generator.annotations.GSerializable; import io.gitlab.jfronny.inceptum.common.GsonPreset; import io.gitlab.jfronny.inceptum.launcher.model.curseforge.CurseforgeFile; import java.util.List; -@GSerializable(configure = GsonPreset.Api.class) +@GSerializable public record FingerprintMatchesResponse(Result data) { - @GSerializable(configure = GsonPreset.Api.class) + @GSerializable public record Result(boolean isCacheBuilt, List exactMatches, List exactFingerprints, List partialMatches, List installedFingerprints, List unmatchedFingerprints) { - @GSerializable(configure = GsonPreset.Api.class) + @GSerializable public record Match(int id, CurseforgeFile file, List latestFiles) { } } diff --git a/launcher/src/main/java/io/gitlab/jfronny/inceptum/launcher/model/curseforge/response/GetModDescriptionResponse.java b/launcher/src/main/java/io/gitlab/jfronny/inceptum/launcher/model/curseforge/response/GetModDescriptionResponse.java index cc66ffc..4796cf5 100644 --- a/launcher/src/main/java/io/gitlab/jfronny/inceptum/launcher/model/curseforge/response/GetModDescriptionResponse.java +++ b/launcher/src/main/java/io/gitlab/jfronny/inceptum/launcher/model/curseforge/response/GetModDescriptionResponse.java @@ -1,8 +1,8 @@ package io.gitlab.jfronny.inceptum.launcher.model.curseforge.response; -import io.gitlab.jfronny.gson.compile.annotations.GSerializable; +import io.gitlab.jfronny.commons.serialize.generator.annotations.GSerializable; import io.gitlab.jfronny.inceptum.common.GsonPreset; -@GSerializable(configure = GsonPreset.Api.class) +@GSerializable public record GetModDescriptionResponse(String data) { } diff --git a/launcher/src/main/java/io/gitlab/jfronny/inceptum/launcher/model/curseforge/response/GetModFileResponse.java b/launcher/src/main/java/io/gitlab/jfronny/inceptum/launcher/model/curseforge/response/GetModFileResponse.java index 3a326e5..081f8c3 100644 --- a/launcher/src/main/java/io/gitlab/jfronny/inceptum/launcher/model/curseforge/response/GetModFileResponse.java +++ b/launcher/src/main/java/io/gitlab/jfronny/inceptum/launcher/model/curseforge/response/GetModFileResponse.java @@ -1,9 +1,9 @@ package io.gitlab.jfronny.inceptum.launcher.model.curseforge.response; -import io.gitlab.jfronny.gson.compile.annotations.GSerializable; +import io.gitlab.jfronny.commons.serialize.generator.annotations.GSerializable; import io.gitlab.jfronny.inceptum.common.GsonPreset; import io.gitlab.jfronny.inceptum.launcher.model.curseforge.CurseforgeFile; -@GSerializable(configure = GsonPreset.Api.class) +@GSerializable public record GetModFileResponse(CurseforgeFile data) { } diff --git a/launcher/src/main/java/io/gitlab/jfronny/inceptum/launcher/model/curseforge/response/GetModResponse.java b/launcher/src/main/java/io/gitlab/jfronny/inceptum/launcher/model/curseforge/response/GetModResponse.java index a615778..e085430 100644 --- a/launcher/src/main/java/io/gitlab/jfronny/inceptum/launcher/model/curseforge/response/GetModResponse.java +++ b/launcher/src/main/java/io/gitlab/jfronny/inceptum/launcher/model/curseforge/response/GetModResponse.java @@ -1,9 +1,9 @@ package io.gitlab.jfronny.inceptum.launcher.model.curseforge.response; -import io.gitlab.jfronny.gson.compile.annotations.GSerializable; +import io.gitlab.jfronny.commons.serialize.generator.annotations.GSerializable; import io.gitlab.jfronny.inceptum.common.GsonPreset; import io.gitlab.jfronny.inceptum.launcher.model.curseforge.CurseforgeMod; -@GSerializable(configure = GsonPreset.Api.class) +@GSerializable public record GetModResponse(CurseforgeMod data) { } diff --git a/launcher/src/main/java/io/gitlab/jfronny/inceptum/launcher/model/curseforge/response/SearchResponse.java b/launcher/src/main/java/io/gitlab/jfronny/inceptum/launcher/model/curseforge/response/SearchResponse.java index c7a6505..26b0dd7 100644 --- a/launcher/src/main/java/io/gitlab/jfronny/inceptum/launcher/model/curseforge/response/SearchResponse.java +++ b/launcher/src/main/java/io/gitlab/jfronny/inceptum/launcher/model/curseforge/response/SearchResponse.java @@ -1,14 +1,14 @@ package io.gitlab.jfronny.inceptum.launcher.model.curseforge.response; -import io.gitlab.jfronny.gson.compile.annotations.GSerializable; +import io.gitlab.jfronny.commons.serialize.generator.annotations.GSerializable; import io.gitlab.jfronny.inceptum.common.GsonPreset; import io.gitlab.jfronny.inceptum.launcher.model.curseforge.CurseforgeMod; import java.util.List; -@GSerializable(configure = GsonPreset.Api.class) +@GSerializable public record SearchResponse(List data, Pagination pagination) { - @GSerializable(configure = GsonPreset.Api.class) + @GSerializable public record Pagination(int index, int pageSite, int resultCount, int totalCount) { } } diff --git a/launcher/src/main/java/io/gitlab/jfronny/inceptum/launcher/model/fabric/FabricLoaderVersion.java b/launcher/src/main/java/io/gitlab/jfronny/inceptum/launcher/model/fabric/FabricLoaderVersion.java index 0675527..7a19466 100644 --- a/launcher/src/main/java/io/gitlab/jfronny/inceptum/launcher/model/fabric/FabricLoaderVersion.java +++ b/launcher/src/main/java/io/gitlab/jfronny/inceptum/launcher/model/fabric/FabricLoaderVersion.java @@ -1,8 +1,8 @@ package io.gitlab.jfronny.inceptum.launcher.model.fabric; -import io.gitlab.jfronny.gson.compile.annotations.GSerializable; +import io.gitlab.jfronny.commons.serialize.generator.annotations.GSerializable; import io.gitlab.jfronny.inceptum.common.GsonPreset; -@GSerializable(configure = GsonPreset.Api.class) +@GSerializable public record FabricLoaderVersion(String separator, int build, String maven, String version, boolean stable) { } diff --git a/launcher/src/main/java/io/gitlab/jfronny/inceptum/launcher/model/fabric/FabricModJson.java b/launcher/src/main/java/io/gitlab/jfronny/inceptum/launcher/model/fabric/FabricModJson.java index 96e0fc0..549bf70 100644 --- a/launcher/src/main/java/io/gitlab/jfronny/inceptum/launcher/model/fabric/FabricModJson.java +++ b/launcher/src/main/java/io/gitlab/jfronny/inceptum/launcher/model/fabric/FabricModJson.java @@ -1,8 +1,8 @@ package io.gitlab.jfronny.inceptum.launcher.model.fabric; -import io.gitlab.jfronny.gson.compile.annotations.GSerializable; +import io.gitlab.jfronny.commons.serialize.generator.annotations.GSerializable; import io.gitlab.jfronny.inceptum.common.GsonPreset; -@GSerializable(configure = GsonPreset.Api.class) +@GSerializable public record FabricModJson(String id, String name, String description, String version) { } diff --git a/launcher/src/main/java/io/gitlab/jfronny/inceptum/launcher/model/fabric/FabricVersionLoaderInfo.java b/launcher/src/main/java/io/gitlab/jfronny/inceptum/launcher/model/fabric/FabricVersionLoaderInfo.java index 06f952e..c73e7a7 100644 --- a/launcher/src/main/java/io/gitlab/jfronny/inceptum/launcher/model/fabric/FabricVersionLoaderInfo.java +++ b/launcher/src/main/java/io/gitlab/jfronny/inceptum/launcher/model/fabric/FabricVersionLoaderInfo.java @@ -1,29 +1,29 @@ package io.gitlab.jfronny.inceptum.launcher.model.fabric; -import io.gitlab.jfronny.gson.compile.annotations.GSerializable; +import io.gitlab.jfronny.commons.serialize.generator.annotations.GSerializable; import io.gitlab.jfronny.inceptum.common.GsonPreset; import java.util.List; -@GSerializable(configure = GsonPreset.Api.class) +@GSerializable public class FabricVersionLoaderInfo { public FabricLoaderVersion loader; public IntermediaryVersion intermediary; - @GSerializable(configure = GsonPreset.Api.class) + @GSerializable public static class WithMeta extends FabricVersionLoaderInfo { public LauncherMeta launcherMeta; - @GSerializable(configure = GsonPreset.Api.class) + @GSerializable public record LauncherMeta(int version, Libraries libraries, MainClass mainClass) { - @GSerializable(configure = GsonPreset.Api.class) + @GSerializable public record Libraries(List client, List common, List server) { - @GSerializable(configure = GsonPreset.Api.class) + @GSerializable public record Library(String name, String url) { } } - @GSerializable(configure = GsonPreset.Api.class) + @GSerializable public record MainClass(String client, String server) { } } diff --git a/launcher/src/main/java/io/gitlab/jfronny/inceptum/launcher/model/fabric/IntermediaryVersion.java b/launcher/src/main/java/io/gitlab/jfronny/inceptum/launcher/model/fabric/IntermediaryVersion.java index 6c65629..05bdcec 100644 --- a/launcher/src/main/java/io/gitlab/jfronny/inceptum/launcher/model/fabric/IntermediaryVersion.java +++ b/launcher/src/main/java/io/gitlab/jfronny/inceptum/launcher/model/fabric/IntermediaryVersion.java @@ -1,8 +1,8 @@ package io.gitlab.jfronny.inceptum.launcher.model.fabric; -import io.gitlab.jfronny.gson.compile.annotations.GSerializable; +import io.gitlab.jfronny.commons.serialize.generator.annotations.GSerializable; import io.gitlab.jfronny.inceptum.common.GsonPreset; -@GSerializable(configure = GsonPreset.Api.class) +@GSerializable public record IntermediaryVersion(String maven, String version, boolean stable) { } diff --git a/launcher/src/main/java/io/gitlab/jfronny/inceptum/launcher/model/inceptum/InstanceMeta.java b/launcher/src/main/java/io/gitlab/jfronny/inceptum/launcher/model/inceptum/InstanceMeta.java index 6666027..9c2ddd7 100644 --- a/launcher/src/main/java/io/gitlab/jfronny/inceptum/launcher/model/inceptum/InstanceMeta.java +++ b/launcher/src/main/java/io/gitlab/jfronny/inceptum/launcher/model/inceptum/InstanceMeta.java @@ -1,13 +1,12 @@ package io.gitlab.jfronny.inceptum.launcher.model.inceptum; -import io.gitlab.jfronny.gson.compile.annotations.GPrefer; -import io.gitlab.jfronny.gson.compile.annotations.GSerializable; -import io.gitlab.jfronny.inceptum.common.GsonPreset; +import io.gitlab.jfronny.commons.serialize.generator.annotations.GPrefer; +import io.gitlab.jfronny.commons.serialize.generator.annotations.GSerializable; import java.util.List; import java.util.Objects; -@GSerializable(configure = GsonPreset.Config.class) +@GSerializable public class InstanceMeta { public String instanceVersion = "1.0"; public String gameVersion; @@ -43,11 +42,12 @@ public class InstanceMeta { arguments = Arguments.checked(arguments); } - @GSerializable(configure = GsonPreset.Config.class) + @GSerializable public record Arguments(List jvm, List client, List server) { public static final Arguments EMPTY = new Arguments(List.of(), List.of(), List.of()); - @GPrefer public Arguments {} + @GPrefer + public Arguments {} public static Arguments checked(Arguments of) { if (of == null) return EMPTY; diff --git a/launcher/src/main/java/io/gitlab/jfronny/inceptum/launcher/model/inceptum/ModMeta.java b/launcher/src/main/java/io/gitlab/jfronny/inceptum/launcher/model/inceptum/ModMeta.java index bbc5f24..c8250dd 100644 --- a/launcher/src/main/java/io/gitlab/jfronny/inceptum/launcher/model/inceptum/ModMeta.java +++ b/launcher/src/main/java/io/gitlab/jfronny/inceptum/launcher/model/inceptum/ModMeta.java @@ -3,9 +3,8 @@ package io.gitlab.jfronny.inceptum.launcher.model.inceptum; import io.gitlab.jfronny.commons.data.MutCollection; import io.gitlab.jfronny.commons.data.delegate.DelegateMap; import io.gitlab.jfronny.commons.io.HashUtils; -import io.gitlab.jfronny.gson.compile.annotations.GPrefer; -import io.gitlab.jfronny.gson.compile.annotations.GSerializable; -import io.gitlab.jfronny.inceptum.common.GsonPreset; +import io.gitlab.jfronny.commons.serialize.generator.annotations.GPrefer; +import io.gitlab.jfronny.commons.serialize.generator.annotations.GSerializable; import io.gitlab.jfronny.inceptum.common.Utils; import io.gitlab.jfronny.inceptum.launcher.api.CurseforgeApi; import io.gitlab.jfronny.inceptum.launcher.api.ModrinthApi; @@ -21,7 +20,7 @@ import java.nio.file.Files; import java.nio.file.Path; import java.util.*; -@GSerializable(configure = GsonPreset.Config.class) +@GSerializable public record ModMeta( Sources sources, //key: source, value: update String sha1, @@ -30,7 +29,7 @@ public record ModMeta( List dependencies, // by file name boolean explicit ) { - @GSerializable(with = ModMetaSourcesAdapter.class, configure = GsonPreset.Config.class) + @GSerializable(with = ModMetaSourcesAdapter.class) public static class Sources extends DelegateMap> { public Sources() { super(MutCollection.mapOf()); diff --git a/launcher/src/main/java/io/gitlab/jfronny/inceptum/launcher/model/microsoft/Entitlements.java b/launcher/src/main/java/io/gitlab/jfronny/inceptum/launcher/model/microsoft/Entitlements.java index 91aa541..2b2d835 100644 --- a/launcher/src/main/java/io/gitlab/jfronny/inceptum/launcher/model/microsoft/Entitlements.java +++ b/launcher/src/main/java/io/gitlab/jfronny/inceptum/launcher/model/microsoft/Entitlements.java @@ -1,13 +1,13 @@ package io.gitlab.jfronny.inceptum.launcher.model.microsoft; -import io.gitlab.jfronny.gson.compile.annotations.GSerializable; +import io.gitlab.jfronny.commons.serialize.generator.annotations.GSerializable; import io.gitlab.jfronny.inceptum.common.GsonPreset; import java.util.List; -@GSerializable(configure = GsonPreset.Api.class) +@GSerializable public record Entitlements(List items, String signature) { - @GSerializable(configure = GsonPreset.Api.class) + @GSerializable public record StoreItem(String name, String signature) { } } diff --git a/launcher/src/main/java/io/gitlab/jfronny/inceptum/launcher/model/microsoft/Profile.java b/launcher/src/main/java/io/gitlab/jfronny/inceptum/launcher/model/microsoft/Profile.java index 0097fd1..ca0b05b 100644 --- a/launcher/src/main/java/io/gitlab/jfronny/inceptum/launcher/model/microsoft/Profile.java +++ b/launcher/src/main/java/io/gitlab/jfronny/inceptum/launcher/model/microsoft/Profile.java @@ -1,17 +1,17 @@ package io.gitlab.jfronny.inceptum.launcher.model.microsoft; -import io.gitlab.jfronny.gson.compile.annotations.GSerializable; +import io.gitlab.jfronny.commons.serialize.generator.annotations.GSerializable; import io.gitlab.jfronny.inceptum.common.GsonPreset; import java.util.List; -@GSerializable(configure = GsonPreset.Api.class) +@GSerializable public record Profile(String id, String name, List skins, List capes) { - @GSerializable(configure = GsonPreset.Api.class) + @GSerializable public record Skin(String id, String state, String url, String variant, String alias) { } - @GSerializable(configure = GsonPreset.Api.class) + @GSerializable public record Cape(String id) { } } diff --git a/launcher/src/main/java/io/gitlab/jfronny/inceptum/launcher/model/microsoft/request/LoginRequest.java b/launcher/src/main/java/io/gitlab/jfronny/inceptum/launcher/model/microsoft/request/LoginRequest.java index 90ca351..f77de46 100644 --- a/launcher/src/main/java/io/gitlab/jfronny/inceptum/launcher/model/microsoft/request/LoginRequest.java +++ b/launcher/src/main/java/io/gitlab/jfronny/inceptum/launcher/model/microsoft/request/LoginRequest.java @@ -1,8 +1,8 @@ package io.gitlab.jfronny.inceptum.launcher.model.microsoft.request; -import io.gitlab.jfronny.gson.compile.annotations.GSerializable; +import io.gitlab.jfronny.commons.serialize.generator.annotations.GSerializable; import io.gitlab.jfronny.inceptum.common.GsonPreset; -@GSerializable(configure = GsonPreset.Api.class) +@GSerializable public record LoginRequest(String xtoken, String platform) { } diff --git a/launcher/src/main/java/io/gitlab/jfronny/inceptum/launcher/model/microsoft/request/XblTokenRequest.java b/launcher/src/main/java/io/gitlab/jfronny/inceptum/launcher/model/microsoft/request/XblTokenRequest.java index 3f732bd..7dcfa43 100644 --- a/launcher/src/main/java/io/gitlab/jfronny/inceptum/launcher/model/microsoft/request/XblTokenRequest.java +++ b/launcher/src/main/java/io/gitlab/jfronny/inceptum/launcher/model/microsoft/request/XblTokenRequest.java @@ -1,14 +1,13 @@ package io.gitlab.jfronny.inceptum.launcher.model.microsoft.request; -import io.gitlab.jfronny.gson.annotations.SerializedName; -import io.gitlab.jfronny.gson.compile.annotations.GSerializable; -import io.gitlab.jfronny.inceptum.common.GsonPreset; +import io.gitlab.jfronny.commons.serialize.annotations.SerializedName; +import io.gitlab.jfronny.commons.serialize.generator.annotations.GSerializable; -@GSerializable(configure = GsonPreset.Api.class) +@GSerializable public record XblTokenRequest(@SerializedName("Properties") Properties properties, @SerializedName("RelyingParty") String relyingParty, @SerializedName("TokenType") String tokenType) { - @GSerializable(configure = GsonPreset.Api.class) + @GSerializable public record Properties(@SerializedName("AuthMethod") String authMethod, @SerializedName("SiteName") String siteName, @SerializedName("RpsTicket") String rpsTicket) { diff --git a/launcher/src/main/java/io/gitlab/jfronny/inceptum/launcher/model/microsoft/request/XstsTokenRequest.java b/launcher/src/main/java/io/gitlab/jfronny/inceptum/launcher/model/microsoft/request/XstsTokenRequest.java index 798ee0f..361671c 100644 --- a/launcher/src/main/java/io/gitlab/jfronny/inceptum/launcher/model/microsoft/request/XstsTokenRequest.java +++ b/launcher/src/main/java/io/gitlab/jfronny/inceptum/launcher/model/microsoft/request/XstsTokenRequest.java @@ -1,16 +1,15 @@ package io.gitlab.jfronny.inceptum.launcher.model.microsoft.request; -import io.gitlab.jfronny.gson.annotations.SerializedName; -import io.gitlab.jfronny.gson.compile.annotations.GSerializable; -import io.gitlab.jfronny.inceptum.common.GsonPreset; +import io.gitlab.jfronny.commons.serialize.annotations.SerializedName; +import io.gitlab.jfronny.commons.serialize.generator.annotations.GSerializable; import java.util.List; -@GSerializable(configure = GsonPreset.Api.class) +@GSerializable public record XstsTokenRequest(@SerializedName("Properties") Properties properties, @SerializedName("RelyingParty") String relyingParty, @SerializedName("TokenType") String tokenType) { - @GSerializable(configure = GsonPreset.Api.class) + @GSerializable public record Properties(@SerializedName("SandboxId") String sandboxId, @SerializedName("UserTokens") List userTokens) { } } diff --git a/launcher/src/main/java/io/gitlab/jfronny/inceptum/launcher/model/microsoft/response/LoginResponse.java b/launcher/src/main/java/io/gitlab/jfronny/inceptum/launcher/model/microsoft/response/LoginResponse.java index 3a0a549..0546f95 100644 --- a/launcher/src/main/java/io/gitlab/jfronny/inceptum/launcher/model/microsoft/response/LoginResponse.java +++ b/launcher/src/main/java/io/gitlab/jfronny/inceptum/launcher/model/microsoft/response/LoginResponse.java @@ -1,10 +1,9 @@ package io.gitlab.jfronny.inceptum.launcher.model.microsoft.response; -import io.gitlab.jfronny.gson.annotations.SerializedName; -import io.gitlab.jfronny.gson.compile.annotations.GSerializable; -import io.gitlab.jfronny.inceptum.common.GsonPreset; +import io.gitlab.jfronny.commons.serialize.annotations.SerializedName; +import io.gitlab.jfronny.commons.serialize.generator.annotations.GSerializable; -@GSerializable(configure = GsonPreset.Api.class) +@GSerializable public record LoginResponse(String username, @SerializedName("access_token") String accessToken, @SerializedName("token_type") String tokenType, diff --git a/launcher/src/main/java/io/gitlab/jfronny/inceptum/launcher/model/microsoft/response/OauthTokenResponse.java b/launcher/src/main/java/io/gitlab/jfronny/inceptum/launcher/model/microsoft/response/OauthTokenResponse.java index 0406491..565c2cf 100644 --- a/launcher/src/main/java/io/gitlab/jfronny/inceptum/launcher/model/microsoft/response/OauthTokenResponse.java +++ b/launcher/src/main/java/io/gitlab/jfronny/inceptum/launcher/model/microsoft/response/OauthTokenResponse.java @@ -1,13 +1,12 @@ package io.gitlab.jfronny.inceptum.launcher.model.microsoft.response; -import io.gitlab.jfronny.gson.annotations.SerializedName; -import io.gitlab.jfronny.gson.compile.annotations.GPrefer; -import io.gitlab.jfronny.gson.compile.annotations.GSerializable; -import io.gitlab.jfronny.inceptum.common.GsonPreset; +import io.gitlab.jfronny.commons.serialize.annotations.SerializedName; +import io.gitlab.jfronny.commons.serialize.generator.annotations.GPrefer; +import io.gitlab.jfronny.commons.serialize.generator.annotations.GSerializable; import java.util.Date; -@GSerializable(configure = GsonPreset.Api.class) +@GSerializable public record OauthTokenResponse( @SerializedName("token_type") String tokenType, @SerializedName("expires_in") int expiresIn, diff --git a/launcher/src/main/java/io/gitlab/jfronny/inceptum/launcher/model/microsoft/response/XboxLiveAuthResponse.java b/launcher/src/main/java/io/gitlab/jfronny/inceptum/launcher/model/microsoft/response/XboxLiveAuthResponse.java index 3fcc04e..387ef63 100644 --- a/launcher/src/main/java/io/gitlab/jfronny/inceptum/launcher/model/microsoft/response/XboxLiveAuthResponse.java +++ b/launcher/src/main/java/io/gitlab/jfronny/inceptum/launcher/model/microsoft/response/XboxLiveAuthResponse.java @@ -1,20 +1,19 @@ package io.gitlab.jfronny.inceptum.launcher.model.microsoft.response; -import io.gitlab.jfronny.gson.annotations.SerializedName; -import io.gitlab.jfronny.gson.compile.annotations.GSerializable; -import io.gitlab.jfronny.inceptum.common.GsonPreset; +import io.gitlab.jfronny.commons.serialize.annotations.SerializedName; +import io.gitlab.jfronny.commons.serialize.generator.annotations.GSerializable; import java.util.Date; import java.util.List; -@GSerializable(configure = GsonPreset.Api.class) +@GSerializable public record XboxLiveAuthResponse(@SerializedName("IssueInstant") Date issueInstant, @SerializedName("NotAfter") Date notAfter, @SerializedName("Token") String token, @SerializedName("DisplayClaims") DisplayClaims displayClaims) { - @GSerializable(configure = GsonPreset.Api.class) + @GSerializable public record DisplayClaims(List xui) { - @GSerializable(configure = GsonPreset.Api.class) + @GSerializable public record XUIClaim(String uhs) { } } diff --git a/launcher/src/main/java/io/gitlab/jfronny/inceptum/launcher/model/modrinth/ModrinthHashes.java b/launcher/src/main/java/io/gitlab/jfronny/inceptum/launcher/model/modrinth/ModrinthHashes.java index db8cd08..8fa767b 100644 --- a/launcher/src/main/java/io/gitlab/jfronny/inceptum/launcher/model/modrinth/ModrinthHashes.java +++ b/launcher/src/main/java/io/gitlab/jfronny/inceptum/launcher/model/modrinth/ModrinthHashes.java @@ -1,8 +1,8 @@ package io.gitlab.jfronny.inceptum.launcher.model.modrinth; -import io.gitlab.jfronny.gson.compile.annotations.GSerializable; +import io.gitlab.jfronny.commons.serialize.generator.annotations.GSerializable; import io.gitlab.jfronny.inceptum.common.GsonPreset; -@GSerializable(configure = GsonPreset.Api.class) +@GSerializable public record ModrinthHashes(String sha1, String sha512) { } diff --git a/launcher/src/main/java/io/gitlab/jfronny/inceptum/launcher/model/modrinth/ModrinthModpackManifest.java b/launcher/src/main/java/io/gitlab/jfronny/inceptum/launcher/model/modrinth/ModrinthModpackManifest.java index e104025..73e1ed1 100644 --- a/launcher/src/main/java/io/gitlab/jfronny/inceptum/launcher/model/modrinth/ModrinthModpackManifest.java +++ b/launcher/src/main/java/io/gitlab/jfronny/inceptum/launcher/model/modrinth/ModrinthModpackManifest.java @@ -1,13 +1,12 @@ package io.gitlab.jfronny.inceptum.launcher.model.modrinth; -import io.gitlab.jfronny.gson.annotations.SerializedName; -import io.gitlab.jfronny.gson.compile.annotations.GSerializable; -import io.gitlab.jfronny.inceptum.common.GsonPreset; +import io.gitlab.jfronny.commons.serialize.annotations.SerializedName; +import io.gitlab.jfronny.commons.serialize.generator.annotations.GSerializable; import org.jetbrains.annotations.Nullable; import java.util.List; -@GSerializable(configure = GsonPreset.Api.class) +@GSerializable public record ModrinthModpackManifest( int formatVersion, // 1 String game, // "minecraft" @@ -17,15 +16,15 @@ public record ModrinthModpackManifest( List files, Dependencies dependencies ) { - @GSerializable(configure = GsonPreset.Api.class) + @GSerializable public record File(String path, ModrinthHashes hashes, @Nullable Env env, List downloads, long fileSize) { - @GSerializable(configure = GsonPreset.Api.class) + @GSerializable public record Env(ModrinthDependencyType client, ModrinthDependencyType server) { } } // All are nullable - @GSerializable(configure = GsonPreset.Api.class) + @GSerializable public record Dependencies(String minecraft, String forge, @SerializedName("fabric-loader") String fabricLoader, diff --git a/launcher/src/main/java/io/gitlab/jfronny/inceptum/launcher/model/modrinth/ModrinthProject.java b/launcher/src/main/java/io/gitlab/jfronny/inceptum/launcher/model/modrinth/ModrinthProject.java index 777d4ba..3e8d81c 100644 --- a/launcher/src/main/java/io/gitlab/jfronny/inceptum/launcher/model/modrinth/ModrinthProject.java +++ b/launcher/src/main/java/io/gitlab/jfronny/inceptum/launcher/model/modrinth/ModrinthProject.java @@ -1,12 +1,12 @@ package io.gitlab.jfronny.inceptum.launcher.model.modrinth; -import io.gitlab.jfronny.gson.compile.annotations.GSerializable; +import io.gitlab.jfronny.commons.serialize.generator.annotations.GSerializable; import io.gitlab.jfronny.inceptum.common.GsonPreset; import java.util.Date; import java.util.List; -@GSerializable(configure = GsonPreset.Api.class) +@GSerializable public record ModrinthProject( String id, String slug, @@ -34,15 +34,15 @@ public record ModrinthProject( List donation_urls, List gallery ) { - @GSerializable(configure = GsonPreset.Api.class) + @GSerializable public record DonationUrl(String id, String platform, String url) { } - @GSerializable(configure = GsonPreset.Api.class) + @GSerializable public record License(String id, String name, String url) { } - @GSerializable(configure = GsonPreset.Api.class) + @GSerializable public record GalleryItem(String url, boolean featured, String title, String description, Date created) { } } diff --git a/launcher/src/main/java/io/gitlab/jfronny/inceptum/launcher/model/modrinth/ModrinthSearchResult.java b/launcher/src/main/java/io/gitlab/jfronny/inceptum/launcher/model/modrinth/ModrinthSearchResult.java index fcc9d7f..e846bee 100644 --- a/launcher/src/main/java/io/gitlab/jfronny/inceptum/launcher/model/modrinth/ModrinthSearchResult.java +++ b/launcher/src/main/java/io/gitlab/jfronny/inceptum/launcher/model/modrinth/ModrinthSearchResult.java @@ -1,14 +1,14 @@ package io.gitlab.jfronny.inceptum.launcher.model.modrinth; -import io.gitlab.jfronny.gson.compile.annotations.GSerializable; +import io.gitlab.jfronny.commons.serialize.generator.annotations.GSerializable; import io.gitlab.jfronny.inceptum.common.GsonPreset; import java.util.Date; import java.util.List; -@GSerializable(configure = GsonPreset.Api.class) +@GSerializable public record ModrinthSearchResult(List hits, int offset, int limit, int total_hits) { - @GSerializable(configure = GsonPreset.Api.class) + @GSerializable public record ModResult( String project_id, ModrinthProjectType project_type, diff --git a/launcher/src/main/java/io/gitlab/jfronny/inceptum/launcher/model/modrinth/ModrinthVersion.java b/launcher/src/main/java/io/gitlab/jfronny/inceptum/launcher/model/modrinth/ModrinthVersion.java index 54b2f86..9f06b78 100644 --- a/launcher/src/main/java/io/gitlab/jfronny/inceptum/launcher/model/modrinth/ModrinthVersion.java +++ b/launcher/src/main/java/io/gitlab/jfronny/inceptum/launcher/model/modrinth/ModrinthVersion.java @@ -1,12 +1,12 @@ package io.gitlab.jfronny.inceptum.launcher.model.modrinth; -import io.gitlab.jfronny.gson.compile.annotations.GSerializable; +import io.gitlab.jfronny.commons.serialize.generator.annotations.GSerializable; import io.gitlab.jfronny.inceptum.common.GsonPreset; import java.util.Date; import java.util.List; -@GSerializable(configure = GsonPreset.Api.class) +@GSerializable public record ModrinthVersion( String id, String project_id, @@ -28,11 +28,11 @@ public record ModrinthVersion( alpha, beta, release } - @GSerializable(configure = GsonPreset.Api.class) + @GSerializable public record File(ModrinthHashes hashes, String url, String filename, boolean primary) { } - @GSerializable(configure = GsonPreset.Api.class) + @GSerializable public record Dependency(String version_id, String project_id, DependencyType dependency_type) { public enum DependencyType { required, diff --git a/launcher/src/main/java/io/gitlab/jfronny/inceptum/launcher/model/mojang/AssetIndex.java b/launcher/src/main/java/io/gitlab/jfronny/inceptum/launcher/model/mojang/AssetIndex.java index 5575ab9..0a8d6cb 100644 --- a/launcher/src/main/java/io/gitlab/jfronny/inceptum/launcher/model/mojang/AssetIndex.java +++ b/launcher/src/main/java/io/gitlab/jfronny/inceptum/launcher/model/mojang/AssetIndex.java @@ -1,13 +1,13 @@ package io.gitlab.jfronny.inceptum.launcher.model.mojang; -import io.gitlab.jfronny.gson.compile.annotations.GSerializable; +import io.gitlab.jfronny.commons.serialize.generator.annotations.GSerializable; import io.gitlab.jfronny.inceptum.common.GsonPreset; import java.util.Map; -@GSerializable(configure = GsonPreset.Api.class) +@GSerializable public record AssetIndex(Map objects) { - @GSerializable(configure = GsonPreset.Api.class) + @GSerializable public record Asset(String hash, int size) { } } diff --git a/launcher/src/main/java/io/gitlab/jfronny/inceptum/launcher/model/mojang/JvmFileInfo.java b/launcher/src/main/java/io/gitlab/jfronny/inceptum/launcher/model/mojang/JvmFileInfo.java index 6dc8a37..aa88515 100644 --- a/launcher/src/main/java/io/gitlab/jfronny/inceptum/launcher/model/mojang/JvmFileInfo.java +++ b/launcher/src/main/java/io/gitlab/jfronny/inceptum/launcher/model/mojang/JvmFileInfo.java @@ -1,15 +1,15 @@ package io.gitlab.jfronny.inceptum.launcher.model.mojang; -import io.gitlab.jfronny.gson.compile.annotations.GSerializable; +import io.gitlab.jfronny.commons.serialize.generator.annotations.GSerializable; import io.gitlab.jfronny.inceptum.common.GsonPreset; import java.util.Map; -@GSerializable(configure = GsonPreset.Api.class) +@GSerializable public record JvmFileInfo(Map files) { - @GSerializable(configure = GsonPreset.Api.class) + @GSerializable public record File(Downloads downloads, boolean executable, String type) { - @GSerializable(configure = GsonPreset.Api.class) + @GSerializable public record Downloads(MojangFileDownload lzma, MojangFileDownload raw) { } } diff --git a/launcher/src/main/java/io/gitlab/jfronny/inceptum/launcher/model/mojang/JvmInfo.java b/launcher/src/main/java/io/gitlab/jfronny/inceptum/launcher/model/mojang/JvmInfo.java index 2d9c716..39ce7f7 100644 --- a/launcher/src/main/java/io/gitlab/jfronny/inceptum/launcher/model/mojang/JvmInfo.java +++ b/launcher/src/main/java/io/gitlab/jfronny/inceptum/launcher/model/mojang/JvmInfo.java @@ -1,23 +1,22 @@ package io.gitlab.jfronny.inceptum.launcher.model.mojang; -import io.gitlab.jfronny.gson.annotations.SerializedName; -import io.gitlab.jfronny.gson.compile.annotations.GSerializable; -import io.gitlab.jfronny.inceptum.common.GsonPreset; +import io.gitlab.jfronny.commons.serialize.annotations.SerializedName; +import io.gitlab.jfronny.commons.serialize.generator.annotations.GSerializable; import java.util.List; import java.util.Map; -@GSerializable(configure = GsonPreset.Api.class) +@GSerializable public record JvmInfo(Map> linux, @SerializedName("mac-os") Map> macOs, @SerializedName("windows-x64") Map> windowsX64) { - @GSerializable(configure = GsonPreset.Api.class) + @GSerializable public record Jvm(Availability availability, MojangFileDownload manifest, Version version) { - @GSerializable(configure = GsonPreset.Api.class) + @GSerializable public record Availability(int group, int progress) { } - @GSerializable(configure = GsonPreset.Api.class) + @GSerializable public record Version(String name, String released) { } } diff --git a/launcher/src/main/java/io/gitlab/jfronny/inceptum/launcher/model/mojang/MinecraftArgument.java b/launcher/src/main/java/io/gitlab/jfronny/inceptum/launcher/model/mojang/MinecraftArgument.java index 47e4c0c..b2c1134 100644 --- a/launcher/src/main/java/io/gitlab/jfronny/inceptum/launcher/model/mojang/MinecraftArgument.java +++ b/launcher/src/main/java/io/gitlab/jfronny/inceptum/launcher/model/mojang/MinecraftArgument.java @@ -1,13 +1,13 @@ package io.gitlab.jfronny.inceptum.launcher.model.mojang; -import io.gitlab.jfronny.gson.compile.annotations.GSerializable; +import io.gitlab.jfronny.commons.serialize.generator.annotations.GSerializable; import io.gitlab.jfronny.inceptum.common.GsonPreset; import io.gitlab.jfronny.inceptum.launcher.gson.MinecraftArgumentAdapter; import java.util.LinkedHashSet; import java.util.Set; -@GSerializable(with = MinecraftArgumentAdapter.class, configure = GsonPreset.Api.class) +@GSerializable(with = MinecraftArgumentAdapter.class) public record MinecraftArgument(Set arg) implements Cloneable { @Override protected MinecraftArgument clone() { diff --git a/launcher/src/main/java/io/gitlab/jfronny/inceptum/launcher/model/mojang/MojangFileDownload.java b/launcher/src/main/java/io/gitlab/jfronny/inceptum/launcher/model/mojang/MojangFileDownload.java index 1ce506d..c76cca4 100644 --- a/launcher/src/main/java/io/gitlab/jfronny/inceptum/launcher/model/mojang/MojangFileDownload.java +++ b/launcher/src/main/java/io/gitlab/jfronny/inceptum/launcher/model/mojang/MojangFileDownload.java @@ -1,9 +1,9 @@ package io.gitlab.jfronny.inceptum.launcher.model.mojang; -import io.gitlab.jfronny.gson.compile.annotations.GSerializable; +import io.gitlab.jfronny.commons.serialize.generator.annotations.GSerializable; import io.gitlab.jfronny.inceptum.common.GsonPreset; -@GSerializable(configure = GsonPreset.Api.class) +@GSerializable public class MojangFileDownload implements Cloneable { public String sha1; public int size; diff --git a/launcher/src/main/java/io/gitlab/jfronny/inceptum/launcher/model/mojang/Rules.java b/launcher/src/main/java/io/gitlab/jfronny/inceptum/launcher/model/mojang/Rules.java index 9bce278..96bd3ba 100644 --- a/launcher/src/main/java/io/gitlab/jfronny/inceptum/launcher/model/mojang/Rules.java +++ b/launcher/src/main/java/io/gitlab/jfronny/inceptum/launcher/model/mojang/Rules.java @@ -1,10 +1,10 @@ package io.gitlab.jfronny.inceptum.launcher.model.mojang; -import io.gitlab.jfronny.gson.compile.annotations.GSerializable; +import io.gitlab.jfronny.commons.serialize.generator.annotations.GSerializable; import io.gitlab.jfronny.inceptum.common.GsonPreset; import io.gitlab.jfronny.inceptum.launcher.gson.RulesAdapter; -@GSerializable(with = RulesAdapter.class, configure = GsonPreset.Api.class) +@GSerializable(with = RulesAdapter.class) public record Rules(boolean allow) implements Cloneable { @Override protected Rules clone() { diff --git a/launcher/src/main/java/io/gitlab/jfronny/inceptum/launcher/model/mojang/VersionInfo.java b/launcher/src/main/java/io/gitlab/jfronny/inceptum/launcher/model/mojang/VersionInfo.java index c9033b2..27179ec 100644 --- a/launcher/src/main/java/io/gitlab/jfronny/inceptum/launcher/model/mojang/VersionInfo.java +++ b/launcher/src/main/java/io/gitlab/jfronny/inceptum/launcher/model/mojang/VersionInfo.java @@ -1,13 +1,12 @@ package io.gitlab.jfronny.inceptum.launcher.model.mojang; -import io.gitlab.jfronny.gson.compile.annotations.GPrefer; -import io.gitlab.jfronny.gson.compile.annotations.GSerializable; -import io.gitlab.jfronny.inceptum.common.GsonPreset; +import io.gitlab.jfronny.commons.serialize.generator.annotations.GPrefer; +import io.gitlab.jfronny.commons.serialize.generator.annotations.GSerializable; import java.util.*; @SuppressWarnings("MethodDoesntCallSuperMethod") -@GSerializable(configure = GsonPreset.Api.class) +@GSerializable public class VersionInfo extends VersionsListInfo implements Cloneable { public Arguments arguments; public AssetIndex assetIndex; @@ -36,7 +35,7 @@ public class VersionInfo extends VersionsListInfo implements Cloneable { return clone; } - @GSerializable(configure = GsonPreset.Api.class) + @GSerializable public record Arguments(List game, List jvm) implements Cloneable { @Override public Arguments clone() { @@ -47,7 +46,7 @@ public class VersionInfo extends VersionsListInfo implements Cloneable { } } - @GSerializable(configure = GsonPreset.Api.class) + @GSerializable public static class AssetIndex extends MojangFileDownload { public String id; public int totalSize; @@ -62,7 +61,7 @@ public class VersionInfo extends VersionsListInfo implements Cloneable { } } - @GSerializable(configure = GsonPreset.Api.class) + @GSerializable public record Downloads(MojangFileDownload client, MojangFileDownload client_mappings, MojangFileDownload server, @@ -78,7 +77,7 @@ public class VersionInfo extends VersionsListInfo implements Cloneable { } } - @GSerializable(configure = GsonPreset.Api.class) + @GSerializable public record JavaVersion(String component, int majorVersion) implements Cloneable { @Override public JavaVersion clone() { @@ -86,7 +85,7 @@ public class VersionInfo extends VersionsListInfo implements Cloneable { } } - @GSerializable(configure = GsonPreset.Api.class) + @GSerializable public record Library(Downloads downloads, String name, Map natives, Rules rules) implements Cloneable { @Override public Library clone() { @@ -100,7 +99,7 @@ public class VersionInfo extends VersionsListInfo implements Cloneable { return clone; } - @GSerializable(configure = GsonPreset.Api.class) + @GSerializable public record Downloads(Artifact artifact, Map classifiers) implements Cloneable { @Override public Downloads clone() { @@ -109,7 +108,7 @@ public class VersionInfo extends VersionsListInfo implements Cloneable { return clone; } - @GSerializable(configure = GsonPreset.Api.class) + @GSerializable public static class Artifact extends MojangFileDownload implements Cloneable { public String path; diff --git a/launcher/src/main/java/io/gitlab/jfronny/inceptum/launcher/model/mojang/VersionsList.java b/launcher/src/main/java/io/gitlab/jfronny/inceptum/launcher/model/mojang/VersionsList.java index 0d38ffe..9e4fab0 100644 --- a/launcher/src/main/java/io/gitlab/jfronny/inceptum/launcher/model/mojang/VersionsList.java +++ b/launcher/src/main/java/io/gitlab/jfronny/inceptum/launcher/model/mojang/VersionsList.java @@ -1,13 +1,13 @@ package io.gitlab.jfronny.inceptum.launcher.model.mojang; -import io.gitlab.jfronny.gson.compile.annotations.GSerializable; +import io.gitlab.jfronny.commons.serialize.generator.annotations.GSerializable; import io.gitlab.jfronny.inceptum.common.GsonPreset; import java.util.List; -@GSerializable(configure = GsonPreset.Api.class) +@GSerializable public record VersionsList(Latest latest, List versions) { - @GSerializable(configure = GsonPreset.Api.class) + @GSerializable public record Latest(String release, String snapshot) { } } diff --git a/launcher/src/main/java/io/gitlab/jfronny/inceptum/launcher/model/mojang/VersionsListInfo.java b/launcher/src/main/java/io/gitlab/jfronny/inceptum/launcher/model/mojang/VersionsListInfo.java index a11f4ea..c611f13 100644 --- a/launcher/src/main/java/io/gitlab/jfronny/inceptum/launcher/model/mojang/VersionsListInfo.java +++ b/launcher/src/main/java/io/gitlab/jfronny/inceptum/launcher/model/mojang/VersionsListInfo.java @@ -1,12 +1,12 @@ package io.gitlab.jfronny.inceptum.launcher.model.mojang; -import io.gitlab.jfronny.gson.compile.annotations.GSerializable; +import io.gitlab.jfronny.commons.serialize.generator.annotations.GSerializable; import io.gitlab.jfronny.inceptum.common.GsonPreset; import java.util.Date; import java.util.Objects; -@GSerializable(configure = GsonPreset.Api.class) +@GSerializable public class VersionsListInfo { public String id; public String type; diff --git a/launcher/src/main/java/io/gitlab/jfronny/inceptum/launcher/model/multimc/MMCPackMeta.java b/launcher/src/main/java/io/gitlab/jfronny/inceptum/launcher/model/multimc/MMCPackMeta.java index d718aa4..eb6e92e 100644 --- a/launcher/src/main/java/io/gitlab/jfronny/inceptum/launcher/model/multimc/MMCPackMeta.java +++ b/launcher/src/main/java/io/gitlab/jfronny/inceptum/launcher/model/multimc/MMCPackMeta.java @@ -1,13 +1,13 @@ package io.gitlab.jfronny.inceptum.launcher.model.multimc; -import io.gitlab.jfronny.gson.compile.annotations.GSerializable; +import io.gitlab.jfronny.commons.serialize.generator.annotations.GSerializable; import io.gitlab.jfronny.inceptum.common.GsonPreset; import java.util.List; -@GSerializable(configure = GsonPreset.Api.class) +@GSerializable public record MMCPackMeta(List components, int formatVersion) { - @GSerializable(configure = GsonPreset.Api.class) + @GSerializable public record Component(boolean dependencyOnly, boolean important, String uid, String version) { } } diff --git a/launcher/src/main/java/io/gitlab/jfronny/inceptum/launcher/system/exporter/CurseForgeExporter.java b/launcher/src/main/java/io/gitlab/jfronny/inceptum/launcher/system/exporter/CurseForgeExporter.java index b14a306..3f33ca3 100644 --- a/launcher/src/main/java/io/gitlab/jfronny/inceptum/launcher/system/exporter/CurseForgeExporter.java +++ b/launcher/src/main/java/io/gitlab/jfronny/inceptum/launcher/system/exporter/CurseForgeExporter.java @@ -1,5 +1,6 @@ package io.gitlab.jfronny.inceptum.launcher.system.exporter; +import io.gitlab.jfronny.inceptum.common.GsonPreset; import io.gitlab.jfronny.inceptum.common.InceptumConfig; import io.gitlab.jfronny.inceptum.launcher.model.curseforge.CurseforgeModpackManifest; import io.gitlab.jfronny.inceptum.launcher.model.curseforge.GC_CurseforgeModpackManifest; @@ -41,7 +42,7 @@ public class CurseForgeExporter extends Exporter { true )); } - GC_CurseforgeModpackManifest.write(manifest, root.resolve("manifest.json")); + GC_CurseforgeModpackManifest.serialize(manifest, root.resolve("manifest.json"), GsonPreset.API); return manifest; } @@ -60,6 +61,6 @@ public class CurseForgeExporter extends Exporter { Files.createDirectories(modsOverrides); Files.copy(mod.getJarPath(), modsOverrides.resolve(mod.getJarPath().getFileName().toString())); } - GC_CurseforgeModpackManifest.write(manifest, root.resolve("manifest.json")); + GC_CurseforgeModpackManifest.serialize(manifest, root.resolve("manifest.json"), GsonPreset.API); } } diff --git a/launcher/src/main/java/io/gitlab/jfronny/inceptum/launcher/system/exporter/ModrinthExporter.java b/launcher/src/main/java/io/gitlab/jfronny/inceptum/launcher/system/exporter/ModrinthExporter.java index c98bdf2..772dc61 100644 --- a/launcher/src/main/java/io/gitlab/jfronny/inceptum/launcher/system/exporter/ModrinthExporter.java +++ b/launcher/src/main/java/io/gitlab/jfronny/inceptum/launcher/system/exporter/ModrinthExporter.java @@ -1,5 +1,6 @@ package io.gitlab.jfronny.inceptum.launcher.system.exporter; +import io.gitlab.jfronny.inceptum.common.GsonPreset; import io.gitlab.jfronny.inceptum.launcher.model.modrinth.GC_ModrinthModpackManifest; import io.gitlab.jfronny.inceptum.launcher.model.modrinth.ModrinthModpackManifest; import io.gitlab.jfronny.inceptum.launcher.system.instance.Instance; @@ -33,7 +34,7 @@ public class ModrinthExporter extends Exporter { null ) ); - GC_ModrinthModpackManifest.write(manifest, root.resolve("modrinth.index.json")); + GC_ModrinthModpackManifest.serialize(manifest, root.resolve("modrinth.index.json"), GsonPreset.API); return manifest; } @@ -52,6 +53,6 @@ public class ModrinthExporter extends Exporter { Files.createDirectories(modsOverrides); Files.copy(mod.getJarPath(), modsOverrides.resolve(mod.getJarPath().getFileName().toString())); } - GC_ModrinthModpackManifest.write(manifest, root.resolve("modrinth.index.json")); + GC_ModrinthModpackManifest.serialize(manifest, root.resolve("modrinth.index.json"), GsonPreset.API); } } diff --git a/launcher/src/main/java/io/gitlab/jfronny/inceptum/launcher/system/exporter/MultiMCExporter.java b/launcher/src/main/java/io/gitlab/jfronny/inceptum/launcher/system/exporter/MultiMCExporter.java index ec93340..25b7a14 100644 --- a/launcher/src/main/java/io/gitlab/jfronny/inceptum/launcher/system/exporter/MultiMCExporter.java +++ b/launcher/src/main/java/io/gitlab/jfronny/inceptum/launcher/system/exporter/MultiMCExporter.java @@ -1,5 +1,6 @@ package io.gitlab.jfronny.inceptum.launcher.system.exporter; +import io.gitlab.jfronny.inceptum.common.GsonPreset; import io.gitlab.jfronny.inceptum.launcher.model.multimc.GC_MMCPackMeta; import io.gitlab.jfronny.inceptum.launcher.model.multimc.MMCPackMeta; import io.gitlab.jfronny.inceptum.launcher.system.instance.Instance; @@ -54,7 +55,7 @@ public class MultiMCExporter extends Exporter { manifest.components().add(new MMCPackMeta.Component(true, false, "net.fabricmc.intermediary", instance.getGameVersion())); manifest.components().add(new MMCPackMeta.Component(false, false, "net.fabricmc.fabric-loader", instance.getLoaderVersion())); } - GC_MMCPackMeta.write(manifest, root.resolve("mmc-pack.json")); + GC_MMCPackMeta.serialize(manifest, root.resolve("mmc-pack.json"), GsonPreset.API); return manifest; } } diff --git a/launcher/src/main/java/io/gitlab/jfronny/inceptum/launcher/system/importer/CurseForgeImporter.java b/launcher/src/main/java/io/gitlab/jfronny/inceptum/launcher/system/importer/CurseForgeImporter.java index dae4023..e9d0be7 100644 --- a/launcher/src/main/java/io/gitlab/jfronny/inceptum/launcher/system/importer/CurseForgeImporter.java +++ b/launcher/src/main/java/io/gitlab/jfronny/inceptum/launcher/system/importer/CurseForgeImporter.java @@ -1,5 +1,6 @@ package io.gitlab.jfronny.inceptum.launcher.system.importer; +import io.gitlab.jfronny.inceptum.common.GsonPreset; import io.gitlab.jfronny.inceptum.launcher.model.curseforge.CurseforgeModpackManifest; import io.gitlab.jfronny.inceptum.launcher.model.curseforge.GC_CurseforgeModpackManifest; import io.gitlab.jfronny.inceptum.launcher.model.inceptum.GC_ModMeta; @@ -15,7 +16,7 @@ import java.nio.file.Path; public class CurseForgeImporter extends Importer { public CurseForgeImporter() { - super("CurseForge", "manifest.json", GC_CurseforgeModpackManifest::read); + super("CurseForge", "manifest.json", path -> GC_CurseforgeModpackManifest.deserialize(path, GsonPreset.API)); } @Override @@ -47,7 +48,7 @@ public class CurseForgeImporter extends Importer { ModDownload download = source.download(); ModMeta imod = ModMeta.of(download.sha1(), download.murmur2(), source, manifest.minecraft().version()); Files.createDirectories(modsPath); - GC_ModMeta.write(imod, modsPath.resolve(source.getShortName() + ModPath.EXT_IMOD)); + GC_ModMeta.serialize(imod, modsPath.resolve(source.getShortName() + ModPath.EXT_IMOD), GsonPreset.CONFIG); } } } diff --git a/launcher/src/main/java/io/gitlab/jfronny/inceptum/launcher/system/importer/Importer.java b/launcher/src/main/java/io/gitlab/jfronny/inceptum/launcher/system/importer/Importer.java index e6add0b..780538c 100644 --- a/launcher/src/main/java/io/gitlab/jfronny/inceptum/launcher/system/importer/Importer.java +++ b/launcher/src/main/java/io/gitlab/jfronny/inceptum/launcher/system/importer/Importer.java @@ -2,6 +2,7 @@ package io.gitlab.jfronny.inceptum.launcher.system.importer; import io.gitlab.jfronny.commons.io.JFiles; import io.gitlab.jfronny.commons.throwable.ThrowingFunction; +import io.gitlab.jfronny.inceptum.common.GsonPreset; import io.gitlab.jfronny.inceptum.common.MetaHolder; import io.gitlab.jfronny.inceptum.common.Utils; import io.gitlab.jfronny.inceptum.launcher.api.FabricMetaApi; @@ -61,7 +62,7 @@ public abstract class Importer { Instance.setSetupLock(iDir, true); InstanceMeta meta = new InstanceMeta(); meta.gameVersion = createVersionString(man.gameVersion(), man.fabricVersion()); - GC_InstanceMeta.write(meta, iDir.resolve(Instance.CONFIG_NAME)); + GC_InstanceMeta.serialize(meta, iDir.resolve(Instance.CONFIG_NAME), GsonPreset.CONFIG); if (state.isCancelled()) { JFiles.deleteRecursive(iDir); diff --git a/launcher/src/main/java/io/gitlab/jfronny/inceptum/launcher/system/importer/ModrinthImporter.java b/launcher/src/main/java/io/gitlab/jfronny/inceptum/launcher/system/importer/ModrinthImporter.java index 196a50e..22bfb6a 100644 --- a/launcher/src/main/java/io/gitlab/jfronny/inceptum/launcher/system/importer/ModrinthImporter.java +++ b/launcher/src/main/java/io/gitlab/jfronny/inceptum/launcher/system/importer/ModrinthImporter.java @@ -1,5 +1,6 @@ package io.gitlab.jfronny.inceptum.launcher.system.importer; +import io.gitlab.jfronny.inceptum.common.GsonPreset; import io.gitlab.jfronny.inceptum.common.Net; import io.gitlab.jfronny.inceptum.launcher.model.modrinth.GC_ModrinthModpackManifest; import io.gitlab.jfronny.inceptum.launcher.model.modrinth.ModrinthModpackManifest; @@ -11,7 +12,7 @@ import java.nio.file.Path; public class ModrinthImporter extends Importer { public ModrinthImporter() { - super("Modrinth", "modrinth.index.json", GC_ModrinthModpackManifest::read); + super("Modrinth", "modrinth.index.json", path -> GC_ModrinthModpackManifest.deserialize(path, GsonPreset.API)); } @Override diff --git a/launcher/src/main/java/io/gitlab/jfronny/inceptum/launcher/system/importer/MultiMCImporter.java b/launcher/src/main/java/io/gitlab/jfronny/inceptum/launcher/system/importer/MultiMCImporter.java index 67f9985..cff8ca1 100644 --- a/launcher/src/main/java/io/gitlab/jfronny/inceptum/launcher/system/importer/MultiMCImporter.java +++ b/launcher/src/main/java/io/gitlab/jfronny/inceptum/launcher/system/importer/MultiMCImporter.java @@ -1,5 +1,6 @@ package io.gitlab.jfronny.inceptum.launcher.system.importer; +import io.gitlab.jfronny.inceptum.common.GsonPreset; import io.gitlab.jfronny.inceptum.launcher.model.multimc.GC_MMCPackMeta; import io.gitlab.jfronny.inceptum.launcher.model.multimc.MMCPackMeta; import io.gitlab.jfronny.inceptum.launcher.util.ProcessState; @@ -11,7 +12,7 @@ import java.util.stream.Stream; public class MultiMCImporter extends Importer { public MultiMCImporter() { - super("MultiMC", "mmc-pack.json", GC_MMCPackMeta::read); + super("MultiMC", "mmc-pack.json", path -> GC_MMCPackMeta.deserialize(path, GsonPreset.API)); } @Override diff --git a/launcher/src/main/java/io/gitlab/jfronny/inceptum/launcher/system/instance/Instance.java b/launcher/src/main/java/io/gitlab/jfronny/inceptum/launcher/system/instance/Instance.java index 38340d1..b83ab26 100644 --- a/launcher/src/main/java/io/gitlab/jfronny/inceptum/launcher/system/instance/Instance.java +++ b/launcher/src/main/java/io/gitlab/jfronny/inceptum/launcher/system/instance/Instance.java @@ -1,6 +1,7 @@ package io.gitlab.jfronny.inceptum.launcher.system.instance; import io.gitlab.jfronny.commons.ref.R; +import io.gitlab.jfronny.inceptum.common.GsonPreset; import io.gitlab.jfronny.inceptum.common.Utils; import io.gitlab.jfronny.inceptum.launcher.model.inceptum.GC_InstanceMeta; import io.gitlab.jfronny.inceptum.launcher.model.inceptum.InstanceMeta; @@ -154,7 +155,7 @@ public record Instance(String id, Path path, InstanceMeta meta, ModsDirScanner m public void writeMeta() { try { - GC_InstanceMeta.write(meta, path.resolve(CONFIG_NAME)); + GC_InstanceMeta.serialize(meta, path.resolve(CONFIG_NAME), GsonPreset.CONFIG); } catch (IOException e) { Utils.LOGGER.error("Could not write instance config", e); } diff --git a/launcher/src/main/java/io/gitlab/jfronny/inceptum/launcher/system/instance/InstanceList.java b/launcher/src/main/java/io/gitlab/jfronny/inceptum/launcher/system/instance/InstanceList.java index e0b069d..8219b81 100644 --- a/launcher/src/main/java/io/gitlab/jfronny/inceptum/launcher/system/instance/InstanceList.java +++ b/launcher/src/main/java/io/gitlab/jfronny/inceptum/launcher/system/instance/InstanceList.java @@ -3,6 +3,7 @@ package io.gitlab.jfronny.inceptum.launcher.system.instance; import io.gitlab.jfronny.commons.io.JFiles; import io.gitlab.jfronny.commons.throwable.ThrowingConsumer; import io.gitlab.jfronny.commons.throwable.ThrowingRunnable; +import io.gitlab.jfronny.inceptum.common.GsonPreset; import io.gitlab.jfronny.inceptum.common.MetaHolder; import io.gitlab.jfronny.inceptum.common.Utils; import io.gitlab.jfronny.inceptum.launcher.model.inceptum.GC_InstanceMeta; @@ -76,7 +77,7 @@ public class InstanceList { if (!metas.containsKey(instancePath)) { metas.put(instancePath, new IEntry( instancePath, - new FileBackedRef<>(instancePath.resolve(Instance.CONFIG_NAME), GC_InstanceMeta::read) + new FileBackedRef<>(instancePath.resolve(Instance.CONFIG_NAME), GC_InstanceMeta::deserialize, GsonPreset.CONFIG) )); } return metas.get(instancePath).toPub(); diff --git a/launcher/src/main/java/io/gitlab/jfronny/inceptum/launcher/system/instance/ModManager.java b/launcher/src/main/java/io/gitlab/jfronny/inceptum/launcher/system/instance/ModManager.java index 098bcca..0e27cc4 100644 --- a/launcher/src/main/java/io/gitlab/jfronny/inceptum/launcher/system/instance/ModManager.java +++ b/launcher/src/main/java/io/gitlab/jfronny/inceptum/launcher/system/instance/ModManager.java @@ -1,5 +1,6 @@ package io.gitlab.jfronny.inceptum.launcher.system.instance; +import io.gitlab.jfronny.inceptum.common.GsonPreset; import io.gitlab.jfronny.inceptum.launcher.model.inceptum.GC_ModMeta; import io.gitlab.jfronny.inceptum.launcher.model.inceptum.ModMeta; import io.gitlab.jfronny.inceptum.launcher.system.mds.ModsDirScanner; @@ -31,7 +32,7 @@ public class ModManager { public record DownloadMeta(ModDownload download, ModMeta meta, ModSource source, Path metaFile) { public void write() throws IOException { - GC_ModMeta.write(meta, metaFile); + GC_ModMeta.serialize(meta, metaFile, GsonPreset.CONFIG); } } } diff --git a/launcher/src/main/java/io/gitlab/jfronny/inceptum/launcher/system/mds/threaded/FileScanTask.java b/launcher/src/main/java/io/gitlab/jfronny/inceptum/launcher/system/mds/threaded/FileScanTask.java index c4c692a..6ae5c11 100644 --- a/launcher/src/main/java/io/gitlab/jfronny/inceptum/launcher/system/mds/threaded/FileScanTask.java +++ b/launcher/src/main/java/io/gitlab/jfronny/inceptum/launcher/system/mds/threaded/FileScanTask.java @@ -1,6 +1,6 @@ package io.gitlab.jfronny.inceptum.launcher.system.mds.threaded; -import io.gitlab.jfronny.gson.JsonParseException; +import io.gitlab.jfronny.inceptum.common.GsonPreset; import io.gitlab.jfronny.inceptum.common.Utils; import io.gitlab.jfronny.inceptum.launcher.model.fabric.FabricModJson; import io.gitlab.jfronny.inceptum.launcher.model.fabric.GC_FabricModJson; @@ -25,7 +25,7 @@ public record FileScanTask(ProtoInstance instance, Path file, BiConsumer info.setState("Scanned " + path)); } diff --git a/launcher/src/main/java/io/gitlab/jfronny/inceptum/launcher/system/setup/steps/WriteMetadataStep.java b/launcher/src/main/java/io/gitlab/jfronny/inceptum/launcher/system/setup/steps/WriteMetadataStep.java index cd1cc0a..140ed71 100644 --- a/launcher/src/main/java/io/gitlab/jfronny/inceptum/launcher/system/setup/steps/WriteMetadataStep.java +++ b/launcher/src/main/java/io/gitlab/jfronny/inceptum/launcher/system/setup/steps/WriteMetadataStep.java @@ -1,5 +1,6 @@ package io.gitlab.jfronny.inceptum.launcher.system.setup.steps; +import io.gitlab.jfronny.inceptum.common.GsonPreset; import io.gitlab.jfronny.inceptum.common.MetaHolder; import io.gitlab.jfronny.inceptum.launcher.model.inceptum.GC_InstanceMeta; import io.gitlab.jfronny.inceptum.launcher.model.inceptum.InstanceMeta; @@ -20,7 +21,7 @@ public class WriteMetadataStep implements Step { if (!Files.exists(metaPath)) { InstanceMeta meta = new InstanceMeta(); meta.gameVersion = info.version().id; - GC_InstanceMeta.write(meta, metaPath); + GC_InstanceMeta.serialize(meta, metaPath, GsonPreset.CONFIG); } if (!Files.exists(instance.resolve(".gitignore"))) { Files.writeString(instance.resolve(".gitignore"), """ diff --git a/launcher/src/main/java/io/gitlab/jfronny/inceptum/launcher/system/source/ModSource.java b/launcher/src/main/java/io/gitlab/jfronny/inceptum/launcher/system/source/ModSource.java index 0b6ddf4..4f1bdfb 100644 --- a/launcher/src/main/java/io/gitlab/jfronny/inceptum/launcher/system/source/ModSource.java +++ b/launcher/src/main/java/io/gitlab/jfronny/inceptum/launcher/system/source/ModSource.java @@ -1,6 +1,6 @@ package io.gitlab.jfronny.inceptum.launcher.system.source; -import io.gitlab.jfronny.gson.compile.annotations.GSerializable; +import io.gitlab.jfronny.commons.serialize.generator.annotations.GSerializable; import io.gitlab.jfronny.inceptum.common.GsonPreset; import io.gitlab.jfronny.inceptum.common.MetaHolder; import io.gitlab.jfronny.inceptum.launcher.gson.ModSourceAdapter; @@ -10,7 +10,7 @@ import java.nio.file.Path; import java.util.Optional; import java.util.Set; -@GSerializable(with = ModSourceAdapter.class, configure = GsonPreset.Api.class) +@GSerializable(with = ModSourceAdapter.class) public interface ModSource { ModDownload download() throws IOException; diff --git a/launcher/src/main/java/io/gitlab/jfronny/inceptum/launcher/system/source/ModrinthModSource.java b/launcher/src/main/java/io/gitlab/jfronny/inceptum/launcher/system/source/ModrinthModSource.java index 26d8660..df991f5 100644 --- a/launcher/src/main/java/io/gitlab/jfronny/inceptum/launcher/system/source/ModrinthModSource.java +++ b/launcher/src/main/java/io/gitlab/jfronny/inceptum/launcher/system/source/ModrinthModSource.java @@ -30,7 +30,7 @@ public final class ModrinthModSource implements ModSource { @Override public ModDownload download() throws IOException { - ModrinthVersion.File file = current.files().get(0); + ModrinthVersion.File file = current.files().getFirst(); Path path = getJarPath(); try { Net.downloadFile(file.url(), file.hashes().sha1(), path); @@ -80,7 +80,7 @@ public final class ModrinthModSource implements ModSource { @Override public String getFileName() { - return current.files().get(0).filename(); + return current.files().getFirst().filename(); } @Override @@ -117,7 +117,7 @@ public final class ModrinthModSource implements ModSource { } public ModrinthModpackManifest.File toManifest() throws IOException { - ModrinthVersion.File orig = current.files().get(0); + ModrinthVersion.File orig = current.files().getFirst(); return new ModrinthModpackManifest.File( "mods/" + orig.filename(), new ModrinthHashes( diff --git a/launcher/src/main/java/io/gitlab/jfronny/inceptum/launcher/util/FileBackedRef.java b/launcher/src/main/java/io/gitlab/jfronny/inceptum/launcher/util/FileBackedRef.java index 37fb757..b590164 100644 --- a/launcher/src/main/java/io/gitlab/jfronny/inceptum/launcher/util/FileBackedRef.java +++ b/launcher/src/main/java/io/gitlab/jfronny/inceptum/launcher/util/FileBackedRef.java @@ -1,5 +1,7 @@ package io.gitlab.jfronny.inceptum.launcher.util; +import io.gitlab.jfronny.commons.serialize.json.JsonReader; +import io.gitlab.jfronny.commons.serialize.json.JsonTransport; import io.gitlab.jfronny.commons.throwable.ThrowingFunction; import java.io.Closeable; @@ -19,6 +21,14 @@ public class FileBackedRef implements Closeable { filePath.getParent().register(service, StandardWatchEventKinds.ENTRY_MODIFY); } + public FileBackedRef(Path filePath, ThrowingFunction read, JsonTransport transport) throws IOException { + this(filePath, path -> { + try (JsonReader reader = transport.createReader(Files.newBufferedReader(path))) { + return read.apply(reader); + } + }); + } + public T get() throws IOException { WatchKey key = service.poll(); boolean update = cache == null; diff --git a/launcher/src/main/java/module-info.java b/launcher/src/main/java/module-info.java index 8ea0880..9773cf8 100644 --- a/launcher/src/main/java/module-info.java +++ b/launcher/src/main/java/module-info.java @@ -28,5 +28,6 @@ module io.gitlab.jfronny.inceptum.launcher { requires transitive io.gitlab.jfronny.inceptum.common; requires transitive io.gitlab.jfronny.commons.http.server; requires static org.jetbrains.annotations; - requires static io.gitlab.jfronny.gson.compile.annotations; + requires static io.gitlab.jfronny.commons.serialize.generator.annotations; + requires io.gitlab.jfronny.commons.serialize; } \ No newline at end of file diff --git a/wrapper/src/main/java/io/gitlab/jfronny/inceptum/wrapper/Wrapper.java b/wrapper/src/main/java/io/gitlab/jfronny/inceptum/wrapper/Wrapper.java index 679a5c1..eebcbe3 100644 --- a/wrapper/src/main/java/io/gitlab/jfronny/inceptum/wrapper/Wrapper.java +++ b/wrapper/src/main/java/io/gitlab/jfronny/inceptum/wrapper/Wrapper.java @@ -26,7 +26,7 @@ public class Wrapper { throw new FileNotFoundException("Something went wrong while downloading the latest version."); } } - List classpath = Updater.getLaunchClasspath(GC_WrapperConfig.read(MetaHolder.WRAPPER_CONFIG_PATH)); + List classpath = Updater.getLaunchClasspath(GC_WrapperConfig.deserialize(MetaHolder.WRAPPER_CONFIG_PATH, GsonPreset.CONFIG)); if (!BuildMetadata.IS_RELEASE) { System.out.println("Using classpath: " + classpath.stream().map(Path::toString).collect(Collectors.joining("" + File.pathSeparator))); }