Skip to content

Commit

Permalink
Cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
senseiwells committed Jan 30, 2024
1 parent 0bfbf0b commit 4b21b46
Show file tree
Hide file tree
Showing 12 changed files with 18 additions and 31 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -16,7 +15,6 @@

import java.util.function.BooleanSupplier;

@Debug(export = true)
@Mixin(ChunkMap.class)
public class ChunkMapMixin {
@Inject(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
4 changes: 1 addition & 3 deletions src/main/kotlin/me/senseiwells/replay/chunk/ChunkRecorder.kt
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -65,7 +63,7 @@ class ChunkRecorder internal constructor(
}

override fun closed(future: CompletableFuture<Long>) {
ChunkRecorders.close(this.server, this.chunks, future)
ChunkRecorders.close(this.server, this.chunks, future, this.getName())
}

override fun spawnPlayer() {
Expand Down
11 changes: 5 additions & 6 deletions src/main/kotlin/me/senseiwells/replay/chunk/ChunkRecorders.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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<ChunkArea, ChunkRecorder>()
private val chunksByName = LinkedHashMap<String, ChunkRecorder>()
private val closing = HashMap<ChunkArea, CompletableFuture<Long>>()
private val closing = HashMap<String, CompletableFuture<Long>>()

@JvmStatic
fun create(level: ServerLevel, from: ChunkPos, to: ChunkPos, name: String): ChunkRecorder {
Expand All @@ -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,
Expand Down Expand Up @@ -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<Long>) {
internal fun close(server: MinecraftServer, area: ChunkArea, future: CompletableFuture<Long>, 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)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<UUID, PlayerRecorder>()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 4 additions & 4 deletions src/main/resources/serverreplay.mixins.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down

0 comments on commit 4b21b46

Please sign in to comment.