diff --git a/.gitignore b/.gitignore index 21638f0..8dfb399 100644 --- a/.gitignore +++ b/.gitignore @@ -1,11 +1,14 @@ .idea/ +.vscode/ *.iml *.ipr *.iws lib/ run/ out/ +bin/ build/ .gradle/ classes/ -lombok.config \ No newline at end of file +lombok.config +extra.properties diff --git a/build.gradle b/build.gradle index a27e24a..74513d6 100644 --- a/build.gradle +++ b/build.gradle @@ -1,15 +1,14 @@ -import javax.net.ssl.HttpsURLConnection -import java.nio.file.Files +// import javax.net.ssl.HttpsURLConnection +// import java.nio.file.Files plugins { - id 'fabric-loom' version '0.11-SNAPSHOT' - id 'maven-publish' - id "io.freefair.lombok" version "6.0.0-m2" - id "com.diffplug.spotless" version "5.17.1" + id "fabric-loom" version "1.11-SNAPSHOT" + id "maven-publish" + id "io.freefair.lombok" version "8.10" } -sourceCompatibility = JavaVersion.VERSION_16 -targetCompatibility = JavaVersion.VERSION_16 +sourceCompatibility = JavaVersion.VERSION_21 +targetCompatibility = JavaVersion.VERSION_21 archivesBaseName = project.archives_base_name version = "${project.minecraft_version}-${project.mod_version}" @@ -20,7 +19,6 @@ if (file("extra.properties").exists()) { additionalProperties.load(file("extra.properties").newReader()) } - repositories { mavenCentral() mavenLocal() // only used to build the mod locally @@ -33,13 +31,13 @@ dependencies { minecraft "com.mojang:minecraft:${project.minecraft_version}" mappings "net.fabricmc:yarn:${project.yarn_mappings}:v2" modImplementation "net.fabricmc:fabric-loader:${project.loader_version}" - modImplementation "net.fabricmc.fabric-api:fabric-api:${project.fabric_api_version}" - modImplementation "fi.dy.masa.malilib:malilib-fabric-1.20.2:${project.malilib_version}" + modImplementation "net.fabricmc.fabric-api:fabric-api:${project.fabric_version}" + modImplementation "com.github.sakura-ryoko:malilib:${project.malilib_version}" //modImplementation "com.github.DarkKronicle:AdvancedChatCore:${project.advancedchat_version}" - modImplementation "io.github.darkkronicle:AdvancedChatCore:1.20.4-1.5.10" // only used to build the mod locally + modImplementation "io.github.darkkronicle:AdvancedChatCore:${project.minecraft_version}-${project.mod_version}" + // modImplementation files("libs/AdvancedChatCore-${project.advancedchat_version}.jar") } - processResources { inputs.property "version", project.version @@ -50,14 +48,15 @@ processResources { tasks.withType(JavaCompile).configureEach { it.options.encoding = "UTF-8" - it.options.release = 16 + it.options.release = 21 } // Loom will automatically attach sourcesJar to a RemapSourcesJar task and to the "build" task // if it is present. // If you remove this task, sources will not be generated. -task sourcesJar(type: Jar, dependsOn: classes) { - classifier = "sources" +tasks.register('sourcesJar', Jar) { + dependsOn classes + archiveClassifier.set('sources') from sourceSets.main.allSource } @@ -65,23 +64,6 @@ jar { from "LICENSE.txt" } -spotless { - ratchetFrom 'origin/main' - format 'misc', { - // define the files to apply `misc` to - target '*.gradle', '*.md', '.gitignore' - - // define the steps to apply to those files - trimTrailingWhitespace() - indentWithTabs() // or spaces. Takes an integer argument if you don't like 4 - endWithNewline() - } - java { - target 'src/*/java/**/*.java' - licenseHeaderFile "HEADER.txt" - } -} - // configure the maven publication publishing { publications { @@ -99,56 +81,6 @@ publishing { // select the repositories you want to publish to repositories { // uncomment to publish to the local maven - // mavenLocal() - } -} - -task discord { - dependsOn build - - doLast { - String webhook - if (additionalProperties["discord_webhook"] != null) { - webhook = additionalProperties["discord_webhook"] - } else if (System.getenv("discord_webhook") != null) { - webhook = System.getenv("discord_webhook") - } else { - System.out.println("No webhook found...") - return - } - - String commitHash = 'git rev-parse --verify --short HEAD'.execute().text.trim() - - File file = remapJar.archiveFile.get().asFile - String fileName = "$project.archives_base_name}-${project.mod_version}-${commitHash}.jar" - String text = "<:Kronos:799707832399691867> **${project.archives_base_name} v${project.mod_version}-${commitHash} for ${project.minecraft_version}**" - URL url = new URL(webhook) - HttpsURLConnection connection = (HttpsURLConnection) url.openConnection() - - def cmdLine = "git log --format=%B -n 1" - def procCommit = cmdLine.execute() - String changeLog = procCommit.in.getText() - text = text + "\n" + changeLog - - String boundary = UUID.randomUUID().toString() - connection.setRequestMethod("POST") - connection.setDoOutput(true) - connection.setRequestProperty("Content-Type", "multipart/form-data;boundary=" + boundary) - DataOutputStream stream = new DataOutputStream(connection.getOutputStream()); - - stream.writeBytes("--" + boundary + "\r\n") - stream.writeBytes("Content-Disposition: form-data; name=\"file\"; filename=\"" + fileName + "\"\r\n\r\n") - stream.write(Files.readAllBytes(file.toPath())) - stream.writeBytes("\r\n") - stream.writeBytes("--" + boundary + "\r\n"); - stream.writeBytes('Content-Disposition: form-data; name="content"\r\n\r\n' + text + '\r\n') - stream.writeBytes("--" + boundary + "--\r\n") - - stream.flush() - stream.close() - - connection.getInputStream().close() - connection.disconnect() + mavenLocal() } - } diff --git a/gradle.properties b/gradle.properties index e9011a7..891ad54 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,12 +1,15 @@ -minecraft_version=1.20.4 -yarn_mappings=1.20.4+build.3 -loader_version=0.15.3 -fabric_api_version=0.92.0+1.20.4 +org.gradle.jvmargs=-Xmx1G +org.gradle.parallel=true + +minecraft_version=1.21.8 +yarn_mappings=1.21.8+build.1 +loader_version=0.17.2 +loom_version=1.11-SNAPSHOT + +fabric_version=0.132.0+1.21.8 -# Mod Properties -mod_version=1.2.3 +mod_version=1.8.0 maven_group=io.github.darkkronicle archives_base_name=AdvancedChatLog -malilib_version=0.17.0 -org.gradle.jvmargs=-Xmx1G -advancedchat_version=1.5.2-build1 \ No newline at end of file + +malilib_version=1.21.8-0.25.5-sakura.4 diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 7c08e4f..d4081da 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,5 +1,7 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-7.2-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.14.3-bin.zip +networkTimeout=10000 +validateDistributionUrl=true zipStoreBase=GRADLE_USER_HOME -zipStorePath=wrapper/dists \ No newline at end of file +zipStorePath=wrapper/dists diff --git a/gradlew b/gradlew index df3a6fe..965aff3 100755 --- a/gradlew +++ b/gradlew @@ -180,4 +180,4 @@ APP_ARGS=`save "$@"` # Collect all arguments for the java command, following the shell quoting and substitution rules eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS" -exec "$JAVACMD" "$@" \ No newline at end of file +exec "$JAVACMD" "$@" diff --git a/src/main/java/io/github/darkkronicle/advancedchatlog/config/ChatLogConfigStorage.java b/src/main/java/io/github/darkkronicle/advancedchatlog/config/ChatLogConfigStorage.java index c174ded..b14f731 100644 --- a/src/main/java/io/github/darkkronicle/advancedchatlog/config/ChatLogConfigStorage.java +++ b/src/main/java/io/github/darkkronicle/advancedchatlog/config/ChatLogConfigStorage.java @@ -17,7 +17,6 @@ import fi.dy.masa.malilib.hotkeys.KeyAction; import fi.dy.masa.malilib.hotkeys.KeybindSettings; import fi.dy.masa.malilib.util.FileUtils; -import fi.dy.masa.malilib.util.JsonUtils; import fi.dy.masa.malilib.util.StringUtils; import io.github.darkkronicle.advancedchatcore.config.ConfigStorage; import io.github.darkkronicle.advancedchatcore.config.SaveableConfig; @@ -138,6 +137,7 @@ public static String translate(String key) { ImmutableList.of(OPEN_LOG); } + @SuppressWarnings("unchecked") public static void loadFromFile() { File configFile = FileUtils.getConfigDirectory() @@ -158,10 +158,10 @@ public static void loadFromFile() { if (element != null && element.isJsonObject()) { JsonObject root = element.getAsJsonObject(); - ConfigStorage.readOptions(root, General.NAME, (List>) General.OPTIONS); - ConfigStorage.readOptions(root, Hotkeys.NAME, (List>) Hotkeys.OPTIONS); + ConfigStorage.readOptions(root, General.NAME, (List>) (List) General.OPTIONS); + ConfigStorage.readOptions(root, Hotkeys.NAME, (List>) (List) Hotkeys.OPTIONS); - int version = JsonUtils.getIntegerOrDefault(root, "configVersion", 0); + // int version = JsonUtils.getIntegerOrDefault(root, "configVersion", 0); } } @@ -187,8 +187,8 @@ public static void saveFromFile() { if ((dir.exists() && dir.isDirectory()) || dir.mkdirs()) { JsonObject root = new JsonObject(); - ConfigStorage.writeOptions(root, General.NAME, (List>) General.OPTIONS); - ConfigStorage.writeOptions(root, Hotkeys.NAME, (List>) Hotkeys.OPTIONS); + ConfigStorage.writeOptions(root, General.NAME, (List>) (List) General.OPTIONS); + ConfigStorage.writeOptions(root, Hotkeys.NAME, (List>) (List) Hotkeys.OPTIONS); root.add("config_version", new JsonPrimitive(CONFIG_VERSION)); diff --git a/src/main/java/io/github/darkkronicle/advancedchatlog/gui/ChatLogScreen.java b/src/main/java/io/github/darkkronicle/advancedchatlog/gui/ChatLogScreen.java index f268ca1..c73d999 100644 --- a/src/main/java/io/github/darkkronicle/advancedchatlog/gui/ChatLogScreen.java +++ b/src/main/java/io/github/darkkronicle/advancedchatlog/gui/ChatLogScreen.java @@ -122,7 +122,7 @@ public void initGui() { textRenderer, (textFieldRunnable -> { if (client.player != null) { - client.player.sendMessage(Text.of(textFieldRunnable.getText())); + client.player.sendMessage(Text.of(textFieldRunnable.getText()), false); } textFieldRunnable.setText(""); }) @@ -303,7 +303,7 @@ public void render(DrawContext context, int mouseX, int mouseY, float partialTic ); context.drawHoverEvent(textRenderer, getHoverStyle(mouseX, mouseY), mouseX, mouseY); if (menu != null) { - menu.render(mouseX, mouseY, true, context); + menu.render(context, mouseX, mouseY, true); } } diff --git a/src/main/java/io/github/darkkronicle/advancedchatlog/gui/ChatLogScreenSection.java b/src/main/java/io/github/darkkronicle/advancedchatlog/gui/ChatLogScreenSection.java index 1406de8..f53d810 100644 --- a/src/main/java/io/github/darkkronicle/advancedchatlog/gui/ChatLogScreenSection.java +++ b/src/main/java/io/github/darkkronicle/advancedchatlog/gui/ChatLogScreenSection.java @@ -25,7 +25,7 @@ @Environment(EnvType.CLIENT) public class ChatLogScreenSection extends AdvancedChatScreenSection { - private final static Identifier LOG_ICON = new Identifier(AdvancedChatLog.MOD_ID, "textures/gui/log.png"); + private final static Identifier LOG_ICON = Identifier.of(AdvancedChatLog.MOD_ID, "textures/gui/log.png"); public ChatLogScreenSection(AdvancedChatScreen screen) { super(screen); diff --git a/src/main/java/io/github/darkkronicle/advancedchatlog/gui/ScissorUtil.java b/src/main/java/io/github/darkkronicle/advancedchatlog/gui/ScissorUtil.java index 5a0746c..3052df3 100644 --- a/src/main/java/io/github/darkkronicle/advancedchatlog/gui/ScissorUtil.java +++ b/src/main/java/io/github/darkkronicle/advancedchatlog/gui/ScissorUtil.java @@ -7,7 +7,7 @@ */ package io.github.darkkronicle.advancedchatlog.gui; -import com.mojang.blaze3d.platform.GlStateManager; +import com.mojang.blaze3d.opengl.GlStateManager; import net.fabricmc.api.EnvType; import net.fabricmc.api.Environment; diff --git a/src/main/java/io/github/darkkronicle/advancedchatlog/util/LogChatMessageSerializer.java b/src/main/java/io/github/darkkronicle/advancedchatlog/util/LogChatMessageSerializer.java index 89195b7..ab0c021 100644 --- a/src/main/java/io/github/darkkronicle/advancedchatlog/util/LogChatMessageSerializer.java +++ b/src/main/java/io/github/darkkronicle/advancedchatlog/util/LogChatMessageSerializer.java @@ -7,7 +7,8 @@ */ package io.github.darkkronicle.advancedchatlog.util; -import com.google.gson.JsonObject; +import com.google.gson.*; +import com.mojang.serialization.JsonOps; import io.github.darkkronicle.advancedchatcore.chat.ChatMessage; import io.github.darkkronicle.advancedchatcore.interfaces.IJsonSave; import io.github.darkkronicle.advancedchatlog.config.ChatLogConfigStorage; @@ -17,14 +18,18 @@ import java.time.format.DateTimeFormatter; import net.fabricmc.api.EnvType; import net.fabricmc.api.Environment; +import net.minecraft.registry.*; +import net.minecraft.text.MutableText; import net.minecraft.text.Style; import net.minecraft.text.Text; +import net.minecraft.text.TextCodecs; @Environment(EnvType.CLIENT) public class LogChatMessageSerializer implements IJsonSave { - private DateTimeFormatter formatter = DateTimeFormatter.ISO_LOCAL_DATE_TIME; + final RegistryWrapper.WrapperLookup wrapperLookup = BuiltinRegistries.createWrapperLookup(); + private DateTimeFormatter formatter = DateTimeFormatter.ISO_LOCAL_DATE_TIME; public LogChatMessageSerializer() {} private Style cleanStyle(Style style) { @@ -53,9 +58,10 @@ public LogChatMessage load(JsonObject obj) { LocalDate date = dateTime.toLocalDate(); LocalTime time = dateTime.toLocalTime(); - Text display = Text.Serialization.fromJson(obj.get("display").getAsString()); - Text original = Text.Serialization.fromJson(obj.get("original").getAsString()); - int stacks = obj.get("stacks").getAsByte(); + Text display = fromJson(obj.get("display"), wrapperLookup); + + Text original = fromJson(obj.get("original"), wrapperLookup); + ChatMessage message = ChatMessage.builder() .time(time) @@ -73,8 +79,16 @@ public JsonObject save(LogChatMessage message) { LocalDateTime dateTime = LocalDateTime.of(message.getDate(), chat.getTime()); json.addProperty("time", formatter.format(dateTime)); json.addProperty("stacks", chat.getStacks()); - json.add("display", Text.Serialization.toJsonTree(transfer(chat.getDisplayText()))); - json.add("original", Text.Serialization.toJsonTree(transfer(chat.getOriginalText()))); + json.add("display", toJson(transfer(chat.getDisplayText()), wrapperLookup)); + json.add("original", toJson(transfer(chat.getOriginalText()), wrapperLookup)); return json; } + + static JsonElement toJson(Text text, RegistryWrapper.WrapperLookup registries) { + return (JsonElement)TextCodecs.CODEC.encodeStart(registries.getOps(JsonOps.INSTANCE), text).getOrThrow(JsonParseException::new); + } + + static MutableText fromJson(JsonElement json, RegistryWrapper.WrapperLookup registries) { + return (MutableText)TextCodecs.CODEC.parse(registries.getOps(JsonOps.INSTANCE), json).getOrThrow(JsonParseException::new); + } } diff --git a/src/main/resources/advancedchatlog.mixins.json b/src/main/resources/advancedchatlog.mixins.json index 481ac55..5df9384 100644 --- a/src/main/resources/advancedchatlog.mixins.json +++ b/src/main/resources/advancedchatlog.mixins.json @@ -1,7 +1,7 @@ { "required": true, "package": "io.github.darkkronicle.advancedchatlog.mixin", - "compatibilityLevel": "JAVA_16", + "compatibilityLevel": "JAVA_21", "mixins": [ ], "client": [ @@ -9,4 +9,4 @@ "injectors": { "defaultRequire": 1 } -} \ No newline at end of file +} diff --git a/src/main/resources/fabric.mod.json b/src/main/resources/fabric.mod.json index 9a24560..c41e983 100644 --- a/src/main/resources/fabric.mod.json +++ b/src/main/resources/fabric.mod.json @@ -24,11 +24,11 @@ "advancedchatlog.mixins.json" ], "depends": { - "fabricloader": ">=0.14.18", + "fabricloader": ">=0.16.3", "fabric": "*", - "minecraft": ">=1.20.0", - "malilib": ">=0.16.0", - "advancedchatcore": ">=1.5.10-1.19" + "minecraft": ">=1.21.4", + "malilib": ">=0.21.0", + "advancedchatcore": ">=1.7.0" }, "custom": { "acmodule": true,