From 0724ba3fa9bec83d2dc4b8a68d576a187f7d0067 Mon Sep 17 00:00:00 2001 From: Helvetica Volubi Date: Sun, 26 Jul 2026 01:38:09 +0800 Subject: [PATCH] fix: bind packetListenerImpl to Connection when place new photographer (#160) --- .../features/0084-Server-I18n.patch | 2 +- .../features/0113-Leaves-Replay-Mod-API.patch | 17 +++++++++-------- .../features/0126-Carpet-features.patch | 8 ++++---- ...30-Restore-vanilla-ender-pearl-loading.patch | 4 ++-- .../org/leavesmc/leaves/replay/Recorder.java | 6 ++++++ 5 files changed, 22 insertions(+), 15 deletions(-) diff --git a/lophine-server/minecraft-patches/features/0084-Server-I18n.patch b/lophine-server/minecraft-patches/features/0084-Server-I18n.patch index ce75f63..6880f58 100644 --- a/lophine-server/minecraft-patches/features/0084-Server-I18n.patch +++ b/lophine-server/minecraft-patches/features/0084-Server-I18n.patch @@ -5,7 +5,7 @@ Subject: [PATCH] Server I18n diff --git a/net/minecraft/locale/Language.java b/net/minecraft/locale/Language.java -index 47cd33bce908744e64356b585853d6a8ecf82443..9e6f89ac7cf730bfc3c15d5a4f648c550cf72e22 100644 +index 47cd33bce908744e64356b585853d6a8ecf82443..bb4011d3c6a1d2a5aa66e68fe719cd5eea2c0dd2 100644 --- a/net/minecraft/locale/Language.java +++ b/net/minecraft/locale/Language.java @@ -37,6 +37,7 @@ public abstract class Language { diff --git a/lophine-server/minecraft-patches/features/0113-Leaves-Replay-Mod-API.patch b/lophine-server/minecraft-patches/features/0113-Leaves-Replay-Mod-API.patch index 289ef1e..7a40c02 100644 --- a/lophine-server/minecraft-patches/features/0113-Leaves-Replay-Mod-API.patch +++ b/lophine-server/minecraft-patches/features/0113-Leaves-Replay-Mod-API.patch @@ -311,7 +311,7 @@ index 1c4c67410849f844946e4883585910fc8fe97048..08a6fc0e58d61b1765e704c500b3aec6 } // Leaves end - skip diff --git a/net/minecraft/server/players/PlayerList.java b/net/minecraft/server/players/PlayerList.java -index ed50484ca24ef24b1e5bef9f6369dfa4b30c359c..64a87785048e103c10f6453e97a37f8501255adc 100644 +index ed50484ca24ef24b1e5bef9f6369dfa4b30c359c..575b4eabcaac48ae87b69dd037493ebfe0a1212c 100644 --- a/net/minecraft/server/players/PlayerList.java +++ b/net/minecraft/server/players/PlayerList.java @@ -129,6 +129,7 @@ public abstract class PlayerList { @@ -330,12 +330,12 @@ index ed50484ca24ef24b1e5bef9f6369dfa4b30c359c..64a87785048e103c10f6453e97a37f85 int count = this.usersCountedAgainstLimit.size(); if (count >= limit) { return false; -@@ -221,6 +223,123 @@ public abstract class PlayerList { +@@ -221,6 +223,124 @@ public abstract class PlayerList { abstract public void loadAndSaveFiles(); // Paper - fix converting txt to json file; moved from DedicatedPlayerList constructor + // Leaves start - replay mod api -+ public void placeNewPhotographer(Connection connection, org.leavesmc.leaves.replay.ServerPhotographer player, ServerLevel worldserver) { ++ public void placeNewPhotographer(org.leavesmc.leaves.replay.Recorder connection, org.leavesmc.leaves.replay.ServerPhotographer player, ServerLevel worldserver) { + player.isRealPlayer = true; // Paper + player.loginTime = System.currentTimeMillis(); // Paper + @@ -347,6 +347,7 @@ index ed50484ca24ef24b1e5bef9f6369dfa4b30c359c..64a87785048e103c10f6453e97a37f85 + LevelData worlddata = worldserver1.getLevelData(); + + ServerGamePacketListenerImpl playerconnection = new ServerGamePacketListenerImpl(this.server, connection, player, CommonListenerCookie.createInitial(player.gameProfile, false)); ++ connection.bind(playerconnection); + GameRules gamerules = worldserver1.getGameRules(); + boolean flag = gamerules.get(GameRules.IMMEDIATE_RESPAWN); + boolean flag1 = gamerules.get(GameRules.REDUCED_DEBUG_INFO); @@ -454,7 +455,7 @@ index ed50484ca24ef24b1e5bef9f6369dfa4b30c359c..64a87785048e103c10f6453e97a37f85 public void placeNewPlayer(final Connection connection, final ServerPlayer player, final CommonListenerCookie cookie) { player.isRealPlayer = true; // Paper player.loginTime = System.currentTimeMillis(); // Paper - Replace OfflinePlayer#getLastPlayed -@@ -295,6 +414,7 @@ public abstract class PlayerList { +@@ -295,6 +415,7 @@ public abstract class PlayerList { // player.connection.send(ClientboundPlayerInfoUpdatePacket.createPlayerInitializing(this.players)); // CraftBukkit - replaced with loop below this.players.add(player); @@ -462,7 +463,7 @@ index ed50484ca24ef24b1e5bef9f6369dfa4b30c359c..64a87785048e103c10f6453e97a37f85 this.playersByName.put(player.getScoreboardName().toLowerCase(java.util.Locale.ROOT), player); // Spigot this.playersByUUID.put(player.getUUID(), player); // this.broadcastAll(ClientboundPlayerInfoUpdatePacket.createPlayerInitializing(List.of(player))); // CraftBukkit - replaced with loop below -@@ -510,6 +630,7 @@ public abstract class PlayerList { +@@ -510,6 +631,7 @@ public abstract class PlayerList { } protected void save(final ServerPlayer player) { @@ -470,7 +471,7 @@ index ed50484ca24ef24b1e5bef9f6369dfa4b30c359c..64a87785048e103c10f6453e97a37f85 if (!player.getBukkitEntity().isPersistent()) return; // CraftBukkit player.lastSave = System.nanoTime(); // Folia - region threading - changed to nanoTime tracking this.playerIo.save(player); -@@ -524,6 +645,48 @@ public abstract class PlayerList { +@@ -524,6 +646,48 @@ public abstract class PlayerList { } } @@ -519,7 +520,7 @@ index ed50484ca24ef24b1e5bef9f6369dfa4b30c359c..64a87785048e103c10f6453e97a37f85 public net.kyori.adventure.text.@Nullable Component remove(final ServerPlayer player) { // CraftBukkit - return string // Paper - return Component // Paper start - Fix kick event leave message not being sent return this.remove(player, net.kyori.adventure.text.Component.translatable("multiplayer.player.left", net.kyori.adventure.text.format.NamedTextColor.YELLOW, io.papermc.paper.configuration.GlobalConfiguration.get().messages.useDisplayNameInQuitMessage ? player.getBukkitEntity().displayName() : io.papermc.paper.adventure.PaperAdventure.asAdventure(player.getDisplayName()))); -@@ -597,6 +760,7 @@ public abstract class PlayerList { +@@ -597,6 +761,7 @@ public abstract class PlayerList { player.getBukkitEntity().packetProcessor.close(); // Folia - region threading player.getAdvancements().clearTriggers(); this.players.remove(player); @@ -527,7 +528,7 @@ index ed50484ca24ef24b1e5bef9f6369dfa4b30c359c..64a87785048e103c10f6453e97a37f85 this.playersByName.remove(player.getScoreboardName().toLowerCase(java.util.Locale.ROOT)); // Spigot if (me.earthme.luminol.config.modules.misc.UsernameCheckConfig.allowOldPlayersJoin) this.playedPlayers.remove(player.getGameProfile().name()); // Leaf - Configurable vanilla username check this.server.getCustomBossEvents().onPlayerDisconnect(player); -@@ -910,15 +1074,15 @@ public abstract class PlayerList { +@@ -910,15 +1075,15 @@ public abstract class PlayerList { } public String[] getPlayerNamesArray() { diff --git a/lophine-server/minecraft-patches/features/0126-Carpet-features.patch b/lophine-server/minecraft-patches/features/0126-Carpet-features.patch index 43a5584..22c63d1 100644 --- a/lophine-server/minecraft-patches/features/0126-Carpet-features.patch +++ b/lophine-server/minecraft-patches/features/0126-Carpet-features.patch @@ -268,10 +268,10 @@ index 77b9cd3d14eddc735d9131597916405fde4230ec..b23a47380fb1178696dc49e35d2c3d7d } else { LOGGER.warn("Player {} was dropping items too fast in creative mode, ignoring.", this.player.getPlainTextName()); diff --git a/net/minecraft/server/players/PlayerList.java b/net/minecraft/server/players/PlayerList.java -index 64a87785048e103c10f6453e97a37f8501255adc..432a6dfff8e45eccea653b0d4cf04956edec6d98 100644 +index 575b4eabcaac48ae87b69dd037493ebfe0a1212c..516561a25d28f2c7bcc3e71c5f2f9da99c2899c3 100644 --- a/net/minecraft/server/players/PlayerList.java +++ b/net/minecraft/server/players/PlayerList.java -@@ -279,7 +279,7 @@ public abstract class PlayerList { +@@ -280,7 +280,7 @@ public abstract class PlayerList { // org.leavesmc.leaves.protocol.core.LeavesProtocolManager.handlePlayerJoin(player); // Leaves - protocol // Leaves start - bot support @@ -280,7 +280,7 @@ index 64a87785048e103c10f6453e97a37f8501255adc..432a6dfff8e45eccea653b0d4cf04956 org.leavesmc.leaves.bot.ServerBot bot = this.server.getBotList().getBotByName(player.getScoreboardName()); if (bot != null) { this.server.getBotList().removeBot(bot, org.leavesmc.leaves.event.bot.BotRemoveEvent.RemoveReason.INTERNAL, player.getBukkitEntity(), false, false); -@@ -441,7 +441,7 @@ public abstract class PlayerList { +@@ -442,7 +442,7 @@ public abstract class PlayerList { org.leavesmc.leaves.protocol.core.LeavesProtocolManager.handlePlayerJoin(player); // Leaves - protocol // Leaves start - bot support @@ -289,7 +289,7 @@ index 64a87785048e103c10f6453e97a37f8501255adc..432a6dfff8e45eccea653b0d4cf04956 org.leavesmc.leaves.bot.ServerBot bot = this.server.getBotList().getBotByName(player.getScoreboardName()); if (bot != null) { this.server.getBotList().removeBot(bot, org.leavesmc.leaves.event.bot.BotRemoveEvent.RemoveReason.INTERNAL, player.getBukkitEntity(), false, false); -@@ -969,7 +969,7 @@ public abstract class PlayerList { +@@ -970,7 +970,7 @@ public abstract class PlayerList { ).callEvent(); // Paper end // Leaves start - bot support diff --git a/lophine-server/minecraft-patches/features/0130-Restore-vanilla-ender-pearl-loading.patch b/lophine-server/minecraft-patches/features/0130-Restore-vanilla-ender-pearl-loading.patch index cb07a1e..b5d2984 100644 --- a/lophine-server/minecraft-patches/features/0130-Restore-vanilla-ender-pearl-loading.patch +++ b/lophine-server/minecraft-patches/features/0130-Restore-vanilla-ender-pearl-loading.patch @@ -66,10 +66,10 @@ index cef9c7887332b91e2466a97a5250db81f7af0dcf..a17212c1910ce9490fe8df8c4ef507e2 public Set getEnderPearls() { diff --git a/net/minecraft/server/players/PlayerList.java b/net/minecraft/server/players/PlayerList.java -index 432a6dfff8e45eccea653b0d4cf04956edec6d98..835c13ff69592951261f917ad999d9a7689e802c 100644 +index 516561a25d28f2c7bcc3e71c5f2f9da99c2899c3..eb652157ef25e83b897f52aff3c49c09c6f656c8 100644 --- a/net/minecraft/server/players/PlayerList.java +++ b/net/minecraft/server/players/PlayerList.java -@@ -748,11 +748,13 @@ public abstract class PlayerList { +@@ -749,11 +749,13 @@ public abstract class PlayerList { player.unRide(); for (ThrownEnderpearl enderpearl : player.getEnderPearls()) { diff --git a/lophine-server/src/main/java/org/leavesmc/leaves/replay/Recorder.java b/lophine-server/src/main/java/org/leavesmc/leaves/replay/Recorder.java index b125a51..097cd17 100644 --- a/lophine-server/src/main/java/org/leavesmc/leaves/replay/Recorder.java +++ b/lophine-server/src/main/java/org/leavesmc/leaves/replay/Recorder.java @@ -41,6 +41,7 @@ import net.minecraft.network.protocol.game.*; import net.minecraft.network.protocol.login.ClientboundLoginFinishedPacket; import net.minecraft.server.MinecraftServer; import net.minecraft.server.RegistryLayer; +import net.minecraft.server.network.ServerGamePacketListenerImpl; import net.minecraft.server.packs.repository.KnownPack; import net.minecraft.tags.TagNetworkSerialization; import net.minecraft.world.entity.EntityTypes; @@ -94,6 +95,11 @@ public class Recorder extends Connection { this.channel = new LocalChannel(); } + public void bind(ServerGamePacketListenerImpl listener) { + this.packetListener = listener; + } + + public void start() { startTime = System.currentTimeMillis();