From 4b21b46a058f37accbe2045aa14ee1c46bcf72ca Mon Sep 17 00:00:00 2001 From: senseiwells Date: Tue, 30 Jan 2024 20:29:37 +0000 Subject: [PATCH] Cleanup --- .../replay/mixin/MinecraftServerMixin.java | 1 - .../me/senseiwells/replay/mixin/ServerLevelMixin.java | 6 ------ .../mixin/ServerLoginPacketListenerImplMixin.java | 1 - .../senseiwells/replay/mixin/chunk/ChunkMapMixin.java | 2 -- .../replay/mixin/chunk/PlayerListMixin.java | 2 -- .../replay/mixin/rejoin/ChunkMapMixin.java | 1 - .../me/senseiwells/replay/chunk/ChunkRecorder.kt | 4 +--- .../me/senseiwells/replay/chunk/ChunkRecorders.kt | 11 +++++------ .../me/senseiwells/replay/player/PlayerRecorder.kt | 6 ++++-- .../me/senseiwells/replay/player/PlayerRecorders.kt | 2 -- .../me/senseiwells/replay/util/SizedZipReplayFile.kt | 5 ++++- src/main/resources/serverreplay.mixins.json | 8 ++++---- 12 files changed, 18 insertions(+), 31 deletions(-) diff --git a/src/main/java/me/senseiwells/replay/mixin/MinecraftServerMixin.java b/src/main/java/me/senseiwells/replay/mixin/MinecraftServerMixin.java index b6d9c29..69d05a5 100644 --- a/src/main/java/me/senseiwells/replay/mixin/MinecraftServerMixin.java +++ b/src/main/java/me/senseiwells/replay/mixin/MinecraftServerMixin.java @@ -5,7 +5,6 @@ import me.senseiwells.replay.config.ReplayConfig; import me.senseiwells.replay.player.PlayerRecorder; import me.senseiwells.replay.player.PlayerRecorders; -import net.fabricmc.fabric.api.event.lifecycle.v1.ServerLifecycleEvents; import net.minecraft.server.MinecraftServer; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; diff --git a/src/main/java/me/senseiwells/replay/mixin/ServerLevelMixin.java b/src/main/java/me/senseiwells/replay/mixin/ServerLevelMixin.java index 1a77de6..6b32a98 100644 --- a/src/main/java/me/senseiwells/replay/mixin/ServerLevelMixin.java +++ b/src/main/java/me/senseiwells/replay/mixin/ServerLevelMixin.java @@ -5,16 +5,10 @@ import me.senseiwells.replay.player.PlayerRecorder; import me.senseiwells.replay.player.PlayerRecorders; import net.minecraft.core.BlockPos; -import net.minecraft.core.Holder; import net.minecraft.network.protocol.game.ClientboundBlockDestructionPacket; -import net.minecraft.network.protocol.game.ClientboundLevelEventPacket; -import net.minecraft.network.protocol.game.ClientboundSoundPacket; import net.minecraft.server.level.ServerLevel; import net.minecraft.server.level.ServerPlayer; -import net.minecraft.sounds.SoundEvent; -import net.minecraft.sounds.SoundSource; import net.minecraft.world.entity.Entity; -import net.minecraft.world.entity.player.Player; import net.minecraft.world.level.ChunkPos; import org.jetbrains.annotations.Nullable; import org.spongepowered.asm.mixin.Mixin; diff --git a/src/main/java/me/senseiwells/replay/mixin/ServerLoginPacketListenerImplMixin.java b/src/main/java/me/senseiwells/replay/mixin/ServerLoginPacketListenerImplMixin.java index 6db28ae..8704cf0 100644 --- a/src/main/java/me/senseiwells/replay/mixin/ServerLoginPacketListenerImplMixin.java +++ b/src/main/java/me/senseiwells/replay/mixin/ServerLoginPacketListenerImplMixin.java @@ -1,7 +1,6 @@ package me.senseiwells.replay.mixin; import com.mojang.authlib.GameProfile; -import me.senseiwells.replay.ServerReplay; import me.senseiwells.replay.config.ReplayConfig; import me.senseiwells.replay.player.PlayerRecorder; import me.senseiwells.replay.player.PlayerRecorders; diff --git a/src/main/java/me/senseiwells/replay/mixin/chunk/ChunkMapMixin.java b/src/main/java/me/senseiwells/replay/mixin/chunk/ChunkMapMixin.java index e0f5c28..1f8bc4a 100644 --- a/src/main/java/me/senseiwells/replay/mixin/chunk/ChunkMapMixin.java +++ b/src/main/java/me/senseiwells/replay/mixin/chunk/ChunkMapMixin.java @@ -7,7 +7,6 @@ import net.minecraft.server.level.ChunkHolder; import net.minecraft.server.level.ChunkMap; import net.minecraft.world.level.ChunkPos; -import org.spongepowered.asm.mixin.Debug; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; @@ -16,7 +15,6 @@ import java.util.function.BooleanSupplier; -@Debug(export = true) @Mixin(ChunkMap.class) public class ChunkMapMixin { @Inject( diff --git a/src/main/java/me/senseiwells/replay/mixin/chunk/PlayerListMixin.java b/src/main/java/me/senseiwells/replay/mixin/chunk/PlayerListMixin.java index 96bd539..5bb9355 100644 --- a/src/main/java/me/senseiwells/replay/mixin/chunk/PlayerListMixin.java +++ b/src/main/java/me/senseiwells/replay/mixin/chunk/PlayerListMixin.java @@ -5,7 +5,6 @@ import me.senseiwells.replay.player.PlayerRecorder; import me.senseiwells.replay.player.PlayerRecorders; import net.minecraft.core.BlockPos; -import net.minecraft.core.LayeredRegistryAccess; import net.minecraft.network.chat.ChatType; import net.minecraft.network.chat.Component; import net.minecraft.network.chat.MessageSignatureCache; @@ -15,7 +14,6 @@ import net.minecraft.network.protocol.game.ClientboundSystemChatPacket; import net.minecraft.resources.ResourceKey; import net.minecraft.server.MinecraftServer; -import net.minecraft.server.RegistryLayer; import net.minecraft.server.level.ServerPlayer; import net.minecraft.server.players.PlayerList; import net.minecraft.world.entity.player.Player; diff --git a/src/main/java/me/senseiwells/replay/mixin/rejoin/ChunkMapMixin.java b/src/main/java/me/senseiwells/replay/mixin/rejoin/ChunkMapMixin.java index ad8932a..d3761db 100644 --- a/src/main/java/me/senseiwells/replay/mixin/rejoin/ChunkMapMixin.java +++ b/src/main/java/me/senseiwells/replay/mixin/rejoin/ChunkMapMixin.java @@ -5,7 +5,6 @@ import net.minecraft.server.level.ChunkMap; import net.minecraft.server.level.ThreadedLevelLightEngine; import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; import org.spongepowered.asm.mixin.Final; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Shadow; diff --git a/src/main/kotlin/me/senseiwells/replay/chunk/ChunkRecorder.kt b/src/main/kotlin/me/senseiwells/replay/chunk/ChunkRecorder.kt index 071eaea..273dee9 100644 --- a/src/main/kotlin/me/senseiwells/replay/chunk/ChunkRecorder.kt +++ b/src/main/kotlin/me/senseiwells/replay/chunk/ChunkRecorder.kt @@ -1,11 +1,9 @@ package me.senseiwells.replay.chunk import me.senseiwells.replay.config.ReplayConfig -import me.senseiwells.replay.mixin.rejoin.ChunkMapAccessor import me.senseiwells.replay.recorder.ChunkSender import me.senseiwells.replay.recorder.ReplayRecorder import me.senseiwells.replay.rejoin.RejoinedReplayPlayer -import me.senseiwells.replay.util.ducks.ChunkMapInvoker import net.minecraft.core.UUIDUtil import net.minecraft.network.chat.Component import net.minecraft.network.protocol.Packet @@ -65,7 +63,7 @@ class ChunkRecorder internal constructor( } override fun closed(future: CompletableFuture) { - ChunkRecorders.close(this.server, this.chunks, future) + ChunkRecorders.close(this.server, this.chunks, future, this.getName()) } override fun spawnPlayer() { diff --git a/src/main/kotlin/me/senseiwells/replay/chunk/ChunkRecorders.kt b/src/main/kotlin/me/senseiwells/replay/chunk/ChunkRecorders.kt index fdab8ee..be686e2 100644 --- a/src/main/kotlin/me/senseiwells/replay/chunk/ChunkRecorders.kt +++ b/src/main/kotlin/me/senseiwells/replay/chunk/ChunkRecorders.kt @@ -4,13 +4,12 @@ import me.senseiwells.replay.config.ReplayConfig import net.minecraft.server.MinecraftServer import net.minecraft.server.level.ServerLevel import net.minecraft.world.level.ChunkPos -import org.jetbrains.annotations.ApiStatus.Internal import java.util.concurrent.CompletableFuture object ChunkRecorders { private val chunks = LinkedHashMap() private val chunksByName = LinkedHashMap() - private val closing = HashMap>() + private val closing = HashMap>() @JvmStatic fun create(level: ServerLevel, from: ChunkPos, to: ChunkPos, name: String): ChunkRecorder { @@ -27,7 +26,7 @@ object ChunkRecorders { throw IllegalArgumentException("Recorder with name already exists") } - this.closing[area]?.join() + this.closing[name]?.join() val recorder = ChunkRecorder( area, @@ -80,9 +79,9 @@ object ChunkRecorders { return "Chunks (${area.from.x}, ${area.from.z}) to (${area.to.x}, ${area.to.z})" } - internal fun close(server: MinecraftServer, area: ChunkArea, future: CompletableFuture) { + internal fun close(server: MinecraftServer, area: ChunkArea, future: CompletableFuture, name: String) { this.remove(area) - this.closing[area] = future - future.thenRunAsync({ this.closing.remove(area) }, server) + this.closing[name] = future + future.thenRunAsync({ this.closing.remove(name) }, server) } } \ No newline at end of file diff --git a/src/main/kotlin/me/senseiwells/replay/player/PlayerRecorder.kt b/src/main/kotlin/me/senseiwells/replay/player/PlayerRecorder.kt index 881b31a..e29b719 100644 --- a/src/main/kotlin/me/senseiwells/replay/player/PlayerRecorder.kt +++ b/src/main/kotlin/me/senseiwells/replay/player/PlayerRecorder.kt @@ -6,12 +6,14 @@ import me.senseiwells.replay.recorder.ChunkSender import me.senseiwells.replay.recorder.ReplayRecorder import me.senseiwells.replay.rejoin.RejoinedReplayPlayer import me.senseiwells.replay.util.LevelUtils.viewDistance -import me.senseiwells.replay.util.ducks.TrackedEntityInvoker import net.minecraft.network.protocol.Packet import net.minecraft.network.protocol.game.ClientboundAddEntityPacket import net.minecraft.network.protocol.game.ClientboundSetEntityDataPacket import net.minecraft.server.MinecraftServer -import net.minecraft.server.level.* +import net.minecraft.server.level.ChunkMap +import net.minecraft.server.level.ChunkTrackingView +import net.minecraft.server.level.ServerLevel +import net.minecraft.server.level.ServerPlayer import net.minecraft.world.entity.Entity import net.minecraft.world.level.ChunkPos import org.jetbrains.annotations.ApiStatus.Internal diff --git a/src/main/kotlin/me/senseiwells/replay/player/PlayerRecorders.kt b/src/main/kotlin/me/senseiwells/replay/player/PlayerRecorders.kt index 9185548..57267c0 100644 --- a/src/main/kotlin/me/senseiwells/replay/player/PlayerRecorders.kt +++ b/src/main/kotlin/me/senseiwells/replay/player/PlayerRecorders.kt @@ -7,8 +7,6 @@ import net.minecraft.server.MinecraftServer import net.minecraft.server.level.ServerPlayer import java.util.* import java.util.concurrent.CompletableFuture -import kotlin.collections.ArrayList -import kotlin.collections.HashMap object PlayerRecorders { private val players = LinkedHashMap() diff --git a/src/main/kotlin/me/senseiwells/replay/util/SizedZipReplayFile.kt b/src/main/kotlin/me/senseiwells/replay/util/SizedZipReplayFile.kt index bfa169a..f1baff5 100644 --- a/src/main/kotlin/me/senseiwells/replay/util/SizedZipReplayFile.kt +++ b/src/main/kotlin/me/senseiwells/replay/util/SizedZipReplayFile.kt @@ -5,7 +5,10 @@ import com.replaymod.replaystudio.studio.ReplayStudio import com.replaymod.replaystudio.util.Utils import me.senseiwells.replay.mixin.studio.ZipReplayFileAccessor import org.apache.commons.lang3.mutable.MutableLong -import java.io.* +import java.io.BufferedInputStream +import java.io.File +import java.io.FileInputStream +import java.io.OutputStream import java.util.* import java.util.zip.ZipEntry import java.util.zip.ZipFile diff --git a/src/main/resources/serverreplay.mixins.json b/src/main/resources/serverreplay.mixins.json index 31e3b5f..8ff0f7b 100644 --- a/src/main/resources/serverreplay.mixins.json +++ b/src/main/resources/serverreplay.mixins.json @@ -5,18 +5,18 @@ "compatibilityLevel": "JAVA_17", "plugin": "me.senseiwells.replay.util.ReplayMixinConfig", "mixins": [ - "chunk.ChunkHolderMixin", - "chunk.ChunkMapMixin", "CommandsMixin", "MinecraftServerMixin", - "chunk.PlayerListMixin", - "chunk.ServerChunkCacheInvoker", "ServerCommonPacketListenerImplMixin", "ServerConfigurationPacketListenerImplMixin", "ServerLevelMixin", "ServerLoginPacketListenerImplMixin", "ServerPlayerMixin", "TrackedEntityMixin", + "chunk.ChunkHolderMixin", + "chunk.ChunkMapMixin", + "chunk.PlayerListMixin", + "chunk.ServerChunkCacheInvoker", "compat.carpet.NetHandlerPlayServerFakeMixin", "rejoin.ChunkMapAccessor", "rejoin.ChunkMapMixin",