From bfd9a1b5d3c17ffd58cf37c64e1893d60f23e923 Mon Sep 17 00:00:00 2001 From: ErdbeerbaerLP Date: Tue, 28 Nov 2023 23:32:08 +0100 Subject: [PATCH 1/2] Fix death message custom embed Signed-off-by: ErdbeerbaerLP --- build.gradle | 2 +- gradle.properties | 2 +- .../dcintegration/forge/DiscordIntegrationMod.java | 4 ++-- update_checker.json | 4 ++++ 4 files changed, 8 insertions(+), 4 deletions(-) diff --git a/build.gradle b/build.gradle index d26f4d2..836c1e9 100644 --- a/build.gradle +++ b/build.gradle @@ -30,7 +30,7 @@ apply plugin: 'org.spongepowered.mixin' //Build variables -version = "3.0.4" +version = "3.0.4.1" group = "de.erdbeerbaerlp.dcintegration" archivesBaseName = "dcintegration-forge" diff --git a/gradle.properties b/gradle.properties index 171f3a3..e0ab216 100644 --- a/gradle.properties +++ b/gradle.properties @@ -2,6 +2,6 @@ # This is required to provide enough memory for the Minecraft decompilation process. org.gradle.jvmargs=-Xmx3G org.gradle.daemon=false -changelog=More bug fixes\nImplement permissions +changelog=Fix death message custom embed releaseType = BETA mcVersion = 1.19.4 \ No newline at end of file diff --git a/src/main/java/de/erdbeerbaerlp/dcintegration/forge/DiscordIntegrationMod.java b/src/main/java/de/erdbeerbaerlp/dcintegration/forge/DiscordIntegrationMod.java index db56153..d23f3c5 100644 --- a/src/main/java/de/erdbeerbaerlp/dcintegration/forge/DiscordIntegrationMod.java +++ b/src/main/java/de/erdbeerbaerlp/dcintegration/forge/DiscordIntegrationMod.java @@ -505,8 +505,8 @@ public void death(LivingDeathEvent ev) { final MessageEmbed embed = ForgeMessageUtils.genItemStackEmbedIfAvailable(deathMessage); if (Configuration.instance().embedMode.enabled && Configuration.instance().embedMode.deathMessage.asEmbed) { final String avatarURL = Configuration.instance().webhook.playerAvatarURL.replace("%uuid%", ev.getEntity().getUUID().toString()).replace("%uuid_dashless%", ev.getEntity().getUUID().toString().replace("-", "")).replace("%name%", ev.getEntity().getName().getString()).replace("%randomUUID%", UUID.randomUUID().toString()); - if (!Configuration.instance().embedMode.playerJoinMessage.customJSON.isBlank()) { - final EmbedBuilder b = Configuration.instance().embedMode.playerJoinMessage.toEmbedJson(Configuration.instance().embedMode.playerJoinMessage.customJSON + if (!Configuration.instance().embedMode.deathMessage.customJSON.isBlank()) { + final EmbedBuilder b = Configuration.instance().embedMode.deathMessage.toEmbedJson(Configuration.instance().embedMode.deathMessage.customJSON .replace("%uuid%", ev.getEntity().getUUID().toString()) .replace("%uuid_dashless%", ev.getEntity().getUUID().toString().replace("-", "")) .replace("%name%", ForgeMessageUtils.formatPlayerName(ev.getEntity())) diff --git a/update_checker.json b/update_checker.json index 836db91..1d587f5 100644 --- a/update_checker.json +++ b/update_checker.json @@ -1,5 +1,9 @@ [ { + "version": "3.0.4.1", + "changelog": "Fix death message custom embed", + "type": "beta" + },{ "version": "3.0.4", "changelog": "More bug fixes\nImplement permissions", "type": "beta" From 02451edaf02817f53f5aa0187ac3eae81d24d319 Mon Sep 17 00:00:00 2001 From: ErdbeerbaerLP Date: Wed, 6 Dec 2023 18:44:14 +0100 Subject: [PATCH 2/2] Fix server stopping not working Fix update checker Implement URL Encoded advancement message Signed-off-by: ErdbeerbaerLP --- build.gradle | 5 ++-- gradle.properties | 2 +- .../forge/DiscordIntegrationMod.java | 23 ++++++++++++++----- update_checker.json | 4 ++++ 4 files changed, 25 insertions(+), 9 deletions(-) diff --git a/build.gradle b/build.gradle index 836c1e9..92cf2b5 100644 --- a/build.gradle +++ b/build.gradle @@ -30,7 +30,7 @@ apply plugin: 'org.spongepowered.mixin' //Build variables -version = "3.0.4.1" +version = "3.0.5" group = "de.erdbeerbaerlp.dcintegration" archivesBaseName = "dcintegration-forge" @@ -94,8 +94,9 @@ configurations.all { //Dependencies dependencies { // ========= Common ===================== - embed('de.erdbeerbaerlp:dcintegration.common:3.0.4.1') { + embed('de.erdbeerbaerlp:dcintegration.common:3.0.5') { changing = true + transitive = false } // ========= Minecraft Forge ============= diff --git a/gradle.properties b/gradle.properties index e0ab216..cdad80e 100644 --- a/gradle.properties +++ b/gradle.properties @@ -2,6 +2,6 @@ # This is required to provide enough memory for the Minecraft decompilation process. org.gradle.jvmargs=-Xmx3G org.gradle.daemon=false -changelog=Fix death message custom embed +changelog=Fix server stopping not working\nFix update checker\nImplement URL Encoded advancement message releaseType = BETA mcVersion = 1.19.4 \ No newline at end of file diff --git a/src/main/java/de/erdbeerbaerlp/dcintegration/forge/DiscordIntegrationMod.java b/src/main/java/de/erdbeerbaerlp/dcintegration/forge/DiscordIntegrationMod.java index d23f3c5..e91a60f 100644 --- a/src/main/java/de/erdbeerbaerlp/dcintegration/forge/DiscordIntegrationMod.java +++ b/src/main/java/de/erdbeerbaerlp/dcintegration/forge/DiscordIntegrationMod.java @@ -60,6 +60,8 @@ import java.io.File; import java.io.IOException; +import java.net.URLEncoder; +import java.nio.charset.StandardCharsets; import java.util.*; import java.util.regex.Pattern; @@ -135,13 +137,15 @@ public void serverSetup(FMLDedicatedServerSetupEvent ev) { } public static final HashMap> nodes = new HashMap(); + @SubscribeEvent public void addPermissions(final PermissionGatherEvent.Nodes ev) { - for(MinecraftPermission p : MinecraftPermission.values()){ + for (MinecraftPermission p : MinecraftPermission.values()) { nodes.put(p.getAsString(), new PermissionNode<>("dcintegration", p.getAsString().replace("dcintegration.", ""), PermissionTypes.BOOLEAN, (player, playerUUID, context) -> p.getDefaultValue())); } ev.addNodes(nodes.values().toArray(new PermissionNode[0])); } + @SubscribeEvent public void playerJoin(final PlayerEvent.PlayerLoggedInEvent ev) { if (INSTANCE != null) { @@ -206,6 +210,8 @@ public void advancement(AdvancementEvent.AdvancementEarnEvent ev) { .replace("%avatarURL%", avatarURL) .replace("%advName%", ChatFormatting.stripFormatting(ev.getAdvancement().getDisplay().getTitle().getString())) .replace("%advDesc%", ChatFormatting.stripFormatting(ev.getAdvancement().getDisplay().getDescription().getString())) + .replace("%advNameURL%", URLEncoder.encode(ChatFormatting.stripFormatting(ev.getAdvancement().getDisplay().getTitle().getString()), StandardCharsets.UTF_8)) + .replace("%advDescURL%", URLEncoder.encode(ChatFormatting.stripFormatting(ev.getAdvancement().getDisplay().getDescription().getString()), StandardCharsets.UTF_8)) .replace("%avatarURL%", avatarURL) .replace("%playerColor%", "" + TextColors.generateFromUUID(ev.getEntity().getUUID()).getRGB()) ); @@ -223,7 +229,9 @@ public void advancement(AdvancementEvent.AdvancementEarnEvent ev) { .getDisplay() .getDescription() .getString())) - .replace("\\n", "\n")); + .replace("\\n", "\n").replace("%advNameURL%", URLEncoder.encode(ChatFormatting.stripFormatting(ev.getAdvancement().getDisplay().getTitle().getString()), StandardCharsets.UTF_8)) + .replace("%advDescURL%", URLEncoder.encode(ChatFormatting.stripFormatting(ev.getAdvancement().getDisplay().getDescription().getString()), StandardCharsets.UTF_8)) + ); INSTANCE.sendMessage(new DiscordMessage(b.build())); } } else INSTANCE.sendMessage(Localization.instance().advancementMessage.replace("%player%", @@ -235,9 +243,11 @@ public void advancement(AdvancementEvent.AdvancementEarnEvent ev) { .getString())) .replace("%advDesc%", ChatFormatting.stripFormatting(ev.getAdvancement() - .getDisplay() - .getDescription() - .getString())) + .getDisplay() + .getDescription() + .getString()).replace("%advNameURL%", URLEncoder.encode(ChatFormatting.stripFormatting(ev.getAdvancement().getDisplay().getTitle().getString()), StandardCharsets.UTF_8)) + .replace("%advDescURL%", URLEncoder.encode(ChatFormatting.stripFormatting(ev.getAdvancement().getDisplay().getDescription().getString()), StandardCharsets.UTF_8)) + ) .replace("\\n", "\n")); } } @@ -444,7 +454,8 @@ else if (ev.getServer().isRunning() && !Localization.instance().serverCrash.isBl @SubscribeEvent public void chat(ServerChatEvent ev) { if (Localization.instance().discordChatMessage.isBlank()) return; - if(!DiscordIntegration.INSTANCE.getServerInterface().playerHasPermissions(ev.getPlayer().getUUID(), MinecraftPermission.SEMD_MESSAGES,MinecraftPermission.USER)) return; + if (!DiscordIntegration.INSTANCE.getServerInterface().playerHasPermissions(ev.getPlayer().getUUID(), MinecraftPermission.SEMD_MESSAGES, MinecraftPermission.USER)) + return; if (LinkManager.isPlayerLinked(ev.getPlayer().getUUID()) && LinkManager.getLink(null, ev.getPlayer().getUUID()).settings.hideFromDiscord) return; final net.minecraft.network.chat.Component msg = ev.getMessage(); diff --git a/update_checker.json b/update_checker.json index 1d587f5..660e510 100644 --- a/update_checker.json +++ b/update_checker.json @@ -1,5 +1,9 @@ [ { + "version": "3.0.5", + "changelog": "Fix server stopping not working\nFix update checker\nImplement URL Encoded advancement message", + "type": "beta" + },{ "version": "3.0.4.1", "changelog": "Fix death message custom embed", "type": "beta"