This commit is contained in:
Jake Potrebic 2022-08-05 15:58:34 -07:00
parent 522db24de0
commit 2782b0c375
20 changed files with 108 additions and 124 deletions

View file

@ -38,7 +38,7 @@ How To (Plugin Developers)
<dependency>
<groupId>io.papermc.paper</groupId>
<artifactId>paper-api</artifactId>
<version>1.19.1-R0.1-SNAPSHOT</version>
<version>1.19.2-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
```
@ -54,7 +54,7 @@ repositories {
}
dependencies {
compileOnly("io.papermc.paper:paper-api:1.19.1-R0.1-SNAPSHOT")
compileOnly("io.papermc.paper:paper-api:1.19.2-R0.1-SNAPSHOT")
}
java {

View file

@ -61,7 +61,7 @@ repositories {
}
dependencies {
paramMappings("net.fabricmc:yarn:1.19.1+build.1:mergedv2")
paramMappings("net.fabricmc:yarn:1.19.2+build.1:mergedv2")
remapper("net.fabricmc:tiny-remapper:0.8.2:fat")
decompiler("net.minecraftforge:forgeflower:1.5.605.7")
spigotDecompiler("io.papermc:patched-spigot-fernflower:0.1+build.6")

View file

@ -1,6 +1,6 @@
group=io.papermc.paper
version=1.19.1-R0.1-SNAPSHOT
mcVersion=1.19.1
version=1.19.2-R0.1-SNAPSHOT
mcVersion=1.19.2
org.gradle.caching=true
org.gradle.parallel=true

View file

@ -125,7 +125,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
-
- <groupId>org.spigotmc</groupId>
- <artifactId>spigot-api</artifactId>
- <version>1.19.1-R0.1-SNAPSHOT</version>
- <version>1.19.2-R0.1-SNAPSHOT</version>
- <packaging>jar</packaging>
-
- <name>Spigot-API</name>

View file

@ -259,7 +259,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
if (this.tryHandleChat(packet.command(), packet.timeStamp(), packet.lastSeenMessages())) {
this.server.submit(() -> {
@@ -0,0 +0,0 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Tic
// Paper end
private boolean tryHandleChat(String message, Instant timestamp, LastSeenMessages.Update acknowledgment) {
if (!this.updateChatOrder(timestamp)) {
ServerGamePacketListenerImpl.LOGGER.warn("{} sent out-of-order chat: '{}'", this.player.getName().getString(), message);
- this.disconnect(Component.translatable("multiplayer.disconnect.out_of_order_chat"));
@ -268,14 +268,14 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
} else if (this.player.isRemoved() || this.player.getChatVisibility() == ChatVisiblity.HIDDEN) { // CraftBukkit - dead men tell no tales
this.send(new ClientboundSystemChatPacket(Component.translatable("chat.disabled.options").withStyle(ChatFormatting.RED), false));
@@ -0,0 +0,0 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Tic
ChatSender chatsender = this.player.asChatSender();
}
if (chatsender.profilePublicKey() != null && !message.verify(chatsender)) {
if (!playerchatmessage.verify(chatsender)) {
- this.disconnect(Component.translatable("multiplayer.disconnect.unsigned_chat"));
+ this.disconnect(Component.translatable("multiplayer.disconnect.unsigned_chat"), org.bukkit.event.player.PlayerKickEvent.Cause.UNSIGNED_CHAT); // Paper - kick event cause
return false;
} else {
if (message.hasExpiredServer(Instant.now())) {
}
}
@@ -0,0 +0,0 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Tic
// this.chatSpamTickCount += 20;
if (this.chatSpamTickCount.addAndGet(20) > 200 && !this.server.getPlayerList().isOp(this.player.getGameProfile())) {

View file

@ -166,9 +166,9 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ final ProfilePublicKey.Data forwardedKey = com.destroystokyo.paper.proxy.VelocityProxy.readForwardedKey(buf);
+ if (this.profilePublicKeyData == null) {
+ try {
+ ProfilePublicKey.createValidated(this.server.getServiceSignatureValidator(), this.gameProfile.getId(), forwardedKey);
+ ProfilePublicKey.createValidated(this.server.getServiceSignatureValidator(), this.gameProfile.getId(), forwardedKey, Duration.ZERO);
+ this.profilePublicKeyData = forwardedKey;
+ } catch (CryptException e) {
+ } catch (ProfilePublicKey.ValidationException e) {
+ this.disconnect("Unable to validate forwarded player key");
+ }
+ }

View file

@ -10,8 +10,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
--- a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
+++ b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
@@ -0,0 +0,0 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Tic
}
// Paper end
private boolean tryHandleChat(String message, Instant timestamp, LastSeenMessages.Update acknowledgment) {
if (!this.updateChatOrder(timestamp)) {
- ServerGamePacketListenerImpl.LOGGER.warn("{} sent out-of-order chat: '{}'", this.player.getName().getString(), message);
+ ServerGamePacketListenerImpl.LOGGER.warn("{} sent out-of-order chat: '{}': {} > {}", this.player.getName().getString(), message, this.lastChatTimeStamp.get().getEpochSecond(), timestamp.getEpochSecond()); // Paper
@ -19,11 +19,11 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
this.disconnect(Component.translatable("multiplayer.disconnect.out_of_order_chat"), org.bukkit.event.player.PlayerKickEvent.Cause.OUT_OF_ORDER_CHAT); // Paper - kick event cause
}); // Paper - push to main
@@ -0,0 +0,0 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Tic
return false;
} else {
if (message.hasExpiredServer(Instant.now())) {
- ServerGamePacketListenerImpl.LOGGER.warn("{} sent expired chat: '{}'. Is the client/server system time unsynchronized?", this.player.getName().getString(), message.signedContent().plain());
+ ServerGamePacketListenerImpl.LOGGER.warn("{} sent expired chat: '{}'. Is the client/server system time unsynchronized? c: {} s: {}", this.player.getName().getString(), message.signedContent().plain(), message.timeStamp().getEpochSecond(), Instant.now().getEpochSecond()); // Paper
}
if (playerchatmessage.hasExpiredServer(Instant.now())) {
- ServerGamePacketListenerImpl.LOGGER.warn("{} sent expired chat: '{}'. Is the client/server system time unsynchronized?", this.player.getName().getString(), playerchatmessage.signedContent().plain());
+ ServerGamePacketListenerImpl.LOGGER.warn("{} sent expired chat: '{}'. Is the client/server system time unsynchronized? c: {} s: {}", this.player.getName().getString(), playerchatmessage.signedContent().plain(), playerchatmessage.timeStamp().getEpochSecond(), Instant.now().getEpochSecond()); // Paper
}
return true;

View file

@ -1510,6 +1510,12 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ @io.papermc.paper.annotation.DoNotUse // Paper
CompletableFuture<Component> decorate(@Nullable ServerPlayer sender, Component message);
+ @io.papermc.paper.annotation.DoNotUse // Paper
default CompletableFuture<PlayerChatMessage> decorate(@Nullable ServerPlayer sender, PlayerChatMessage message) {
- return message.signedContent().isDecorated() ? CompletableFuture.completedFuture(message) : this.decorate(sender, message.serverContent()).thenApply(message::withUnsignedContent);
+ return this.decorate(sender, null, message); // Paper
}
+ // Paper start
+ default CompletableFuture<Result> decorate(@Nullable ServerPlayer sender, @Nullable net.minecraft.commands.CommandSourceStack commandSourceStack, Component message, boolean isPreview) {
+ throw new UnsupportedOperationException("Must override this implementation");
@ -1576,16 +1582,11 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ return new PlayerChatMessage(playerChatMessage.signedHeader(), playerChatMessage.headerSignature(), playerChatMessage.signedBody().withContent(playerChatMessage.signedContent().withDecorationResult(result)), playerChatMessage.unsignedContent(), playerChatMessage.filterMask()).withUnsignedContent(result.component());
+ });
+ }
+
+ // Paper end
+
+ @io.papermc.paper.annotation.DoNotUse // Paper
default CompletableFuture<PlayerChatMessage> decorate(@Nullable ServerPlayer serverPlayer, PlayerChatMessage playerChatMessage) {
- return playerChatMessage.signedContent().isDecorated() ? CompletableFuture.completedFuture(playerChatMessage) : this.decorate(serverPlayer, playerChatMessage.serverContent()).thenApply(playerChatMessage::withUnsignedContent);
+ return this.decorate(serverPlayer, null, playerChatMessage); // Paper
static PlayerChatMessage attachIfNotDecorated(PlayerChatMessage message, Component attached) {
return !message.signedContent().isDecorated() ? message.withUnsignedContent(attached) : message;
}
static PlayerChatMessage attachIfNotDecorated(PlayerChatMessage playerChatMessage, Component component) {
diff --git a/src/main/java/net/minecraft/network/chat/ChatMessageContent.java b/src/main/java/net/minecraft/network/chat/ChatMessageContent.java
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
--- a/src/main/java/net/minecraft/network/chat/ChatMessageContent.java
@ -1694,49 +1695,50 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
--- a/src/main/java/net/minecraft/network/chat/OutgoingPlayerChatMessage.java
+++ b/src/main/java/net/minecraft/network/chat/OutgoingPlayerChatMessage.java
@@ -0,0 +0,0 @@ public interface OutgoingPlayerChatMessage {
Component serverContent();
void sendToPlayer(ServerPlayer serverPlayer, boolean bl, ChatType.Bound bound);
void sendToPlayer(ServerPlayer sender, boolean filterMaskEnabled, ChatType.Bound params);
+ // Paper start
+ default void sendToPlayer(ServerPlayer serverPlayer, boolean shouldFilter, ChatType.Bound bound, @javax.annotation.Nullable Component unsigned) {
+ this.sendToPlayer(serverPlayer, shouldFilter, bound);
+ default void sendToPlayer(ServerPlayer sender, boolean filterMaskEnabled, ChatType.Bound params, @javax.annotation.Nullable Component unsigned) {
+ this.sendToPlayer(sender, filterMaskEnabled, params);
+ }
+ // Paper end
+
void sendHeadersToRemainingPlayers(PlayerList playerManager);
static OutgoingPlayerChatMessage create(PlayerChatMessage message) {
@@ -0,0 +0,0 @@ public interface OutgoingPlayerChatMessage {
@Override
public void sendToPlayer(ServerPlayer serverPlayer, boolean bl, ChatType.Bound bound) {
public void sendToPlayer(ServerPlayer sender, boolean filterMaskEnabled, ChatType.Bound params) {
+ // Paper start
+ this.sendToPlayer(serverPlayer, bl, bound, null);
+ this.sendToPlayer(sender, filterMaskEnabled, params, null);
+ }
+
+ @Override
+ public void sendToPlayer(ServerPlayer serverPlayer, boolean bl, ChatType.Bound bound, @javax.annotation.Nullable Component unsigned) {
+ public void sendToPlayer(ServerPlayer sender, boolean filterMaskEnabled, ChatType.Bound params, @javax.annotation.Nullable Component unsigned) {
+ // Paper end
PlayerChatMessage playerChatMessage = this.message.filter(bl);
PlayerChatMessage playerChatMessage = this.message.filter(filterMaskEnabled);
+ playerChatMessage = unsigned != null ? playerChatMessage.withUnsignedContent(unsigned) : playerChatMessage; // Paper
if (!playerChatMessage.isFullyFiltered()) {
RegistryAccess registryAccess = serverPlayer.level.registryAccess();
ChatType.BoundNetwork boundNetwork = bound.toNetwork(registryAccess);
RegistryAccess registryAccess = sender.level.registryAccess();
ChatType.BoundNetwork boundNetwork = params.toNetwork(registryAccess);
@@ -0,0 +0,0 @@ public interface OutgoingPlayerChatMessage {
@Override
public void sendToPlayer(ServerPlayer serverPlayer, boolean bl, ChatType.Bound bound) {
public void sendToPlayer(ServerPlayer sender, boolean filterMaskEnabled, ChatType.Bound params) {
+ // Paper start
+ this.sendToPlayer(serverPlayer, bl, bound, null);
+ this.sendToPlayer(sender, filterMaskEnabled, params, null);
+ }
+
+ @Override
+ public void sendToPlayer(ServerPlayer serverPlayer, boolean bl, ChatType.Bound bound, @javax.annotation.Nullable Component unsigned) {
+ public void sendToPlayer(ServerPlayer sender, boolean filterMaskEnabled, ChatType.Bound params, @javax.annotation.Nullable Component unsigned) {
+ // Paper end
PlayerChatMessage playerChatMessage = this.message.filter(bl);
PlayerChatMessage playerChatMessage = this.message.filter(filterMaskEnabled);
+ playerChatMessage = unsigned != null ? playerChatMessage.withUnsignedContent(unsigned) : playerChatMessage; // Paper
if (!playerChatMessage.isFullyFiltered()) {
this.playersWithFullMessage.add(serverPlayer);
RegistryAccess registryAccess = serverPlayer.level.registryAccess();
this.playersWithFullMessage.add(sender);
RegistryAccess registryAccess = sender.level.registryAccess();
diff --git a/src/main/java/net/minecraft/network/protocol/game/ClientboundSetActionBarTextPacket.java b/src/main/java/net/minecraft/network/protocol/game/ClientboundSetActionBarTextPacket.java
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
--- a/src/main/java/net/minecraft/network/protocol/game/ClientboundSetActionBarTextPacket.java
@ -2011,15 +2013,15 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
@@ -0,0 +0,0 @@ public class ServerPlayer extends Player {
}
public void sendChatMessage(OutgoingPlayerChatMessage message, boolean flag, ChatType.Bound chatmessagetype_a) {
public void sendChatMessage(OutgoingPlayerChatMessage message, boolean filterMaskEnabled, ChatType.Bound params) {
+ // Paper start
+ this.sendChatMessage(message, flag, chatmessagetype_a, null);
+ this.sendChatMessage(message, filterMaskEnabled, params, null);
+ }
+ public void sendChatMessage(OutgoingPlayerChatMessage message, boolean flag, ChatType.Bound chatmessagetype_a, @Nullable Component unsigned) {
+ public void sendChatMessage(OutgoingPlayerChatMessage message, boolean filterMaskEnabled, ChatType.Bound params, @Nullable Component unsigned) {
+ // Paper end
if (this.acceptsChatMessages()) {
- message.sendToPlayer(this, flag, chatmessagetype_a);
+ message.sendToPlayer(this, flag, chatmessagetype_a, unsigned); // Paper
- message.sendToPlayer(this, filterMaskEnabled, params);
+ message.sendToPlayer(this, filterMaskEnabled, params, unsigned); // Paper
}
}
@ -2161,7 +2163,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ return packet.signedPreview() && ichatbasecomponent != null ? new ChatMessageContent(packet.message(), ichatbasecomponent, result.decoratorResult()) : new ChatMessageContent(packet.message()); // Paper end
}
private void broadcastChatMessage(PlayerChatMessage playerchatmessage) {
private void broadcastChatMessage(PlayerChatMessage message) {
@@ -0,0 +0,0 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Tic
private CompletableFuture<Component> queryChatPreview(String query) {
@ -2391,38 +2393,38 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
@@ -0,0 +0,0 @@ public abstract class PlayerList {
}
public void broadcastChatMessage(PlayerChatMessage playerchatmessage, ServerPlayer sender, ChatType.Bound params) {
public void broadcastChatMessage(PlayerChatMessage message, ServerPlayer sender, ChatType.Bound params) {
+ // Paper start
+ this.broadcastChatMessage(playerchatmessage, sender, params, null);
+ this.broadcastChatMessage(message, sender, params, null);
+ }
+ public void broadcastChatMessage(PlayerChatMessage playerchatmessage, ServerPlayer sender, ChatType.Bound params, @Nullable Function<net.kyori.adventure.audience.Audience, Component> unsignedFunction) {
+ public void broadcastChatMessage(PlayerChatMessage message, ServerPlayer sender, ChatType.Bound params, @Nullable Function<net.kyori.adventure.audience.Audience, Component> unsignedFunction) {
+ // Paper end
Objects.requireNonNull(sender);
- this.broadcastChatMessage(playerchatmessage, sender::shouldFilterMessageTo, sender, sender.asChatSender(), params);
+ this.broadcastChatMessage(playerchatmessage, sender::shouldFilterMessageTo, sender, sender.asChatSender(), params, unsignedFunction); // Paper
- this.broadcastChatMessage(message, sender::shouldFilterMessageTo, sender, sender.asChatSender(), params);
+ this.broadcastChatMessage(message, sender::shouldFilterMessageTo, sender, sender.asChatSender(), params, unsignedFunction); // Paper
}
private void broadcastChatMessage(PlayerChatMessage playerchatmessage, Predicate<ServerPlayer> shouldSendFiltered, @Nullable ServerPlayer entityplayer, ChatSender chatsender, ChatType.Bound chatmessagetype_a) {
private void broadcastChatMessage(PlayerChatMessage message, Predicate<ServerPlayer> shouldSendFiltered, @Nullable ServerPlayer sender, ChatSender sourceProfile, ChatType.Bound params) {
+ // Paper start
+ this.broadcastChatMessage(playerchatmessage, shouldSendFiltered, entityplayer, chatsender, chatmessagetype_a, null);
+ this.broadcastChatMessage(message, shouldSendFiltered, sender, sourceProfile, params, null);
+ }
+
+ private void broadcastChatMessage(PlayerChatMessage playerchatmessage, Predicate<ServerPlayer> shouldSendFiltered, @Nullable ServerPlayer entityplayer, ChatSender chatsender, ChatType.Bound chatmessagetype_a, @Nullable Function<net.kyori.adventure.audience.Audience, Component> unsignedFunction) {
+ private void broadcastChatMessage(PlayerChatMessage message, Predicate<ServerPlayer> shouldSendFiltered, @Nullable ServerPlayer sender, ChatSender sourceProfile, ChatType.Bound params, @Nullable Function<net.kyori.adventure.audience.Audience, Component> unsignedFunction) {
+ // Paper end
boolean flag = this.verifyChatTrusted(playerchatmessage, chatsender);
boolean flag = this.verifyChatTrusted(message, sourceProfile);
- this.server.logChatMessage(playerchatmessage.serverContent(), chatmessagetype_a, flag ? null : "Not Secure");
+ this.server.logChatMessage((unsignedFunction == null ? playerchatmessage : playerchatmessage.withUnsignedContent(unsignedFunction.apply(this.server.console))).serverContent(), chatmessagetype_a, flag ? null : "Not Secure"); // Paper
OutgoingPlayerChatMessage outgoingplayerchatmessage = OutgoingPlayerChatMessage.create(playerchatmessage);
boolean flag1 = playerchatmessage.isFullyFiltered();
- this.server.logChatMessage(message.serverContent(), params, flag ? null : "Not Secure");
+ this.server.logChatMessage((unsignedFunction == null ? message : message.withUnsignedContent(unsignedFunction.apply(this.server.console))).serverContent(), params, flag ? null : "Not Secure"); // Paper
OutgoingPlayerChatMessage outgoingplayerchatmessage = OutgoingPlayerChatMessage.create(message);
boolean flag1 = message.isFullyFiltered();
boolean flag2 = false;
@@ -0,0 +0,0 @@ public abstract class PlayerList {
ServerPlayer entityplayer1 = (ServerPlayer) iterator.next();
boolean flag3 = shouldSendFiltered.test(entityplayer1);
- entityplayer1.sendChatMessage(outgoingplayerchatmessage, flag3, chatmessagetype_a);
+ entityplayer1.sendChatMessage(outgoingplayerchatmessage, flag3, chatmessagetype_a, unsignedFunction == null ? null : unsignedFunction.apply(entityplayer1.getBukkitEntity()));
if (entityplayer != entityplayer1) {
- entityplayer1.sendChatMessage(outgoingplayerchatmessage, flag3, params);
+ entityplayer1.sendChatMessage(outgoingplayerchatmessage, flag3, params, unsignedFunction == null ? null : unsignedFunction.apply(entityplayer1.getBukkitEntity())); // Paper
if (sender != entityplayer1) {
flag2 |= flag1 && flag3;
}
@@ -0,0 +0,0 @@ public abstract class PlayerList {

View file

@ -56,19 +56,19 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
net.minecraft.server.MCUtil.isMainThread() && packet.isReady() && this.queue.isEmpty() &&
(packet.getExtraPackets() == null || packet.getExtraPackets().isEmpty())
))) {
- this.sendPacket(packet, packetsendlistener);
+ this.sendPacket(packet, packetsendlistener, null); // Paper
- this.sendPacket(packet, callbacks);
+ this.sendPacket(packet, callbacks, null); // Paper
return;
}
// write the packets to the queue, then flush - antixray hooks there already
@@ -0,0 +0,0 @@ public class Connection extends SimpleChannelInboundHandler<Packet<?>> {
}
private void sendPacket(Packet<?> packet, @Nullable PacketSendListener packetsendlistener) {
private void sendPacket(Packet<?> packet, @Nullable PacketSendListener callbacks) {
+ // Paper start - add flush parameter
+ this.sendPacket(packet, packetsendlistener, Boolean.TRUE);
+ this.sendPacket(packet, callbacks, Boolean.TRUE);
+ }
+ private void sendPacket(Packet<?> packet, @Nullable PacketSendListener packetsendlistener, Boolean flushConditional) {
+ private void sendPacket(Packet<?> packet, @Nullable PacketSendListener callbacks, Boolean flushConditional) {
+ this.packetWrites.getAndIncrement(); // must be befeore using canFlush
+ boolean effectiveFlush = flushConditional == null ? this.canFlush : flushConditional.booleanValue();
+ final boolean flush = effectiveFlush || packet instanceof net.minecraft.network.protocol.game.ClientboundKeepAlivePacket || packet instanceof ClientboundDisconnectPacket; // no delay for certain packets
@ -80,22 +80,22 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
}
if (this.channel.eventLoop().inEventLoop()) {
- this.doSendPacket(packet, packetsendlistener, enumprotocol, enumprotocol1);
+ this.doSendPacket(packet, packetsendlistener, enumprotocol, enumprotocol1, flush); // Paper - add flush parameter
- this.doSendPacket(packet, callbacks, enumprotocol, enumprotocol1);
+ this.doSendPacket(packet, callbacks, enumprotocol, enumprotocol1, flush); // Paper
} else {
this.channel.eventLoop().execute(() -> {
- this.doSendPacket(packet, packetsendlistener, enumprotocol, enumprotocol1);
+ this.doSendPacket(packet, packetsendlistener, enumprotocol, enumprotocol1, flush); // Paper - add flush parameter
- this.doSendPacket(packet, callbacks, enumprotocol, enumprotocol1);
+ this.doSendPacket(packet, callbacks, enumprotocol, enumprotocol1, flush); // Paper
});
}
}
private void doSendPacket(Packet<?> packet, @Nullable PacketSendListener packetsendlistener, ConnectionProtocol packetState, ConnectionProtocol currentState) {
private void doSendPacket(Packet<?> packet, @Nullable PacketSendListener callbacks, ConnectionProtocol packetState, ConnectionProtocol currentState) {
+ // Paper start - add flush parameter
+ this.doSendPacket(packet, packetsendlistener, packetState, currentState, true);
+ this.doSendPacket(packet, callbacks, packetState, currentState, true);
+ }
+ private void doSendPacket(Packet<?> packet, @Nullable PacketSendListener packetsendlistener, ConnectionProtocol packetState, ConnectionProtocol currentState, boolean flush) {
+ private void doSendPacket(Packet<?> packet, @Nullable PacketSendListener callbacks, ConnectionProtocol packetState, ConnectionProtocol currentState, boolean flush) {
+ // Paper end - add flush parameter
if (packetState != currentState) {
this.setProtocol(packetState);
@ -107,7 +107,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
- ChannelFuture channelfuture = this.channel.writeAndFlush(packet);
+ ChannelFuture channelfuture = flush ? this.channel.writeAndFlush(packet) : this.channel.write(packet); // Paper - add flush parameter
if (packetsendlistener != null) {
if (callbacks != null) {
channelfuture.addListener((future) -> {
@@ -0,0 +0,0 @@ public class Connection extends SimpleChannelInboundHandler<Packet<?>> {
}

View file

@ -598,24 +598,6 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
// CraftBukkit start
String s = (String) Optional.ofNullable((String) optionset.valueOf("world")).orElse(dedicatedserversettings.getProperties().levelName);
LevelStorageSource convertable = LevelStorageSource.createDefault(file.toPath());
diff --git a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
--- a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
+++ b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
@@ -0,0 +0,0 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Tic
}
private boolean tryHandleChat(String message, Instant timestamp, LastSeenMessages.Update acknowledgment) {
+ // Paper start
+ final ProfilePublicKey key = this.player.getProfilePublicKey();
+ if (key != null && key.data().hasExpired()) {
+ this.disconnect(Component.translatable("multiplayer.disconnect.missing_public_key"), org.bukkit.event.player.PlayerKickEvent.Cause.CHAT_VALIDATION_FAILED);
+ return false;
+ }
+ // Paper end
if (!this.updateChatOrder(timestamp)) {
ServerGamePacketListenerImpl.LOGGER.warn("{} sent out-of-order chat: '{}'", this.player.getName().getString(), message);
this.disconnect(Component.translatable("multiplayer.disconnect.out_of_order_chat"));
diff --git a/src/main/java/net/minecraft/server/players/GameProfileCache.java b/src/main/java/net/minecraft/server/players/GameProfileCache.java
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
--- a/src/main/java/net/minecraft/server/players/GameProfileCache.java

View file

@ -16,4 +16,4 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ minecraftserver.scheduleOnMain(networkmanager::handleDisconnection); // Paper
}
private <T, R> CompletableFuture<R> filterTextPacket(T text, BiFunction<TextFilter, T, CompletableFuture<R>> bifunction) {
private <T, R> CompletableFuture<R> filterTextPacket(T text, BiFunction<TextFilter, T, CompletableFuture<R>> filterer) {

View file

@ -31,7 +31,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
if (this.tryHandleChat(packet.command(), packet.timeStamp(), packet.lastSeenMessages())) {
this.server.submit(() -> {
@@ -0,0 +0,0 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Tic
// Paper end
private boolean tryHandleChat(String message, Instant timestamp, LastSeenMessages.Update acknowledgment) {
if (!this.updateChatOrder(timestamp)) {
ServerGamePacketListenerImpl.LOGGER.warn("{} sent out-of-order chat: '{}'", this.player.getName().getString(), message);
+ this.server.scheduleOnMain(() -> { // Paper - push to main

View file

@ -34,20 +34,20 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
private static final float AVERAGE_PACKETS_SMOOTHING = 0.75F;
@@ -0,0 +0,0 @@ public class Connection extends SimpleChannelInboundHandler<Packet<?>> {
if (this.channel.eventLoop().inEventLoop()) {
this.doSendPacket(packet, packetsendlistener, enumprotocol, enumprotocol1, flush); // Paper - add flush parameter
this.doSendPacket(packet, callbacks, enumprotocol, enumprotocol1, flush); // Paper
} else {
+ // Paper start - optimise packets that are not flushed
+ // note: since the type is not dynamic here, we need to actually copy the old executor code
+ // into two branches. On conflict, just re-copy - no changes were made inside the executor code.
+ if (!flush) {
+ AbstractEventExecutor.LazyRunnable run = () -> {
+ this.doSendPacket(packet, packetsendlistener, enumprotocol, enumprotocol1, flush); // Paper - add flush parameter
+ this.doSendPacket(packet, callbacks, enumprotocol, enumprotocol1, flush); // Paper - add flush parameter
+ };
+ this.channel.eventLoop().execute(run);
+ } else { // Paper end - optimise packets that are not flushed
this.channel.eventLoop().execute(() -> {
- this.doSendPacket(packet, packetsendlistener, enumprotocol, enumprotocol1, flush); // Paper - add flush parameter
+ this.doSendPacket(packet, packetsendlistener, enumprotocol, enumprotocol1, flush); // Paper - add flush parameter // Paper - diff on change
- this.doSendPacket(packet, callbacks, enumprotocol, enumprotocol1, flush); // Paper
+ this.doSendPacket(packet, callbacks, enumprotocol, enumprotocol1, flush); // Paper - add flush parameter // Paper - diff on change
});
+ } // Paper
}

View file

@ -105,7 +105,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
this.send(packet, (PacketSendListener) null);
}
public void send(Packet<?> packet, @Nullable PacketSendListener packetsendlistener) {
public void send(Packet<?> packet, @Nullable PacketSendListener callbacks) {
- if (this.isConnected()) {
- this.flushQueue();
+ // Paper start - handle oversized packets better
@ -118,16 +118,16 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ net.minecraft.server.MCUtil.isMainThread() && packet.isReady() && this.queue.isEmpty() &&
+ (packet.getExtraPackets() == null || packet.getExtraPackets().isEmpty())
+ ))) {
this.sendPacket(packet, packetsendlistener);
this.sendPacket(packet, callbacks);
- } else {
- this.queue.add(new Connection.PacketHolder(packet, packetsendlistener));
- this.queue.add(new Connection.PacketHolder(packet, callbacks));
+ return;
}
+ // write the packets to the queue, then flush - antixray hooks there already
+ java.util.List<Packet> extraPackets = InnerUtil.buildExtraPackets(packet);
+ boolean hasExtraPackets = extraPackets != null && !extraPackets.isEmpty();
+ if (!hasExtraPackets) {
+ this.queue.add(new Connection.PacketHolder(packet, packetsendlistener));
+ this.queue.add(new Connection.PacketHolder(packet, callbacks));
+ } else {
+ 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
@ -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 ? packetsendlistener : null)); // append listener to the end
+ packets.add(new Connection.PacketHolder(extra, end ? callbacks : null)); // append listener to the end
+ }
+ this.queue.addAll(packets); // atomic
+ }
@ -143,7 +143,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ // Paper end
}
private void sendPacket(Packet<?> packet, @Nullable PacketSendListener packetsendlistener) {
private void sendPacket(Packet<?> packet, @Nullable PacketSendListener callbacks) {
@@ -0,0 +0,0 @@ public class Connection extends SimpleChannelInboundHandler<Packet<?>> {
this.setProtocol(packetState);
}
@ -159,7 +159,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ // Paper end
ChannelFuture channelfuture = this.channel.writeAndFlush(packet);
if (packetsendlistener != null) {
if (callbacks != null) {
@@ -0,0 +0,0 @@ public class Connection extends SimpleChannelInboundHandler<Packet<?>> {
});

View file

@ -11,9 +11,9 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
@@ -0,0 +0,0 @@ public class ServerLoginPacketListenerImpl implements TickablePacketListener, Se
profilepublickey = ServerLoginPacketListenerImpl.validatePublicKey(this.profilePublicKeyData, this.gameProfile.getId(), signaturevalidator, this.server.enforceSecureProfile());
} catch (ServerLoginPacketListenerImpl.PublicKeyValidationException loginlistener_a) {
- ServerLoginPacketListenerImpl.LOGGER.error(loginlistener_a.getMessage(), loginlistener_a.getCause());
+ //ServerLoginPacketListenerImpl.LOGGER.error(loginlistener_a.getMessage(), loginlistener_a.getCause()); // Paper - unnecessary stacktrace
} catch (ProfilePublicKey.ValidationException profilepublickey_b) {
- ServerLoginPacketListenerImpl.LOGGER.error("Failed to validate profile key: {}", profilepublickey_b.getMessage());
+ // ServerLoginPacketListenerImpl.LOGGER.error("Failed to validate profile key: {}", profilepublickey_b.getMessage()); // Paper - unnecessary log
if (!this.connection.isMemoryConnection()) {
this.disconnect(loginlistener_a.getComponent());
this.disconnect(profilepublickey_b.getComponent());
return;

View file

@ -182,7 +182,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
- <groupId>org.spigotmc</groupId>
- <artifactId>spigot</artifactId>
- <packaging>jar</packaging>
- <version>1.19.1-R0.1-SNAPSHOT</version>
- <version>1.19.2-R0.1-SNAPSHOT</version>
- <name>Spigot</name>
- <url>https://www.spigotmc.org/</url>
-

@ -1 +1 @@
Subproject commit c540b6e228dc33c13c02b2af63a2691cda0cdea8
Subproject commit d96ad8e1e64b7c35bb632339c23621353be1f028

@ -1 +1 @@
Subproject commit caa7c4866ac49b04808b75284715543f221649a5
Subproject commit bf60995c031e1c046dfe1a322b94298426eb2f84

@ -1 +1 @@
Subproject commit 1e3bf58cdb2b099308d94dbc34d950155ee83ac3
Subproject commit ec2b5d4cd1f039ef34be82c2d3954fb1a88bf3b5

@ -1 +1 @@
Subproject commit 21831450a43f67f1730dd0dec987c7a7ff19caa9
Subproject commit 584b459dceac6e6f4708b70706671206d7a2c8ea