Mirror von
https://github.com/PaperMC/Velocity.git
synchronisiert 2024-11-16 21:10:30 +01: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:
Ursprung
b5ee9dd20a
Commit
077968089e
@ -1112,6 +1112,7 @@ public class ConnectedPlayer implements MinecraftConnectionAssociation, Player,
|
|||||||
ChatBuilderV2 message = getChatBuilderFactory().builder().asPlayer(this).message(input);
|
ChatBuilderV2 message = getChatBuilderFactory().builder().asPlayer(this).message(input);
|
||||||
this.chatQueue.queuePacket(chatState -> {
|
this.chatQueue.queuePacket(chatState -> {
|
||||||
message.setTimestamp(chatState.lastTimestamp);
|
message.setTimestamp(chatState.lastTimestamp);
|
||||||
|
message.setLastSeenMessages(chatState.createLastSeen());
|
||||||
return message.toServer();
|
return message.toServer();
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
|
@ -21,6 +21,7 @@ import com.velocitypowered.api.network.ProtocolVersion;
|
|||||||
import com.velocitypowered.api.proxy.Player;
|
import com.velocitypowered.api.proxy.Player;
|
||||||
import com.velocitypowered.proxy.protocol.MinecraftPacket;
|
import com.velocitypowered.proxy.protocol.MinecraftPacket;
|
||||||
import com.velocitypowered.proxy.protocol.packet.chat.ChatType;
|
import com.velocitypowered.proxy.protocol.packet.chat.ChatType;
|
||||||
|
import com.velocitypowered.proxy.protocol.packet.chat.LastSeenMessages;
|
||||||
import java.time.Instant;
|
import java.time.Instant;
|
||||||
import net.kyori.adventure.identity.Identity;
|
import net.kyori.adventure.identity.Identity;
|
||||||
import net.kyori.adventure.text.Component;
|
import net.kyori.adventure.text.Component;
|
||||||
@ -36,6 +37,7 @@ public abstract class ChatBuilderV2 {
|
|||||||
protected @Nullable Identity senderIdentity;
|
protected @Nullable Identity senderIdentity;
|
||||||
protected Instant timestamp;
|
protected Instant timestamp;
|
||||||
protected ChatType type = ChatType.CHAT;
|
protected ChatType type = ChatType.CHAT;
|
||||||
|
protected @Nullable LastSeenMessages lastSeenMessages;
|
||||||
|
|
||||||
protected ChatBuilderV2(ProtocolVersion version) {
|
protected ChatBuilderV2(ProtocolVersion version) {
|
||||||
this.version = version;
|
this.version = version;
|
||||||
@ -77,6 +79,11 @@ public abstract class ChatBuilderV2 {
|
|||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public ChatBuilderV2 setLastSeenMessages(LastSeenMessages lastSeenMessages) {
|
||||||
|
this.lastSeenMessages = lastSeenMessages;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
public abstract MinecraftPacket toClient();
|
public abstract MinecraftPacket toClient();
|
||||||
|
|
||||||
public abstract MinecraftPacket toServer();
|
public abstract MinecraftPacket toServer();
|
||||||
|
@ -41,6 +41,7 @@ public class SessionChatBuilder extends ChatBuilderV2 {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public MinecraftPacket toServer() {
|
public MinecraftPacket toServer() {
|
||||||
|
LastSeenMessages lastSeenMessages = this.lastSeenMessages != null ? this.lastSeenMessages : new LastSeenMessages();
|
||||||
if (message.startsWith("/")) {
|
if (message.startsWith("/")) {
|
||||||
if (version.noLessThan(ProtocolVersion.MINECRAFT_1_20_5)) {
|
if (version.noLessThan(ProtocolVersion.MINECRAFT_1_20_5)) {
|
||||||
UnsignedPlayerCommandPacket command = new UnsignedPlayerCommandPacket();
|
UnsignedPlayerCommandPacket command = new UnsignedPlayerCommandPacket();
|
||||||
@ -52,7 +53,7 @@ public class SessionChatBuilder extends ChatBuilderV2 {
|
|||||||
command.salt = 0L;
|
command.salt = 0L;
|
||||||
command.timeStamp = timestamp;
|
command.timeStamp = timestamp;
|
||||||
command.argumentSignatures = new SessionPlayerCommandPacket.ArgumentSignatures();
|
command.argumentSignatures = new SessionPlayerCommandPacket.ArgumentSignatures();
|
||||||
command.lastSeenMessages = new LastSeenMessages();
|
command.lastSeenMessages = lastSeenMessages;
|
||||||
return command;
|
return command;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@ -62,8 +63,8 @@ public class SessionChatBuilder extends ChatBuilderV2 {
|
|||||||
chat.signature = new byte[0];
|
chat.signature = new byte[0];
|
||||||
chat.timestamp = timestamp;
|
chat.timestamp = timestamp;
|
||||||
chat.salt = 0L;
|
chat.salt = 0L;
|
||||||
chat.lastSeenMessages = new LastSeenMessages();
|
chat.lastSeenMessages = lastSeenMessages;
|
||||||
return chat;
|
return chat;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -73,6 +73,7 @@ public class SessionChatHandler implements ChatHandler<SessionPlayerChatPacket>
|
|||||||
}
|
}
|
||||||
return this.player.getChatBuilderFactory().builder().message(packet.message)
|
return this.player.getChatBuilderFactory().builder().message(packet.message)
|
||||||
.setTimestamp(packet.timestamp)
|
.setTimestamp(packet.timestamp)
|
||||||
|
.setLastSeenMessages(newLastSeenMessages)
|
||||||
.toServer();
|
.toServer();
|
||||||
}
|
}
|
||||||
return packet.withLastSeenMessages(newLastSeenMessages);
|
return packet.withLastSeenMessages(newLastSeenMessages);
|
||||||
|
@ -86,6 +86,7 @@ public class SessionCommandHandler implements CommandHandler<SessionPlayerComman
|
|||||||
return this.player.getChatBuilderFactory()
|
return this.player.getChatBuilderFactory()
|
||||||
.builder()
|
.builder()
|
||||||
.setTimestamp(packet.timeStamp)
|
.setTimestamp(packet.timeStamp)
|
||||||
|
.setLastSeenMessages(packet.lastSeenMessages)
|
||||||
.asPlayer(this.player)
|
.asPlayer(this.player)
|
||||||
.message("/" + newCommand)
|
.message("/" + newCommand)
|
||||||
.toServer();
|
.toServer();
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren