|
|
|
@@ -97,27 +97,31 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
|
|
|
|
|
|
|
|
|
|
|
this.chatPreviewThrottler.tick();
|
|
|
|
this.chatPreviewThrottler.tick();
|
|
|
|
@@ -0,0 +0,0 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Tic
|
|
|
|
@@ -0,0 +0,0 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Tic
|
|
|
|
|
|
|
|
return this.server.isSingleplayerOwner(this.player.getGameProfile());
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
+ @io.papermc.paper.annotation.DoNotUse // Paper
|
|
|
|
public void disconnect(String s) {
|
|
|
|
public void disconnect(String s) {
|
|
|
|
// Paper start
|
|
|
|
// Paper start
|
|
|
|
- this.disconnect(net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer.legacySection().deserialize(s));
|
|
|
|
- this.disconnect(net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer.legacySection().deserialize(s));
|
|
|
|
+ this.disconnect(net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer.legacySection().deserialize(s), org.bukkit.event.player.PlayerKickEvent.Cause.UNKNOWN);
|
|
|
|
+ this.disconnect(net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer.legacySection().deserialize(s), org.bukkit.event.player.PlayerKickEvent.Cause.UNKNOWN);
|
|
|
|
+ }
|
|
|
|
|
|
|
|
+
|
|
|
|
|
|
|
|
+ public void disconnect(String s, PlayerKickEvent.Cause cause) {
|
|
|
|
|
|
|
|
+ this.disconnect(net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer.legacySection().deserialize(s), cause);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
+ public void disconnect(String s, PlayerKickEvent.Cause cause) {
|
|
|
|
|
|
|
|
+ this.disconnect(net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer.legacySection().deserialize(s), cause);
|
|
|
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
+
|
|
|
|
|
|
|
|
+ @io.papermc.paper.annotation.DoNotUse // Paper
|
|
|
|
public void disconnect(final Component reason) {
|
|
|
|
public void disconnect(final Component reason) {
|
|
|
|
- this.disconnect(PaperAdventure.asAdventure(reason));
|
|
|
|
- this.disconnect(PaperAdventure.asAdventure(reason));
|
|
|
|
+ this.disconnect(PaperAdventure.asAdventure(reason), org.bukkit.event.player.PlayerKickEvent.Cause.UNKNOWN);
|
|
|
|
+ this.disconnect(PaperAdventure.asAdventure(reason), org.bukkit.event.player.PlayerKickEvent.Cause.UNKNOWN);
|
|
|
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
+
|
|
|
|
|
|
|
|
+ public void disconnect(final Component reason, PlayerKickEvent.Cause cause) {
|
|
|
|
|
|
|
|
+ this.disconnect(PaperAdventure.asAdventure(reason), cause);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
- public void disconnect(net.kyori.adventure.text.Component reason) {
|
|
|
|
- public void disconnect(net.kyori.adventure.text.Component reason) {
|
|
|
|
+ public void disconnect(final Component reason, PlayerKickEvent.Cause cause) {
|
|
|
|
|
|
|
|
+ this.disconnect(PaperAdventure.asAdventure(reason), cause);
|
|
|
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
+
|
|
|
|
|
|
|
|
+ public void disconnect(net.kyori.adventure.text.Component reason, org.bukkit.event.player.PlayerKickEvent.Cause cause) {
|
|
|
|
+ public void disconnect(net.kyori.adventure.text.Component reason, org.bukkit.event.player.PlayerKickEvent.Cause cause) {
|
|
|
|
// Paper end
|
|
|
|
// Paper end
|
|
|
|
// CraftBukkit start - fire PlayerKickEvent
|
|
|
|
// CraftBukkit start - fire PlayerKickEvent
|
|
|
|
@@ -140,6 +144,15 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
Entity entity = this.player.getRootVehicle();
|
|
|
|
Entity entity = this.player.getRootVehicle();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@@ -0,0 +0,0 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Tic
|
|
|
|
|
|
|
|
PacketUtils.ensureRunningOnSameThread(packet, this, this.player.getLevel());
|
|
|
|
|
|
|
|
if (packet.getId() == this.awaitingTeleport) {
|
|
|
|
|
|
|
|
if (this.awaitingPositionFromClient == null) {
|
|
|
|
|
|
|
|
- this.disconnect(Component.translatable("multiplayer.disconnect.invalid_player_movement"));
|
|
|
|
|
|
|
|
+ this.disconnect(Component.translatable("multiplayer.disconnect.invalid_player_movement"), org.bukkit.event.player.PlayerKickEvent.Cause.INVALID_PLAYER_MOVEMENT); // Paper - kick event cause
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@@ -0,0 +0,0 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Tic
|
|
|
|
@@ -0,0 +0,0 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Tic
|
|
|
|
// PacketUtils.ensureRunningOnSameThread(packet, this, this.player.getLevel()); // Paper - run this async
|
|
|
|
// PacketUtils.ensureRunningOnSameThread(packet, this, this.player.getLevel()); // Paper - run this async
|
|
|
|
// CraftBukkit start
|
|
|
|
// CraftBukkit start
|
|
|
|
@@ -196,7 +209,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
|
|
|
PacketUtils.ensureRunningOnSameThread(packet, this, this.player.getLevel());
|
|
|
|
PacketUtils.ensureRunningOnSameThread(packet, this, this.player.getLevel());
|
|
|
|
if (ServerGamePacketListenerImpl.containsInvalidValues(packet.getX(0.0D), packet.getY(0.0D), packet.getZ(0.0D), packet.getYRot(0.0F), packet.getXRot(0.0F))) {
|
|
|
|
if (ServerGamePacketListenerImpl.containsInvalidValues(packet.getX(0.0D), packet.getY(0.0D), packet.getZ(0.0D), packet.getYRot(0.0F), packet.getXRot(0.0F))) {
|
|
|
|
- this.disconnect(Component.translatable("multiplayer.disconnect.invalid_player_movement"));
|
|
|
|
- this.disconnect(Component.translatable("multiplayer.disconnect.invalid_player_movement"));
|
|
|
|
+ this.disconnect(Component.translatable(("multiplayer.disconnect.invalid_player_movement"), org.bukkit.event.player.PlayerKickEvent.Cause.INVALID_PLAYER_MOVEMENT)); // Paper - kick event cause
|
|
|
|
+ this.disconnect(Component.translatable("multiplayer.disconnect.invalid_player_movement"), org.bukkit.event.player.PlayerKickEvent.Cause.INVALID_PLAYER_MOVEMENT); // Paper - kick event cause
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
ServerLevel worldserver = this.player.getLevel();
|
|
|
|
ServerLevel worldserver = this.player.getLevel();
|
|
|
|
|
|
|
|
|
|
|
|
@@ -236,6 +249,33 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
if (this.tryHandleChat(packet.message(), packet.timeStamp(), packet.lastSeenMessages())) {
|
|
|
|
if (this.tryHandleChat(packet.message(), packet.timeStamp(), packet.lastSeenMessages())) {
|
|
|
|
// this.server.submit(() -> { // CraftBukkit - async chat
|
|
|
|
// this.server.submit(() -> { // CraftBukkit - async chat
|
|
|
|
|
|
|
|
@@ -0,0 +0,0 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Tic
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
|
|
|
public void handleChatCommand(ServerboundChatCommandPacket packet) {
|
|
|
|
|
|
|
|
if (ServerGamePacketListenerImpl.isChatMessageIllegal(packet.command())) {
|
|
|
|
|
|
|
|
- this.disconnect(Component.translatable("multiplayer.disconnect.illegal_characters"));
|
|
|
|
|
|
|
|
+ this.disconnect(Component.translatable("multiplayer.disconnect.illegal_characters"), org.bukkit.event.player.PlayerKickEvent.Cause.ILLEGAL_CHARACTERS); // Paper
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
if (this.tryHandleChat(packet.command(), packet.timeStamp(), packet.lastSeenMessages())) {
|
|
|
|
|
|
|
|
this.server.submit(() -> {
|
|
|
|
|
|
|
|
@@ -0,0 +0,0 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Tic
|
|
|
|
|
|
|
|
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"));
|
|
|
|
|
|
|
|
+ this.disconnect(Component.translatable("multiplayer.disconnect.out_of_order_chat"), org.bukkit.event.player.PlayerKickEvent.Cause.OUT_OF_ORDER_CHAT); // Paper - kick event cause
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
} 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)) {
|
|
|
|
|
|
|
|
- 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
|
|
|
|
@@ -0,0 +0,0 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Tic
|
|
|
|
// this.chatSpamTickCount += 20;
|
|
|
|
// this.chatSpamTickCount += 20;
|
|
|
|
if (this.chatSpamTickCount.addAndGet(20) > 200 && !this.server.getPlayerList().isOp(this.player.getGameProfile())) {
|
|
|
|
if (this.chatSpamTickCount.addAndGet(20) > 200 && !this.server.getPlayerList().isOp(this.player.getGameProfile())) {
|
|
|
|
@@ -246,6 +286,24 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
@@ -0,0 +0,0 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Tic
|
|
|
|
@@ -0,0 +0,0 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Tic
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private void handleValidationFailure(Set<LastSeenMessagesValidator.ErrorCondition> reasons) {
|
|
|
|
|
|
|
|
ServerGamePacketListenerImpl.LOGGER.warn("Failed to validate message from {}, reasons: {}", this.player.getName().getString(), reasons.stream().map(LastSeenMessagesValidator.ErrorCondition::message).collect(Collectors.joining(",")));
|
|
|
|
|
|
|
|
- this.disconnect(Component.translatable("multiplayer.disconnect.chat_validation_failed"));
|
|
|
|
|
|
|
|
+ this.disconnect(Component.translatable("multiplayer.disconnect.chat_validation_failed"), org.bukkit.event.player.PlayerKickEvent.Cause.CHAT_VALIDATION_FAILED); // Paper - kick event cause
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
|
|
|
@@ -0,0 +0,0 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Tic
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (i > 4096) {
|
|
|
|
|
|
|
|
- this.disconnect(Component.translatable("multiplayer.disconnect.too_many_pending_chats"));
|
|
|
|
|
|
|
|
+ this.disconnect(Component.translatable("multiplayer.disconnect.too_many_pending_chats"), org.bukkit.event.player.PlayerKickEvent.Cause.TOO_MANY_PENDING_CHATS); // Paper - kick event cause
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
@@ -0,0 +0,0 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Tic
|
|
|
|
// Spigot Start
|
|
|
|
// Spigot Start
|
|
|
|
if ( entity == this.player && !this.player.isSpectator() )
|
|
|
|
if ( entity == this.player && !this.player.isSpectator() )
|
|
|
|
{
|
|
|
|
{
|
|
|
|
|