From 82e941734a8a916d2483bfa1682b3ab3f80991ef Mon Sep 17 00:00:00 2001 From: senseiwells Date: Mon, 22 Jan 2024 02:44:54 +0000 Subject: [PATCH] Fix replay players interfering with advancements --- build.gradle.kts | 4 ++-- .../mixin/rejoin/ServerPlayerMixin.java | 22 +++++++++++++++++++ src/main/resources/serverreplay.mixins.json | 1 + 3 files changed, 25 insertions(+), 2 deletions(-) create mode 100644 src/main/java/me/senseiwells/replay/mixin/rejoin/ServerPlayerMixin.java diff --git a/build.gradle.kts b/build.gradle.kts index 15bd793..bf4019b 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -38,12 +38,12 @@ dependencies { // I've had some issues with ReplayStudio and slf4j (in dev) // Simplest workaround that I've found is just to unzip the // jar and yeet the org.slf4j packages then rezip the jar. - modImplementation("com.github.ReplayMod:ReplayStudio:6cd39b0874") { + include(modImplementation("com.github.ReplayMod:ReplayStudio:6cd39b0874") { exclude(group = "org.slf4j") exclude(group = "com.google.guava", module = "guava-jdk5") exclude(group = "com.google.guava", module = "guava") exclude(group = "com.google.code.gson", module = "gson") - } + }) include(modImplementation("net.fabricmc:fabric-language-kotlin:${property("fabric_kotlin_version")}")!!) include(modImplementation("me.lucko:fabric-permissions-api:${property("permissions_version")}")!!) diff --git a/src/main/java/me/senseiwells/replay/mixin/rejoin/ServerPlayerMixin.java b/src/main/java/me/senseiwells/replay/mixin/rejoin/ServerPlayerMixin.java new file mode 100644 index 0000000..45426a2 --- /dev/null +++ b/src/main/java/me/senseiwells/replay/mixin/rejoin/ServerPlayerMixin.java @@ -0,0 +1,22 @@ +package me.senseiwells.replay.mixin.rejoin; + +import com.llamalad7.mixinextras.injector.WrapWithCondition; +import me.senseiwells.replay.rejoin.RejoinedReplayPlayer; +import net.minecraft.server.level.ServerPlayer; +import net.minecraft.server.players.PlayerList; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.injection.At; + +@Mixin(ServerPlayer.class) +public class ServerPlayerMixin { + @WrapWithCondition( + method = "", + at = @At( + value = "INVOKE", + target = "Lnet/minecraft/server/players/PlayerList;getPlayerAdvancements(Lnet/minecraft/server/level/ServerPlayer;)Lnet/minecraft/server/PlayerAdvancements;" + ) + ) + private boolean shouldUpdateAdvancements(PlayerList instance, ServerPlayer player) { + return !(player instanceof RejoinedReplayPlayer); + } +} diff --git a/src/main/resources/serverreplay.mixins.json b/src/main/resources/serverreplay.mixins.json index 189383d..fd5bb76 100644 --- a/src/main/resources/serverreplay.mixins.json +++ b/src/main/resources/serverreplay.mixins.json @@ -17,6 +17,7 @@ "rejoin.ChunkMapMixin", "rejoin.ConnectionAccessor", "rejoin.ServerConfigurationPacketListenerImplAccessor", + "rejoin.ServerPlayerMixin", "rejoin.TrackedEntityAccessor", "rejoin.TrackedEntityMixin", "studio.ZipReplayFileAccessor"