#3659: Cleanup command packets for 1.20.5
This commit is contained in:
parent
a9218a7aa7
commit
de60af0d7b
@ -5,7 +5,6 @@ import net.md_5.bungee.protocol.packet.Chat;
|
||||
import net.md_5.bungee.protocol.packet.ClearTitles;
|
||||
import net.md_5.bungee.protocol.packet.ClientChat;
|
||||
import net.md_5.bungee.protocol.packet.ClientCommand;
|
||||
import net.md_5.bungee.protocol.packet.ClientCommandSigned;
|
||||
import net.md_5.bungee.protocol.packet.ClientSettings;
|
||||
import net.md_5.bungee.protocol.packet.ClientStatus;
|
||||
import net.md_5.bungee.protocol.packet.Commands;
|
||||
@ -52,6 +51,7 @@ import net.md_5.bungee.protocol.packet.Team;
|
||||
import net.md_5.bungee.protocol.packet.Title;
|
||||
import net.md_5.bungee.protocol.packet.TitleTimes;
|
||||
import net.md_5.bungee.protocol.packet.Transfer;
|
||||
import net.md_5.bungee.protocol.packet.UnsignedClientCommand;
|
||||
import net.md_5.bungee.protocol.packet.ViewDistance;
|
||||
|
||||
public abstract class AbstractPacketHandler
|
||||
@ -105,7 +105,7 @@ public abstract class AbstractPacketHandler
|
||||
{
|
||||
}
|
||||
|
||||
public void handle(ClientCommandSigned command) throws Exception
|
||||
public void handle(UnsignedClientCommand command) throws Exception
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -14,7 +14,6 @@ import net.md_5.bungee.protocol.packet.Chat;
|
||||
import net.md_5.bungee.protocol.packet.ClearTitles;
|
||||
import net.md_5.bungee.protocol.packet.ClientChat;
|
||||
import net.md_5.bungee.protocol.packet.ClientCommand;
|
||||
import net.md_5.bungee.protocol.packet.ClientCommandSigned;
|
||||
import net.md_5.bungee.protocol.packet.ClientSettings;
|
||||
import net.md_5.bungee.protocol.packet.Commands;
|
||||
import net.md_5.bungee.protocol.packet.CookieRequest;
|
||||
@ -58,6 +57,7 @@ import net.md_5.bungee.protocol.packet.Team;
|
||||
import net.md_5.bungee.protocol.packet.Title;
|
||||
import net.md_5.bungee.protocol.packet.TitleTimes;
|
||||
import net.md_5.bungee.protocol.packet.Transfer;
|
||||
import net.md_5.bungee.protocol.packet.UnsignedClientCommand;
|
||||
import net.md_5.bungee.protocol.packet.ViewDistance;
|
||||
|
||||
public enum Protocol
|
||||
@ -529,12 +529,13 @@ public enum Protocol
|
||||
ClientCommand.class,
|
||||
ClientCommand::new,
|
||||
map( ProtocolConstants.MINECRAFT_1_19, 0x03 ),
|
||||
map( ProtocolConstants.MINECRAFT_1_19_1, 0x04 )
|
||||
map( ProtocolConstants.MINECRAFT_1_19_1, 0x04 ),
|
||||
map( ProtocolConstants.MINECRAFT_1_20_5, 0x05 )
|
||||
);
|
||||
TO_SERVER.registerPacket(
|
||||
ClientCommandSigned.class,
|
||||
ClientCommandSigned::new,
|
||||
map( ProtocolConstants.MINECRAFT_1_20_5, 0x05 )
|
||||
UnsignedClientCommand.class,
|
||||
UnsignedClientCommand::new,
|
||||
map( ProtocolConstants.MINECRAFT_1_20_5, 0x04 )
|
||||
);
|
||||
TO_SERVER.registerPacket(
|
||||
ClientChat.class,
|
||||
|
@ -33,11 +33,6 @@ public class ClientCommand extends DefinedPacket
|
||||
public void read(ByteBuf buf, ProtocolConstants.Direction direction, int protocolVersion)
|
||||
{
|
||||
command = readString( buf, 256 );
|
||||
if ( protocolVersion >= ProtocolConstants.MINECRAFT_1_20_5 )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
timestamp = buf.readLong();
|
||||
salt = buf.readLong();
|
||||
|
||||
@ -79,11 +74,6 @@ public class ClientCommand extends DefinedPacket
|
||||
public void write(ByteBuf buf, ProtocolConstants.Direction direction, int protocolVersion)
|
||||
{
|
||||
writeString( command, buf );
|
||||
if ( protocolVersion >= ProtocolConstants.MINECRAFT_1_20_5 )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
buf.writeLong( timestamp );
|
||||
buf.writeLong( salt );
|
||||
|
||||
|
@ -1,111 +0,0 @@
|
||||
package net.md_5.bungee.protocol.packet;
|
||||
|
||||
import com.google.common.base.Preconditions;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.NoArgsConstructor;
|
||||
import net.md_5.bungee.protocol.AbstractPacketHandler;
|
||||
import net.md_5.bungee.protocol.ChatChain;
|
||||
import net.md_5.bungee.protocol.DefinedPacket;
|
||||
import net.md_5.bungee.protocol.ProtocolConstants;
|
||||
import net.md_5.bungee.protocol.SeenMessages;
|
||||
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
public class ClientCommandSigned extends DefinedPacket
|
||||
{
|
||||
|
||||
private String command;
|
||||
private long timestamp;
|
||||
private long salt;
|
||||
private Map<String, byte[]> signatures;
|
||||
private boolean signedPreview;
|
||||
private ChatChain chain;
|
||||
private SeenMessages seenMessages;
|
||||
|
||||
@Override
|
||||
public void read(ByteBuf buf, ProtocolConstants.Direction direction, int protocolVersion)
|
||||
{
|
||||
command = readString( buf, 256 );
|
||||
timestamp = buf.readLong();
|
||||
salt = buf.readLong();
|
||||
|
||||
int cnt = readVarInt( buf );
|
||||
Preconditions.checkArgument( cnt <= 8, "Too many signatures" );
|
||||
signatures = new HashMap<>( cnt );
|
||||
for ( int i = 0; i < cnt; i++ )
|
||||
{
|
||||
String name = readString( buf, 16 );
|
||||
byte[] signature;
|
||||
|
||||
if ( protocolVersion >= ProtocolConstants.MINECRAFT_1_19_3 )
|
||||
{
|
||||
signature = new byte[ 256 ];
|
||||
buf.readBytes( signature );
|
||||
} else
|
||||
{
|
||||
signature = readArray( buf );
|
||||
}
|
||||
signatures.put( name, signature );
|
||||
}
|
||||
|
||||
if ( protocolVersion < ProtocolConstants.MINECRAFT_1_19_3 )
|
||||
{
|
||||
signedPreview = buf.readBoolean();
|
||||
}
|
||||
if ( protocolVersion >= ProtocolConstants.MINECRAFT_1_19_3 )
|
||||
{
|
||||
seenMessages = new SeenMessages();
|
||||
seenMessages.read( buf, direction, protocolVersion );
|
||||
} else if ( protocolVersion >= ProtocolConstants.MINECRAFT_1_19_1 )
|
||||
{
|
||||
chain = new ChatChain();
|
||||
chain.read( buf, direction, protocolVersion );
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void write(ByteBuf buf, ProtocolConstants.Direction direction, int protocolVersion)
|
||||
{
|
||||
writeString( command, buf );
|
||||
buf.writeLong( timestamp );
|
||||
buf.writeLong( salt );
|
||||
|
||||
writeVarInt( signatures.size(), buf );
|
||||
for ( Map.Entry<String, byte[]> entry : signatures.entrySet() )
|
||||
{
|
||||
writeString( entry.getKey(), buf );
|
||||
if ( protocolVersion >= ProtocolConstants.MINECRAFT_1_19_3 )
|
||||
{
|
||||
buf.writeBytes( entry.getValue() );
|
||||
} else
|
||||
{
|
||||
writeArray( entry.getValue(), buf );
|
||||
}
|
||||
}
|
||||
|
||||
if ( protocolVersion < ProtocolConstants.MINECRAFT_1_19_3 )
|
||||
{
|
||||
buf.writeBoolean( signedPreview );
|
||||
}
|
||||
if ( protocolVersion >= ProtocolConstants.MINECRAFT_1_19_3 )
|
||||
{
|
||||
seenMessages.write( buf, direction, protocolVersion );
|
||||
} else if ( protocolVersion >= ProtocolConstants.MINECRAFT_1_19_1 )
|
||||
{
|
||||
chain.write( buf, direction, protocolVersion );
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handle(AbstractPacketHandler handler) throws Exception
|
||||
{
|
||||
handler.handle( this );
|
||||
}
|
||||
}
|
@ -0,0 +1,38 @@
|
||||
package net.md_5.bungee.protocol.packet;
|
||||
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.NoArgsConstructor;
|
||||
import net.md_5.bungee.protocol.AbstractPacketHandler;
|
||||
import net.md_5.bungee.protocol.DefinedPacket;
|
||||
import net.md_5.bungee.protocol.ProtocolConstants;
|
||||
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
public class UnsignedClientCommand extends DefinedPacket
|
||||
{
|
||||
|
||||
private String command;
|
||||
|
||||
@Override
|
||||
public void read(ByteBuf buf, ProtocolConstants.Direction direction, int protocolVersion)
|
||||
{
|
||||
command = readString( buf, 256 );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void write(ByteBuf buf, ProtocolConstants.Direction direction, int protocolVersion)
|
||||
{
|
||||
writeString( command, buf );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handle(AbstractPacketHandler handler) throws Exception
|
||||
{
|
||||
handler.handle( this );
|
||||
}
|
||||
}
|
@ -31,7 +31,6 @@ import net.md_5.bungee.protocol.ProtocolConstants;
|
||||
import net.md_5.bungee.protocol.packet.Chat;
|
||||
import net.md_5.bungee.protocol.packet.ClientChat;
|
||||
import net.md_5.bungee.protocol.packet.ClientCommand;
|
||||
import net.md_5.bungee.protocol.packet.ClientCommandSigned;
|
||||
import net.md_5.bungee.protocol.packet.ClientSettings;
|
||||
import net.md_5.bungee.protocol.packet.CookieResponse;
|
||||
import net.md_5.bungee.protocol.packet.FinishConfiguration;
|
||||
@ -43,6 +42,7 @@ import net.md_5.bungee.protocol.packet.PluginMessage;
|
||||
import net.md_5.bungee.protocol.packet.StartConfiguration;
|
||||
import net.md_5.bungee.protocol.packet.TabCompleteRequest;
|
||||
import net.md_5.bungee.protocol.packet.TabCompleteResponse;
|
||||
import net.md_5.bungee.protocol.packet.UnsignedClientCommand;
|
||||
import net.md_5.bungee.util.AllowedCharacters;
|
||||
|
||||
public class UpstreamBridge extends PacketHandler
|
||||
@ -198,7 +198,7 @@ public class UpstreamBridge extends PacketHandler
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handle(ClientCommandSigned command) throws Exception
|
||||
public void handle(UnsignedClientCommand command) throws Exception
|
||||
{
|
||||
handleChat( "/" + command.getCommand() );
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user