Fix a handful of 1.19.3 compile issues (#8615)

This commit is contained in:
Noah van der Aa
2022-12-07 22:36:56 +01:00
parent bbd997db62
commit 6513000165
7 changed files with 24 additions and 75 deletions

View File

@@ -115,13 +115,13 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
public void disconnect(final Component reason) {
- this.disconnect(PaperAdventure.asAdventure(reason));
+ 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(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) {
// Paper end
// CraftBukkit start - fire PlayerKickEvent
@@ -267,39 +267,6 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
return Optional.empty();
} 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
this.detectRateSpam(s); // Spigot
}
+<<<<<<< HEAD
+=======
+ private boolean verifyChatMessage(PlayerChatMessage message) {
+ ChatSender chatsender = this.player.asChatSender();
+ ProfilePublicKey profilepublickey = chatsender.profilePublicKey();
+
+ if (profilepublickey != null) {
+ if (profilepublickey.data().hasExpired()) {
+ this.player.sendSystemMessage(Component.translatable("chat.disabled.expiredProfileKey").withStyle(ChatFormatting.RED));
+ return false;
+ }
+
+ if (!message.verify(chatsender)) {
+ this.disconnect(Component.translatable("multiplayer.disconnect.unsigned_chat"), org.bukkit.event.player.PlayerKickEvent.Cause.UNSIGNED_CHAT); // Paper - kick event cause
+ return false;
+ }
+ }
+
+ 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());
+ }
+
+ return true;
+ }
+
+>>>>>>> Add PlayerKickEvent causes
// Spigot start - spam exclusions
private void detectRateSpam(String s) {
// CraftBukkit start - replaced with thread safe throttle
@@ -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())) {
@@ -312,22 +279,6 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
@@ -0,0 +0,0 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Tic
}
}
+<<<<<<< HEAD
+=======
+
+ }
+
+ 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"), org.bukkit.event.player.PlayerKickEvent.Cause.CHAT_VALIDATION_FAILED); // Paper - kick event cause
+>>>>>>> Add PlayerKickEvent causes
}
@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