Skip to content

Commit

Permalink
Update to 1.20.2
Browse files Browse the repository at this point in the history
Signed-off-by: ErdbeerbaerLP <[email protected]>
  • Loading branch information
ErdbeerbaerLP committed Sep 30, 2023
1 parent 4563e37 commit dbb0611
Show file tree
Hide file tree
Showing 7 changed files with 28 additions and 17 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -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
mcVersion = 1.20.2
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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();
Expand Down Expand Up @@ -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());
Expand All @@ -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())
);
Expand All @@ -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"));
Expand All @@ -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"));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -24,7 +27,9 @@ public class DCCommandSender extends FakePlayer {
final StringBuilder message = new StringBuilder();

public DCCommandSender(CompletableFuture<InteractionHook> 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;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions src/main/resources/META-INF/mods.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"

0 comments on commit dbb0611

Please sign in to comment.