Skip to content

Commit

Permalink
Fix replay players interfering with advancements
Browse files Browse the repository at this point in the history
  • Loading branch information
senseiwells committed Jan 22, 2024
1 parent fd80e86 commit 82e9417
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 2 deletions.
4 changes: 2 additions & 2 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -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")}")!!)

Expand Down
Original file line number Diff line number Diff line change
@@ -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 = "<init>",
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);
}
}
1 change: 1 addition & 0 deletions src/main/resources/serverreplay.mixins.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
"rejoin.ChunkMapMixin",
"rejoin.ConnectionAccessor",
"rejoin.ServerConfigurationPacketListenerImplAccessor",
"rejoin.ServerPlayerMixin",
"rejoin.TrackedEntityAccessor",
"rejoin.TrackedEntityMixin",
"studio.ZipReplayFileAccessor"
Expand Down

0 comments on commit 82e9417

Please sign in to comment.