[BUG] Fix Adventure Serializer being configured wrong

This commit is contained in:
2024-06-11 18:53:10 +02:00
parent a355daccb2
commit fabef0e6f1
6 changed files with 31 additions and 21 deletions

6
.gitignore vendored
View File

@@ -22,4 +22,8 @@ eclipse
run run
artifacts artifacts
src/test/** src/test/**
workspace
upstream
rejects

View File

@@ -1,7 +1,9 @@
def JDK = "21"
pipeline { pipeline {
agent { agent {
docker { docker {
image "registry.firstdark.dev/java21:latest" image "registry.firstdark.dev/java${JDK}:latest"
alwaysPull true alwaysPull true
args '-v gradle-cache:/home/gradle/.gradle' args '-v gradle-cache:/home/gradle/.gradle'
} }

View File

@@ -1,10 +1,15 @@
def projectName = "CraterLib"; def projectName = "CraterLib";
def projectIcon = "https://cdn.modrinth.com/data/Nn8Wasaq/a172c634683a11a2e9ae593e56eba7885743bb44.png"; def projectIcon = "https://cdn.modrinth.com/data/Nn8Wasaq/a172c634683a11a2e9ae593e56eba7885743bb44.png";
def JDK = "21";
def majorMc = "Port";
def modLoaders = "neoforge|fabric|quilt";
def supportedMc = "1.21";
def reltype = "port";
pipeline { pipeline {
agent { agent {
docker { docker {
image "registry.firstdark.dev/java21:latest" image "registry.firstdark.dev/java${JDK}:latest"
alwaysPull true alwaysPull true
args '-v gradle-cache:/home/gradle/.gradle' args '-v gradle-cache:/home/gradle/.gradle'
} }
@@ -18,7 +23,7 @@ pipeline {
stage("Notify Discord") { stage("Notify Discord") {
steps { steps {
discordSend webhookURL: env.SSS_WEBHOOK, discordSend webhookURL: env.SSS_WEBHOOK,
title: "Deploy Started: ${projectName} Port Deploy #${BUILD_NUMBER}", title: "Deploy Started: ${projectName} ${majorMc} Deploy #${BUILD_NUMBER}",
link: env.BUILD_URL, link: env.BUILD_URL,
result: 'SUCCESS', result: 'SUCCESS',
description: "Build: [${BUILD_NUMBER}](${env.BUILD_URL})" description: "Build: [${BUILD_NUMBER}](${env.BUILD_URL})"
@@ -28,12 +33,6 @@ pipeline {
stage("Prepare") { stage("Prepare") {
steps { steps {
sh "chmod +x ./gradlew" sh "chmod +x ./gradlew"
sh "./gradlew clean"
}
}
stage("Build") {
steps {
sh "./gradlew build -PreleaseType=port" sh "./gradlew build -PreleaseType=port"
} }
} }
@@ -41,7 +40,7 @@ pipeline {
stage("Publish to Maven") { stage("Publish to Maven") {
steps { steps {
catchError(buildResult: 'SUCCESS', stageResult: 'FAILURE') { catchError(buildResult: 'SUCCESS', stageResult: 'FAILURE') {
sh "./gradlew publish -PreleaseType=port" sh "./gradlew publish -PreleaseType=${reltype}"
} }
} }
} }
@@ -50,14 +49,13 @@ pipeline {
post { post {
always { always {
sh "./gradlew --stop" sh "./gradlew --stop"
archiveArtifacts artifacts: 'artifacts/*.jar'
fddsnapshotter apiKey: env.PLATFORM_KEY, fddsnapshotter apiKey: env.PLATFORM_KEY,
projectSlug: "craterlib", projectSlug: "craterlib",
projectName: "${projectName}", projectName: "${projectName}",
projectIcon: "${projectIcon}", projectIcon: "${projectIcon}",
modLoaders: "neoforge|fabric|quilt", modLoaders: "${modLoaders}",
minecraftVersions: "1.21", minecraftVersions: "${supportedMc}",
failWebhook: env.SSS_WEBHOOK, failWebhook: env.SSS_WEBHOOK,
publishWebhooks: "${env.SSS_WEBHOOK}|${env.FDD_WH}" publishWebhooks: "${env.SSS_WEBHOOK}|${env.FDD_WH}"

View File

@@ -5,22 +5,30 @@ import me.hypherionmc.mcdiscordformatter.discord.DiscordSerializer;
import me.hypherionmc.mcdiscordformatter.minecraft.MinecraftSerializer; import me.hypherionmc.mcdiscordformatter.minecraft.MinecraftSerializer;
import net.kyori.adventure.text.format.NamedTextColor; import net.kyori.adventure.text.format.NamedTextColor;
import net.kyori.adventure.text.serializer.gson.GsonComponentSerializer; import net.kyori.adventure.text.serializer.gson.GsonComponentSerializer;
import net.kyori.adventure.text.serializer.json.JSONOptions;
import net.minecraft.ChatFormatting; import net.minecraft.ChatFormatting;
import net.minecraft.SharedConstants;
import net.minecraft.Util; import net.minecraft.Util;
import net.minecraft.core.RegistryAccess; import net.minecraft.core.RegistryAccess;
import net.minecraft.network.chat.Component; import net.minecraft.network.chat.Component;
import net.minecraft.network.chat.Style; import net.minecraft.network.chat.Style;
import java.util.function.Consumer;
public class ChatUtils { public class ChatUtils {
private static final GsonComponentSerializer adventureSerializer = GsonComponentSerializer.builder().options(
JSONOptions.byDataVersion().at(SharedConstants.getCurrentVersion().getDataVersion().getVersion())
).build();
public static Component adventureToMojang(net.kyori.adventure.text.Component inComponent) { public static Component adventureToMojang(net.kyori.adventure.text.Component inComponent) {
final String serialised = GsonComponentSerializer.gson().serialize(inComponent); final String serialised = adventureSerializer.serialize(inComponent);
return Component.Serializer.fromJson(serialised, RegistryAccess.EMPTY); return Component.Serializer.fromJson(serialised, RegistryAccess.EMPTY);
} }
public static net.kyori.adventure.text.Component mojangToAdventure(Component inComponent) { public static net.kyori.adventure.text.Component mojangToAdventure(Component inComponent) {
final String serialised = Component.Serializer.toJson(inComponent, RegistryAccess.EMPTY); final String serialised = Component.Serializer.toJson(inComponent, RegistryAccess.EMPTY);
return GsonComponentSerializer.gson().deserialize(serialised); return adventureSerializer.deserialize(serialised);
} }
// Some text components contain duplicate text, resulting in duplicate messages // Some text components contain duplicate text, resulting in duplicate messages
@@ -87,4 +95,5 @@ public class ChatUtils {
return mojangToAdventure(Component.translatable(Util.makeDescriptionId("biome", identifier.toMojang()))); return mojangToAdventure(Component.translatable(Util.makeDescriptionId("biome", identifier.toMojang())));
} }
} }

View File

@@ -15,7 +15,8 @@ A Library mod and modding api for easier multi-version minecraft and mod loader
| < 1.18.2 | | | < 1.18.2 | |
| 1.18.2-1.20.2 | | | 1.18.2-1.20.2 | |
| 1.20.4 | | | 1.20.4 | |
| 1.20.6 | 🚧 | | 1.20.6 | |
| 1.21 | |
- - Not Supported; no bug fixes or new features. - - Not Supported; no bug fixes or new features.
- 🚧 - Work in Progress; not ready for release. - 🚧 - Work in Progress; not ready for release.

View File

@@ -1,4 +0,0 @@
{
"action": "port",
"devBranch": "porting"
}