From dbb0611def1685947b4de654ce4c4d89c50e7165 Mon Sep 17 00:00:00 2001 From: ErdbeerbaerLP Date: Sat, 30 Sep 2023 14:38:55 +0200 Subject: [PATCH] Update to 1.20.2 Signed-off-by: ErdbeerbaerLP --- build.gradle | 2 +- gradle.properties | 2 +- .../forge/DiscordIntegrationMod.java | 25 ++++++++++++------- .../forge/command/DCCommandSender.java | 7 +++++- .../mixin/MixinNetHandlerPlayServer.java | 2 +- .../forge/util/ForgeServerInterface.java | 3 +-- src/main/resources/META-INF/mods.toml | 4 +-- 7 files changed, 28 insertions(+), 17 deletions(-) diff --git a/build.gradle b/build.gradle index ee4cf5c7..3732d738 100644 --- a/build.gradle +++ b/build.gradle @@ -101,7 +101,7 @@ dependencies { } // ========= Minecraft Forge ============= - minecraft "net.minecraftforge:forge:${project.mcVersion}-47.1.43" + minecraft "net.minecraftforge:forge:${project.mcVersion}-48.0.13" //Mixin annotationProcessor 'org.spongepowered:mixin:0.8.5:processor' diff --git a/gradle.properties b/gradle.properties index 9a7a4963..8e5765c4 100644 --- a/gradle.properties +++ b/gradle.properties @@ -4,4 +4,4 @@ org.gradle.jvmargs=-Xmx3G org.gradle.daemon=false 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 releaseType = BETA -mcVersion = 1.20.1 \ No newline at end of file +mcVersion = 1.20.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 61b16303..6c2c9ff8 100644 --- a/src/main/java/de/erdbeerbaerlp/dcintegration/forge/DiscordIntegrationMod.java +++ b/src/main/java/de/erdbeerbaerlp/dcintegration/forge/DiscordIntegrationMod.java @@ -51,7 +51,6 @@ import net.minecraftforge.fml.event.lifecycle.FMLDedicatedServerSetupEvent; import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext; import net.minecraftforge.fml.loading.FMLEnvironment; -import net.minecraftforge.network.NetworkConstants; import org.apache.commons.lang3.ArrayUtils; import java.io.File; @@ -77,7 +76,7 @@ public class DiscordIntegrationMod { private boolean stopped = false; public DiscordIntegrationMod() { - ModLoadingContext.get().registerExtensionPoint(IExtensionPoint.DisplayTest.class, () -> new IExtensionPoint.DisplayTest(() -> NetworkConstants.IGNORESERVERONLY, (a, b) -> true)); + ModLoadingContext.get().registerExtensionPoint(IExtensionPoint.DisplayTest.class, () -> new IExtensionPoint.DisplayTest(() -> IExtensionPoint.DisplayTest.IGNORESERVERONLY, (a, b) -> true)); try { //Create data directory if missing if (!discordDataDir.exists()) discordDataDir.mkdir(); @@ -183,7 +182,7 @@ public void advancement(AdvancementEvent.AdvancementEarnEvent ev) { if (LinkManager.isPlayerLinked(ev.getEntity().getUUID()) && LinkManager.getLink(null, ev.getEntity().getUUID()).settings.hideFromDiscord) return; if (ev.getEntity().getServer().getPlayerList().getPlayerAdvancements((ServerPlayer) ev.getEntity()).getOrStartProgress(ev.getAdvancement()).isDone()) - if (INSTANCE != null && ev.getAdvancement() != null && ev.getAdvancement().getDisplay() != null && ev.getAdvancement().getDisplay().shouldAnnounceChat()) + if (INSTANCE != null && ev.getAdvancement() != null && ev.getAdvancement().value().display().isPresent() && ev.getAdvancement().value().display().get().shouldAnnounceChat()) if (!Localization.instance().advancementMessage.isBlank()) { if (Configuration.instance().embedMode.enabled && Configuration.instance().embedMode.advancementMessage.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()); @@ -194,8 +193,8 @@ public void advancement(AdvancementEvent.AdvancementEarnEvent ev) { .replace("%name%", ForgeMessageUtils.formatPlayerName(ev.getEntity())) .replace("%randomUUID%", UUID.randomUUID().toString()) .replace("%avatarURL%", avatarURL) - .replace("%advName%", ChatFormatting.stripFormatting(ev.getAdvancement().getDisplay().getTitle().getString())) - .replace("%advDesc%", ChatFormatting.stripFormatting(ev.getAdvancement().getDisplay().getDescription().getString())) + .replace("%advName%", ChatFormatting.stripFormatting(ev.getAdvancement().value().display().get().getTitle().getString())) + .replace("%advDesc%", ChatFormatting.stripFormatting(ev.getAdvancement().value().display().get().getDescription().getString())) .replace("%avatarURL%", avatarURL) .replace("%playerColor%", "" + TextColors.generateFromUUID(ev.getEntity().getUUID()).getRGB()) ); @@ -205,12 +204,16 @@ public void advancement(AdvancementEvent.AdvancementEarnEvent ev) { b = b.setAuthor(ForgeMessageUtils.formatPlayerName(ev.getEntity()), null, avatarURL) .setDescription(Localization.instance().advancementMessage.replace("%player%", ForgeMessageUtils.formatPlayerName(ev.getEntity())).replace("%advName%", ChatFormatting.stripFormatting(ev.getAdvancement() - .getDisplay() + .value() + .display() + .get() .getTitle() .getString())) .replace("%advDesc%", ChatFormatting.stripFormatting(ev.getAdvancement() - .getDisplay() + .value() + .display() + .get() .getDescription() .getString())) .replace("\\n", "\n")); @@ -220,12 +223,16 @@ public void advancement(AdvancementEvent.AdvancementEarnEvent ev) { ChatFormatting.stripFormatting(ForgeMessageUtils.formatPlayerName(ev.getEntity()))) .replace("%advName%", ChatFormatting.stripFormatting(ev.getAdvancement() - .getDisplay() + .value() + .display() + .get() .getTitle() .getString())) .replace("%advDesc%", ChatFormatting.stripFormatting(ev.getAdvancement() - .getDisplay() + .value() + .display() + .get() .getDescription() .getString())) .replace("\\n", "\n")); diff --git a/src/main/java/de/erdbeerbaerlp/dcintegration/forge/command/DCCommandSender.java b/src/main/java/de/erdbeerbaerlp/dcintegration/forge/command/DCCommandSender.java index f951ef72..bb0ddf6a 100644 --- a/src/main/java/de/erdbeerbaerlp/dcintegration/forge/command/DCCommandSender.java +++ b/src/main/java/de/erdbeerbaerlp/dcintegration/forge/command/DCCommandSender.java @@ -9,6 +9,9 @@ import net.minecraft.network.chat.ChatType; import net.minecraft.network.chat.Component; import net.minecraft.network.chat.OutgoingChatMessage; +import net.minecraft.server.level.ClientInformation; +import net.minecraft.world.entity.HumanoidArm; +import net.minecraft.world.entity.player.ChatVisiblity; import net.minecraftforge.common.util.FakePlayer; import net.minecraftforge.server.ServerLifecycleHooks; @@ -24,7 +27,9 @@ public class DCCommandSender extends FakePlayer { final StringBuilder message = new StringBuilder(); public DCCommandSender(CompletableFuture cmdMsg, User user) { - super(ServerLifecycleHooks.getCurrentServer().overworld(), new GameProfile(uuid, "@" + (!user.getDiscriminator().equals("0000") ? user.getAsTag() : user.getName()))); + super(ServerLifecycleHooks.getCurrentServer().overworld(), + new GameProfile(uuid, "@" + (!user.getDiscriminator().equals("0000") ? user.getAsTag() : user.getName())), + new ClientInformation("en-US",0, ChatVisiblity.FULL, true,0,HumanoidArm.RIGHT, false, false)); this.cmdMsg = cmdMsg; } diff --git a/src/main/java/de/erdbeerbaerlp/dcintegration/forge/mixin/MixinNetHandlerPlayServer.java b/src/main/java/de/erdbeerbaerlp/dcintegration/forge/mixin/MixinNetHandlerPlayServer.java index 9f89ebbd..7baccf3a 100644 --- a/src/main/java/de/erdbeerbaerlp/dcintegration/forge/mixin/MixinNetHandlerPlayServer.java +++ b/src/main/java/de/erdbeerbaerlp/dcintegration/forge/mixin/MixinNetHandlerPlayServer.java @@ -18,7 +18,7 @@ public class MixinNetHandlerPlayServer { @Shadow public ServerPlayer player; - @Inject(method = "disconnect", at = @At("HEAD")) + @Inject(method = "onDisconnect", at = @At("HEAD")) private void onDisconnect(final Component textComponent, CallbackInfo ci) { if (textComponent.equals(Component.translatable("disconnect.timeout"))) DiscordIntegrationMod.timeouts.add(this.player.getUUID()); diff --git a/src/main/java/de/erdbeerbaerlp/dcintegration/forge/util/ForgeServerInterface.java b/src/main/java/de/erdbeerbaerlp/dcintegration/forge/util/ForgeServerInterface.java index 9fbada21..2b3204e1 100644 --- a/src/main/java/de/erdbeerbaerlp/dcintegration/forge/util/ForgeServerInterface.java +++ b/src/main/java/de/erdbeerbaerlp/dcintegration/forge/util/ForgeServerInterface.java @@ -1,6 +1,5 @@ package de.erdbeerbaerlp.dcintegration.forge.util; -import com.mojang.authlib.GameProfile; import com.mojang.brigadier.StringReader; import com.mojang.brigadier.exceptions.CommandSyntaxException; import dcshadow.com.vdurmont.emoji.EmojiParser; @@ -157,7 +156,7 @@ private void sendReactionMCMessage(ServerPlayer target, Component msgComp) { @Override public String getNameFromUUID(UUID uuid) { - return ServerLifecycleHooks.getCurrentServer().getSessionService().fillProfileProperties(new GameProfile(uuid, ""), false).getName(); + return ServerLifecycleHooks.getCurrentServer().getSessionService().fetchProfile(uuid, false).profile().getName(); } @Override diff --git a/src/main/resources/META-INF/mods.toml b/src/main/resources/META-INF/mods.toml index ea42f1ad..1f19363a 100644 --- a/src/main/resources/META-INF/mods.toml +++ b/src/main/resources/META-INF/mods.toml @@ -23,12 +23,12 @@ This mod links your server chat with a channel on your discord server. [[dependencies.dcintegration]] modId = "minecraft" mandatory = true -versionRange = "[1.20,]" +versionRange = "[1.20.2,]" ordering = "NONE" side = "SERVER" [[dependencies.dcintegration]] modId = "forge" mandatory = true -versionRange = "[47.0.0,)" +versionRange = "[48.0.0,)" ordering = "NONE" side = "BOTH" \ No newline at end of file