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:
Ursprung
d3e5dc1354
Commit
fa17a5d4cc
@ -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();
|
||||
}
|
||||
}
|
||||
|
@ -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);
|
||||
|
@ -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(
|
||||
|
@ -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);
|
||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren