3
0
Mirror von https://github.com/PaperMC/Velocity.git synchronisiert 2024-12-24 23:30:26 +01:00

Fix command packet (#900)

fix https://github.com/PaperMC/Velocity/issues/898
Dieser Commit ist enthalten in:
James58899 2022-12-09 02:13:57 +08:00 committet von GitHub
Ursprung d3e5dc1354
Commit fa17a5d4cc
Es konnte kein GPG-Schlüssel zu dieser Signatur gefunden werden
GPG-Schlüssel-ID: 4AEE18F83AFDEB23
4 geänderte Dateien mit 15 neuen und 7 gelöschten Zeilen

Datei anzeigen

@ -44,4 +44,8 @@ public class LastSeenMessages {
ProtocolUtils.writeVarInt(buf, offset);
buf.writeBytes(Arrays.copyOf(acknowledged.toByteArray(), DIV_FLOOR));
}
public boolean isEmpty() {
return acknowledged.isEmpty();
}
}

Datei anzeigen

@ -43,7 +43,7 @@ public class LegacyCommandHandler implements CommandHandler<LegacyChat> {
String command = packet.getMessage().substring(1);
queueCommandResult(this.server, this.player, event -> {
CommandExecuteEvent.CommandResult result = event.getResult();
if (!result.isAllowed()) {
if (result == CommandExecuteEvent.CommandResult.denied()) {
return CompletableFuture.completedFuture(null);
}
String commandToRun = result.getCommand().orElse(command);

Datei anzeigen

@ -42,8 +42,8 @@ public class SessionCommandHandler implements CommandHandler<SessionPlayerComman
public void handlePlayerCommandInternal(SessionPlayerCommand packet) {
queueCommandResult(this.server, this.player, event -> {
CommandExecuteEvent.CommandResult result = event.getResult();
if (!result.isAllowed()) {
if (!packet.argumentSignatures.isEmpty()) {
if (result == CommandExecuteEvent.CommandResult.denied()) {
if (packet.isSigned()) {
logger.fatal("A plugin tried to deny a command with signable component(s). " + "This is not supported. "
+ "Disconnecting player " + player.getUsername());
player.disconnect(Component.text(
@ -54,10 +54,10 @@ public class SessionCommandHandler implements CommandHandler<SessionPlayerComman
String commandToRun = result.getCommand().orElse(packet.command);
if (result.isForwardToServer()) {
if (!packet.argumentSignatures.isEmpty() && commandToRun.equals(packet.command)) {
if (!packet.isSigned() && commandToRun.equals(packet.command)) {
return CompletableFuture.completedFuture(packet);
} else {
if (!packet.argumentSignatures.isEmpty()) {
if (packet.isSigned()) {
logger.fatal("A plugin tried to change a command with signed component(s). " + "This is not supported. "
+ "Disconnecting player " + player.getUsername());
player.disconnect(Component.text(
@ -76,10 +76,10 @@ public class SessionCommandHandler implements CommandHandler<SessionPlayerComman
return runCommand(this.server, this.player, commandToRun, hasRun -> {
if (!hasRun) {
if (!packet.argumentSignatures.isEmpty() && commandToRun.equals(packet.command)) {
if (packet.isSigned() && commandToRun.equals(packet.command)) {
return packet;
} else {
if (!packet.argumentSignatures.isEmpty()) {
if (packet.isSigned()) {
logger.fatal("A plugin tried to change a command with signed component(s). " + "This is not supported. "
+ "Disconnecting player " + player.getUsername());
player.disconnect(Component.text(

Datei anzeigen

@ -61,6 +61,10 @@ public class SessionPlayerCommand implements MinecraftPacket {
return timeStamp;
}
public boolean isSigned() {
return salt != 0 || !lastSeenMessages.isEmpty() || !argumentSignatures.isEmpty();
}
@Override
public boolean handle(MinecraftSessionHandler handler) {
return handler.handle(this);