Mirror von
https://github.com/PaperMC/Velocity.git
synchronisiert 2024-11-06 00:00:47 +01:00
acknowledge seen messages to server when running proxy commands (#1100)
Dieser Commit ist enthalten in:
Ursprung
0d9a097a59
Commit
98163cb82c
@ -50,6 +50,7 @@ import com.velocitypowered.proxy.protocol.packet.StatusResponse;
|
||||
import com.velocitypowered.proxy.protocol.packet.TabCompleteRequest;
|
||||
import com.velocitypowered.proxy.protocol.packet.TabCompleteResponse;
|
||||
import com.velocitypowered.proxy.protocol.packet.UpsertPlayerInfo;
|
||||
import com.velocitypowered.proxy.protocol.packet.chat.ChatAcknowledgement;
|
||||
import com.velocitypowered.proxy.protocol.packet.chat.PlayerChatCompletion;
|
||||
import com.velocitypowered.proxy.protocol.packet.chat.SystemChat;
|
||||
import com.velocitypowered.proxy.protocol.packet.chat.keyed.KeyedPlayerChat;
|
||||
@ -314,4 +315,8 @@ public interface MinecraftSessionHandler {
|
||||
default boolean handle(PingIdentify pingIdentify) {
|
||||
return false;
|
||||
}
|
||||
|
||||
default boolean handle(ChatAcknowledgement chatAcknowledgement) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -75,6 +75,7 @@ import com.velocitypowered.proxy.protocol.packet.StatusResponse;
|
||||
import com.velocitypowered.proxy.protocol.packet.TabCompleteRequest;
|
||||
import com.velocitypowered.proxy.protocol.packet.TabCompleteResponse;
|
||||
import com.velocitypowered.proxy.protocol.packet.UpsertPlayerInfo;
|
||||
import com.velocitypowered.proxy.protocol.packet.chat.ChatAcknowledgement;
|
||||
import com.velocitypowered.proxy.protocol.packet.chat.PlayerChatCompletion;
|
||||
import com.velocitypowered.proxy.protocol.packet.chat.SystemChat;
|
||||
import com.velocitypowered.proxy.protocol.packet.chat.keyed.KeyedPlayerChat;
|
||||
@ -184,6 +185,10 @@ public enum StateRegistry {
|
||||
map(0x03, MINECRAFT_1_12, false),
|
||||
map(0x02, MINECRAFT_1_12_1, false),
|
||||
map(0x03, MINECRAFT_1_14, MINECRAFT_1_18_2, false));
|
||||
serverbound.register(
|
||||
ChatAcknowledgement.class,
|
||||
ChatAcknowledgement::new,
|
||||
map(0x03, MINECRAFT_1_19_3, false));
|
||||
serverbound.register(KeyedPlayerCommand.class, KeyedPlayerCommand::new,
|
||||
map(0x03, MINECRAFT_1_19, false),
|
||||
map(0x04, MINECRAFT_1_19_1, MINECRAFT_1_19_1, false));
|
||||
|
@ -0,0 +1,57 @@
|
||||
/*
|
||||
* Copyright (C) 2023 Velocity Contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.velocitypowered.proxy.protocol.packet.chat;
|
||||
|
||||
import com.velocitypowered.api.network.ProtocolVersion;
|
||||
import com.velocitypowered.proxy.connection.MinecraftSessionHandler;
|
||||
import com.velocitypowered.proxy.protocol.MinecraftPacket;
|
||||
import com.velocitypowered.proxy.protocol.ProtocolUtils;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
|
||||
public class ChatAcknowledgement implements MinecraftPacket {
|
||||
int offset;
|
||||
|
||||
public ChatAcknowledgement(int offset) {
|
||||
this.offset = offset;
|
||||
}
|
||||
|
||||
public ChatAcknowledgement() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void decode(ByteBuf buf, ProtocolUtils.Direction direction, ProtocolVersion protocolVersion) {
|
||||
offset = ProtocolUtils.readVarInt(buf);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void encode(ByteBuf buf, ProtocolUtils.Direction direction, ProtocolVersion protocolVersion) {
|
||||
ProtocolUtils.writeVarInt(buf, offset);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean handle(MinecraftSessionHandler handler) {
|
||||
return handler.handle(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "ChatAcknowledgement{" +
|
||||
"offset=" + offset +
|
||||
'}';
|
||||
}
|
||||
}
|
@ -50,6 +50,10 @@ public class LastSeenMessages {
|
||||
return acknowledged.isEmpty();
|
||||
}
|
||||
|
||||
public int getOffset() {
|
||||
return this.offset;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "LastSeenMessages{" +
|
||||
|
@ -18,8 +18,10 @@
|
||||
package com.velocitypowered.proxy.protocol.packet.chat.session;
|
||||
|
||||
import com.velocitypowered.api.event.command.CommandExecuteEvent;
|
||||
import com.velocitypowered.api.network.ProtocolVersion;
|
||||
import com.velocitypowered.proxy.VelocityServer;
|
||||
import com.velocitypowered.proxy.connection.client.ConnectedPlayer;
|
||||
import com.velocitypowered.proxy.protocol.packet.chat.ChatAcknowledgement;
|
||||
import com.velocitypowered.proxy.protocol.packet.chat.CommandHandler;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
import net.kyori.adventure.text.Component;
|
||||
@ -52,6 +54,10 @@ public class SessionCommandHandler implements CommandHandler<SessionPlayerComman
|
||||
"A proxy plugin caused an illegal protocol state. "
|
||||
+ "Contact your network administrator."));
|
||||
}
|
||||
// We seemingly can't actually do this if signed args exist, if not, we can probs keep stuff happy
|
||||
if (player.getProtocolVersion().compareTo(ProtocolVersion.MINECRAFT_1_19_3) >= 0) {
|
||||
return CompletableFuture.completedFuture(new ChatAcknowledgement(packet.lastSeenMessages.getOffset()));
|
||||
}
|
||||
return CompletableFuture.completedFuture(null);
|
||||
}
|
||||
|
||||
@ -102,6 +108,9 @@ public class SessionCommandHandler implements CommandHandler<SessionPlayerComman
|
||||
.toServer();
|
||||
}
|
||||
}
|
||||
if (player.getProtocolVersion().compareTo(ProtocolVersion.MINECRAFT_1_19_3) >= 0) {
|
||||
return new ChatAcknowledgement(packet.lastSeenMessages.getOffset());
|
||||
}
|
||||
return null;
|
||||
});
|
||||
}, packet.command, packet.timeStamp);
|
||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren