diff --git a/src/main/java/de/erdbeerbaerlp/dcintegration/forge/DiscordIntegrationMod.java b/src/main/java/de/erdbeerbaerlp/dcintegration/forge/DiscordIntegrationMod.java index db56153..df09357 100644 --- a/src/main/java/de/erdbeerbaerlp/dcintegration/forge/DiscordIntegrationMod.java +++ b/src/main/java/de/erdbeerbaerlp/dcintegration/forge/DiscordIntegrationMod.java @@ -2,7 +2,6 @@ import com.mojang.brigadier.StringReader; import com.mojang.brigadier.exceptions.CommandSyntaxException; -import dcshadow.dev.vankka.mcdiscordreserializer.discord.DiscordSerializer; import dcshadow.net.kyori.adventure.text.Component; import dcshadow.net.kyori.adventure.text.serializer.gson.GsonComponentSerializer; import de.erdbeerbaerlp.dcintegration.common.DiscordIntegration; @@ -120,16 +119,16 @@ public void serverSetup(FMLDedicatedServerSetupEvent ev) { if (DiscordIntegration.INSTANCE.getJDA() != null) { Thread.sleep(2000); //Wait for it to cache the channels CommandRegistry.registerDefaultCommands(); - if (!Localization.instance().serverStarting.isBlank()) - if (DiscordIntegration.INSTANCE.getChannel() != null) { - final MessageCreateData m; - if (Configuration.instance().embedMode.enabled && Configuration.instance().embedMode.startMessages.asEmbed) - m = new MessageCreateBuilder().setEmbeds(Configuration.instance().embedMode.startMessages.toEmbed().setDescription(Localization.instance().serverStarting).build()).build(); - else - m = new MessageCreateBuilder().addContent(Localization.instance().serverStarting).build(); - DiscordIntegration.startingMsg = DiscordIntegration.INSTANCE.sendMessageReturns(m, DiscordIntegration.INSTANCE.getChannel(Configuration.instance().advanced.serverChannelID)); - } - } + if (!Localization.instance().serverStarting.isBlank()) + if (DiscordIntegration.INSTANCE.getChannel() != null) { + final MessageCreateData m; + if (Configuration.instance().embedMode.enabled && Configuration.instance().embedMode.startMessages.asEmbed) + m = new MessageCreateBuilder().setEmbeds(Configuration.instance().embedMode.startMessages.toEmbed().setDescription(Localization.instance().serverStarting).build()).build(); + else + m = new MessageCreateBuilder().addContent(Localization.instance().serverStarting).build(); + DiscordIntegration.startingMsg = DiscordIntegration.INSTANCE.sendMessageReturns(m, DiscordIntegration.INSTANCE.getChannel(Configuration.instance().advanced.serverChannelID)); + } + } } catch (InterruptedException | NullPointerException ignored) { } } @@ -227,18 +226,18 @@ public void advancement(AdvancementEvent.AdvancementEarnEvent ev) { INSTANCE.sendMessage(new DiscordMessage(b.build())); } } else INSTANCE.sendMessage(Localization.instance().advancementMessage.replace("%player%", - ChatFormatting.stripFormatting(ForgeMessageUtils.formatPlayerName(ev.getEntity()))) - .replace("%advName%", - ChatFormatting.stripFormatting(ev.getAdvancement() - .getDisplay() - .getTitle() - .getString())) - .replace("%advDesc%", - ChatFormatting.stripFormatting(ev.getAdvancement() - .getDisplay() - .getDescription() - .getString())) - .replace("\\n", "\n")); + ChatFormatting.stripFormatting(ForgeMessageUtils.formatPlayerName(ev.getEntity()))) + .replace("%advName%", + ChatFormatting.stripFormatting(ev.getAdvancement() + .getDisplay() + .getTitle() + .getString())) + .replace("%advDesc%", + ChatFormatting.stripFormatting(ev.getAdvancement() + .getDisplay() + .getDescription() + .getString())) + .replace("\\n", "\n")); } } @@ -273,7 +272,7 @@ public void serverStarted(final ServerStartedEvent ev) { } INSTANCE.startThreads(); } - UpdateChecker.runUpdateCheck("https://raw.githubusercontent.com/ErdbeerbaerLP/Discord-Chat-Integration/1.19.4/update_checker.json"); + UpdateChecker.runUpdateCheck("https://raw.githubusercontent.com/ErdbeerbaerLP/Discord-Chat-Integration/1.19.2/update_checker.json"); if (ModList.get().getModContainerById("dynmap").isPresent()) { new DynmapListener().register(); } @@ -484,7 +483,7 @@ public void chat(ServerChatEvent ev) { } } else INSTANCE.sendMessage(ForgeMessageUtils.formatPlayerName(ev.getPlayer()), ev.getPlayer().getUUID().toString(), new DiscordMessage(embed, text, true), channel); - if (!Configuration.instance().compatibility.disableParsingMentionsIngame) { + if(!Configuration.instance().compatibility.disableParsingMentionsIngame) { final String json = net.minecraft.network.chat.Component.Serializer.toJson(msg); Component comp = GsonComponentSerializer.gson().deserialize(json); final String editedJson = GsonComponentSerializer.gson().serialize(MessageUtils.mentionsToNames(comp, channel.getGuild())); diff --git a/update_checker.json b/update_checker.json index 197a0f9..5f08258 100644 --- a/update_checker.json +++ b/update_checker.json @@ -6,7 +6,7 @@ }, { "version": "3.0.0", - "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", + "changelog": "Large discord integration rewrite adding new features and fixing long existing bugs Old configuration can be used as-is", "type": "alpha" },{ "version": "2.6.4",