3
0
Mirror von https://github.com/PaperMC/Velocity.git synchronisiert 2024-09-28 22:21:13 +02:00

Fix: pass through last seen update in a few missing places

This is hardly useful in the case of signed player chat messages, as these fundamentally cannot be spoofed or modified - however, for any unsigned input (particularly commands without any signed arguments), 'last seen' updates are still required and should be passed through in a consistent state.
Dieser Commit ist enthalten in:
Gegy 2023-11-27 18:30:32 +01:00 committet von Riley Park
Ursprung b5ee9dd20a
Commit 077968089e
5 geänderte Dateien mit 14 neuen und 3 gelöschten Zeilen

Datei anzeigen

@ -1112,6 +1112,7 @@ public class ConnectedPlayer implements MinecraftConnectionAssociation, Player,
ChatBuilderV2 message = getChatBuilderFactory().builder().asPlayer(this).message(input);
this.chatQueue.queuePacket(chatState -> {
message.setTimestamp(chatState.lastTimestamp);
message.setLastSeenMessages(chatState.createLastSeen());
return message.toServer();
});
} else {

Datei anzeigen

@ -21,6 +21,7 @@ import com.velocitypowered.api.network.ProtocolVersion;
import com.velocitypowered.api.proxy.Player;
import com.velocitypowered.proxy.protocol.MinecraftPacket;
import com.velocitypowered.proxy.protocol.packet.chat.ChatType;
import com.velocitypowered.proxy.protocol.packet.chat.LastSeenMessages;
import java.time.Instant;
import net.kyori.adventure.identity.Identity;
import net.kyori.adventure.text.Component;
@ -36,6 +37,7 @@ public abstract class ChatBuilderV2 {
protected @Nullable Identity senderIdentity;
protected Instant timestamp;
protected ChatType type = ChatType.CHAT;
protected @Nullable LastSeenMessages lastSeenMessages;
protected ChatBuilderV2(ProtocolVersion version) {
this.version = version;
@ -77,6 +79,11 @@ public abstract class ChatBuilderV2 {
return this;
}
public ChatBuilderV2 setLastSeenMessages(LastSeenMessages lastSeenMessages) {
this.lastSeenMessages = lastSeenMessages;
return this;
}
public abstract MinecraftPacket toClient();
public abstract MinecraftPacket toServer();

Datei anzeigen

@ -41,6 +41,7 @@ public class SessionChatBuilder extends ChatBuilderV2 {
@Override
public MinecraftPacket toServer() {
LastSeenMessages lastSeenMessages = this.lastSeenMessages != null ? this.lastSeenMessages : new LastSeenMessages();
if (message.startsWith("/")) {
if (version.noLessThan(ProtocolVersion.MINECRAFT_1_20_5)) {
UnsignedPlayerCommandPacket command = new UnsignedPlayerCommandPacket();
@ -52,7 +53,7 @@ public class SessionChatBuilder extends ChatBuilderV2 {
command.salt = 0L;
command.timeStamp = timestamp;
command.argumentSignatures = new SessionPlayerCommandPacket.ArgumentSignatures();
command.lastSeenMessages = new LastSeenMessages();
command.lastSeenMessages = lastSeenMessages;
return command;
}
} else {
@ -62,8 +63,8 @@ public class SessionChatBuilder extends ChatBuilderV2 {
chat.signature = new byte[0];
chat.timestamp = timestamp;
chat.salt = 0L;
chat.lastSeenMessages = new LastSeenMessages();
chat.lastSeenMessages = lastSeenMessages;
return chat;
}
}
}
}

Datei anzeigen

@ -73,6 +73,7 @@ public class SessionChatHandler implements ChatHandler<SessionPlayerChatPacket>
}
return this.player.getChatBuilderFactory().builder().message(packet.message)
.setTimestamp(packet.timestamp)
.setLastSeenMessages(newLastSeenMessages)
.toServer();
}
return packet.withLastSeenMessages(newLastSeenMessages);

Datei anzeigen

@ -86,6 +86,7 @@ public class SessionCommandHandler implements CommandHandler<SessionPlayerComman
return this.player.getChatBuilderFactory()
.builder()
.setTimestamp(packet.timeStamp)
.setLastSeenMessages(packet.lastSeenMessages)
.asPlayer(this.player)
.message("/" + newCommand)
.toServer();