some compile fixes

Dieser Commit ist enthalten in:
Jake Potrebic 2022-07-27 15:00:14 -07:00
Ursprung c8f3d9ee8c
Commit 64cb313386
Es konnte kein GPG-Schlüssel zu dieser Signatur gefunden werden
GPG-Schlüssel-ID: ECE0B3C133C016C5
7 geänderte Dateien mit 24 neuen und 26 gelöschten Zeilen

Datei anzeigen

@ -34,23 +34,21 @@ how PlayerPreLoginEvent interacts with PlayerConnectionCloseEvent
is undefined. is undefined.
diff --git a/src/main/java/net/minecraft/network/Connection.java b/src/main/java/net/minecraft/network/Connection.java diff --git a/src/main/java/net/minecraft/network/Connection.java b/src/main/java/net/minecraft/network/Connection.java
index 83c5264e4af146d3712cee4550d84c824a3a96d6..5ec25b729d1e7fce232ecdc723b8286c4eaf182c 100644 index 83c5264e4af146d3712cee4550d84c824a3a96d6..66274a749af1e77363190fda99b5999efac40bdb 100644
--- a/src/main/java/net/minecraft/network/Connection.java --- a/src/main/java/net/minecraft/network/Connection.java
+++ b/src/main/java/net/minecraft/network/Connection.java +++ b/src/main/java/net/minecraft/network/Connection.java
@@ -439,6 +439,26 @@ public class Connection extends SimpleChannelInboundHandler<Packet<?>> { @@ -439,6 +439,24 @@ public class Connection extends SimpleChannelInboundHandler<Packet<?>> {
this.getPacketListener().onDisconnect(Component.translatable("multiplayer.disconnect.generic")); this.getPacketListener().onDisconnect(Component.translatable("multiplayer.disconnect.generic"));
} }
this.queue.clear(); // Free up packet queue. this.queue.clear(); // Free up packet queue.
+ // Paper start - Add PlayerConnectionCloseEvent + // Paper start - Add PlayerConnectionCloseEvent
+ final PacketListener packetListener = this.getPacketListener(); + final PacketListener packetListener = this.getPacketListener();
+ if (packetListener instanceof ServerGamePacketListenerImpl) { + if (packetListener instanceof net.minecraft.server.network.ServerGamePacketListenerImpl playerConnection) {
+ /* Player was logged in */ + /* Player was logged in */
+ final ServerGamePacketListenerImpl playerConnection = (ServerGamePacketListenerImpl) packetListener;
+ new com.destroystokyo.paper.event.player.PlayerConnectionCloseEvent(playerConnection.player.getUUID(), + new com.destroystokyo.paper.event.player.PlayerConnectionCloseEvent(playerConnection.player.getUUID(),
+ playerConnection.player.getScoreboardName(), ((java.net.InetSocketAddress)address).getAddress(), false).callEvent(); + 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 */ + /* Player is login stage */
+ final ServerLoginPacketListenerImpl loginListener = (ServerLoginPacketListenerImpl) packetListener;
+ switch (loginListener.state) { + switch (loginListener.state) {
+ case READY_TO_ACCEPT: + case READY_TO_ACCEPT:
+ case DELAY_ACCEPT: + case DELAY_ACCEPT:

Datei anzeigen

@ -28,7 +28,7 @@ and then catch exceptions and close if they fire.
Part of this commit was authored by: Spottedleaf Part of this commit was authored by: Spottedleaf
diff --git a/src/main/java/net/minecraft/network/Connection.java b/src/main/java/net/minecraft/network/Connection.java diff --git a/src/main/java/net/minecraft/network/Connection.java b/src/main/java/net/minecraft/network/Connection.java
index 5ec25b729d1e7fce232ecdc723b8286c4eaf182c..a18e2146c4398b45ae50623fc6800a78718f4c81 100644 index 66274a749af1e77363190fda99b5999efac40bdb..26849a8af6149b710df8a7e0a335d98df2e2a4d2 100644
--- a/src/main/java/net/minecraft/network/Connection.java --- a/src/main/java/net/minecraft/network/Connection.java
+++ b/src/main/java/net/minecraft/network/Connection.java +++ b/src/main/java/net/minecraft/network/Connection.java
@@ -93,6 +93,10 @@ public class Connection extends SimpleChannelInboundHandler<Packet<?>> { @@ -93,6 +93,10 @@ public class Connection extends SimpleChannelInboundHandler<Packet<?>> {
@ -55,9 +55,9 @@ index 5ec25b729d1e7fce232ecdc723b8286c4eaf182c..a18e2146c4398b45ae50623fc6800a78
this.packetListener = listener; this.packetListener = listener;
} }
+ // Paper start + // Paper start
+ public net.minecraft.server.level.ServerPlayer getPlayer() { + public @Nullable net.minecraft.server.level.ServerPlayer getPlayer() {
+ if (packetListener instanceof ServerGamePacketListenerImpl) { + if (packetListener instanceof net.minecraft.server.network.ServerGamePacketListenerImpl serverGamePacketListener) {
+ return ((ServerGamePacketListenerImpl) packetListener).player; + return serverGamePacketListener.player;
+ } else { + } else {
+ return null; + return null;
+ } + }
@ -127,7 +127,7 @@ index 5ec25b729d1e7fce232ecdc723b8286c4eaf182c..a18e2146c4398b45ae50623fc6800a78
+ java.util.List<Packet> extraPackets = InnerUtil.buildExtraPackets(packet); + java.util.List<Packet> extraPackets = InnerUtil.buildExtraPackets(packet);
+ boolean hasExtraPackets = extraPackets != null && !extraPackets.isEmpty(); + boolean hasExtraPackets = extraPackets != null && !extraPackets.isEmpty();
+ if (!hasExtraPackets) { + if (!hasExtraPackets) {
+ this.queue.add(new Connection.PacketHolder(packet, callback)); + this.queue.add(new Connection.PacketHolder(packet, packetsendlistener));
+ } else { + } else {
+ java.util.List<Connection.PacketHolder> packets = new java.util.ArrayList<>(1 + extraPackets.size()); + java.util.List<Connection.PacketHolder> 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 + packets.add(new Connection.PacketHolder(packet, null)); // delay the future listener until the end of the extra packets
@ -135,7 +135,7 @@ index 5ec25b729d1e7fce232ecdc723b8286c4eaf182c..a18e2146c4398b45ae50623fc6800a78
+ for (int i = 0, len = extraPackets.size(); i < len;) { + for (int i = 0, len = extraPackets.size(); i < len;) {
+ Packet extra = extraPackets.get(i); + Packet extra = extraPackets.get(i);
+ boolean end = ++i == len; + 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 + this.queue.addAll(packets); // atomic
+ } + }
@ -275,7 +275,7 @@ index 5ec25b729d1e7fce232ecdc723b8286c4eaf182c..a18e2146c4398b45ae50623fc6800a78
+ clearPacketQueue(); // Paper + clearPacketQueue(); // Paper
// Paper start - Add PlayerConnectionCloseEvent // Paper start - Add PlayerConnectionCloseEvent
final PacketListener packetListener = this.getPacketListener(); 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 diff --git a/src/main/java/net/minecraft/network/protocol/Packet.java b/src/main/java/net/minecraft/network/protocol/Packet.java
index 74bfe0d3942259c45702b099efdc4e101a4e3022..e8fcd56906d26f6dc87959e32c4c7c78cfea9658 100644 index 74bfe0d3942259c45702b099efdc4e101a4e3022..e8fcd56906d26f6dc87959e32c4c7c78cfea9658 100644
--- a/src/main/java/net/minecraft/network/protocol/Packet.java --- a/src/main/java/net/minecraft/network/protocol/Packet.java

Datei anzeigen

@ -5,7 +5,7 @@ Subject: [PATCH] Don't allow null UUID's for chat
diff --git a/src/main/java/net/minecraft/network/chat/ChatSender.java b/src/main/java/net/minecraft/network/chat/ChatSender.java diff --git a/src/main/java/net/minecraft/network/chat/ChatSender.java b/src/main/java/net/minecraft/network/chat/ChatSender.java
index eb33c74d51f9b096ac39adf167fa09afdaa5e56b..64b7ef689743b12723a6b0319948d6ad6152f448 100644 index eb33c74d51f9b096ac39adf167fa09afdaa5e56b..d3d5487e9a4e95271a88c094058ec9d37a10d370 100644
--- a/src/main/java/net/minecraft/network/chat/ChatSender.java --- a/src/main/java/net/minecraft/network/chat/ChatSender.java
+++ b/src/main/java/net/minecraft/network/chat/ChatSender.java +++ b/src/main/java/net/minecraft/network/chat/ChatSender.java
@@ -8,6 +8,12 @@ import net.minecraft.world.entity.player.ProfilePublicKey; @@ -8,6 +8,12 @@ import net.minecraft.world.entity.player.ProfilePublicKey;
@ -14,7 +14,7 @@ index eb33c74d51f9b096ac39adf167fa09afdaa5e56b..64b7ef689743b12723a6b0319948d6ad
+ // Paper start + // Paper start
+ public ChatSender { + 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 + // Paper end
+ +

Datei anzeigen

@ -8,7 +8,7 @@ the world per tick, this attempts to reduce the impact that join floods
has on the server has on the server
diff --git a/src/main/java/net/minecraft/network/Connection.java b/src/main/java/net/minecraft/network/Connection.java diff --git a/src/main/java/net/minecraft/network/Connection.java b/src/main/java/net/minecraft/network/Connection.java
index c06cb0f0e300c4d00b3aeed12772c38e8379cb0c..eb18253d4ae0618884c9061f8dda689119e10ef0 100644 index 8440b3d6f9811fa16b10843ada91248e0722acc4..2ed32f8c503b7196abfaa1c1e2456fbd4760eac3 100644
--- a/src/main/java/net/minecraft/network/Connection.java --- a/src/main/java/net/minecraft/network/Connection.java
+++ b/src/main/java/net/minecraft/network/Connection.java +++ b/src/main/java/net/minecraft/network/Connection.java
@@ -396,8 +396,23 @@ public class Connection extends SimpleChannelInboundHandler<Packet<?>> { @@ -396,8 +396,23 @@ public class Connection extends SimpleChannelInboundHandler<Packet<?>> {
@ -26,10 +26,10 @@ index c06cb0f0e300c4d00b3aeed12772c38e8379cb0c..eb18253d4ae0618884c9061f8dda6891
+ joinAttemptsThisTick = 0; + joinAttemptsThisTick = 0;
+ } + }
+ // Paper end + // Paper end
+ if (this.packetListener instanceof ServerLoginPacketListenerImpl) { + if (this.packetListener instanceof net.minecraft.server.network.ServerLoginPacketListenerImpl serverLoginPacketListener) {
+ if ( ((ServerLoginPacketListenerImpl) this.packetListener).state != ServerLoginPacketListenerImpl.State.READY_TO_ACCEPT // Paper + 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 + || (joinAttemptsThisTick++ < MAX_PER_TICK)) { // Paper - limit the number of joins which can be processed each tick
+ ((ServerLoginPacketListenerImpl) this.packetListener).tick(); + serverLoginPacketListener.tick();
+ } // Paper + } // Paper
+ } + }
PacketListener packetlistener = this.packetListener; PacketListener packetlistener = this.packetListener;

Datei anzeigen

@ -11,10 +11,10 @@ Tested-by: Mariell Hoversholm <proximyst@proximyst.com>
Reviewed-by: Mariell Hoversholm <proximyst@proximyst.com> Reviewed-by: Mariell Hoversholm <proximyst@proximyst.com>
diff --git a/src/main/java/net/minecraft/network/Connection.java b/src/main/java/net/minecraft/network/Connection.java diff --git a/src/main/java/net/minecraft/network/Connection.java b/src/main/java/net/minecraft/network/Connection.java
index 023c564248adb2c5c4b679be9075ca88cb2d5b62..ca6b12b61874913f6d4abac97a3df67d0053cd8f 100644 index 9c80b1048f7c855c43dc114ffcd94b6f9df74661..25d26ba482edac4158ba247e105d8c5fac0729e4 100644
--- a/src/main/java/net/minecraft/network/Connection.java --- a/src/main/java/net/minecraft/network/Connection.java
+++ b/src/main/java/net/minecraft/network/Connection.java +++ b/src/main/java/net/minecraft/network/Connection.java
@@ -641,6 +641,11 @@ public class Connection extends SimpleChannelInboundHandler<Packet<?>> { @@ -639,6 +639,11 @@ public class Connection extends SimpleChannelInboundHandler<Packet<?>> {
// Spigot Start // Spigot Start
public SocketAddress getRawAddress() public SocketAddress getRawAddress()
{ {

Datei anzeigen

@ -9,7 +9,7 @@ This patch will be used to optimise out flush calls in later
patches. patches.
diff --git a/src/main/java/net/minecraft/network/Connection.java b/src/main/java/net/minecraft/network/Connection.java diff --git a/src/main/java/net/minecraft/network/Connection.java b/src/main/java/net/minecraft/network/Connection.java
index ca6b12b61874913f6d4abac97a3df67d0053cd8f..2195024a7b2626f4e6844db56071130226cf1364 100644 index 25d26ba482edac4158ba247e105d8c5fac0729e4..b8e127f19c38d51baaa1a2c47a0d2eab62d71e90 100644
--- a/src/main/java/net/minecraft/network/Connection.java --- a/src/main/java/net/minecraft/network/Connection.java
+++ b/src/main/java/net/minecraft/network/Connection.java +++ b/src/main/java/net/minecraft/network/Connection.java
@@ -99,6 +99,39 @@ public class Connection extends SimpleChannelInboundHandler<Packet<?>> { @@ -99,6 +99,39 @@ public class Connection extends SimpleChannelInboundHandler<Packet<?>> {
@ -140,7 +140,7 @@ index ca6b12b61874913f6d4abac97a3df67d0053cd8f..2195024a7b2626f4e6844db560711302
} else { } else {
iterator.remove(); iterator.remove();
- this.sendPacket(packet, queued.listener); - 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 + hasWrotePacket = true; // Paper - make only one flush call per sendPacketQueue() call
} }
} }

Datei anzeigen

@ -24,7 +24,7 @@ and an action can be defined: DROP or KICK
If interval or rate are less-than 0, the limit is ignored If interval or rate are less-than 0, the limit is ignored
diff --git a/src/main/java/net/minecraft/network/Connection.java b/src/main/java/net/minecraft/network/Connection.java diff --git a/src/main/java/net/minecraft/network/Connection.java b/src/main/java/net/minecraft/network/Connection.java
index 92b36499c7b655b1b7d866fe116486962aef1803..80cc3b62af324512f695e971cce2b01f6eadbdbf 100644 index 30f8053547ebbe05549ede851835a707793f8e45..e5b7145efddefb8bf756c3b0f115c92306830ae4 100644
--- a/src/main/java/net/minecraft/network/Connection.java --- a/src/main/java/net/minecraft/network/Connection.java
+++ b/src/main/java/net/minecraft/network/Connection.java +++ b/src/main/java/net/minecraft/network/Connection.java
@@ -131,6 +131,22 @@ public class Connection extends SimpleChannelInboundHandler<Packet<?>> { @@ -131,6 +131,22 @@ public class Connection extends SimpleChannelInboundHandler<Packet<?>> {
@ -40,9 +40,9 @@ index 92b36499c7b655b1b7d866fe116486962aef1803..80cc3b62af324512f695e971cce2b01f
+ +
+ private boolean stopReadingPackets; + private boolean stopReadingPackets;
+ private void killForPacketSpam() { + 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.disconnect(io.papermc.paper.adventure.PaperAdventure.asVanilla(io.papermc.paper.configuration.GlobalConfiguration.get().packetLimiter.kickMessage));
+ }); + }));
+ this.setReadOnly(); + this.setReadOnly();
+ this.stopReadingPackets = true; + this.stopReadingPackets = true;
+ } + }