diff --git a/build.gradle b/build.gradle index 989163e..5f1975c 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.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 9eebb1c..5f69bb3 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 server stopping not working\nFix update checker\nImplement URL Encoded advancement message releaseType = BETA mcVersion = 1.18.2 \ 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 2001427..1b344ad 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 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 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()),INSTANCE.getChannel(Configuration.instance().advanced.serverChannelID)); } } else INSTANCE.sendMessage(Localization.instance().advancementMessage.replace("%player%", @@ -237,7 +245,8 @@ public void advancement(AdvancementEvent ev) { ChatFormatting.stripFormatting(ev.getAdvancement() .getDisplay() .getDescription() - .getString())) + .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"),INSTANCE.getChannel(Configuration.instance().advanced.serverChannelID)); } } @@ -444,7 +453,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.getComponent(); diff --git a/update_checker.json b/update_checker.json index 1d2acc5..150d4b7 100644 --- a/update_checker.json +++ b/update_checker.json @@ -1,21 +1,16 @@ [ { + "version": "3.0.5", + "changelog": "Fix server stopping not working\nFix update checker\nImplement URL Encoded advancement message", + "type": "beta" + },{ "version": "3.0.4", "changelog": "More bug fixes\nImplement permissions", "type": "beta" }, { - "version": "3.0.3", - "changelog": "Large discord integration rewrite adding new features and fixing long existing bugs\nOld configuration can be used as-is\n\nAdded custom status\nAdded tellraw\nAdded option to disable chat message editing for compatibility reasons\nFixed lots of bugs", - "type": "beta" - }, - { - "version": "3.0.2", - "changelog": "Fixed linking not being saved\nOptimized code", - "type": "alpha" - },{ "version": "3.0.0", - "changelog": "Large discord integration rewrite adding new features and fixing long existing bugs Old configuration can be used as-is", + "changelog": "Added new event handling methods for addons\nOtherwise mostly a bug fix update\nDon't forget to use 'discord migrate' in console when updating from below 2.6.0", "type": "alpha" },{ "version": "2.6.4",