Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
.idea/
.vscode/
*.iml
*.ipr
*.iws
lib/
run/
out/
bin/
build/
.gradle/
classes/
lombok.config
lombok.config
extra.properties
100 changes: 16 additions & 84 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -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}"
Expand All @@ -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
Expand All @@ -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

Expand All @@ -50,38 +48,22 @@ 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
}

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 {
Expand All @@ -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()
}

}
21 changes: 12 additions & 9 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -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

malilib_version=1.21.8-0.25.5-sakura.4
6 changes: 4 additions & 2 deletions gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -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
zipStorePath=wrapper/dists
2 changes: 1 addition & 1 deletion gradlew

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -138,6 +137,7 @@ public static String translate(String key) {
ImmutableList.of(OPEN_LOG);
}

@SuppressWarnings("unchecked")
public static void loadFromFile() {
File configFile =
FileUtils.getConfigDirectory()
Expand All @@ -158,10 +158,10 @@ public static void loadFromFile() {
if (element != null && element.isJsonObject()) {
JsonObject root = element.getAsJsonObject();

ConfigStorage.readOptions(root, General.NAME, (List<SaveableConfig<?>>) General.OPTIONS);
ConfigStorage.readOptions(root, Hotkeys.NAME, (List<SaveableConfig<?>>) Hotkeys.OPTIONS);
ConfigStorage.readOptions(root, General.NAME, (List<SaveableConfig<?>>) (List<?>) General.OPTIONS);
ConfigStorage.readOptions(root, Hotkeys.NAME, (List<SaveableConfig<?>>) (List<?>) Hotkeys.OPTIONS);

int version = JsonUtils.getIntegerOrDefault(root, "configVersion", 0);
// int version = JsonUtils.getIntegerOrDefault(root, "configVersion", 0);
}
}

Expand All @@ -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<SaveableConfig<?>>) General.OPTIONS);
ConfigStorage.writeOptions(root, Hotkeys.NAME, (List<SaveableConfig<?>>) Hotkeys.OPTIONS);
ConfigStorage.writeOptions(root, General.NAME, (List<SaveableConfig<?>>) (List<?>) General.OPTIONS);
ConfigStorage.writeOptions(root, Hotkeys.NAME, (List<SaveableConfig<?>>) (List<?>) Hotkeys.OPTIONS);

root.add("config_version", new JsonPrimitive(CONFIG_VERSION));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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("");
})
Expand Down Expand Up @@ -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);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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<LogChatMessage> {

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) {
Expand Down Expand Up @@ -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)
Expand All @@ -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);
}
}
4 changes: 2 additions & 2 deletions src/main/resources/advancedchatlog.mixins.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
{
"required": true,
"package": "io.github.darkkronicle.advancedchatlog.mixin",
"compatibilityLevel": "JAVA_16",
"compatibilityLevel": "JAVA_21",
"mixins": [
],
"client": [
],
"injectors": {
"defaultRequire": 1
}
}
}
8 changes: 4 additions & 4 deletions src/main/resources/fabric.mod.json
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down