Always call plugin message dispatch on PlayerConnection

This commit is contained in:
Nassim Jahnke
2025-07-01 21:09:44 +02:00
parent 6ea679eb07
commit c3be00f0ec
4 changed files with 20 additions and 11 deletions

View File

@@ -100,7 +100,7 @@ index 962084054c0208470d0c3c99c5dca6327c9b8752..2abc21102bbd2da79dc0c50826cff7da
} }
} }
diff --git a/net/minecraft/server/network/ServerCommonPacketListenerImpl.java b/net/minecraft/server/network/ServerCommonPacketListenerImpl.java diff --git a/net/minecraft/server/network/ServerCommonPacketListenerImpl.java b/net/minecraft/server/network/ServerCommonPacketListenerImpl.java
index ab2bcd5b547c8db418de7ea0b7f144058aa8b0f4..1ae3724eec5fac852c6cc6bb88b1ecb9f0b790f0 100644 index b2b5fe493f71d7300e5009ae0307dbfd8da99991..27b8ce14ad51566155e457279ec3db1c4b755da7 100644
--- a/net/minecraft/server/network/ServerCommonPacketListenerImpl.java --- a/net/minecraft/server/network/ServerCommonPacketListenerImpl.java
+++ b/net/minecraft/server/network/ServerCommonPacketListenerImpl.java +++ b/net/minecraft/server/network/ServerCommonPacketListenerImpl.java
@@ -38,12 +38,13 @@ public abstract class ServerCommonPacketListenerImpl implements ServerCommonPack @@ -38,12 +38,13 @@ public abstract class ServerCommonPacketListenerImpl implements ServerCommonPack
@@ -185,7 +185,7 @@ index ab2bcd5b547c8db418de7ea0b7f144058aa8b0f4..1ae3724eec5fac852c6cc6bb88b1ecb9
} }
@Override @Override
@@ -225,20 +255,23 @@ public abstract class ServerCommonPacketListenerImpl implements ServerCommonPack @@ -224,20 +254,23 @@ public abstract class ServerCommonPacketListenerImpl implements ServerCommonPack
protected void keepConnectionAlive() { protected void keepConnectionAlive() {
Profiler.get().push("keepAlive"); Profiler.get().push("keepAlive");
long millis = Util.getMillis(); long millis = Util.getMillis();
@@ -223,7 +223,7 @@ index ab2bcd5b547c8db418de7ea0b7f144058aa8b0f4..1ae3724eec5fac852c6cc6bb88b1ecb9
} }
} }
@@ -418,6 +451,6 @@ public abstract class ServerCommonPacketListenerImpl implements ServerCommonPack @@ -417,6 +450,6 @@ public abstract class ServerCommonPacketListenerImpl implements ServerCommonPack
} }
protected CommonListenerCookie createCookie(ClientInformation clientInformation) { protected CommonListenerCookie createCookie(ClientInformation clientInformation) {

View File

@@ -48,7 +48,7 @@
} }
} }
@@ -90,8 +_,81 @@ @@ -90,8 +_,80 @@
public void handlePong(ServerboundPongPacket packet) { public void handlePong(ServerboundPongPacket packet) {
} }
@@ -93,10 +93,9 @@
+ } + }
+ +
+ +
+ this.cserver.getMessenger().dispatchIncomingMessage(paperConnection(), identifier.toString(), data);
+ if (this instanceof ServerGamePacketListenerImpl gamePacketListener) { + if (this instanceof ServerGamePacketListenerImpl gamePacketListener) {
+ this.cserver.getMessenger().dispatchIncomingMessage(gamePacketListener.player.getBukkitEntity(), identifier.toString(), data); + this.cserver.getMessenger().dispatchIncomingMessage(gamePacketListener.player.getBukkitEntity(), identifier.toString(), data);
+ } else if (this instanceof ServerConfigurationPacketListenerImpl configurationPacketListener) {
+ this.cserver.getMessenger().dispatchIncomingMessage(configurationPacketListener.paperConnection, identifier.toString(), data);
+ } + }
+ } catch (final Exception e) { + } catch (final Exception e) {
+ ServerGamePacketListenerImpl.LOGGER.error("Couldn't handle custom payload on channel {}", identifier, e); + ServerGamePacketListenerImpl.LOGGER.error("Couldn't handle custom payload on channel {}", identifier, e);
@@ -161,7 +160,7 @@
@Override @Override
public void handleCookieResponse(ServerboundCookieResponsePacket packet) { public void handleCookieResponse(ServerboundCookieResponsePacket packet) {
- this.disconnect(DISCONNECT_UNEXPECTED_QUERY); - this.disconnect(DISCONNECT_UNEXPECTED_QUERY);
+ if (this.getCookieConnection().handleCookieResponse(packet)) return; // Paper + if (this.paperConnection().handleCookieResponse(packet)) return; // Paper
+ this.disconnect(DISCONNECT_UNEXPECTED_QUERY, io.papermc.paper.connection.DisconnectionReason.INVALID_COOKIE); // Paper - kick event cause + this.disconnect(DISCONNECT_UNEXPECTED_QUERY, io.papermc.paper.connection.DisconnectionReason.INVALID_COOKIE); // Paper - kick event cause
} }
@@ -317,11 +316,11 @@
+ +
+ public abstract void disconnectAsync(DisconnectionDetails disconnectionInfo); + public abstract void disconnectAsync(DisconnectionDetails disconnectionInfo);
+ +
+ public abstract io.papermc.paper.connection.ReadablePlayerCookieConnectionImpl getCookieConnection();
+
+ public boolean isTransferred() { + public boolean isTransferred() {
+ return this.transferred; + return this.transferred;
+ } + }
+
+ public abstract io.papermc.paper.connection.PaperCommonConnection<?> paperConnection();
+ // Paper end - add proper async disconnect + // Paper end - add proper async disconnect
protected boolean isSingleplayerOwner() { protected boolean isSingleplayerOwner() {

View File

@@ -99,7 +99,7 @@
this.connection.send(new ClientboundDisconnectPacket(DISCONNECT_REASON_INVALID_DATA)); this.connection.send(new ClientboundDisconnectPacket(DISCONNECT_REASON_INVALID_DATA));
this.connection.disconnect(DISCONNECT_REASON_INVALID_DATA); this.connection.disconnect(DISCONNECT_REASON_INVALID_DATA);
} }
@@ -180,4 +_,29 @@ @@ -180,4 +_,35 @@
this.startNextTask(); this.startNextTask();
} }
} }
@@ -127,5 +127,11 @@
+ public void handleCustomPayload(net.minecraft.network.protocol.common.ServerboundCustomPayloadPacket packet) { + public void handleCustomPayload(net.minecraft.network.protocol.common.ServerboundCustomPayloadPacket packet) {
+ super.handleCustomPayload(packet); + super.handleCustomPayload(packet);
+ } + }
+
+ @Override
+ public io.papermc.paper.connection.PaperPlayerConfigurationConnection paperConnection() {
+ return paperConnection;
+ }
+
+ // Paper end + // Paper end
} }

View File

@@ -2610,7 +2610,7 @@
if (!this.receivedMovementThisTick) { if (!this.receivedMovementThisTick) {
this.player.setKnownMovement(Vec3.ZERO); this.player.setKnownMovement(Vec3.ZERO);
} }
@@ -2078,4 +_,93 @@ @@ -2078,4 +_,97 @@
interface EntityInteraction { interface EntityInteraction {
InteractionResult run(ServerPlayer player, Entity entity, InteractionHand hand); InteractionResult run(ServerPlayer player, Entity entity, InteractionHand hand);
} }
@@ -2702,5 +2702,9 @@
+ return this.playerGameConnection; + return this.playerGameConnection;
+ } + }
+ +
+ @Override
+ public io.papermc.paper.connection.PaperPlayerGameConnection paperConnection() {
+ return this.playerGameConnection;
+ }
+ // Paper end + // Paper end
} }