diff --git a/patches/server/Add-PlayerConnectionCloseEvent.patch b/patches/server/Add-PlayerConnectionCloseEvent.patch index 7ba913bc95..d474d2e1c1 100644 --- a/patches/server/Add-PlayerConnectionCloseEvent.patch +++ b/patches/server/Add-PlayerConnectionCloseEvent.patch @@ -43,14 +43,12 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 this.queue.clear(); // Free up packet queue. + // Paper start - Add PlayerConnectionCloseEvent + final PacketListener packetListener = this.getPacketListener(); -+ if (packetListener instanceof ServerGamePacketListenerImpl) { ++ if (packetListener instanceof net.minecraft.server.network.ServerGamePacketListenerImpl playerConnection) { + /* Player was logged in */ -+ final ServerGamePacketListenerImpl playerConnection = (ServerGamePacketListenerImpl) packetListener; + new com.destroystokyo.paper.event.player.PlayerConnectionCloseEvent(playerConnection.player.getUUID(), + playerConnection.player.getScoreboardName(), ((java.net.InetSocketAddress)address).getAddress(), false).callEvent(); -+ } else if (packetListener instanceof ServerLoginPacketListenerImpl) { ++ } else if (packetListener instanceof net.minecraft.server.network.ServerLoginPacketListenerImpl loginListener) { + /* Player is login stage */ -+ final ServerLoginPacketListenerImpl loginListener = (ServerLoginPacketListenerImpl) packetListener; + switch (loginListener.state) { + case READY_TO_ACCEPT: + case DELAY_ACCEPT: diff --git a/patches/server/Add-packet-limiter-config.patch b/patches/server/Add-packet-limiter-config.patch index adf4647038..b78aa8d090 100644 --- a/patches/server/Add-packet-limiter-config.patch +++ b/patches/server/Add-packet-limiter-config.patch @@ -40,9 +40,9 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + + private boolean stopReadingPackets; + private void killForPacketSpam() { -+ this.sendPacket(new ClientboundDisconnectPacket(io.papermc.paper.adventure.PaperAdventure.asVanilla(io.papermc.paper.configuration.GlobalConfiguration.get().packetLimiter.kickMessage)), (future) -> { ++ this.sendPacket(new ClientboundDisconnectPacket(io.papermc.paper.adventure.PaperAdventure.asVanilla(io.papermc.paper.configuration.GlobalConfiguration.get().packetLimiter.kickMessage)), PacketSendListener.thenRun(() -> { + this.disconnect(io.papermc.paper.adventure.PaperAdventure.asVanilla(io.papermc.paper.configuration.GlobalConfiguration.get().packetLimiter.kickMessage)); -+ }); ++ })); + this.setReadOnly(); + this.stopReadingPackets = true; + } diff --git a/patches/server/Allow-controlled-flushing-for-network-manager.patch b/patches/server/Allow-controlled-flushing-for-network-manager.patch index a9e2237c79..5f4cd480df 100644 --- a/patches/server/Allow-controlled-flushing-for-network-manager.patch +++ b/patches/server/Allow-controlled-flushing-for-network-manager.patch @@ -140,7 +140,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 } else { iterator.remove(); - this.sendPacket(packet, queued.listener); -+ this.writePacket(packet, queued.listener, (!iterator.hasNext() && (needsFlush || this.canFlush)) ? Boolean.TRUE : Boolean.FALSE); // Paper - make only one flush call per sendPacketQueue() call ++ this.sendPacket(packet, queued.listener, (!iterator.hasNext() && (needsFlush || this.canFlush)) ? Boolean.TRUE : Boolean.FALSE); // Paper - make only one flush call per sendPacketQueue() call + hasWrotePacket = true; // Paper - make only one flush call per sendPacketQueue() call } } diff --git a/patches/server/Buffer-joins-to-world.patch b/patches/server/Buffer-joins-to-world.patch index 1342669ea7..7589335ec3 100644 --- a/patches/server/Buffer-joins-to-world.patch +++ b/patches/server/Buffer-joins-to-world.patch @@ -26,10 +26,10 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + joinAttemptsThisTick = 0; + } + // Paper end -+ if (this.packetListener instanceof ServerLoginPacketListenerImpl) { -+ if ( ((ServerLoginPacketListenerImpl) this.packetListener).state != ServerLoginPacketListenerImpl.State.READY_TO_ACCEPT // Paper ++ if (this.packetListener instanceof net.minecraft.server.network.ServerLoginPacketListenerImpl serverLoginPacketListener) { ++ if ( serverLoginPacketListener.state != net.minecraft.server.network.ServerLoginPacketListenerImpl.State.READY_TO_ACCEPT // Paper + || (joinAttemptsThisTick++ < MAX_PER_TICK)) { // Paper - limit the number of joins which can be processed each tick -+ ((ServerLoginPacketListenerImpl) this.packetListener).tick(); ++ serverLoginPacketListener.tick(); + } // Paper + } PacketListener packetlistener = this.packetListener; diff --git a/patches/server/Don-t-allow-null-UUID-s-for-chat.patch b/patches/server/Don-t-allow-null-UUID-s-for-chat.patch index d90a6c3682..0e5c96bbb3 100644 --- a/patches/server/Don-t-allow-null-UUID-s-for-chat.patch +++ b/patches/server/Don-t-allow-null-UUID-s-for-chat.patch @@ -14,7 +14,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + // Paper start + public ChatSender { -+ com.google.common.base.Preconditions.checkNotNull(uuid, "uuid cannot be null"); ++ com.google.common.base.Preconditions.checkNotNull(profileId, "uuid cannot be null"); + } + // Paper end + diff --git a/patches/server/Optimize-Network-Manager-and-add-advanced-packet-sup.patch b/patches/server/Optimize-Network-Manager-and-add-advanced-packet-sup.patch index 46615764b0..b777030b12 100644 --- a/patches/server/Optimize-Network-Manager-and-add-advanced-packet-sup.patch +++ b/patches/server/Optimize-Network-Manager-and-add-advanced-packet-sup.patch @@ -55,9 +55,9 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 this.packetListener = listener; } + // Paper start -+ public net.minecraft.server.level.ServerPlayer getPlayer() { -+ if (packetListener instanceof ServerGamePacketListenerImpl) { -+ return ((ServerGamePacketListenerImpl) packetListener).player; ++ public @Nullable net.minecraft.server.level.ServerPlayer getPlayer() { ++ if (packetListener instanceof net.minecraft.server.network.ServerGamePacketListenerImpl serverGamePacketListener) { ++ return serverGamePacketListener.player; + } else { + return null; + } @@ -127,7 +127,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + java.util.List extraPackets = InnerUtil.buildExtraPackets(packet); + boolean hasExtraPackets = extraPackets != null && !extraPackets.isEmpty(); + if (!hasExtraPackets) { -+ this.queue.add(new Connection.PacketHolder(packet, callback)); ++ this.queue.add(new Connection.PacketHolder(packet, packetsendlistener)); + } else { + java.util.List packets = new java.util.ArrayList<>(1 + extraPackets.size()); + packets.add(new Connection.PacketHolder(packet, null)); // delay the future listener until the end of the extra packets @@ -135,7 +135,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + for (int i = 0, len = extraPackets.size(); i < len;) { + Packet extra = extraPackets.get(i); + boolean end = ++i == len; -+ packets.add(new Connection.PacketHolder(extra, end ? callback : null)); // append listener to the end ++ packets.add(new Connection.PacketHolder(extra, end ? packetsendlistener : null)); // append listener to the end + } + this.queue.addAll(packets); // atomic + } @@ -275,7 +275,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + clearPacketQueue(); // Paper // Paper start - Add PlayerConnectionCloseEvent final PacketListener packetListener = this.getPacketListener(); - if (packetListener instanceof ServerGamePacketListenerImpl) { + if (packetListener instanceof net.minecraft.server.network.ServerGamePacketListenerImpl playerConnection) { diff --git a/src/main/java/net/minecraft/network/protocol/Packet.java b/src/main/java/net/minecraft/network/protocol/Packet.java index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/net/minecraft/network/protocol/Packet.java