Mirror von
https://github.com/PaperMC/Velocity.git
synchronisiert 2024-11-16 21:10:30 +01:00
Updated the packet classes to include the "Packet" suffix (#1202)
* Updated the packet classes to include the "Packet" suffix * Fixed test checkstyle
Dieser Commit ist enthalten in:
Ursprung
75e24a0c59
Commit
2ac8751337
@ -48,6 +48,7 @@ import com.velocitypowered.proxy.protocol.netty.MinecraftDecoder;
|
|||||||
import com.velocitypowered.proxy.protocol.netty.MinecraftEncoder;
|
import com.velocitypowered.proxy.protocol.netty.MinecraftEncoder;
|
||||||
import com.velocitypowered.proxy.protocol.netty.MinecraftVarintLengthEncoder;
|
import com.velocitypowered.proxy.protocol.netty.MinecraftVarintLengthEncoder;
|
||||||
import com.velocitypowered.proxy.protocol.netty.PlayPacketQueueHandler;
|
import com.velocitypowered.proxy.protocol.netty.PlayPacketQueueHandler;
|
||||||
|
import com.velocitypowered.proxy.protocol.packet.SetCompressionPacket;
|
||||||
import com.velocitypowered.proxy.util.except.QuietDecoderException;
|
import com.velocitypowered.proxy.util.except.QuietDecoderException;
|
||||||
import io.netty.buffer.ByteBuf;
|
import io.netty.buffer.ByteBuf;
|
||||||
import io.netty.channel.Channel;
|
import io.netty.channel.Channel;
|
||||||
@ -501,7 +502,7 @@ public class MinecraftConnection extends ChannelInboundHandlerAdapter {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the compression threshold on the connection. You are responsible for sending {@link
|
* Sets the compression threshold on the connection. You are responsible for sending {@link
|
||||||
* com.velocitypowered.proxy.protocol.packet.SetCompression} beforehand.
|
* SetCompressionPacket} beforehand.
|
||||||
*
|
*
|
||||||
* @param threshold the compression threshold to use
|
* @param threshold the compression threshold to use
|
||||||
*/
|
*/
|
||||||
|
@ -18,52 +18,52 @@
|
|||||||
package com.velocitypowered.proxy.connection;
|
package com.velocitypowered.proxy.connection;
|
||||||
|
|
||||||
import com.velocitypowered.proxy.protocol.MinecraftPacket;
|
import com.velocitypowered.proxy.protocol.MinecraftPacket;
|
||||||
import com.velocitypowered.proxy.protocol.packet.AvailableCommands;
|
import com.velocitypowered.proxy.protocol.packet.AvailableCommandsPacket;
|
||||||
import com.velocitypowered.proxy.protocol.packet.BossBar;
|
import com.velocitypowered.proxy.protocol.packet.BossBarPacket;
|
||||||
import com.velocitypowered.proxy.protocol.packet.ClientSettings;
|
import com.velocitypowered.proxy.protocol.packet.ClientSettingsPacket;
|
||||||
import com.velocitypowered.proxy.protocol.packet.Disconnect;
|
import com.velocitypowered.proxy.protocol.packet.DisconnectPacket;
|
||||||
import com.velocitypowered.proxy.protocol.packet.EncryptionRequest;
|
import com.velocitypowered.proxy.protocol.packet.EncryptionRequestPacket;
|
||||||
import com.velocitypowered.proxy.protocol.packet.EncryptionResponse;
|
import com.velocitypowered.proxy.protocol.packet.EncryptionResponsePacket;
|
||||||
import com.velocitypowered.proxy.protocol.packet.Handshake;
|
import com.velocitypowered.proxy.protocol.packet.HandshakePacket;
|
||||||
import com.velocitypowered.proxy.protocol.packet.HeaderAndFooter;
|
import com.velocitypowered.proxy.protocol.packet.HeaderAndFooterPacket;
|
||||||
import com.velocitypowered.proxy.protocol.packet.JoinGame;
|
import com.velocitypowered.proxy.protocol.packet.JoinGamePacket;
|
||||||
import com.velocitypowered.proxy.protocol.packet.KeepAlive;
|
import com.velocitypowered.proxy.protocol.packet.KeepAlivePacket;
|
||||||
import com.velocitypowered.proxy.protocol.packet.LegacyHandshake;
|
import com.velocitypowered.proxy.protocol.packet.LegacyHandshakePacket;
|
||||||
import com.velocitypowered.proxy.protocol.packet.LegacyPing;
|
import com.velocitypowered.proxy.protocol.packet.LegacyPingPacket;
|
||||||
import com.velocitypowered.proxy.protocol.packet.LegacyPlayerListItem;
|
import com.velocitypowered.proxy.protocol.packet.LegacyPlayerListItemPacket;
|
||||||
import com.velocitypowered.proxy.protocol.packet.LoginAcknowledged;
|
import com.velocitypowered.proxy.protocol.packet.LoginAcknowledgedPacket;
|
||||||
import com.velocitypowered.proxy.protocol.packet.LoginPluginMessage;
|
import com.velocitypowered.proxy.protocol.packet.LoginPluginMessagePacket;
|
||||||
import com.velocitypowered.proxy.protocol.packet.LoginPluginResponse;
|
import com.velocitypowered.proxy.protocol.packet.LoginPluginResponsePacket;
|
||||||
import com.velocitypowered.proxy.protocol.packet.PingIdentify;
|
import com.velocitypowered.proxy.protocol.packet.PingIdentifyPacket;
|
||||||
import com.velocitypowered.proxy.protocol.packet.PluginMessage;
|
import com.velocitypowered.proxy.protocol.packet.PluginMessagePacket;
|
||||||
import com.velocitypowered.proxy.protocol.packet.RemovePlayerInfo;
|
import com.velocitypowered.proxy.protocol.packet.RemovePlayerInfoPacket;
|
||||||
import com.velocitypowered.proxy.protocol.packet.RemoveResourcePack;
|
import com.velocitypowered.proxy.protocol.packet.RemoveResourcePackPacket;
|
||||||
import com.velocitypowered.proxy.protocol.packet.ResourcePackRequest;
|
import com.velocitypowered.proxy.protocol.packet.ResourcePackRequestPacket;
|
||||||
import com.velocitypowered.proxy.protocol.packet.ResourcePackResponse;
|
import com.velocitypowered.proxy.protocol.packet.ResourcePackResponsePacket;
|
||||||
import com.velocitypowered.proxy.protocol.packet.Respawn;
|
import com.velocitypowered.proxy.protocol.packet.RespawnPacket;
|
||||||
import com.velocitypowered.proxy.protocol.packet.ServerData;
|
import com.velocitypowered.proxy.protocol.packet.ServerDataPacket;
|
||||||
import com.velocitypowered.proxy.protocol.packet.ServerLogin;
|
import com.velocitypowered.proxy.protocol.packet.ServerLoginPacket;
|
||||||
import com.velocitypowered.proxy.protocol.packet.ServerLoginSuccess;
|
import com.velocitypowered.proxy.protocol.packet.ServerLoginSuccessPacket;
|
||||||
import com.velocitypowered.proxy.protocol.packet.SetCompression;
|
import com.velocitypowered.proxy.protocol.packet.SetCompressionPacket;
|
||||||
import com.velocitypowered.proxy.protocol.packet.StatusPing;
|
import com.velocitypowered.proxy.protocol.packet.StatusPingPacket;
|
||||||
import com.velocitypowered.proxy.protocol.packet.StatusRequest;
|
import com.velocitypowered.proxy.protocol.packet.StatusRequestPacket;
|
||||||
import com.velocitypowered.proxy.protocol.packet.StatusResponse;
|
import com.velocitypowered.proxy.protocol.packet.StatusResponsePacket;
|
||||||
import com.velocitypowered.proxy.protocol.packet.TabCompleteRequest;
|
import com.velocitypowered.proxy.protocol.packet.TabCompleteRequestPacket;
|
||||||
import com.velocitypowered.proxy.protocol.packet.TabCompleteResponse;
|
import com.velocitypowered.proxy.protocol.packet.TabCompleteResponsePacket;
|
||||||
import com.velocitypowered.proxy.protocol.packet.UpsertPlayerInfo;
|
import com.velocitypowered.proxy.protocol.packet.UpsertPlayerInfoPacket;
|
||||||
import com.velocitypowered.proxy.protocol.packet.chat.ChatAcknowledgement;
|
import com.velocitypowered.proxy.protocol.packet.chat.ChatAcknowledgementPacket;
|
||||||
import com.velocitypowered.proxy.protocol.packet.chat.PlayerChatCompletion;
|
import com.velocitypowered.proxy.protocol.packet.chat.PlayerChatCompletionPacket;
|
||||||
import com.velocitypowered.proxy.protocol.packet.chat.SystemChat;
|
import com.velocitypowered.proxy.protocol.packet.chat.SystemChatPacket;
|
||||||
import com.velocitypowered.proxy.protocol.packet.chat.keyed.KeyedPlayerChat;
|
import com.velocitypowered.proxy.protocol.packet.chat.keyed.KeyedPlayerChatPacket;
|
||||||
import com.velocitypowered.proxy.protocol.packet.chat.keyed.KeyedPlayerCommand;
|
import com.velocitypowered.proxy.protocol.packet.chat.keyed.KeyedPlayerCommandPacket;
|
||||||
import com.velocitypowered.proxy.protocol.packet.chat.legacy.LegacyChat;
|
import com.velocitypowered.proxy.protocol.packet.chat.legacy.LegacyChatPacket;
|
||||||
import com.velocitypowered.proxy.protocol.packet.chat.session.SessionPlayerChat;
|
import com.velocitypowered.proxy.protocol.packet.chat.session.SessionPlayerChatPacket;
|
||||||
import com.velocitypowered.proxy.protocol.packet.chat.session.SessionPlayerCommand;
|
import com.velocitypowered.proxy.protocol.packet.chat.session.SessionPlayerCommandPacket;
|
||||||
import com.velocitypowered.proxy.protocol.packet.config.ActiveFeatures;
|
import com.velocitypowered.proxy.protocol.packet.config.ActiveFeaturesPacket;
|
||||||
import com.velocitypowered.proxy.protocol.packet.config.FinishedUpdate;
|
import com.velocitypowered.proxy.protocol.packet.config.FinishedUpdatePacket;
|
||||||
import com.velocitypowered.proxy.protocol.packet.config.RegistrySync;
|
import com.velocitypowered.proxy.protocol.packet.config.RegistrySyncPacket;
|
||||||
import com.velocitypowered.proxy.protocol.packet.config.StartUpdate;
|
import com.velocitypowered.proxy.protocol.packet.config.StartUpdatePacket;
|
||||||
import com.velocitypowered.proxy.protocol.packet.config.TagsUpdate;
|
import com.velocitypowered.proxy.protocol.packet.config.TagsUpdatePacket;
|
||||||
import com.velocitypowered.proxy.protocol.packet.title.LegacyTitlePacket;
|
import com.velocitypowered.proxy.protocol.packet.title.LegacyTitlePacket;
|
||||||
import com.velocitypowered.proxy.protocol.packet.title.TitleActionbarPacket;
|
import com.velocitypowered.proxy.protocol.packet.title.TitleActionbarPacket;
|
||||||
import com.velocitypowered.proxy.protocol.packet.title.TitleClearPacket;
|
import com.velocitypowered.proxy.protocol.packet.title.TitleClearPacket;
|
||||||
@ -117,103 +117,103 @@ public interface MinecraftSessionHandler {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
default boolean handle(AvailableCommands commands) {
|
default boolean handle(AvailableCommandsPacket commands) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
default boolean handle(BossBar packet) {
|
default boolean handle(BossBarPacket packet) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
default boolean handle(LegacyChat packet) {
|
default boolean handle(LegacyChatPacket packet) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
default boolean handle(ClientSettings packet) {
|
default boolean handle(ClientSettingsPacket packet) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
default boolean handle(Disconnect packet) {
|
default boolean handle(DisconnectPacket packet) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
default boolean handle(EncryptionRequest packet) {
|
default boolean handle(EncryptionRequestPacket packet) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
default boolean handle(EncryptionResponse packet) {
|
default boolean handle(EncryptionResponsePacket packet) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
default boolean handle(Handshake packet) {
|
default boolean handle(HandshakePacket packet) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
default boolean handle(HeaderAndFooter packet) {
|
default boolean handle(HeaderAndFooterPacket packet) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
default boolean handle(JoinGame packet) {
|
default boolean handle(JoinGamePacket packet) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
default boolean handle(KeepAlive packet) {
|
default boolean handle(KeepAlivePacket packet) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
default boolean handle(LegacyHandshake packet) {
|
default boolean handle(LegacyHandshakePacket packet) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
default boolean handle(LegacyPing packet) {
|
default boolean handle(LegacyPingPacket packet) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
default boolean handle(LoginPluginMessage packet) {
|
default boolean handle(LoginPluginMessagePacket packet) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
default boolean handle(LoginPluginResponse packet) {
|
default boolean handle(LoginPluginResponsePacket packet) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
default boolean handle(PluginMessage packet) {
|
default boolean handle(PluginMessagePacket packet) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
default boolean handle(Respawn packet) {
|
default boolean handle(RespawnPacket packet) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
default boolean handle(ServerLogin packet) {
|
default boolean handle(ServerLoginPacket packet) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
default boolean handle(ServerLoginSuccess packet) {
|
default boolean handle(ServerLoginSuccessPacket packet) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
default boolean handle(SetCompression packet) {
|
default boolean handle(SetCompressionPacket packet) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
default boolean handle(StatusPing packet) {
|
default boolean handle(StatusPingPacket packet) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
default boolean handle(StatusRequest packet) {
|
default boolean handle(StatusRequestPacket packet) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
default boolean handle(StatusResponse packet) {
|
default boolean handle(StatusResponsePacket packet) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
default boolean handle(TabCompleteRequest packet) {
|
default boolean handle(TabCompleteRequestPacket packet) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
default boolean handle(TabCompleteResponse packet) {
|
default boolean handle(TabCompleteResponsePacket packet) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -241,87 +241,87 @@ public interface MinecraftSessionHandler {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
default boolean handle(LegacyPlayerListItem packet) {
|
default boolean handle(LegacyPlayerListItemPacket packet) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
default boolean handle(ResourcePackRequest packet) {
|
default boolean handle(ResourcePackRequestPacket packet) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
default boolean handle(RemoveResourcePack packet) {
|
default boolean handle(RemoveResourcePackPacket packet) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
default boolean handle(ResourcePackResponse packet) {
|
default boolean handle(ResourcePackResponsePacket packet) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
default boolean handle(KeyedPlayerChat packet) {
|
default boolean handle(KeyedPlayerChatPacket packet) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
default boolean handle(SessionPlayerChat packet) {
|
default boolean handle(SessionPlayerChatPacket packet) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
default boolean handle(SystemChat packet) {
|
default boolean handle(SystemChatPacket packet) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
default boolean handle(KeyedPlayerCommand packet) {
|
default boolean handle(KeyedPlayerCommandPacket packet) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
default boolean handle(SessionPlayerCommand packet) {
|
default boolean handle(SessionPlayerCommandPacket packet) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
default boolean handle(PlayerChatCompletion packet) {
|
default boolean handle(PlayerChatCompletionPacket packet) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
default boolean handle(ServerData serverData) {
|
default boolean handle(ServerDataPacket serverData) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
default boolean handle(RemovePlayerInfo packet) {
|
default boolean handle(RemovePlayerInfoPacket packet) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
default boolean handle(UpsertPlayerInfo packet) {
|
default boolean handle(UpsertPlayerInfoPacket packet) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
default boolean handle(LoginAcknowledged packet) {
|
default boolean handle(LoginAcknowledgedPacket packet) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
default boolean handle(ActiveFeatures packet) {
|
default boolean handle(ActiveFeaturesPacket packet) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
default boolean handle(FinishedUpdate packet) {
|
default boolean handle(FinishedUpdatePacket packet) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
default boolean handle(RegistrySync packet) {
|
default boolean handle(RegistrySyncPacket packet) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
default boolean handle(TagsUpdate packet) {
|
default boolean handle(TagsUpdatePacket packet) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
default boolean handle(StartUpdate packet) {
|
default boolean handle(StartUpdatePacket packet) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
default boolean handle(PingIdentify pingIdentify) {
|
default boolean handle(PingIdentifyPacket pingIdentify) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
default boolean handle(ChatAcknowledgement chatAcknowledgement) {
|
default boolean handle(ChatAcknowledgementPacket chatAcknowledgement) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -19,7 +19,7 @@ package com.velocitypowered.proxy.connection.backend;
|
|||||||
|
|
||||||
import com.velocitypowered.proxy.connection.client.ConnectedPlayer;
|
import com.velocitypowered.proxy.connection.client.ConnectedPlayer;
|
||||||
import com.velocitypowered.proxy.connection.forge.legacy.LegacyForgeHandshakeBackendPhase;
|
import com.velocitypowered.proxy.connection.forge.legacy.LegacyForgeHandshakeBackendPhase;
|
||||||
import com.velocitypowered.proxy.protocol.packet.PluginMessage;
|
import com.velocitypowered.proxy.protocol.packet.PluginMessagePacket;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Provides connection phase specific actions.
|
* Provides connection phase specific actions.
|
||||||
@ -39,7 +39,7 @@ public interface BackendConnectionPhase {
|
|||||||
*/
|
*/
|
||||||
default boolean handle(VelocityServerConnection server,
|
default boolean handle(VelocityServerConnection server,
|
||||||
ConnectedPlayer player,
|
ConnectedPlayer player,
|
||||||
PluginMessage message) {
|
PluginMessagePacket message) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -19,7 +19,7 @@ package com.velocitypowered.proxy.connection.backend;
|
|||||||
|
|
||||||
import com.velocitypowered.proxy.connection.client.ConnectedPlayer;
|
import com.velocitypowered.proxy.connection.client.ConnectedPlayer;
|
||||||
import com.velocitypowered.proxy.connection.forge.legacy.LegacyForgeHandshakeBackendPhase;
|
import com.velocitypowered.proxy.connection.forge.legacy.LegacyForgeHandshakeBackendPhase;
|
||||||
import com.velocitypowered.proxy.protocol.packet.PluginMessage;
|
import com.velocitypowered.proxy.protocol.packet.PluginMessagePacket;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Contains Vanilla {@link BackendConnectionPhase}s.
|
* Contains Vanilla {@link BackendConnectionPhase}s.
|
||||||
@ -47,7 +47,7 @@ public final class BackendConnectionPhases {
|
|||||||
@Override
|
@Override
|
||||||
public boolean handle(VelocityServerConnection serverConn,
|
public boolean handle(VelocityServerConnection serverConn,
|
||||||
ConnectedPlayer player,
|
ConnectedPlayer player,
|
||||||
PluginMessage message) {
|
PluginMessagePacket message) {
|
||||||
// The connection may be legacy forge. If so, the Forge handler will deal with this
|
// The connection may be legacy forge. If so, the Forge handler will deal with this
|
||||||
// for us. Otherwise, we have nothing to do.
|
// for us. Otherwise, we have nothing to do.
|
||||||
return LegacyForgeHandshakeBackendPhase.NOT_STARTED.handle(serverConn, player, message);
|
return LegacyForgeHandshakeBackendPhase.NOT_STARTED.handle(serverConn, player, message);
|
||||||
|
@ -40,22 +40,22 @@ import com.velocitypowered.proxy.connection.util.ConnectionMessages;
|
|||||||
import com.velocitypowered.proxy.protocol.MinecraftPacket;
|
import com.velocitypowered.proxy.protocol.MinecraftPacket;
|
||||||
import com.velocitypowered.proxy.protocol.StateRegistry;
|
import com.velocitypowered.proxy.protocol.StateRegistry;
|
||||||
import com.velocitypowered.proxy.protocol.netty.MinecraftDecoder;
|
import com.velocitypowered.proxy.protocol.netty.MinecraftDecoder;
|
||||||
import com.velocitypowered.proxy.protocol.packet.AvailableCommands;
|
import com.velocitypowered.proxy.protocol.packet.AvailableCommandsPacket;
|
||||||
import com.velocitypowered.proxy.protocol.packet.BossBar;
|
import com.velocitypowered.proxy.protocol.packet.BossBarPacket;
|
||||||
import com.velocitypowered.proxy.protocol.packet.ClientSettings;
|
import com.velocitypowered.proxy.protocol.packet.ClientSettingsPacket;
|
||||||
import com.velocitypowered.proxy.protocol.packet.Disconnect;
|
import com.velocitypowered.proxy.protocol.packet.DisconnectPacket;
|
||||||
import com.velocitypowered.proxy.protocol.packet.KeepAlive;
|
import com.velocitypowered.proxy.protocol.packet.KeepAlivePacket;
|
||||||
import com.velocitypowered.proxy.protocol.packet.LegacyPlayerListItem;
|
import com.velocitypowered.proxy.protocol.packet.LegacyPlayerListItemPacket;
|
||||||
import com.velocitypowered.proxy.protocol.packet.PluginMessage;
|
import com.velocitypowered.proxy.protocol.packet.PluginMessagePacket;
|
||||||
import com.velocitypowered.proxy.protocol.packet.RemovePlayerInfo;
|
import com.velocitypowered.proxy.protocol.packet.RemovePlayerInfoPacket;
|
||||||
import com.velocitypowered.proxy.protocol.packet.RemoveResourcePack;
|
import com.velocitypowered.proxy.protocol.packet.RemoveResourcePackPacket;
|
||||||
import com.velocitypowered.proxy.protocol.packet.ResourcePackRequest;
|
import com.velocitypowered.proxy.protocol.packet.ResourcePackRequestPacket;
|
||||||
import com.velocitypowered.proxy.protocol.packet.ResourcePackResponse;
|
import com.velocitypowered.proxy.protocol.packet.ResourcePackResponsePacket;
|
||||||
import com.velocitypowered.proxy.protocol.packet.ServerData;
|
import com.velocitypowered.proxy.protocol.packet.ServerDataPacket;
|
||||||
import com.velocitypowered.proxy.protocol.packet.TabCompleteResponse;
|
import com.velocitypowered.proxy.protocol.packet.TabCompleteResponsePacket;
|
||||||
import com.velocitypowered.proxy.protocol.packet.UpsertPlayerInfo;
|
import com.velocitypowered.proxy.protocol.packet.UpsertPlayerInfoPacket;
|
||||||
import com.velocitypowered.proxy.protocol.packet.chat.ComponentHolder;
|
import com.velocitypowered.proxy.protocol.packet.chat.ComponentHolder;
|
||||||
import com.velocitypowered.proxy.protocol.packet.config.StartUpdate;
|
import com.velocitypowered.proxy.protocol.packet.config.StartUpdatePacket;
|
||||||
import com.velocitypowered.proxy.protocol.util.PluginMessageUtil;
|
import com.velocitypowered.proxy.protocol.util.PluginMessageUtil;
|
||||||
import io.netty.buffer.ByteBuf;
|
import io.netty.buffer.ByteBuf;
|
||||||
import io.netty.buffer.ByteBufUtil;
|
import io.netty.buffer.ByteBufUtil;
|
||||||
@ -126,7 +126,7 @@ public class BackendPlaySessionHandler implements MinecraftSessionHandler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean handle(StartUpdate packet) {
|
public boolean handle(StartUpdatePacket packet) {
|
||||||
MinecraftConnection smc = serverConn.ensureConnected();
|
MinecraftConnection smc = serverConn.ensureConnected();
|
||||||
smc.setAutoReading(false);
|
smc.setAutoReading(false);
|
||||||
// Even when not auto reading messages are still decoded. Decode them with the correct state
|
// Even when not auto reading messages are still decoded. Decode them with the correct state
|
||||||
@ -136,36 +136,36 @@ public class BackendPlaySessionHandler implements MinecraftSessionHandler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean handle(KeepAlive packet) {
|
public boolean handle(KeepAlivePacket packet) {
|
||||||
serverConn.getPendingPings().put(packet.getRandomId(), System.nanoTime());
|
serverConn.getPendingPings().put(packet.getRandomId(), System.nanoTime());
|
||||||
return false; // forwards on
|
return false; // forwards on
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean handle(ClientSettings packet) {
|
public boolean handle(ClientSettingsPacket packet) {
|
||||||
serverConn.ensureConnected().write(packet);
|
serverConn.ensureConnected().write(packet);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean handle(Disconnect packet) {
|
public boolean handle(DisconnectPacket packet) {
|
||||||
serverConn.disconnect();
|
serverConn.disconnect();
|
||||||
serverConn.getPlayer().handleConnectionException(serverConn.getServer(), packet, true);
|
serverConn.getPlayer().handleConnectionException(serverConn.getServer(), packet, true);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean handle(BossBar packet) {
|
public boolean handle(BossBarPacket packet) {
|
||||||
if (packet.getAction() == BossBar.ADD) {
|
if (packet.getAction() == BossBarPacket.ADD) {
|
||||||
playerSessionHandler.getServerBossBars().add(packet.getUuid());
|
playerSessionHandler.getServerBossBars().add(packet.getUuid());
|
||||||
} else if (packet.getAction() == BossBar.REMOVE) {
|
} else if (packet.getAction() == BossBarPacket.REMOVE) {
|
||||||
playerSessionHandler.getServerBossBars().remove(packet.getUuid());
|
playerSessionHandler.getServerBossBars().remove(packet.getUuid());
|
||||||
}
|
}
|
||||||
return false; // forward
|
return false; // forward
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean handle(ResourcePackRequest packet) {
|
public boolean handle(ResourcePackRequestPacket packet) {
|
||||||
ResourcePackInfo.Builder builder = new VelocityResourcePackInfo.BuilderImpl(
|
ResourcePackInfo.Builder builder = new VelocityResourcePackInfo.BuilderImpl(
|
||||||
Preconditions.checkNotNull(packet.getUrl()))
|
Preconditions.checkNotNull(packet.getUrl()))
|
||||||
.setId(packet.getId())
|
.setId(packet.getId())
|
||||||
@ -196,7 +196,7 @@ public class BackendPlaySessionHandler implements MinecraftSessionHandler {
|
|||||||
|
|
||||||
serverConn.getPlayer().queueResourcePack(toSend);
|
serverConn.getPlayer().queueResourcePack(toSend);
|
||||||
} else if (serverConn.getConnection() != null) {
|
} else if (serverConn.getConnection() != null) {
|
||||||
serverConn.getConnection().write(new ResourcePackResponse(
|
serverConn.getConnection().write(new ResourcePackResponsePacket(
|
||||||
packet.getId(),
|
packet.getId(),
|
||||||
packet.getHash(),
|
packet.getHash(),
|
||||||
PlayerResourcePackStatusEvent.Status.DECLINED
|
PlayerResourcePackStatusEvent.Status.DECLINED
|
||||||
@ -204,7 +204,7 @@ public class BackendPlaySessionHandler implements MinecraftSessionHandler {
|
|||||||
}
|
}
|
||||||
}, playerConnection.eventLoop()).exceptionally((ex) -> {
|
}, playerConnection.eventLoop()).exceptionally((ex) -> {
|
||||||
if (serverConn.getConnection() != null) {
|
if (serverConn.getConnection() != null) {
|
||||||
serverConn.getConnection().write(new ResourcePackResponse(
|
serverConn.getConnection().write(new ResourcePackResponsePacket(
|
||||||
packet.getId(),
|
packet.getId(),
|
||||||
packet.getHash(),
|
packet.getHash(),
|
||||||
PlayerResourcePackStatusEvent.Status.DECLINED
|
PlayerResourcePackStatusEvent.Status.DECLINED
|
||||||
@ -218,12 +218,12 @@ public class BackendPlaySessionHandler implements MinecraftSessionHandler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean handle(RemoveResourcePack packet) {
|
public boolean handle(RemoveResourcePackPacket packet) {
|
||||||
return false; //TODO
|
return false; //TODO
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean handle(PluginMessage packet) {
|
public boolean handle(PluginMessagePacket packet) {
|
||||||
if (bungeecordMessageResponder.process(packet)) {
|
if (bungeecordMessageResponder.process(packet)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -234,8 +234,9 @@ public class BackendPlaySessionHandler implements MinecraftSessionHandler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (PluginMessageUtil.isMcBrand(packet)) {
|
if (PluginMessageUtil.isMcBrand(packet)) {
|
||||||
PluginMessage rewritten = PluginMessageUtil.rewriteMinecraftBrand(packet, server.getVersion(),
|
PluginMessagePacket rewritten = PluginMessageUtil
|
||||||
playerConnection.getProtocolVersion());
|
.rewriteMinecraftBrand(packet,
|
||||||
|
server.getVersion(), playerConnection.getProtocolVersion());
|
||||||
playerConnection.write(rewritten);
|
playerConnection.write(rewritten);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -254,7 +255,8 @@ public class BackendPlaySessionHandler implements MinecraftSessionHandler {
|
|||||||
PluginMessageEvent event = new PluginMessageEvent(serverConn, serverConn.getPlayer(), id, copy);
|
PluginMessageEvent event = new PluginMessageEvent(serverConn, serverConn.getPlayer(), id, copy);
|
||||||
server.getEventManager().fire(event).thenAcceptAsync(pme -> {
|
server.getEventManager().fire(event).thenAcceptAsync(pme -> {
|
||||||
if (pme.getResult().isAllowed() && !playerConnection.isClosed()) {
|
if (pme.getResult().isAllowed() && !playerConnection.isClosed()) {
|
||||||
PluginMessage copied = new PluginMessage(packet.getChannel(), Unpooled.wrappedBuffer(copy));
|
PluginMessagePacket copied = new PluginMessagePacket(
|
||||||
|
packet.getChannel(), Unpooled.wrappedBuffer(copy));
|
||||||
playerConnection.write(copied);
|
playerConnection.write(copied);
|
||||||
}
|
}
|
||||||
}, playerConnection.eventLoop()).exceptionally((ex) -> {
|
}, playerConnection.eventLoop()).exceptionally((ex) -> {
|
||||||
@ -265,31 +267,31 @@ public class BackendPlaySessionHandler implements MinecraftSessionHandler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean handle(TabCompleteResponse packet) {
|
public boolean handle(TabCompleteResponsePacket packet) {
|
||||||
playerSessionHandler.handleTabCompleteResponse(packet);
|
playerSessionHandler.handleTabCompleteResponse(packet);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean handle(LegacyPlayerListItem packet) {
|
public boolean handle(LegacyPlayerListItemPacket packet) {
|
||||||
serverConn.getPlayer().getTabList().processLegacy(packet);
|
serverConn.getPlayer().getTabList().processLegacy(packet);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean handle(UpsertPlayerInfo packet) {
|
public boolean handle(UpsertPlayerInfoPacket packet) {
|
||||||
serverConn.getPlayer().getTabList().processUpdate(packet);
|
serverConn.getPlayer().getTabList().processUpdate(packet);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean handle(RemovePlayerInfo packet) {
|
public boolean handle(RemovePlayerInfoPacket packet) {
|
||||||
serverConn.getPlayer().getTabList().processRemove(packet);
|
serverConn.getPlayer().getTabList().processRemove(packet);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean handle(AvailableCommands commands) {
|
public boolean handle(AvailableCommandsPacket commands) {
|
||||||
RootCommandNode<CommandSource> rootNode = commands.getRootNode();
|
RootCommandNode<CommandSource> rootNode = commands.getRootNode();
|
||||||
if (server.getConfiguration().isAnnounceProxyCommands()) {
|
if (server.getConfiguration().isAnnounceProxyCommands()) {
|
||||||
// Inject commands from the proxy.
|
// Inject commands from the proxy.
|
||||||
@ -308,12 +310,12 @@ public class BackendPlaySessionHandler implements MinecraftSessionHandler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean handle(ServerData packet) {
|
public boolean handle(ServerDataPacket packet) {
|
||||||
server.getServerListPingHandler().getInitialPing(this.serverConn.getPlayer()).thenComposeAsync(
|
server.getServerListPingHandler().getInitialPing(this.serverConn.getPlayer()).thenComposeAsync(
|
||||||
ping -> server.getEventManager()
|
ping -> server.getEventManager()
|
||||||
.fire(new ProxyPingEvent(this.serverConn.getPlayer(), ping)),
|
.fire(new ProxyPingEvent(this.serverConn.getPlayer(), ping)),
|
||||||
playerConnection.eventLoop()).thenAcceptAsync(pingEvent -> this.playerConnection.write(
|
playerConnection.eventLoop()).thenAcceptAsync(pingEvent -> this.playerConnection.write(
|
||||||
new ServerData(new ComponentHolder(
|
new ServerDataPacket(new ComponentHolder(
|
||||||
this.serverConn.ensureConnected().getProtocolVersion(),
|
this.serverConn.ensureConnected().getProtocolVersion(),
|
||||||
pingEvent.getPing().getDescriptionComponent()),
|
pingEvent.getPing().getDescriptionComponent()),
|
||||||
pingEvent.getPing().getFavicon().orElse(null), packet.isSecureChatEnforced())),
|
pingEvent.getPing().getFavicon().orElse(null), packet.isSecureChatEnforced())),
|
||||||
@ -323,8 +325,8 @@ public class BackendPlaySessionHandler implements MinecraftSessionHandler {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void handleGeneric(MinecraftPacket packet) {
|
public void handleGeneric(MinecraftPacket packet) {
|
||||||
if (packet instanceof PluginMessage) {
|
if (packet instanceof PluginMessagePacket) {
|
||||||
((PluginMessage) packet).retain();
|
((PluginMessagePacket) packet).retain();
|
||||||
}
|
}
|
||||||
playerConnection.delayedWrite(packet);
|
playerConnection.delayedWrite(packet);
|
||||||
if (++packetsFlushed >= MAXIMUM_PACKETS_TO_FLUSH) {
|
if (++packetsFlushed >= MAXIMUM_PACKETS_TO_FLUSH) {
|
||||||
@ -365,7 +367,7 @@ public class BackendPlaySessionHandler implements MinecraftSessionHandler {
|
|||||||
if (!serverConn.isGracefulDisconnect() && !exceptionTriggered) {
|
if (!serverConn.isGracefulDisconnect() && !exceptionTriggered) {
|
||||||
if (server.getConfiguration().isFailoverOnUnexpectedServerDisconnect()) {
|
if (server.getConfiguration().isFailoverOnUnexpectedServerDisconnect()) {
|
||||||
serverConn.getPlayer().handleConnectionException(serverConn.getServer(),
|
serverConn.getPlayer().handleConnectionException(serverConn.getServer(),
|
||||||
Disconnect.create(ConnectionMessages.INTERNAL_SERVER_CONNECTION_ERROR,
|
DisconnectPacket.create(ConnectionMessages.INTERNAL_SERVER_CONNECTION_ERROR,
|
||||||
serverConn.getPlayer().getProtocolVersion(), false), true);
|
serverConn.getPlayer().getProtocolVersion(), false), true);
|
||||||
} else {
|
} else {
|
||||||
serverConn.getPlayer().disconnect(ConnectionMessages.INTERNAL_SERVER_CONNECTION_ERROR);
|
serverConn.getPlayer().disconnect(ConnectionMessages.INTERNAL_SERVER_CONNECTION_ERROR);
|
||||||
|
@ -28,7 +28,7 @@ import com.velocitypowered.api.util.UuidUtils;
|
|||||||
import com.velocitypowered.proxy.VelocityServer;
|
import com.velocitypowered.proxy.VelocityServer;
|
||||||
import com.velocitypowered.proxy.connection.MinecraftConnection;
|
import com.velocitypowered.proxy.connection.MinecraftConnection;
|
||||||
import com.velocitypowered.proxy.connection.client.ConnectedPlayer;
|
import com.velocitypowered.proxy.connection.client.ConnectedPlayer;
|
||||||
import com.velocitypowered.proxy.protocol.packet.PluginMessage;
|
import com.velocitypowered.proxy.protocol.packet.PluginMessagePacket;
|
||||||
import com.velocitypowered.proxy.protocol.util.ByteBufDataInput;
|
import com.velocitypowered.proxy.protocol.util.ByteBufDataInput;
|
||||||
import com.velocitypowered.proxy.protocol.util.ByteBufDataOutput;
|
import com.velocitypowered.proxy.protocol.util.ByteBufDataOutput;
|
||||||
import com.velocitypowered.proxy.server.VelocityRegisteredServer;
|
import com.velocitypowered.proxy.server.VelocityRegisteredServer;
|
||||||
@ -68,7 +68,7 @@ public class BungeeCordMessageResponder {
|
|||||||
this.player = player;
|
this.player = player;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean isBungeeCordMessage(PluginMessage message) {
|
public static boolean isBungeeCordMessage(PluginMessagePacket message) {
|
||||||
return MODERN_CHANNEL.getId().equals(message.getChannel()) || LEGACY_CHANNEL.getId()
|
return MODERN_CHANNEL.getId().equals(message.getChannel()) || LEGACY_CHANNEL.getId()
|
||||||
.equals(message.getChannel());
|
.equals(message.getChannel());
|
||||||
}
|
}
|
||||||
@ -310,11 +310,11 @@ public class BungeeCordMessageResponder {
|
|||||||
private static void sendServerResponse(ConnectedPlayer player, ByteBuf buf) {
|
private static void sendServerResponse(ConnectedPlayer player, ByteBuf buf) {
|
||||||
MinecraftConnection serverConnection = player.ensureAndGetCurrentServer().ensureConnected();
|
MinecraftConnection serverConnection = player.ensureAndGetCurrentServer().ensureConnected();
|
||||||
String chan = getBungeeCordChannel(serverConnection.getProtocolVersion());
|
String chan = getBungeeCordChannel(serverConnection.getProtocolVersion());
|
||||||
PluginMessage msg = new PluginMessage(chan, buf);
|
PluginMessagePacket msg = new PluginMessagePacket(chan, buf);
|
||||||
serverConnection.write(msg);
|
serverConnection.write(msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean process(PluginMessage message) {
|
boolean process(PluginMessagePacket message) {
|
||||||
if (!proxy.getConfiguration().isBungeePluginChannelEnabled()) {
|
if (!proxy.getConfiguration().isBungeePluginChannelEnabled()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -33,15 +33,15 @@ import com.velocitypowered.proxy.connection.util.ConnectionRequestResults.Impl;
|
|||||||
import com.velocitypowered.proxy.protocol.MinecraftPacket;
|
import com.velocitypowered.proxy.protocol.MinecraftPacket;
|
||||||
import com.velocitypowered.proxy.protocol.StateRegistry;
|
import com.velocitypowered.proxy.protocol.StateRegistry;
|
||||||
import com.velocitypowered.proxy.protocol.netty.MinecraftDecoder;
|
import com.velocitypowered.proxy.protocol.netty.MinecraftDecoder;
|
||||||
import com.velocitypowered.proxy.protocol.packet.Disconnect;
|
import com.velocitypowered.proxy.protocol.packet.DisconnectPacket;
|
||||||
import com.velocitypowered.proxy.protocol.packet.KeepAlive;
|
import com.velocitypowered.proxy.protocol.packet.KeepAlivePacket;
|
||||||
import com.velocitypowered.proxy.protocol.packet.PluginMessage;
|
import com.velocitypowered.proxy.protocol.packet.PluginMessagePacket;
|
||||||
import com.velocitypowered.proxy.protocol.packet.ResourcePackRequest;
|
import com.velocitypowered.proxy.protocol.packet.ResourcePackRequestPacket;
|
||||||
import com.velocitypowered.proxy.protocol.packet.ResourcePackResponse;
|
import com.velocitypowered.proxy.protocol.packet.ResourcePackResponsePacket;
|
||||||
import com.velocitypowered.proxy.protocol.packet.config.FinishedUpdate;
|
import com.velocitypowered.proxy.protocol.packet.config.FinishedUpdatePacket;
|
||||||
import com.velocitypowered.proxy.protocol.packet.config.RegistrySync;
|
import com.velocitypowered.proxy.protocol.packet.config.RegistrySyncPacket;
|
||||||
import com.velocitypowered.proxy.protocol.packet.config.StartUpdate;
|
import com.velocitypowered.proxy.protocol.packet.config.StartUpdatePacket;
|
||||||
import com.velocitypowered.proxy.protocol.packet.config.TagsUpdate;
|
import com.velocitypowered.proxy.protocol.packet.config.TagsUpdatePacket;
|
||||||
import com.velocitypowered.proxy.protocol.util.PluginMessageUtil;
|
import com.velocitypowered.proxy.protocol.util.PluginMessageUtil;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.concurrent.CompletableFuture;
|
import java.util.concurrent.CompletableFuture;
|
||||||
@ -100,25 +100,25 @@ public class ConfigSessionHandler implements MinecraftSessionHandler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean handle(StartUpdate packet) {
|
public boolean handle(StartUpdatePacket packet) {
|
||||||
serverConn.ensureConnected().write(packet);
|
serverConn.ensureConnected().write(packet);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean handle(TagsUpdate packet) {
|
public boolean handle(TagsUpdatePacket packet) {
|
||||||
serverConn.getPlayer().getConnection().write(packet);
|
serverConn.getPlayer().getConnection().write(packet);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean handle(KeepAlive packet) {
|
public boolean handle(KeepAlivePacket packet) {
|
||||||
serverConn.ensureConnected().write(packet);
|
serverConn.ensureConnected().write(packet);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean handle(ResourcePackRequest packet) {
|
public boolean handle(ResourcePackRequestPacket packet) {
|
||||||
final MinecraftConnection playerConnection = serverConn.getPlayer().getConnection();
|
final MinecraftConnection playerConnection = serverConn.getPlayer().getConnection();
|
||||||
|
|
||||||
ServerResourcePackSendEvent event =
|
ServerResourcePackSendEvent event =
|
||||||
@ -138,13 +138,13 @@ public class ConfigSessionHandler implements MinecraftSessionHandler {
|
|||||||
resourcePackToApply = null;
|
resourcePackToApply = null;
|
||||||
serverConn.getPlayer().queueResourcePack(toSend);
|
serverConn.getPlayer().queueResourcePack(toSend);
|
||||||
} else if (serverConn.getConnection() != null) {
|
} else if (serverConn.getConnection() != null) {
|
||||||
serverConn.getConnection().write(new ResourcePackResponse(packet.getId(), packet.getHash(),
|
serverConn.getConnection().write(new ResourcePackResponsePacket(
|
||||||
PlayerResourcePackStatusEvent.Status.DECLINED));
|
packet.getId(), packet.getHash(), PlayerResourcePackStatusEvent.Status.DECLINED));
|
||||||
}
|
}
|
||||||
}, playerConnection.eventLoop()).exceptionally((ex) -> {
|
}, playerConnection.eventLoop()).exceptionally((ex) -> {
|
||||||
if (serverConn.getConnection() != null) {
|
if (serverConn.getConnection() != null) {
|
||||||
serverConn.getConnection().write(new ResourcePackResponse(packet.getId(), packet.getHash(),
|
serverConn.getConnection().write(new ResourcePackResponsePacket(
|
||||||
PlayerResourcePackStatusEvent.Status.DECLINED));
|
packet.getId(), packet.getHash(), PlayerResourcePackStatusEvent.Status.DECLINED));
|
||||||
}
|
}
|
||||||
logger.error("Exception while handling resource pack send for {}", playerConnection, ex);
|
logger.error("Exception while handling resource pack send for {}", playerConnection, ex);
|
||||||
return null;
|
return null;
|
||||||
@ -154,7 +154,7 @@ public class ConfigSessionHandler implements MinecraftSessionHandler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean handle(FinishedUpdate packet) {
|
public boolean handle(FinishedUpdatePacket packet) {
|
||||||
MinecraftConnection smc = serverConn.ensureConnected();
|
MinecraftConnection smc = serverConn.ensureConnected();
|
||||||
ConnectedPlayer player = serverConn.getPlayer();
|
ConnectedPlayer player = serverConn.getPlayer();
|
||||||
ClientConfigSessionHandler configHandler =
|
ClientConfigSessionHandler configHandler =
|
||||||
@ -183,14 +183,14 @@ public class ConfigSessionHandler implements MinecraftSessionHandler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean handle(Disconnect packet) {
|
public boolean handle(DisconnectPacket packet) {
|
||||||
serverConn.disconnect();
|
serverConn.disconnect();
|
||||||
resultFuture.complete(ConnectionRequestResults.forDisconnect(packet, serverConn.getServer()));
|
resultFuture.complete(ConnectionRequestResults.forDisconnect(packet, serverConn.getServer()));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean handle(PluginMessage packet) {
|
public boolean handle(PluginMessagePacket packet) {
|
||||||
if (PluginMessageUtil.isMcBrand(packet)) {
|
if (PluginMessageUtil.isMcBrand(packet)) {
|
||||||
serverConn.getPlayer().getConnection().write(
|
serverConn.getPlayer().getConnection().write(
|
||||||
PluginMessageUtil.rewriteMinecraftBrand(packet, server.getVersion(),
|
PluginMessageUtil.rewriteMinecraftBrand(packet, server.getVersion(),
|
||||||
@ -202,7 +202,7 @@ public class ConfigSessionHandler implements MinecraftSessionHandler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean handle(RegistrySync packet) {
|
public boolean handle(RegistrySyncPacket packet) {
|
||||||
serverConn.getPlayer().getConnection().write(packet.retain());
|
serverConn.getPlayer().getConnection().write(packet.retain());
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -33,13 +33,13 @@ import com.velocitypowered.proxy.connection.util.ConnectionRequestResults;
|
|||||||
import com.velocitypowered.proxy.connection.util.ConnectionRequestResults.Impl;
|
import com.velocitypowered.proxy.connection.util.ConnectionRequestResults.Impl;
|
||||||
import com.velocitypowered.proxy.protocol.ProtocolUtils;
|
import com.velocitypowered.proxy.protocol.ProtocolUtils;
|
||||||
import com.velocitypowered.proxy.protocol.StateRegistry;
|
import com.velocitypowered.proxy.protocol.StateRegistry;
|
||||||
import com.velocitypowered.proxy.protocol.packet.Disconnect;
|
import com.velocitypowered.proxy.protocol.packet.DisconnectPacket;
|
||||||
import com.velocitypowered.proxy.protocol.packet.EncryptionRequest;
|
import com.velocitypowered.proxy.protocol.packet.EncryptionRequestPacket;
|
||||||
import com.velocitypowered.proxy.protocol.packet.LoginAcknowledged;
|
import com.velocitypowered.proxy.protocol.packet.LoginAcknowledgedPacket;
|
||||||
import com.velocitypowered.proxy.protocol.packet.LoginPluginMessage;
|
import com.velocitypowered.proxy.protocol.packet.LoginPluginMessagePacket;
|
||||||
import com.velocitypowered.proxy.protocol.packet.LoginPluginResponse;
|
import com.velocitypowered.proxy.protocol.packet.LoginPluginResponsePacket;
|
||||||
import com.velocitypowered.proxy.protocol.packet.ServerLoginSuccess;
|
import com.velocitypowered.proxy.protocol.packet.ServerLoginSuccessPacket;
|
||||||
import com.velocitypowered.proxy.protocol.packet.SetCompression;
|
import com.velocitypowered.proxy.protocol.packet.SetCompressionPacket;
|
||||||
import com.velocitypowered.proxy.util.except.QuietRuntimeException;
|
import com.velocitypowered.proxy.util.except.QuietRuntimeException;
|
||||||
import io.netty.buffer.ByteBuf;
|
import io.netty.buffer.ByteBuf;
|
||||||
import io.netty.buffer.ByteBufUtil;
|
import io.netty.buffer.ByteBufUtil;
|
||||||
@ -77,12 +77,12 @@ public class LoginSessionHandler implements MinecraftSessionHandler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean handle(EncryptionRequest packet) {
|
public boolean handle(EncryptionRequestPacket packet) {
|
||||||
throw new IllegalStateException("Backend server is online-mode!");
|
throw new IllegalStateException("Backend server is online-mode!");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean handle(LoginPluginMessage packet) {
|
public boolean handle(LoginPluginMessagePacket packet) {
|
||||||
MinecraftConnection mc = serverConn.ensureConnected();
|
MinecraftConnection mc = serverConn.ensureConnected();
|
||||||
VelocityConfiguration configuration = server.getConfiguration();
|
VelocityConfiguration configuration = server.getConfiguration();
|
||||||
if (configuration.getPlayerInfoForwardingMode() == PlayerInfoForwarding.MODERN
|
if (configuration.getPlayerInfoForwardingMode() == PlayerInfoForwarding.MODERN
|
||||||
@ -97,13 +97,14 @@ public class LoginSessionHandler implements MinecraftSessionHandler {
|
|||||||
serverConn.getPlayerRemoteAddressAsString(), serverConn.getPlayer(),
|
serverConn.getPlayerRemoteAddressAsString(), serverConn.getPlayer(),
|
||||||
requestedForwardingVersion);
|
requestedForwardingVersion);
|
||||||
|
|
||||||
LoginPluginResponse response = new LoginPluginResponse(packet.getId(), true, forwardingData);
|
LoginPluginResponsePacket response = new LoginPluginResponsePacket(
|
||||||
|
packet.getId(), true, forwardingData);
|
||||||
mc.write(response);
|
mc.write(response);
|
||||||
informationForwarded = true;
|
informationForwarded = true;
|
||||||
} else {
|
} else {
|
||||||
// Don't understand, fire event if we have subscribers
|
// Don't understand, fire event if we have subscribers
|
||||||
if (!this.server.getEventManager().hasSubscribers(ServerLoginPluginMessageEvent.class)) {
|
if (!this.server.getEventManager().hasSubscribers(ServerLoginPluginMessageEvent.class)) {
|
||||||
mc.write(new LoginPluginResponse(packet.getId(), false, Unpooled.EMPTY_BUFFER));
|
mc.write(new LoginPluginResponsePacket(packet.getId(), false, Unpooled.EMPTY_BUFFER));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -114,10 +115,10 @@ public class LoginSessionHandler implements MinecraftSessionHandler {
|
|||||||
contents, packet.getId()))
|
contents, packet.getId()))
|
||||||
.thenAcceptAsync(event -> {
|
.thenAcceptAsync(event -> {
|
||||||
if (event.getResult().isAllowed()) {
|
if (event.getResult().isAllowed()) {
|
||||||
mc.write(new LoginPluginResponse(packet.getId(), true, Unpooled
|
mc.write(new LoginPluginResponsePacket(packet.getId(), true, Unpooled
|
||||||
.wrappedBuffer(event.getResult().getResponse())));
|
.wrappedBuffer(event.getResult().getResponse())));
|
||||||
} else {
|
} else {
|
||||||
mc.write(new LoginPluginResponse(packet.getId(), false, Unpooled.EMPTY_BUFFER));
|
mc.write(new LoginPluginResponsePacket(packet.getId(), false, Unpooled.EMPTY_BUFFER));
|
||||||
}
|
}
|
||||||
}, mc.eventLoop());
|
}, mc.eventLoop());
|
||||||
}
|
}
|
||||||
@ -125,20 +126,20 @@ public class LoginSessionHandler implements MinecraftSessionHandler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean handle(Disconnect packet) {
|
public boolean handle(DisconnectPacket packet) {
|
||||||
resultFuture.complete(ConnectionRequestResults.forDisconnect(packet, serverConn.getServer()));
|
resultFuture.complete(ConnectionRequestResults.forDisconnect(packet, serverConn.getServer()));
|
||||||
serverConn.disconnect();
|
serverConn.disconnect();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean handle(SetCompression packet) {
|
public boolean handle(SetCompressionPacket packet) {
|
||||||
serverConn.ensureConnected().setCompressionThreshold(packet.getThreshold());
|
serverConn.ensureConnected().setCompressionThreshold(packet.getThreshold());
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean handle(ServerLoginSuccess packet) {
|
public boolean handle(ServerLoginSuccessPacket packet) {
|
||||||
if (server.getConfiguration().getPlayerInfoForwardingMode() == PlayerInfoForwarding.MODERN
|
if (server.getConfiguration().getPlayerInfoForwardingMode() == PlayerInfoForwarding.MODERN
|
||||||
&& !informationForwarded) {
|
&& !informationForwarded) {
|
||||||
resultFuture.complete(ConnectionRequestResults.forDisconnect(MODERN_IP_FORWARDING_FAILURE,
|
resultFuture.complete(ConnectionRequestResults.forDisconnect(MODERN_IP_FORWARDING_FAILURE,
|
||||||
@ -156,7 +157,7 @@ public class LoginSessionHandler implements MinecraftSessionHandler {
|
|||||||
smc.setActiveSessionHandler(StateRegistry.PLAY,
|
smc.setActiveSessionHandler(StateRegistry.PLAY,
|
||||||
new TransitionSessionHandler(server, serverConn, resultFuture));
|
new TransitionSessionHandler(server, serverConn, resultFuture));
|
||||||
} else {
|
} else {
|
||||||
smc.write(new LoginAcknowledged());
|
smc.write(new LoginAcknowledgedPacket());
|
||||||
smc.setActiveSessionHandler(StateRegistry.CONFIG,
|
smc.setActiveSessionHandler(StateRegistry.CONFIG,
|
||||||
new ConfigSessionHandler(server, serverConn, resultFuture));
|
new ConfigSessionHandler(server, serverConn, resultFuture));
|
||||||
ConnectedPlayer player = serverConn.getPlayer();
|
ConnectedPlayer player = serverConn.getPlayer();
|
||||||
@ -184,11 +185,12 @@ public class LoginSessionHandler implements MinecraftSessionHandler {
|
|||||||
public void disconnected() {
|
public void disconnected() {
|
||||||
if (server.getConfiguration().getPlayerInfoForwardingMode() == PlayerInfoForwarding.LEGACY) {
|
if (server.getConfiguration().getPlayerInfoForwardingMode() == PlayerInfoForwarding.LEGACY) {
|
||||||
resultFuture.completeExceptionally(new QuietRuntimeException(
|
resultFuture.completeExceptionally(new QuietRuntimeException(
|
||||||
"The connection to the remote server was unexpectedly closed.\n"
|
"""
|
||||||
+ "This is usually because the remote server "
|
The connection to the remote server was unexpectedly closed.
|
||||||
+ "does not have BungeeCord IP forwarding "
|
This is usually because the remote server does not have \
|
||||||
+ "correctly enabled.\nSee https://velocitypowered.com/wiki/users/forwarding/ "
|
BungeeCord IP forwarding correctly enabled.
|
||||||
+ "for instructions on how to configure player info forwarding correctly."));
|
See https://velocitypowered.com/wiki/users/forwarding/ for instructions \
|
||||||
|
on how to configure player info forwarding correctly."""));
|
||||||
} else {
|
} else {
|
||||||
resultFuture.completeExceptionally(
|
resultFuture.completeExceptionally(
|
||||||
new QuietRuntimeException("The connection to the remote server was unexpectedly closed.")
|
new QuietRuntimeException("The connection to the remote server was unexpectedly closed.")
|
||||||
|
@ -34,10 +34,10 @@ import com.velocitypowered.proxy.connection.util.ConnectionMessages;
|
|||||||
import com.velocitypowered.proxy.connection.util.ConnectionRequestResults;
|
import com.velocitypowered.proxy.connection.util.ConnectionRequestResults;
|
||||||
import com.velocitypowered.proxy.connection.util.ConnectionRequestResults.Impl;
|
import com.velocitypowered.proxy.connection.util.ConnectionRequestResults.Impl;
|
||||||
import com.velocitypowered.proxy.protocol.StateRegistry;
|
import com.velocitypowered.proxy.protocol.StateRegistry;
|
||||||
import com.velocitypowered.proxy.protocol.packet.Disconnect;
|
import com.velocitypowered.proxy.protocol.packet.DisconnectPacket;
|
||||||
import com.velocitypowered.proxy.protocol.packet.JoinGame;
|
import com.velocitypowered.proxy.protocol.packet.JoinGamePacket;
|
||||||
import com.velocitypowered.proxy.protocol.packet.KeepAlive;
|
import com.velocitypowered.proxy.protocol.packet.KeepAlivePacket;
|
||||||
import com.velocitypowered.proxy.protocol.packet.PluginMessage;
|
import com.velocitypowered.proxy.protocol.packet.PluginMessagePacket;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.concurrent.CompletableFuture;
|
import java.util.concurrent.CompletableFuture;
|
||||||
import org.apache.logging.log4j.LogManager;
|
import org.apache.logging.log4j.LogManager;
|
||||||
@ -83,13 +83,13 @@ public class TransitionSessionHandler implements MinecraftSessionHandler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean handle(KeepAlive packet) {
|
public boolean handle(KeepAlivePacket packet) {
|
||||||
serverConn.ensureConnected().write(packet);
|
serverConn.ensureConnected().write(packet);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean handle(JoinGame packet) {
|
public boolean handle(JoinGamePacket packet) {
|
||||||
MinecraftConnection smc = serverConn.ensureConnected();
|
MinecraftConnection smc = serverConn.ensureConnected();
|
||||||
final RegisteredServer previousServer = serverConn.getPreviousServer().orElse(null);
|
final RegisteredServer previousServer = serverConn.getPreviousServer().orElse(null);
|
||||||
final ConnectedPlayer player = serverConn.getPlayer();
|
final ConnectedPlayer player = serverConn.getPlayer();
|
||||||
@ -166,7 +166,7 @@ public class TransitionSessionHandler implements MinecraftSessionHandler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean handle(Disconnect packet) {
|
public boolean handle(DisconnectPacket packet) {
|
||||||
final MinecraftConnection connection = serverConn.ensureConnected();
|
final MinecraftConnection connection = serverConn.ensureConnected();
|
||||||
serverConn.disconnect();
|
serverConn.disconnect();
|
||||||
|
|
||||||
@ -184,7 +184,7 @@ public class TransitionSessionHandler implements MinecraftSessionHandler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean handle(PluginMessage packet) {
|
public boolean handle(PluginMessagePacket packet) {
|
||||||
if (bungeecordMessageResponder.process(packet)) {
|
if (bungeecordMessageResponder.process(packet)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -39,9 +39,10 @@ import com.velocitypowered.proxy.connection.client.ConnectedPlayer;
|
|||||||
import com.velocitypowered.proxy.connection.forge.modern.ModernForgeConnectionType;
|
import com.velocitypowered.proxy.connection.forge.modern.ModernForgeConnectionType;
|
||||||
import com.velocitypowered.proxy.connection.util.ConnectionRequestResults.Impl;
|
import com.velocitypowered.proxy.connection.util.ConnectionRequestResults.Impl;
|
||||||
import com.velocitypowered.proxy.protocol.StateRegistry;
|
import com.velocitypowered.proxy.protocol.StateRegistry;
|
||||||
import com.velocitypowered.proxy.protocol.packet.Handshake;
|
import com.velocitypowered.proxy.protocol.packet.HandshakePacket;
|
||||||
import com.velocitypowered.proxy.protocol.packet.PluginMessage;
|
import com.velocitypowered.proxy.protocol.packet.JoinGamePacket;
|
||||||
import com.velocitypowered.proxy.protocol.packet.ServerLogin;
|
import com.velocitypowered.proxy.protocol.packet.PluginMessagePacket;
|
||||||
|
import com.velocitypowered.proxy.protocol.packet.ServerLoginPacket;
|
||||||
import com.velocitypowered.proxy.server.VelocityRegisteredServer;
|
import com.velocitypowered.proxy.server.VelocityRegisteredServer;
|
||||||
import io.netty.buffer.ByteBuf;
|
import io.netty.buffer.ByteBuf;
|
||||||
import io.netty.buffer.Unpooled;
|
import io.netty.buffer.Unpooled;
|
||||||
@ -179,7 +180,7 @@ public class VelocityServerConnection implements MinecraftConnectionAssociation,
|
|||||||
proxyPlayer.getVirtualHost().orElseGet(() -> registeredServer.getServerInfo().getAddress())
|
proxyPlayer.getVirtualHost().orElseGet(() -> registeredServer.getServerInfo().getAddress())
|
||||||
.getHostString();
|
.getHostString();
|
||||||
|
|
||||||
Handshake handshake = new Handshake();
|
HandshakePacket handshake = new HandshakePacket();
|
||||||
handshake.setNextStatus(StateRegistry.LOGIN_ID);
|
handshake.setNextStatus(StateRegistry.LOGIN_ID);
|
||||||
handshake.setProtocolVersion(protocolVersion);
|
handshake.setProtocolVersion(protocolVersion);
|
||||||
if (forwardingMode == PlayerInfoForwarding.LEGACY) {
|
if (forwardingMode == PlayerInfoForwarding.LEGACY) {
|
||||||
@ -203,9 +204,10 @@ public class VelocityServerConnection implements MinecraftConnectionAssociation,
|
|||||||
mc.setActiveSessionHandler(StateRegistry.LOGIN);
|
mc.setActiveSessionHandler(StateRegistry.LOGIN);
|
||||||
if (proxyPlayer.getIdentifiedKey() == null
|
if (proxyPlayer.getIdentifiedKey() == null
|
||||||
&& proxyPlayer.getProtocolVersion().compareTo(ProtocolVersion.MINECRAFT_1_19_3) >= 0) {
|
&& proxyPlayer.getProtocolVersion().compareTo(ProtocolVersion.MINECRAFT_1_19_3) >= 0) {
|
||||||
mc.delayedWrite(new ServerLogin(proxyPlayer.getUsername(), proxyPlayer.getUniqueId()));
|
mc.delayedWrite(new ServerLoginPacket(proxyPlayer.getUsername(), proxyPlayer.getUniqueId()));
|
||||||
} else {
|
} else {
|
||||||
mc.delayedWrite(new ServerLogin(proxyPlayer.getUsername(), proxyPlayer.getIdentifiedKey()));
|
mc.delayedWrite(new ServerLoginPacket(proxyPlayer.getUsername(),
|
||||||
|
proxyPlayer.getIdentifiedKey()));
|
||||||
}
|
}
|
||||||
mc.flush();
|
mc.flush();
|
||||||
}
|
}
|
||||||
@ -282,7 +284,7 @@ public class VelocityServerConnection implements MinecraftConnectionAssociation,
|
|||||||
|
|
||||||
MinecraftConnection mc = ensureConnected();
|
MinecraftConnection mc = ensureConnected();
|
||||||
|
|
||||||
PluginMessage message = new PluginMessage(identifier.getId(), data);
|
PluginMessagePacket message = new PluginMessagePacket(identifier.getId(), data);
|
||||||
mc.write(message);
|
mc.write(message);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -342,7 +344,7 @@ public class VelocityServerConnection implements MinecraftConnectionAssociation,
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets whether the {@link com.velocitypowered.proxy.protocol.packet.JoinGame} packet has been
|
* Gets whether the {@link JoinGamePacket} packet has been
|
||||||
* sent by this server.
|
* sent by this server.
|
||||||
*
|
*
|
||||||
* @return Whether the join has been completed.
|
* @return Whether the join has been completed.
|
||||||
|
@ -39,9 +39,9 @@ import com.velocitypowered.proxy.connection.MinecraftConnection;
|
|||||||
import com.velocitypowered.proxy.connection.MinecraftSessionHandler;
|
import com.velocitypowered.proxy.connection.MinecraftSessionHandler;
|
||||||
import com.velocitypowered.proxy.crypto.IdentifiedKeyImpl;
|
import com.velocitypowered.proxy.crypto.IdentifiedKeyImpl;
|
||||||
import com.velocitypowered.proxy.protocol.StateRegistry;
|
import com.velocitypowered.proxy.protocol.StateRegistry;
|
||||||
import com.velocitypowered.proxy.protocol.packet.LoginAcknowledged;
|
import com.velocitypowered.proxy.protocol.packet.LoginAcknowledgedPacket;
|
||||||
import com.velocitypowered.proxy.protocol.packet.ServerLoginSuccess;
|
import com.velocitypowered.proxy.protocol.packet.ServerLoginSuccessPacket;
|
||||||
import com.velocitypowered.proxy.protocol.packet.SetCompression;
|
import com.velocitypowered.proxy.protocol.packet.SetCompressionPacket;
|
||||||
import io.netty.buffer.ByteBuf;
|
import io.netty.buffer.ByteBuf;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
@ -132,7 +132,7 @@ public class AuthSessionHandler implements MinecraftSessionHandler {
|
|||||||
private void startLoginCompletion(ConnectedPlayer player) {
|
private void startLoginCompletion(ConnectedPlayer player) {
|
||||||
int threshold = server.getConfiguration().getCompressionThreshold();
|
int threshold = server.getConfiguration().getCompressionThreshold();
|
||||||
if (threshold >= 0 && mcConnection.getProtocolVersion().compareTo(MINECRAFT_1_8) >= 0) {
|
if (threshold >= 0 && mcConnection.getProtocolVersion().compareTo(MINECRAFT_1_8) >= 0) {
|
||||||
mcConnection.write(new SetCompression(threshold));
|
mcConnection.write(new SetCompressionPacket(threshold));
|
||||||
mcConnection.setCompressionThreshold(threshold);
|
mcConnection.setCompressionThreshold(threshold);
|
||||||
}
|
}
|
||||||
VelocityConfiguration configuration = server.getConfiguration();
|
VelocityConfiguration configuration = server.getConfiguration();
|
||||||
@ -171,7 +171,7 @@ public class AuthSessionHandler implements MinecraftSessionHandler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean handle(LoginAcknowledged packet) {
|
public boolean handle(LoginAcknowledgedPacket packet) {
|
||||||
if (loginState != State.SUCCESS_SENT) {
|
if (loginState != State.SUCCESS_SENT) {
|
||||||
inbound.disconnect(Component.translatable("multiplayer.disconnect.invalid_player_data"));
|
inbound.disconnect(Component.translatable("multiplayer.disconnect.invalid_player_data"));
|
||||||
} else {
|
} else {
|
||||||
@ -209,7 +209,7 @@ public class AuthSessionHandler implements MinecraftSessionHandler {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
ServerLoginSuccess success = new ServerLoginSuccess();
|
ServerLoginSuccessPacket success = new ServerLoginSuccessPacket();
|
||||||
success.setUsername(player.getUsername());
|
success.setUsername(player.getUsername());
|
||||||
success.setProperties(player.getGameProfileProperties());
|
success.setProperties(player.getGameProfileProperties());
|
||||||
success.setUuid(player.getUniqueId());
|
success.setUuid(player.getUniqueId());
|
||||||
|
@ -26,12 +26,12 @@ import com.velocitypowered.proxy.protocol.MinecraftPacket;
|
|||||||
import com.velocitypowered.proxy.protocol.ProtocolUtils;
|
import com.velocitypowered.proxy.protocol.ProtocolUtils;
|
||||||
import com.velocitypowered.proxy.protocol.StateRegistry;
|
import com.velocitypowered.proxy.protocol.StateRegistry;
|
||||||
import com.velocitypowered.proxy.protocol.netty.MinecraftEncoder;
|
import com.velocitypowered.proxy.protocol.netty.MinecraftEncoder;
|
||||||
import com.velocitypowered.proxy.protocol.packet.ClientSettings;
|
import com.velocitypowered.proxy.protocol.packet.ClientSettingsPacket;
|
||||||
import com.velocitypowered.proxy.protocol.packet.KeepAlive;
|
import com.velocitypowered.proxy.protocol.packet.KeepAlivePacket;
|
||||||
import com.velocitypowered.proxy.protocol.packet.PingIdentify;
|
import com.velocitypowered.proxy.protocol.packet.PingIdentifyPacket;
|
||||||
import com.velocitypowered.proxy.protocol.packet.PluginMessage;
|
import com.velocitypowered.proxy.protocol.packet.PluginMessagePacket;
|
||||||
import com.velocitypowered.proxy.protocol.packet.ResourcePackResponse;
|
import com.velocitypowered.proxy.protocol.packet.ResourcePackResponsePacket;
|
||||||
import com.velocitypowered.proxy.protocol.packet.config.FinishedUpdate;
|
import com.velocitypowered.proxy.protocol.packet.config.FinishedUpdatePacket;
|
||||||
import com.velocitypowered.proxy.protocol.util.PluginMessageUtil;
|
import com.velocitypowered.proxy.protocol.util.PluginMessageUtil;
|
||||||
import io.netty.buffer.ByteBuf;
|
import io.netty.buffer.ByteBuf;
|
||||||
import io.netty.buffer.Unpooled;
|
import io.netty.buffer.Unpooled;
|
||||||
@ -75,7 +75,7 @@ public class ClientConfigSessionHandler implements MinecraftSessionHandler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean handle(KeepAlive packet) {
|
public boolean handle(KeepAlivePacket packet) {
|
||||||
VelocityServerConnection serverConnection = player.getConnectedServer();
|
VelocityServerConnection serverConnection = player.getConnectedServer();
|
||||||
if (serverConnection != null) {
|
if (serverConnection != null) {
|
||||||
Long sentTime = serverConnection.getPendingPings().remove(packet.getRandomId());
|
Long sentTime = serverConnection.getPendingPings().remove(packet.getRandomId());
|
||||||
@ -91,13 +91,13 @@ public class ClientConfigSessionHandler implements MinecraftSessionHandler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean handle(ClientSettings packet) {
|
public boolean handle(ClientSettingsPacket packet) {
|
||||||
player.setClientSettings(packet);
|
player.setClientSettings(packet);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean handle(ResourcePackResponse packet) {
|
public boolean handle(ResourcePackResponsePacket packet) {
|
||||||
if (player.getConnectionInFlight() != null) {
|
if (player.getConnectionInFlight() != null) {
|
||||||
player.getConnectionInFlight().ensureConnected().write(packet);
|
player.getConnectionInFlight().ensureConnected().write(packet);
|
||||||
}
|
}
|
||||||
@ -105,7 +105,7 @@ public class ClientConfigSessionHandler implements MinecraftSessionHandler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean handle(FinishedUpdate packet) {
|
public boolean handle(FinishedUpdatePacket packet) {
|
||||||
player.getConnection()
|
player.getConnection()
|
||||||
.setActiveSessionHandler(StateRegistry.PLAY, new ClientPlaySessionHandler(server, player));
|
.setActiveSessionHandler(StateRegistry.PLAY, new ClientPlaySessionHandler(server, player));
|
||||||
|
|
||||||
@ -114,7 +114,7 @@ public class ClientConfigSessionHandler implements MinecraftSessionHandler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean handle(PluginMessage packet) {
|
public boolean handle(PluginMessagePacket packet) {
|
||||||
VelocityServerConnection serverConn = player.getConnectionInFlight();
|
VelocityServerConnection serverConn = player.getConnectionInFlight();
|
||||||
if (serverConn != null) {
|
if (serverConn != null) {
|
||||||
if (PluginMessageUtil.isMcBrand(packet)) {
|
if (PluginMessageUtil.isMcBrand(packet)) {
|
||||||
@ -132,7 +132,7 @@ public class ClientConfigSessionHandler implements MinecraftSessionHandler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean handle(PingIdentify packet) {
|
public boolean handle(PingIdentifyPacket packet) {
|
||||||
if (player.getConnectionInFlight() != null) {
|
if (player.getConnectionInFlight() != null) {
|
||||||
player.getConnectionInFlight().ensureConnected().write(packet);
|
player.getConnectionInFlight().ensureConnected().write(packet);
|
||||||
}
|
}
|
||||||
@ -149,8 +149,8 @@ public class ClientConfigSessionHandler implements MinecraftSessionHandler {
|
|||||||
|
|
||||||
MinecraftConnection smc = serverConnection.getConnection();
|
MinecraftConnection smc = serverConnection.getConnection();
|
||||||
if (smc != null && serverConnection.getPhase().consideredComplete()) {
|
if (smc != null && serverConnection.getPhase().consideredComplete()) {
|
||||||
if (packet instanceof PluginMessage) {
|
if (packet instanceof PluginMessagePacket) {
|
||||||
((PluginMessage) packet).retain();
|
((PluginMessagePacket) packet).retain();
|
||||||
}
|
}
|
||||||
smc.write(packet);
|
smc.write(packet);
|
||||||
}
|
}
|
||||||
@ -194,13 +194,13 @@ public class ClientConfigSessionHandler implements MinecraftSessionHandler {
|
|||||||
if (brand != null && brandChannel != null) {
|
if (brand != null && brandChannel != null) {
|
||||||
ByteBuf buf = Unpooled.buffer();
|
ByteBuf buf = Unpooled.buffer();
|
||||||
ProtocolUtils.writeString(buf, brand);
|
ProtocolUtils.writeString(buf, brand);
|
||||||
PluginMessage brandPacket = new PluginMessage(brandChannel, buf);
|
PluginMessagePacket brandPacket = new PluginMessagePacket(brandChannel, buf);
|
||||||
smc.write(brandPacket);
|
smc.write(brandPacket);
|
||||||
}
|
}
|
||||||
|
|
||||||
player.getConnection().write(new FinishedUpdate());
|
player.getConnection().write(new FinishedUpdatePacket());
|
||||||
|
|
||||||
smc.write(new FinishedUpdate());
|
smc.write(new FinishedUpdatePacket());
|
||||||
smc.getChannel().pipeline().get(MinecraftEncoder.class).setState(StateRegistry.PLAY);
|
smc.getChannel().pipeline().get(MinecraftEncoder.class).setState(StateRegistry.PLAY);
|
||||||
|
|
||||||
return configSwitchFuture;
|
return configSwitchFuture;
|
||||||
|
@ -19,7 +19,7 @@ package com.velocitypowered.proxy.connection.client;
|
|||||||
|
|
||||||
import com.velocitypowered.proxy.connection.backend.VelocityServerConnection;
|
import com.velocitypowered.proxy.connection.backend.VelocityServerConnection;
|
||||||
import com.velocitypowered.proxy.connection.forge.legacy.LegacyForgeHandshakeClientPhase;
|
import com.velocitypowered.proxy.connection.forge.legacy.LegacyForgeHandshakeClientPhase;
|
||||||
import com.velocitypowered.proxy.protocol.packet.PluginMessage;
|
import com.velocitypowered.proxy.protocol.packet.PluginMessagePacket;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Provides connection phase specific actions.
|
* Provides connection phase specific actions.
|
||||||
@ -38,7 +38,7 @@ public interface ClientConnectionPhase {
|
|||||||
* @return true if handled, false otherwise.
|
* @return true if handled, false otherwise.
|
||||||
*/
|
*/
|
||||||
default boolean handle(ConnectedPlayer player,
|
default boolean handle(ConnectedPlayer player,
|
||||||
PluginMessage message,
|
PluginMessagePacket message,
|
||||||
VelocityServerConnection server) {
|
VelocityServerConnection server) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -40,32 +40,32 @@ import com.velocitypowered.proxy.connection.backend.VelocityServerConnection;
|
|||||||
import com.velocitypowered.proxy.connection.forge.legacy.LegacyForgeConstants;
|
import com.velocitypowered.proxy.connection.forge.legacy.LegacyForgeConstants;
|
||||||
import com.velocitypowered.proxy.protocol.MinecraftPacket;
|
import com.velocitypowered.proxy.protocol.MinecraftPacket;
|
||||||
import com.velocitypowered.proxy.protocol.StateRegistry;
|
import com.velocitypowered.proxy.protocol.StateRegistry;
|
||||||
import com.velocitypowered.proxy.protocol.packet.BossBar;
|
import com.velocitypowered.proxy.protocol.packet.BossBarPacket;
|
||||||
import com.velocitypowered.proxy.protocol.packet.ClientSettings;
|
import com.velocitypowered.proxy.protocol.packet.ClientSettingsPacket;
|
||||||
import com.velocitypowered.proxy.protocol.packet.JoinGame;
|
import com.velocitypowered.proxy.protocol.packet.JoinGamePacket;
|
||||||
import com.velocitypowered.proxy.protocol.packet.KeepAlive;
|
import com.velocitypowered.proxy.protocol.packet.KeepAlivePacket;
|
||||||
import com.velocitypowered.proxy.protocol.packet.PluginMessage;
|
import com.velocitypowered.proxy.protocol.packet.PluginMessagePacket;
|
||||||
import com.velocitypowered.proxy.protocol.packet.ResourcePackResponse;
|
import com.velocitypowered.proxy.protocol.packet.ResourcePackResponsePacket;
|
||||||
import com.velocitypowered.proxy.protocol.packet.Respawn;
|
import com.velocitypowered.proxy.protocol.packet.RespawnPacket;
|
||||||
import com.velocitypowered.proxy.protocol.packet.TabCompleteRequest;
|
import com.velocitypowered.proxy.protocol.packet.TabCompleteRequestPacket;
|
||||||
import com.velocitypowered.proxy.protocol.packet.TabCompleteResponse;
|
import com.velocitypowered.proxy.protocol.packet.TabCompleteResponsePacket;
|
||||||
import com.velocitypowered.proxy.protocol.packet.TabCompleteResponse.Offer;
|
import com.velocitypowered.proxy.protocol.packet.TabCompleteResponsePacket.Offer;
|
||||||
import com.velocitypowered.proxy.protocol.packet.chat.ChatHandler;
|
import com.velocitypowered.proxy.protocol.packet.chat.ChatHandler;
|
||||||
import com.velocitypowered.proxy.protocol.packet.chat.ChatTimeKeeper;
|
import com.velocitypowered.proxy.protocol.packet.chat.ChatTimeKeeper;
|
||||||
import com.velocitypowered.proxy.protocol.packet.chat.CommandHandler;
|
import com.velocitypowered.proxy.protocol.packet.chat.CommandHandler;
|
||||||
import com.velocitypowered.proxy.protocol.packet.chat.ComponentHolder;
|
import com.velocitypowered.proxy.protocol.packet.chat.ComponentHolder;
|
||||||
import com.velocitypowered.proxy.protocol.packet.chat.keyed.KeyedChatHandler;
|
import com.velocitypowered.proxy.protocol.packet.chat.keyed.KeyedChatHandler;
|
||||||
import com.velocitypowered.proxy.protocol.packet.chat.keyed.KeyedCommandHandler;
|
import com.velocitypowered.proxy.protocol.packet.chat.keyed.KeyedCommandHandler;
|
||||||
import com.velocitypowered.proxy.protocol.packet.chat.keyed.KeyedPlayerChat;
|
import com.velocitypowered.proxy.protocol.packet.chat.keyed.KeyedPlayerChatPacket;
|
||||||
import com.velocitypowered.proxy.protocol.packet.chat.keyed.KeyedPlayerCommand;
|
import com.velocitypowered.proxy.protocol.packet.chat.keyed.KeyedPlayerCommandPacket;
|
||||||
import com.velocitypowered.proxy.protocol.packet.chat.legacy.LegacyChat;
|
|
||||||
import com.velocitypowered.proxy.protocol.packet.chat.legacy.LegacyChatHandler;
|
import com.velocitypowered.proxy.protocol.packet.chat.legacy.LegacyChatHandler;
|
||||||
|
import com.velocitypowered.proxy.protocol.packet.chat.legacy.LegacyChatPacket;
|
||||||
import com.velocitypowered.proxy.protocol.packet.chat.legacy.LegacyCommandHandler;
|
import com.velocitypowered.proxy.protocol.packet.chat.legacy.LegacyCommandHandler;
|
||||||
import com.velocitypowered.proxy.protocol.packet.chat.session.SessionChatHandler;
|
import com.velocitypowered.proxy.protocol.packet.chat.session.SessionChatHandler;
|
||||||
import com.velocitypowered.proxy.protocol.packet.chat.session.SessionCommandHandler;
|
import com.velocitypowered.proxy.protocol.packet.chat.session.SessionCommandHandler;
|
||||||
import com.velocitypowered.proxy.protocol.packet.chat.session.SessionPlayerChat;
|
import com.velocitypowered.proxy.protocol.packet.chat.session.SessionPlayerChatPacket;
|
||||||
import com.velocitypowered.proxy.protocol.packet.chat.session.SessionPlayerCommand;
|
import com.velocitypowered.proxy.protocol.packet.chat.session.SessionPlayerCommandPacket;
|
||||||
import com.velocitypowered.proxy.protocol.packet.config.FinishedUpdate;
|
import com.velocitypowered.proxy.protocol.packet.config.FinishedUpdatePacket;
|
||||||
import com.velocitypowered.proxy.protocol.packet.title.GenericTitlePacket;
|
import com.velocitypowered.proxy.protocol.packet.title.GenericTitlePacket;
|
||||||
import com.velocitypowered.proxy.protocol.util.PluginMessageUtil;
|
import com.velocitypowered.proxy.protocol.util.PluginMessageUtil;
|
||||||
import com.velocitypowered.proxy.util.CharacterUtil;
|
import com.velocitypowered.proxy.util.CharacterUtil;
|
||||||
@ -99,9 +99,9 @@ public class ClientPlaySessionHandler implements MinecraftSessionHandler {
|
|||||||
private final ConnectedPlayer player;
|
private final ConnectedPlayer player;
|
||||||
private boolean spawned = false;
|
private boolean spawned = false;
|
||||||
private final List<UUID> serverBossBars = new ArrayList<>();
|
private final List<UUID> serverBossBars = new ArrayList<>();
|
||||||
private final Queue<PluginMessage> loginPluginMessages = new ConcurrentLinkedQueue<>();
|
private final Queue<PluginMessagePacket> loginPluginMessages = new ConcurrentLinkedQueue<>();
|
||||||
private final VelocityServer server;
|
private final VelocityServer server;
|
||||||
private @Nullable TabCompleteRequest outstandingTabComplete;
|
private @Nullable TabCompleteRequestPacket outstandingTabComplete;
|
||||||
private final ChatHandler<? extends MinecraftPacket> chatHandler;
|
private final ChatHandler<? extends MinecraftPacket> chatHandler;
|
||||||
private final CommandHandler<? extends MinecraftPacket> commandHandler;
|
private final CommandHandler<? extends MinecraftPacket> commandHandler;
|
||||||
private final ChatTimeKeeper timeKeeper = new ChatTimeKeeper();
|
private final ChatTimeKeeper timeKeeper = new ChatTimeKeeper();
|
||||||
@ -158,20 +158,20 @@ public class ClientPlaySessionHandler implements MinecraftSessionHandler {
|
|||||||
Collection<String> channels =
|
Collection<String> channels =
|
||||||
server.getChannelRegistrar().getChannelsForProtocol(player.getProtocolVersion());
|
server.getChannelRegistrar().getChannelsForProtocol(player.getProtocolVersion());
|
||||||
if (!channels.isEmpty()) {
|
if (!channels.isEmpty()) {
|
||||||
PluginMessage register = constructChannelsPacket(player.getProtocolVersion(), channels);
|
PluginMessagePacket register = constructChannelsPacket(player.getProtocolVersion(), channels);
|
||||||
player.getConnection().write(register);
|
player.getConnection().write(register);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void deactivated() {
|
public void deactivated() {
|
||||||
for (PluginMessage message : loginPluginMessages) {
|
for (PluginMessagePacket message : loginPluginMessages) {
|
||||||
ReferenceCountUtil.release(message);
|
ReferenceCountUtil.release(message);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean handle(KeepAlive packet) {
|
public boolean handle(KeepAlivePacket packet) {
|
||||||
VelocityServerConnection serverConnection = player.getConnectedServer();
|
VelocityServerConnection serverConnection = player.getConnectedServer();
|
||||||
if (serverConnection != null) {
|
if (serverConnection != null) {
|
||||||
Long sentTime = serverConnection.getPendingPings().remove(packet.getRandomId());
|
Long sentTime = serverConnection.getPendingPings().remove(packet.getRandomId());
|
||||||
@ -187,7 +187,7 @@ public class ClientPlaySessionHandler implements MinecraftSessionHandler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean handle(ClientSettings packet) {
|
public boolean handle(ClientSettingsPacket packet) {
|
||||||
player.setClientSettings(packet);
|
player.setClientSettings(packet);
|
||||||
VelocityServerConnection serverConnection = player.getConnectedServer();
|
VelocityServerConnection serverConnection = player.getConnectedServer();
|
||||||
if (serverConnection == null) {
|
if (serverConnection == null) {
|
||||||
@ -199,7 +199,7 @@ public class ClientPlaySessionHandler implements MinecraftSessionHandler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean handle(SessionPlayerCommand packet) {
|
public boolean handle(SessionPlayerCommandPacket packet) {
|
||||||
player.ensureAndGetCurrentServer();
|
player.ensureAndGetCurrentServer();
|
||||||
|
|
||||||
if (!updateTimeKeeper(packet.getTimeStamp())) {
|
if (!updateTimeKeeper(packet.getTimeStamp())) {
|
||||||
@ -214,7 +214,7 @@ public class ClientPlaySessionHandler implements MinecraftSessionHandler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean handle(SessionPlayerChat packet) {
|
public boolean handle(SessionPlayerChatPacket packet) {
|
||||||
player.ensureAndGetCurrentServer();
|
player.ensureAndGetCurrentServer();
|
||||||
|
|
||||||
if (!updateTimeKeeper(packet.getTimestamp())) {
|
if (!updateTimeKeeper(packet.getTimestamp())) {
|
||||||
@ -229,7 +229,7 @@ public class ClientPlaySessionHandler implements MinecraftSessionHandler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean handle(KeyedPlayerCommand packet) {
|
public boolean handle(KeyedPlayerCommandPacket packet) {
|
||||||
player.ensureAndGetCurrentServer();
|
player.ensureAndGetCurrentServer();
|
||||||
|
|
||||||
if (!updateTimeKeeper(packet.getTimestamp())) {
|
if (!updateTimeKeeper(packet.getTimestamp())) {
|
||||||
@ -244,7 +244,7 @@ public class ClientPlaySessionHandler implements MinecraftSessionHandler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean handle(KeyedPlayerChat packet) {
|
public boolean handle(KeyedPlayerChatPacket packet) {
|
||||||
player.ensureAndGetCurrentServer();
|
player.ensureAndGetCurrentServer();
|
||||||
|
|
||||||
if (!updateTimeKeeper(packet.getExpiry())) {
|
if (!updateTimeKeeper(packet.getExpiry())) {
|
||||||
@ -259,7 +259,7 @@ public class ClientPlaySessionHandler implements MinecraftSessionHandler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean handle(LegacyChat packet) {
|
public boolean handle(LegacyChatPacket packet) {
|
||||||
player.ensureAndGetCurrentServer();
|
player.ensureAndGetCurrentServer();
|
||||||
String msg = packet.getMessage();
|
String msg = packet.getMessage();
|
||||||
if (!validateChat(msg)) {
|
if (!validateChat(msg)) {
|
||||||
@ -275,7 +275,7 @@ public class ClientPlaySessionHandler implements MinecraftSessionHandler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean handle(TabCompleteRequest packet) {
|
public boolean handle(TabCompleteRequestPacket packet) {
|
||||||
boolean isCommand = !packet.isAssumeCommand() && packet.getCommand().startsWith("/");
|
boolean isCommand = !packet.isAssumeCommand() && packet.getCommand().startsWith("/");
|
||||||
|
|
||||||
if (isCommand) {
|
if (isCommand) {
|
||||||
@ -286,7 +286,7 @@ public class ClientPlaySessionHandler implements MinecraftSessionHandler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean handle(PluginMessage packet) {
|
public boolean handle(PluginMessagePacket packet) {
|
||||||
// Handling edge case when packet with FML client handshake (state COMPLETE)
|
// Handling edge case when packet with FML client handshake (state COMPLETE)
|
||||||
// arrives after JoinGame packet from destination server
|
// arrives after JoinGame packet from destination server
|
||||||
VelocityServerConnection serverConn =
|
VelocityServerConnection serverConn =
|
||||||
@ -356,7 +356,7 @@ public class ClientPlaySessionHandler implements MinecraftSessionHandler {
|
|||||||
PluginMessageEvent event = new PluginMessageEvent(player, serverConn, id, copy);
|
PluginMessageEvent event = new PluginMessageEvent(player, serverConn, id, copy);
|
||||||
server.getEventManager().fire(event).thenAcceptAsync(pme -> {
|
server.getEventManager().fire(event).thenAcceptAsync(pme -> {
|
||||||
if (pme.getResult().isAllowed()) {
|
if (pme.getResult().isAllowed()) {
|
||||||
PluginMessage message = new PluginMessage(packet.getChannel(),
|
PluginMessagePacket message = new PluginMessagePacket(packet.getChannel(),
|
||||||
Unpooled.wrappedBuffer(copy));
|
Unpooled.wrappedBuffer(copy));
|
||||||
if (!player.getPhase().consideredComplete() || !serverConn.getPhase()
|
if (!player.getPhase().consideredComplete() || !serverConn.getPhase()
|
||||||
.consideredComplete()) {
|
.consideredComplete()) {
|
||||||
@ -379,12 +379,12 @@ public class ClientPlaySessionHandler implements MinecraftSessionHandler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean handle(ResourcePackResponse packet) {
|
public boolean handle(ResourcePackResponsePacket packet) {
|
||||||
return player.onResourcePackResponse(packet.getStatus());
|
return player.onResourcePackResponse(packet.getStatus());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean handle(FinishedUpdate packet) {
|
public boolean handle(FinishedUpdatePacket packet) {
|
||||||
// Complete client switch
|
// Complete client switch
|
||||||
player.getConnection().setActiveSessionHandler(StateRegistry.CONFIG);
|
player.getConnection().setActiveSessionHandler(StateRegistry.CONFIG);
|
||||||
VelocityServerConnection serverConnection = player.getConnectedServer();
|
VelocityServerConnection serverConnection = player.getConnectedServer();
|
||||||
@ -413,8 +413,8 @@ public class ClientPlaySessionHandler implements MinecraftSessionHandler {
|
|||||||
|
|
||||||
MinecraftConnection smc = serverConnection.getConnection();
|
MinecraftConnection smc = serverConnection.getConnection();
|
||||||
if (smc != null && serverConnection.getPhase().consideredComplete()) {
|
if (smc != null && serverConnection.getPhase().consideredComplete()) {
|
||||||
if (packet instanceof PluginMessage) {
|
if (packet instanceof PluginMessagePacket) {
|
||||||
((PluginMessage) packet).retain();
|
((PluginMessagePacket) packet).retain();
|
||||||
}
|
}
|
||||||
smc.write(packet);
|
smc.write(packet);
|
||||||
}
|
}
|
||||||
@ -501,7 +501,7 @@ public class ClientPlaySessionHandler implements MinecraftSessionHandler {
|
|||||||
* @param joinGame the join game packet
|
* @param joinGame the join game packet
|
||||||
* @param destination the new server we are connecting to
|
* @param destination the new server we are connecting to
|
||||||
*/
|
*/
|
||||||
public void handleBackendJoinGame(JoinGame joinGame, VelocityServerConnection destination) {
|
public void handleBackendJoinGame(JoinGamePacket joinGame, VelocityServerConnection destination) {
|
||||||
final MinecraftConnection serverMc = destination.ensureConnected();
|
final MinecraftConnection serverMc = destination.ensureConnected();
|
||||||
|
|
||||||
if (!spawned) {
|
if (!spawned) {
|
||||||
@ -529,9 +529,9 @@ public class ClientPlaySessionHandler implements MinecraftSessionHandler {
|
|||||||
// Remove previous boss bars. These don't get cleared when sending JoinGame, thus the need to
|
// Remove previous boss bars. These don't get cleared when sending JoinGame, thus the need to
|
||||||
// track them.
|
// track them.
|
||||||
for (UUID serverBossBar : serverBossBars) {
|
for (UUID serverBossBar : serverBossBars) {
|
||||||
BossBar deletePacket = new BossBar();
|
BossBarPacket deletePacket = new BossBarPacket();
|
||||||
deletePacket.setUuid(serverBossBar);
|
deletePacket.setUuid(serverBossBar);
|
||||||
deletePacket.setAction(BossBar.REMOVE);
|
deletePacket.setAction(BossBarPacket.REMOVE);
|
||||||
player.getConnection().delayedWrite(deletePacket);
|
player.getConnection().delayedWrite(deletePacket);
|
||||||
}
|
}
|
||||||
serverBossBars.clear();
|
serverBossBars.clear();
|
||||||
@ -545,7 +545,7 @@ public class ClientPlaySessionHandler implements MinecraftSessionHandler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// If we had plugin messages queued during login/FML handshake, send them now.
|
// If we had plugin messages queued during login/FML handshake, send them now.
|
||||||
PluginMessage pm;
|
PluginMessagePacket pm;
|
||||||
while ((pm = loginPluginMessages.poll()) != null) {
|
while ((pm = loginPluginMessages.poll()) != null) {
|
||||||
serverMc.delayedWrite(pm);
|
serverMc.delayedWrite(pm);
|
||||||
}
|
}
|
||||||
@ -563,7 +563,7 @@ public class ClientPlaySessionHandler implements MinecraftSessionHandler {
|
|||||||
destination.completeJoin();
|
destination.completeJoin();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void doFastClientServerSwitch(JoinGame joinGame) {
|
private void doFastClientServerSwitch(JoinGamePacket joinGame) {
|
||||||
// In order to handle switching to another server, you will need to send two packets:
|
// In order to handle switching to another server, you will need to send two packets:
|
||||||
//
|
//
|
||||||
// - The join game packet from the backend server, with a different dimension
|
// - The join game packet from the backend server, with a different dimension
|
||||||
@ -572,7 +572,7 @@ public class ClientPlaySessionHandler implements MinecraftSessionHandler {
|
|||||||
// Most notably, by having the client accept the join game packet, we can work around the need
|
// Most notably, by having the client accept the join game packet, we can work around the need
|
||||||
// to perform entity ID rewrites, eliminating potential issues from rewriting packets and
|
// to perform entity ID rewrites, eliminating potential issues from rewriting packets and
|
||||||
// improving compatibility with mods.
|
// improving compatibility with mods.
|
||||||
final Respawn respawn = Respawn.fromJoinGame(joinGame);
|
final RespawnPacket respawn = RespawnPacket.fromJoinGame(joinGame);
|
||||||
|
|
||||||
if (player.getProtocolVersion().compareTo(ProtocolVersion.MINECRAFT_1_16) < 0) {
|
if (player.getProtocolVersion().compareTo(ProtocolVersion.MINECRAFT_1_16) < 0) {
|
||||||
// Before Minecraft 1.16, we could not switch to the same dimension without sending an
|
// Before Minecraft 1.16, we could not switch to the same dimension without sending an
|
||||||
@ -584,7 +584,7 @@ public class ClientPlaySessionHandler implements MinecraftSessionHandler {
|
|||||||
player.getConnection().delayedWrite(respawn);
|
player.getConnection().delayedWrite(respawn);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void doSafeClientServerSwitch(JoinGame joinGame) {
|
private void doSafeClientServerSwitch(JoinGamePacket joinGame) {
|
||||||
// Some clients do not behave well with the "fast" respawn sequence. In this case we will use
|
// Some clients do not behave well with the "fast" respawn sequence. In this case we will use
|
||||||
// a "safe" respawn sequence that involves sending three packets to the client. They have the
|
// a "safe" respawn sequence that involves sending three packets to the client. They have the
|
||||||
// same effect but tend to work better with buggier clients (Forge 1.8 in particular).
|
// same effect but tend to work better with buggier clients (Forge 1.8 in particular).
|
||||||
@ -593,12 +593,12 @@ public class ClientPlaySessionHandler implements MinecraftSessionHandler {
|
|||||||
player.getConnection().delayedWrite(joinGame);
|
player.getConnection().delayedWrite(joinGame);
|
||||||
|
|
||||||
// Send a respawn packet in a different dimension.
|
// Send a respawn packet in a different dimension.
|
||||||
final Respawn fakeSwitchPacket = Respawn.fromJoinGame(joinGame);
|
final RespawnPacket fakeSwitchPacket = RespawnPacket.fromJoinGame(joinGame);
|
||||||
fakeSwitchPacket.setDimension(joinGame.getDimension() == 0 ? -1 : 0);
|
fakeSwitchPacket.setDimension(joinGame.getDimension() == 0 ? -1 : 0);
|
||||||
player.getConnection().delayedWrite(fakeSwitchPacket);
|
player.getConnection().delayedWrite(fakeSwitchPacket);
|
||||||
|
|
||||||
// Now send a respawn packet in the correct dimension.
|
// Now send a respawn packet in the correct dimension.
|
||||||
final Respawn correctSwitchPacket = Respawn.fromJoinGame(joinGame);
|
final RespawnPacket correctSwitchPacket = RespawnPacket.fromJoinGame(joinGame);
|
||||||
player.getConnection().delayedWrite(correctSwitchPacket);
|
player.getConnection().delayedWrite(correctSwitchPacket);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -606,7 +606,7 @@ public class ClientPlaySessionHandler implements MinecraftSessionHandler {
|
|||||||
return serverBossBars;
|
return serverBossBars;
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean handleCommandTabComplete(TabCompleteRequest packet) {
|
private boolean handleCommandTabComplete(TabCompleteRequestPacket packet) {
|
||||||
// In 1.13+, we need to do additional work for the richer suggestions available.
|
// In 1.13+, we need to do additional work for the richer suggestions available.
|
||||||
String command = packet.getCommand().substring(1);
|
String command = packet.getCommand().substring(1);
|
||||||
int commandEndPosition = command.indexOf(' ');
|
int commandEndPosition = command.indexOf(' ');
|
||||||
@ -643,7 +643,7 @@ public class ClientPlaySessionHandler implements MinecraftSessionHandler {
|
|||||||
}
|
}
|
||||||
int startPos = packet.getCommand().lastIndexOf(' ') + 1;
|
int startPos = packet.getCommand().lastIndexOf(' ') + 1;
|
||||||
if (startPos > 0) {
|
if (startPos > 0) {
|
||||||
TabCompleteResponse resp = new TabCompleteResponse();
|
TabCompleteResponsePacket resp = new TabCompleteResponsePacket();
|
||||||
resp.setTransactionId(packet.getTransactionId());
|
resp.setTransactionId(packet.getTransactionId());
|
||||||
resp.setStart(startPos);
|
resp.setStart(startPos);
|
||||||
resp.setLength(packet.getCommand().length() - startPos);
|
resp.setLength(packet.getCommand().length() - startPos);
|
||||||
@ -658,7 +658,7 @@ public class ClientPlaySessionHandler implements MinecraftSessionHandler {
|
|||||||
return true; // Sorry, handler; we're just gonna have to lie to you here.
|
return true; // Sorry, handler; we're just gonna have to lie to you here.
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean handleRegularTabComplete(TabCompleteRequest packet) {
|
private boolean handleRegularTabComplete(TabCompleteRequestPacket packet) {
|
||||||
if (player.getProtocolVersion().compareTo(ProtocolVersion.MINECRAFT_1_13) < 0) {
|
if (player.getProtocolVersion().compareTo(ProtocolVersion.MINECRAFT_1_13) < 0) {
|
||||||
// Outstanding tab completes are recorded for use with 1.12 clients and below to provide
|
// Outstanding tab completes are recorded for use with 1.12 clients and below to provide
|
||||||
// additional tab completion support.
|
// additional tab completion support.
|
||||||
@ -672,7 +672,7 @@ public class ClientPlaySessionHandler implements MinecraftSessionHandler {
|
|||||||
*
|
*
|
||||||
* @param response the tab complete response from the backend
|
* @param response the tab complete response from the backend
|
||||||
*/
|
*/
|
||||||
public void handleTabCompleteResponse(TabCompleteResponse response) {
|
public void handleTabCompleteResponse(TabCompleteResponsePacket response) {
|
||||||
if (outstandingTabComplete != null && !outstandingTabComplete.isAssumeCommand()) {
|
if (outstandingTabComplete != null && !outstandingTabComplete.isAssumeCommand()) {
|
||||||
if (outstandingTabComplete.getCommand().startsWith("/")) {
|
if (outstandingTabComplete.getCommand().startsWith("/")) {
|
||||||
this.finishCommandTabComplete(outstandingTabComplete, response);
|
this.finishCommandTabComplete(outstandingTabComplete, response);
|
||||||
@ -686,7 +686,8 @@ public class ClientPlaySessionHandler implements MinecraftSessionHandler {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void finishCommandTabComplete(TabCompleteRequest request, TabCompleteResponse response) {
|
private void finishCommandTabComplete(TabCompleteRequestPacket request,
|
||||||
|
TabCompleteResponsePacket response) {
|
||||||
String command = request.getCommand().substring(1);
|
String command = request.getCommand().substring(1);
|
||||||
server.getCommandManager().offerBrigadierSuggestions(player, command)
|
server.getCommandManager().offerBrigadierSuggestions(player, command)
|
||||||
.thenAcceptAsync(offers -> {
|
.thenAcceptAsync(offers -> {
|
||||||
@ -723,7 +724,8 @@ public class ClientPlaySessionHandler implements MinecraftSessionHandler {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private void finishRegularTabComplete(TabCompleteRequest request, TabCompleteResponse response) {
|
private void finishRegularTabComplete(TabCompleteRequestPacket request,
|
||||||
|
TabCompleteResponsePacket response) {
|
||||||
List<String> offers = new ArrayList<>();
|
List<String> offers = new ArrayList<>();
|
||||||
for (Offer offer : response.getOffers()) {
|
for (Offer offer : response.getOffers()) {
|
||||||
offers.add(offer.getText());
|
offers.add(offer.getText());
|
||||||
@ -752,7 +754,7 @@ public class ClientPlaySessionHandler implements MinecraftSessionHandler {
|
|||||||
if (serverConnection != null) {
|
if (serverConnection != null) {
|
||||||
MinecraftConnection connection = serverConnection.getConnection();
|
MinecraftConnection connection = serverConnection.getConnection();
|
||||||
if (connection != null) {
|
if (connection != null) {
|
||||||
PluginMessage pm;
|
PluginMessagePacket pm;
|
||||||
while ((pm = loginPluginMessages.poll()) != null) {
|
while ((pm = loginPluginMessages.poll()) != null) {
|
||||||
connection.write(pm);
|
connection.write(pm);
|
||||||
}
|
}
|
||||||
|
@ -19,7 +19,7 @@ package com.velocitypowered.proxy.connection.client;
|
|||||||
|
|
||||||
import com.velocitypowered.api.proxy.player.PlayerSettings;
|
import com.velocitypowered.api.proxy.player.PlayerSettings;
|
||||||
import com.velocitypowered.api.proxy.player.SkinParts;
|
import com.velocitypowered.api.proxy.player.SkinParts;
|
||||||
import com.velocitypowered.proxy.protocol.packet.ClientSettings;
|
import com.velocitypowered.proxy.protocol.packet.ClientSettingsPacket;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||||
@ -30,13 +30,13 @@ import org.checkerframework.checker.nullness.qual.Nullable;
|
|||||||
public class ClientSettingsWrapper implements PlayerSettings {
|
public class ClientSettingsWrapper implements PlayerSettings {
|
||||||
|
|
||||||
static final PlayerSettings DEFAULT = new ClientSettingsWrapper(
|
static final PlayerSettings DEFAULT = new ClientSettingsWrapper(
|
||||||
new ClientSettings("en_US", (byte) 10, 0, true, (short) 127, 1, true, false));
|
new ClientSettingsPacket("en_US", (byte) 10, 0, true, (short) 127, 1, true, false));
|
||||||
|
|
||||||
private final ClientSettings settings;
|
private final ClientSettingsPacket settings;
|
||||||
private final SkinParts parts;
|
private final SkinParts parts;
|
||||||
private @Nullable Locale locale;
|
private @Nullable Locale locale;
|
||||||
|
|
||||||
ClientSettingsWrapper(ClientSettings settings) {
|
ClientSettingsWrapper(ClientSettingsPacket settings) {
|
||||||
this.settings = settings;
|
this.settings = settings;
|
||||||
this.parts = new SkinParts((byte) settings.getSkinParts());
|
this.parts = new SkinParts((byte) settings.getSkinParts());
|
||||||
}
|
}
|
||||||
|
@ -59,18 +59,18 @@ import com.velocitypowered.proxy.connection.util.ConnectionRequestResults.Impl;
|
|||||||
import com.velocitypowered.proxy.connection.util.VelocityInboundConnection;
|
import com.velocitypowered.proxy.connection.util.VelocityInboundConnection;
|
||||||
import com.velocitypowered.proxy.protocol.StateRegistry;
|
import com.velocitypowered.proxy.protocol.StateRegistry;
|
||||||
import com.velocitypowered.proxy.protocol.netty.MinecraftEncoder;
|
import com.velocitypowered.proxy.protocol.netty.MinecraftEncoder;
|
||||||
import com.velocitypowered.proxy.protocol.packet.ClientSettings;
|
import com.velocitypowered.proxy.protocol.packet.ClientSettingsPacket;
|
||||||
import com.velocitypowered.proxy.protocol.packet.Disconnect;
|
import com.velocitypowered.proxy.protocol.packet.DisconnectPacket;
|
||||||
import com.velocitypowered.proxy.protocol.packet.HeaderAndFooter;
|
import com.velocitypowered.proxy.protocol.packet.HeaderAndFooterPacket;
|
||||||
import com.velocitypowered.proxy.protocol.packet.KeepAlive;
|
import com.velocitypowered.proxy.protocol.packet.KeepAlivePacket;
|
||||||
import com.velocitypowered.proxy.protocol.packet.PluginMessage;
|
import com.velocitypowered.proxy.protocol.packet.PluginMessagePacket;
|
||||||
import com.velocitypowered.proxy.protocol.packet.ResourcePackRequest;
|
import com.velocitypowered.proxy.protocol.packet.ResourcePackRequestPacket;
|
||||||
import com.velocitypowered.proxy.protocol.packet.chat.ChatQueue;
|
import com.velocitypowered.proxy.protocol.packet.chat.ChatQueue;
|
||||||
import com.velocitypowered.proxy.protocol.packet.chat.ChatType;
|
import com.velocitypowered.proxy.protocol.packet.chat.ChatType;
|
||||||
import com.velocitypowered.proxy.protocol.packet.chat.ComponentHolder;
|
import com.velocitypowered.proxy.protocol.packet.chat.ComponentHolder;
|
||||||
import com.velocitypowered.proxy.protocol.packet.chat.builder.ChatBuilderFactory;
|
import com.velocitypowered.proxy.protocol.packet.chat.builder.ChatBuilderFactory;
|
||||||
import com.velocitypowered.proxy.protocol.packet.chat.legacy.LegacyChat;
|
import com.velocitypowered.proxy.protocol.packet.chat.legacy.LegacyChatPacket;
|
||||||
import com.velocitypowered.proxy.protocol.packet.config.StartUpdate;
|
import com.velocitypowered.proxy.protocol.packet.config.StartUpdatePacket;
|
||||||
import com.velocitypowered.proxy.protocol.packet.title.GenericTitlePacket;
|
import com.velocitypowered.proxy.protocol.packet.title.GenericTitlePacket;
|
||||||
import com.velocitypowered.proxy.server.VelocityRegisteredServer;
|
import com.velocitypowered.proxy.server.VelocityRegisteredServer;
|
||||||
import com.velocitypowered.proxy.tablist.InternalTabList;
|
import com.velocitypowered.proxy.tablist.InternalTabList;
|
||||||
@ -163,7 +163,7 @@ public class ConnectedPlayer implements MinecraftConnectionAssociation, Player,
|
|||||||
private @Nullable String clientBrand;
|
private @Nullable String clientBrand;
|
||||||
private @Nullable Locale effectiveLocale;
|
private @Nullable Locale effectiveLocale;
|
||||||
private @Nullable IdentifiedKey playerKey;
|
private @Nullable IdentifiedKey playerKey;
|
||||||
private @Nullable ClientSettings clientSettingsPacket;
|
private @Nullable ClientSettingsPacket clientSettingsPacket;
|
||||||
private final ChatQueue chatQueue;
|
private final ChatQueue chatQueue;
|
||||||
private final ChatBuilderFactory chatBuilderFactory;
|
private final ChatBuilderFactory chatBuilderFactory;
|
||||||
|
|
||||||
@ -272,7 +272,7 @@ public class ConnectedPlayer implements MinecraftConnectionAssociation, Player,
|
|||||||
return settings == null ? ClientSettingsWrapper.DEFAULT : this.settings;
|
return settings == null ? ClientSettingsWrapper.DEFAULT : this.settings;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ClientSettings getClientSettingsPacket() {
|
public ClientSettingsPacket getClientSettingsPacket() {
|
||||||
return clientSettingsPacket;
|
return clientSettingsPacket;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -286,7 +286,7 @@ public class ConnectedPlayer implements MinecraftConnectionAssociation, Player,
|
|||||||
*
|
*
|
||||||
* @param clientSettingsPacket the player settings packet
|
* @param clientSettingsPacket the player settings packet
|
||||||
*/
|
*/
|
||||||
public void setClientSettings(final ClientSettings clientSettingsPacket) {
|
public void setClientSettings(final ClientSettingsPacket clientSettingsPacket) {
|
||||||
this.clientSettingsPacket = clientSettingsPacket;
|
this.clientSettingsPacket = clientSettingsPacket;
|
||||||
final ClientSettingsWrapper cs = new ClientSettingsWrapper(clientSettingsPacket);
|
final ClientSettingsWrapper cs = new ClientSettingsWrapper(clientSettingsPacket);
|
||||||
this.settings = cs;
|
this.settings = cs;
|
||||||
@ -383,9 +383,9 @@ public class ConnectedPlayer implements MinecraftConnectionAssociation, Player,
|
|||||||
JsonObject object = new JsonObject();
|
JsonObject object = new JsonObject();
|
||||||
object.addProperty("text", LegacyComponentSerializer.legacySection()
|
object.addProperty("text", LegacyComponentSerializer.legacySection()
|
||||||
.serialize(translated));
|
.serialize(translated));
|
||||||
LegacyChat legacyChat = new LegacyChat();
|
LegacyChatPacket legacyChat = new LegacyChatPacket();
|
||||||
legacyChat.setMessage(object.toString());
|
legacyChat.setMessage(object.toString());
|
||||||
legacyChat.setType(LegacyChat.GAME_INFO_TYPE);
|
legacyChat.setType(LegacyChatPacket.GAME_INFO_TYPE);
|
||||||
connection.write(legacyChat);
|
connection.write(legacyChat);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -417,7 +417,7 @@ public class ConnectedPlayer implements MinecraftConnectionAssociation, Player,
|
|||||||
this.playerListHeader = translatedHeader;
|
this.playerListHeader = translatedHeader;
|
||||||
this.playerListFooter = translatedFooter;
|
this.playerListFooter = translatedFooter;
|
||||||
if (this.getProtocolVersion().compareTo(ProtocolVersion.MINECRAFT_1_8) >= 0) {
|
if (this.getProtocolVersion().compareTo(ProtocolVersion.MINECRAFT_1_8) >= 0) {
|
||||||
this.connection.write(HeaderAndFooter.create(
|
this.connection.write(HeaderAndFooterPacket.create(
|
||||||
translatedHeader, translatedFooter, this.getProtocolVersion()));
|
translatedHeader, translatedFooter, this.getProtocolVersion()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -543,7 +543,7 @@ public class ConnectedPlayer implements MinecraftConnectionAssociation, Player,
|
|||||||
public void clearPlayerListHeaderAndFooter() {
|
public void clearPlayerListHeaderAndFooter() {
|
||||||
clearPlayerListHeaderAndFooterSilent();
|
clearPlayerListHeaderAndFooterSilent();
|
||||||
if (this.getProtocolVersion().compareTo(ProtocolVersion.MINECRAFT_1_8) >= 0) {
|
if (this.getProtocolVersion().compareTo(ProtocolVersion.MINECRAFT_1_8) >= 0) {
|
||||||
this.connection.write(HeaderAndFooter.reset(this.getProtocolVersion()));
|
this.connection.write(HeaderAndFooterPacket.reset(this.getProtocolVersion()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -578,7 +578,8 @@ public class ConnectedPlayer implements MinecraftConnectionAssociation, Player,
|
|||||||
if (server.getConfiguration().isLogPlayerConnections()) {
|
if (server.getConfiguration().isLogPlayerConnections()) {
|
||||||
logger.info(Component.text(this + " has disconnected: ").append(translated));
|
logger.info(Component.text(this + " has disconnected: ").append(translated));
|
||||||
}
|
}
|
||||||
connection.closeWith(Disconnect.create(translated, this.getProtocolVersion(), duringLogin));
|
connection.closeWith(DisconnectPacket.create(translated,
|
||||||
|
this.getProtocolVersion(), duringLogin));
|
||||||
}
|
}
|
||||||
|
|
||||||
public @Nullable VelocityServerConnection getConnectedServer() {
|
public @Nullable VelocityServerConnection getConnectedServer() {
|
||||||
@ -639,7 +640,7 @@ public class ConnectedPlayer implements MinecraftConnectionAssociation, Player,
|
|||||||
* @param disconnect the disconnect packet
|
* @param disconnect the disconnect packet
|
||||||
* @param safe whether or not we can safely reconnect to a new server
|
* @param safe whether or not we can safely reconnect to a new server
|
||||||
*/
|
*/
|
||||||
public void handleConnectionException(RegisteredServer server, Disconnect disconnect,
|
public void handleConnectionException(RegisteredServer server, DisconnectPacket disconnect,
|
||||||
boolean safe) {
|
boolean safe) {
|
||||||
if (!isActive()) {
|
if (!isActive()) {
|
||||||
// If the connection is no longer active, it makes no sense to try and recover it.
|
// If the connection is no longer active, it makes no sense to try and recover it.
|
||||||
@ -749,7 +750,7 @@ public class ConnectedPlayer implements MinecraftConnectionAssociation, Player,
|
|||||||
Component reason = status.getReasonComponent()
|
Component reason = status.getReasonComponent()
|
||||||
.orElse(ConnectionMessages.INTERNAL_SERVER_CONNECTION_ERROR);
|
.orElse(ConnectionMessages.INTERNAL_SERVER_CONNECTION_ERROR);
|
||||||
handleConnectionException(res.getServer(),
|
handleConnectionException(res.getServer(),
|
||||||
Disconnect.create(reason, getProtocolVersion(), false),
|
DisconnectPacket.create(reason, getProtocolVersion(), false),
|
||||||
((Impl) status).isSafe());
|
((Impl) status).isSafe());
|
||||||
break;
|
break;
|
||||||
case SUCCESS:
|
case SUCCESS:
|
||||||
@ -921,7 +922,8 @@ public class ConnectedPlayer implements MinecraftConnectionAssociation, Player,
|
|||||||
public boolean sendPluginMessage(ChannelIdentifier identifier, byte[] data) {
|
public boolean sendPluginMessage(ChannelIdentifier identifier, byte[] data) {
|
||||||
Preconditions.checkNotNull(identifier, "identifier");
|
Preconditions.checkNotNull(identifier, "identifier");
|
||||||
Preconditions.checkNotNull(data, "data");
|
Preconditions.checkNotNull(data, "data");
|
||||||
PluginMessage message = new PluginMessage(identifier.getId(), Unpooled.wrappedBuffer(data));
|
PluginMessagePacket message = new PluginMessagePacket(identifier.getId(),
|
||||||
|
Unpooled.wrappedBuffer(data));
|
||||||
connection.write(message);
|
connection.write(message);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -937,8 +939,8 @@ public class ConnectedPlayer implements MinecraftConnectionAssociation, Player,
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void spoofChatInput(String input) {
|
public void spoofChatInput(String input) {
|
||||||
Preconditions.checkArgument(input.length() <= LegacyChat.MAX_SERVERBOUND_MESSAGE_LENGTH,
|
Preconditions.checkArgument(input.length() <= LegacyChatPacket.MAX_SERVERBOUND_MESSAGE_LENGTH,
|
||||||
"input cannot be greater than " + LegacyChat.MAX_SERVERBOUND_MESSAGE_LENGTH
|
"input cannot be greater than " + LegacyChatPacket.MAX_SERVERBOUND_MESSAGE_LENGTH
|
||||||
+ " characters in length");
|
+ " characters in length");
|
||||||
if (getProtocolVersion().compareTo(ProtocolVersion.MINECRAFT_1_19) >= 0) {
|
if (getProtocolVersion().compareTo(ProtocolVersion.MINECRAFT_1_19) >= 0) {
|
||||||
this.chatQueue.hijack(getChatBuilderFactory().builder().asPlayer(this).message(input),
|
this.chatQueue.hijack(getChatBuilderFactory().builder().asPlayer(this).message(input),
|
||||||
@ -1006,7 +1008,7 @@ public class ConnectedPlayer implements MinecraftConnectionAssociation, Player,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ResourcePackRequest request = new ResourcePackRequest();
|
ResourcePackRequestPacket request = new ResourcePackRequestPacket();
|
||||||
request.setId(queued.getId());
|
request.setId(queued.getId());
|
||||||
request.setUrl(queued.getUrl());
|
request.setUrl(queued.getUrl());
|
||||||
if (queued.getHash() != null) {
|
if (queued.getHash() != null) {
|
||||||
@ -1109,13 +1111,14 @@ public class ConnectedPlayer implements MinecraftConnectionAssociation, Player,
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sends a {@link KeepAlive} packet to the player with a random ID. The response will be ignored
|
* Sends a {@link KeepAlivePacket} packet to the player with a random ID.
|
||||||
* by Velocity as it will not match the ID last sent by the server.
|
* The response will be ignored by Velocity as it will not match
|
||||||
|
* the ID last sent by the server.
|
||||||
*/
|
*/
|
||||||
public void sendKeepAlive() {
|
public void sendKeepAlive() {
|
||||||
if (connection.getState() == StateRegistry.PLAY
|
if (connection.getState() == StateRegistry.PLAY
|
||||||
|| connection.getState() == StateRegistry.CONFIG) {
|
|| connection.getState() == StateRegistry.CONFIG) {
|
||||||
KeepAlive keepAlive = new KeepAlive();
|
KeepAlivePacket keepAlive = new KeepAlivePacket();
|
||||||
keepAlive.setRandomId(ThreadLocalRandom.current().nextLong());
|
keepAlive.setRandomId(ThreadLocalRandom.current().nextLong());
|
||||||
connection.write(keepAlive);
|
connection.write(keepAlive);
|
||||||
}
|
}
|
||||||
@ -1126,7 +1129,7 @@ public class ConnectedPlayer implements MinecraftConnectionAssociation, Player,
|
|||||||
*/
|
*/
|
||||||
public void switchToConfigState() {
|
public void switchToConfigState() {
|
||||||
CompletableFuture.runAsync(() -> {
|
CompletableFuture.runAsync(() -> {
|
||||||
connection.write(new StartUpdate());
|
connection.write(new StartUpdatePacket());
|
||||||
connection.getChannel().pipeline()
|
connection.getChannel().pipeline()
|
||||||
.get(MinecraftEncoder.class).setState(StateRegistry.CONFIG);
|
.get(MinecraftEncoder.class).setState(StateRegistry.CONFIG);
|
||||||
// Make sure we don't send any play packets to the player after update start
|
// Make sure we don't send any play packets to the player after update start
|
||||||
@ -1275,7 +1278,7 @@ public class ConnectedPlayer implements MinecraftConnectionAssociation, Player,
|
|||||||
Component reason = status.getReasonComponent()
|
Component reason = status.getReasonComponent()
|
||||||
.orElse(ConnectionMessages.INTERNAL_SERVER_CONNECTION_ERROR);
|
.orElse(ConnectionMessages.INTERNAL_SERVER_CONNECTION_ERROR);
|
||||||
handleConnectionException(toConnect,
|
handleConnectionException(toConnect,
|
||||||
Disconnect.create(reason, getProtocolVersion(), false), status.isSafe());
|
DisconnectPacket.create(reason, getProtocolVersion(), false), status.isSafe());
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
// The only remaining value is successful (no need to do anything!)
|
// The only remaining value is successful (no need to do anything!)
|
||||||
|
@ -33,10 +33,10 @@ import com.velocitypowered.proxy.connection.forge.modern.ModernForgeConstants;
|
|||||||
import com.velocitypowered.proxy.connection.util.VelocityInboundConnection;
|
import com.velocitypowered.proxy.connection.util.VelocityInboundConnection;
|
||||||
import com.velocitypowered.proxy.protocol.MinecraftPacket;
|
import com.velocitypowered.proxy.protocol.MinecraftPacket;
|
||||||
import com.velocitypowered.proxy.protocol.StateRegistry;
|
import com.velocitypowered.proxy.protocol.StateRegistry;
|
||||||
import com.velocitypowered.proxy.protocol.packet.Handshake;
|
import com.velocitypowered.proxy.protocol.packet.HandshakePacket;
|
||||||
import com.velocitypowered.proxy.protocol.packet.LegacyDisconnect;
|
import com.velocitypowered.proxy.protocol.packet.LegacyDisconnect;
|
||||||
import com.velocitypowered.proxy.protocol.packet.LegacyHandshake;
|
import com.velocitypowered.proxy.protocol.packet.LegacyHandshakePacket;
|
||||||
import com.velocitypowered.proxy.protocol.packet.LegacyPing;
|
import com.velocitypowered.proxy.protocol.packet.LegacyPingPacket;
|
||||||
import io.netty.buffer.ByteBuf;
|
import io.netty.buffer.ByteBuf;
|
||||||
import java.net.InetAddress;
|
import java.net.InetAddress;
|
||||||
import java.net.InetSocketAddress;
|
import java.net.InetSocketAddress;
|
||||||
@ -65,7 +65,7 @@ public class HandshakeSessionHandler implements MinecraftSessionHandler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean handle(LegacyPing packet) {
|
public boolean handle(LegacyPingPacket packet) {
|
||||||
connection.setProtocolVersion(ProtocolVersion.LEGACY);
|
connection.setProtocolVersion(ProtocolVersion.LEGACY);
|
||||||
StatusSessionHandler handler =
|
StatusSessionHandler handler =
|
||||||
new StatusSessionHandler(server, new LegacyInboundConnection(connection, packet));
|
new StatusSessionHandler(server, new LegacyInboundConnection(connection, packet));
|
||||||
@ -75,7 +75,7 @@ public class HandshakeSessionHandler implements MinecraftSessionHandler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean handle(LegacyHandshake packet) {
|
public boolean handle(LegacyHandshakePacket packet) {
|
||||||
connection.closeWith(LegacyDisconnect.from(Component.text(
|
connection.closeWith(LegacyDisconnect.from(Component.text(
|
||||||
"Your client is extremely old. Please update to a newer version of Minecraft.",
|
"Your client is extremely old. Please update to a newer version of Minecraft.",
|
||||||
NamedTextColor.RED)
|
NamedTextColor.RED)
|
||||||
@ -84,7 +84,7 @@ public class HandshakeSessionHandler implements MinecraftSessionHandler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean handle(Handshake handshake) {
|
public boolean handle(HandshakePacket handshake) {
|
||||||
InitialInboundConnection ic = new InitialInboundConnection(connection,
|
InitialInboundConnection ic = new InitialInboundConnection(connection,
|
||||||
cleanVhost(handshake.getServerAddress()), handshake);
|
cleanVhost(handshake.getServerAddress()), handshake);
|
||||||
StateRegistry nextState = getStateForProtocol(handshake.getNextStatus());
|
StateRegistry nextState = getStateForProtocol(handshake.getNextStatus());
|
||||||
@ -123,7 +123,7 @@ public class HandshakeSessionHandler implements MinecraftSessionHandler {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void handleLogin(Handshake handshake, InitialInboundConnection ic) {
|
private void handleLogin(HandshakePacket handshake, InitialInboundConnection ic) {
|
||||||
if (!ProtocolVersion.isSupported(handshake.getProtocolVersion())) {
|
if (!ProtocolVersion.isSupported(handshake.getProtocolVersion())) {
|
||||||
ic.disconnectQuietly(Component.translatable("multiplayer.disconnect.outdated_client")
|
ic.disconnectQuietly(Component.translatable("multiplayer.disconnect.outdated_client")
|
||||||
.args(Component.text(ProtocolVersion.SUPPORTED_VERSION_STRING)));
|
.args(Component.text(ProtocolVersion.SUPPORTED_VERSION_STRING)));
|
||||||
@ -153,7 +153,7 @@ public class HandshakeSessionHandler implements MinecraftSessionHandler {
|
|||||||
new InitialLoginSessionHandler(server, connection, lic));
|
new InitialLoginSessionHandler(server, connection, lic));
|
||||||
}
|
}
|
||||||
|
|
||||||
private ConnectionType getHandshakeConnectionType(Handshake handshake) {
|
private ConnectionType getHandshakeConnectionType(HandshakePacket handshake) {
|
||||||
if (handshake.getServerAddress().contains(ModernForgeConstants.MODERN_FORGE_TOKEN)
|
if (handshake.getServerAddress().contains(ModernForgeConstants.MODERN_FORGE_TOKEN)
|
||||||
&& handshake.getProtocolVersion().compareTo(ProtocolVersion.MINECRAFT_1_20_2) >= 0) {
|
&& handshake.getProtocolVersion().compareTo(ProtocolVersion.MINECRAFT_1_20_2) >= 0) {
|
||||||
return new ModernForgeConnectionType(handshake.getServerAddress());
|
return new ModernForgeConnectionType(handshake.getServerAddress());
|
||||||
@ -212,10 +212,10 @@ public class HandshakeSessionHandler implements MinecraftSessionHandler {
|
|||||||
private static class LegacyInboundConnection implements VelocityInboundConnection {
|
private static class LegacyInboundConnection implements VelocityInboundConnection {
|
||||||
|
|
||||||
private final MinecraftConnection connection;
|
private final MinecraftConnection connection;
|
||||||
private final LegacyPing ping;
|
private final LegacyPingPacket ping;
|
||||||
|
|
||||||
private LegacyInboundConnection(MinecraftConnection connection,
|
private LegacyInboundConnection(MinecraftConnection connection,
|
||||||
LegacyPing ping) {
|
LegacyPingPacket ping) {
|
||||||
this.connection = connection;
|
this.connection = connection;
|
||||||
this.ping = ping;
|
this.ping = ping;
|
||||||
}
|
}
|
||||||
|
@ -23,7 +23,7 @@ import com.velocitypowered.proxy.VelocityServer;
|
|||||||
import com.velocitypowered.proxy.connection.MinecraftSessionHandler;
|
import com.velocitypowered.proxy.connection.MinecraftSessionHandler;
|
||||||
import com.velocitypowered.proxy.connection.backend.BungeeCordMessageResponder;
|
import com.velocitypowered.proxy.connection.backend.BungeeCordMessageResponder;
|
||||||
import com.velocitypowered.proxy.connection.backend.VelocityServerConnection;
|
import com.velocitypowered.proxy.connection.backend.VelocityServerConnection;
|
||||||
import com.velocitypowered.proxy.protocol.packet.PluginMessage;
|
import com.velocitypowered.proxy.protocol.packet.PluginMessagePacket;
|
||||||
import io.netty.buffer.ByteBufUtil;
|
import io.netty.buffer.ByteBufUtil;
|
||||||
import io.netty.buffer.Unpooled;
|
import io.netty.buffer.Unpooled;
|
||||||
import org.apache.logging.log4j.LogManager;
|
import org.apache.logging.log4j.LogManager;
|
||||||
@ -47,7 +47,7 @@ public class InitialConnectSessionHandler implements MinecraftSessionHandler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean handle(PluginMessage packet) {
|
public boolean handle(PluginMessagePacket packet) {
|
||||||
VelocityServerConnection serverConn = player.getConnectionInFlight();
|
VelocityServerConnection serverConn = player.getConnectionInFlight();
|
||||||
if (serverConn != null) {
|
if (serverConn != null) {
|
||||||
if (player.getPhase().handle(player, packet, serverConn)) {
|
if (player.getPhase().handle(player, packet, serverConn)) {
|
||||||
@ -70,7 +70,7 @@ public class InitialConnectSessionHandler implements MinecraftSessionHandler {
|
|||||||
server.getEventManager().fire(event)
|
server.getEventManager().fire(event)
|
||||||
.thenAcceptAsync(pme -> {
|
.thenAcceptAsync(pme -> {
|
||||||
if (pme.getResult().isAllowed() && serverConn.isActive()) {
|
if (pme.getResult().isAllowed() && serverConn.isActive()) {
|
||||||
PluginMessage copied = new PluginMessage(packet.getChannel(),
|
PluginMessagePacket copied = new PluginMessagePacket(packet.getChannel(),
|
||||||
Unpooled.wrappedBuffer(copy));
|
Unpooled.wrappedBuffer(copy));
|
||||||
serverConn.ensureConnected().write(copied);
|
serverConn.ensureConnected().write(copied);
|
||||||
}
|
}
|
||||||
|
@ -22,8 +22,8 @@ import com.velocitypowered.api.proxy.InboundConnection;
|
|||||||
import com.velocitypowered.proxy.connection.MinecraftConnection;
|
import com.velocitypowered.proxy.connection.MinecraftConnection;
|
||||||
import com.velocitypowered.proxy.connection.MinecraftConnectionAssociation;
|
import com.velocitypowered.proxy.connection.MinecraftConnectionAssociation;
|
||||||
import com.velocitypowered.proxy.connection.util.VelocityInboundConnection;
|
import com.velocitypowered.proxy.connection.util.VelocityInboundConnection;
|
||||||
import com.velocitypowered.proxy.protocol.packet.Disconnect;
|
import com.velocitypowered.proxy.protocol.packet.DisconnectPacket;
|
||||||
import com.velocitypowered.proxy.protocol.packet.Handshake;
|
import com.velocitypowered.proxy.protocol.packet.HandshakePacket;
|
||||||
import com.velocitypowered.proxy.util.ClosestLocaleMatcher;
|
import com.velocitypowered.proxy.util.ClosestLocaleMatcher;
|
||||||
import java.net.InetSocketAddress;
|
import java.net.InetSocketAddress;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
@ -43,10 +43,10 @@ public final class InitialInboundConnection implements VelocityInboundConnection
|
|||||||
|
|
||||||
private final MinecraftConnection connection;
|
private final MinecraftConnection connection;
|
||||||
private final String cleanedAddress;
|
private final String cleanedAddress;
|
||||||
private final Handshake handshake;
|
private final HandshakePacket handshake;
|
||||||
|
|
||||||
InitialInboundConnection(MinecraftConnection connection, String cleanedAddress,
|
InitialInboundConnection(MinecraftConnection connection, String cleanedAddress,
|
||||||
Handshake handshake) {
|
HandshakePacket handshake) {
|
||||||
this.connection = connection;
|
this.connection = connection;
|
||||||
this.cleanedAddress = cleanedAddress;
|
this.cleanedAddress = cleanedAddress;
|
||||||
this.handshake = handshake;
|
this.handshake = handshake;
|
||||||
@ -98,7 +98,7 @@ public final class InitialInboundConnection implements VelocityInboundConnection
|
|||||||
if (connection.server.getConfiguration().isLogPlayerConnections()) {
|
if (connection.server.getConfiguration().isLogPlayerConnections()) {
|
||||||
logger.info(Component.text(this + " has disconnected: ").append(translated));
|
logger.info(Component.text(this + " has disconnected: ").append(translated));
|
||||||
}
|
}
|
||||||
connection.closeWith(Disconnect.create(translated, getProtocolVersion(), true));
|
connection.closeWith(DisconnectPacket.create(translated, getProtocolVersion(), true));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -109,6 +109,6 @@ public final class InitialInboundConnection implements VelocityInboundConnection
|
|||||||
public void disconnectQuietly(Component reason) {
|
public void disconnectQuietly(Component reason) {
|
||||||
Component translated = GlobalTranslator.render(reason, ClosestLocaleMatcher.INSTANCE
|
Component translated = GlobalTranslator.render(reason, ClosestLocaleMatcher.INSTANCE
|
||||||
.lookupClosest(Locale.getDefault()));
|
.lookupClosest(Locale.getDefault()));
|
||||||
connection.closeWith(Disconnect.create(translated, getProtocolVersion(), true));
|
connection.closeWith(DisconnectPacket.create(translated, getProtocolVersion(), true));
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -36,10 +36,10 @@ import com.velocitypowered.proxy.connection.MinecraftSessionHandler;
|
|||||||
import com.velocitypowered.proxy.crypto.IdentifiedKeyImpl;
|
import com.velocitypowered.proxy.crypto.IdentifiedKeyImpl;
|
||||||
import com.velocitypowered.proxy.protocol.StateRegistry;
|
import com.velocitypowered.proxy.protocol.StateRegistry;
|
||||||
import com.velocitypowered.proxy.protocol.netty.MinecraftDecoder;
|
import com.velocitypowered.proxy.protocol.netty.MinecraftDecoder;
|
||||||
import com.velocitypowered.proxy.protocol.packet.EncryptionRequest;
|
import com.velocitypowered.proxy.protocol.packet.EncryptionRequestPacket;
|
||||||
import com.velocitypowered.proxy.protocol.packet.EncryptionResponse;
|
import com.velocitypowered.proxy.protocol.packet.EncryptionResponsePacket;
|
||||||
import com.velocitypowered.proxy.protocol.packet.LoginPluginResponse;
|
import com.velocitypowered.proxy.protocol.packet.LoginPluginResponsePacket;
|
||||||
import com.velocitypowered.proxy.protocol.packet.ServerLogin;
|
import com.velocitypowered.proxy.protocol.packet.ServerLoginPacket;
|
||||||
import io.netty.buffer.ByteBuf;
|
import io.netty.buffer.ByteBuf;
|
||||||
import java.net.InetSocketAddress;
|
import java.net.InetSocketAddress;
|
||||||
import java.net.URI;
|
import java.net.URI;
|
||||||
@ -71,7 +71,7 @@ public class InitialLoginSessionHandler implements MinecraftSessionHandler {
|
|||||||
private final VelocityServer server;
|
private final VelocityServer server;
|
||||||
private final MinecraftConnection mcConnection;
|
private final MinecraftConnection mcConnection;
|
||||||
private final LoginInboundConnection inbound;
|
private final LoginInboundConnection inbound;
|
||||||
private @MonotonicNonNull ServerLogin login;
|
private @MonotonicNonNull ServerLoginPacket login;
|
||||||
private byte[] verify = EMPTY_BYTE_ARRAY;
|
private byte[] verify = EMPTY_BYTE_ARRAY;
|
||||||
private LoginState currentState = LoginState.LOGIN_PACKET_EXPECTED;
|
private LoginState currentState = LoginState.LOGIN_PACKET_EXPECTED;
|
||||||
private boolean forceKeyAuthentication;
|
private boolean forceKeyAuthentication;
|
||||||
@ -87,7 +87,7 @@ public class InitialLoginSessionHandler implements MinecraftSessionHandler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean handle(ServerLogin packet) {
|
public boolean handle(ServerLoginPacket packet) {
|
||||||
assertState(LoginState.LOGIN_PACKET_EXPECTED);
|
assertState(LoginState.LOGIN_PACKET_EXPECTED);
|
||||||
this.currentState = LoginState.LOGIN_PACKET_RECEIVED;
|
this.currentState = LoginState.LOGIN_PACKET_RECEIVED;
|
||||||
IdentifiedKey playerKey = packet.getPlayerKey();
|
IdentifiedKey playerKey = packet.getPlayerKey();
|
||||||
@ -145,7 +145,7 @@ public class InitialLoginSessionHandler implements MinecraftSessionHandler {
|
|||||||
if (!result.isForceOfflineMode()
|
if (!result.isForceOfflineMode()
|
||||||
&& (server.getConfiguration().isOnlineMode() || result.isOnlineModeAllowed())) {
|
&& (server.getConfiguration().isOnlineMode() || result.isOnlineModeAllowed())) {
|
||||||
// Request encryption.
|
// Request encryption.
|
||||||
EncryptionRequest request = generateEncryptionRequest();
|
EncryptionRequestPacket request = generateEncryptionRequest();
|
||||||
this.verify = Arrays.copyOf(request.getVerifyToken(), 4);
|
this.verify = Arrays.copyOf(request.getVerifyToken(), 4);
|
||||||
mcConnection.write(request);
|
mcConnection.write(request);
|
||||||
this.currentState = LoginState.ENCRYPTION_REQUEST_SENT;
|
this.currentState = LoginState.ENCRYPTION_REQUEST_SENT;
|
||||||
@ -165,16 +165,16 @@ public class InitialLoginSessionHandler implements MinecraftSessionHandler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean handle(LoginPluginResponse packet) {
|
public boolean handle(LoginPluginResponsePacket packet) {
|
||||||
this.inbound.handleLoginPluginResponse(packet);
|
this.inbound.handleLoginPluginResponse(packet);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean handle(EncryptionResponse packet) {
|
public boolean handle(EncryptionResponsePacket packet) {
|
||||||
assertState(LoginState.ENCRYPTION_REQUEST_SENT);
|
assertState(LoginState.ENCRYPTION_REQUEST_SENT);
|
||||||
this.currentState = LoginState.ENCRYPTION_RESPONSE_RECEIVED;
|
this.currentState = LoginState.ENCRYPTION_RESPONSE_RECEIVED;
|
||||||
ServerLogin login = this.login;
|
ServerLoginPacket login = this.login;
|
||||||
if (login == null) {
|
if (login == null) {
|
||||||
throw new IllegalStateException("No ServerLogin packet received yet.");
|
throw new IllegalStateException("No ServerLogin packet received yet.");
|
||||||
}
|
}
|
||||||
@ -274,11 +274,11 @@ public class InitialLoginSessionHandler implements MinecraftSessionHandler {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
private EncryptionRequest generateEncryptionRequest() {
|
private EncryptionRequestPacket generateEncryptionRequest() {
|
||||||
byte[] verify = new byte[4];
|
byte[] verify = new byte[4];
|
||||||
ThreadLocalRandom.current().nextBytes(verify);
|
ThreadLocalRandom.current().nextBytes(verify);
|
||||||
|
|
||||||
EncryptionRequest request = new EncryptionRequest();
|
EncryptionRequestPacket request = new EncryptionRequestPacket();
|
||||||
request.setPublicKey(server.getServerKeyPair().getPublic().getEncoded());
|
request.setPublicKey(server.getServerKeyPair().getPublic().getEncoded());
|
||||||
request.setVerifyToken(verify);
|
request.setVerifyToken(verify);
|
||||||
return request;
|
return request;
|
||||||
|
@ -23,8 +23,8 @@ import com.velocitypowered.api.proxy.crypto.IdentifiedKey;
|
|||||||
import com.velocitypowered.api.proxy.crypto.KeyIdentifiable;
|
import com.velocitypowered.api.proxy.crypto.KeyIdentifiable;
|
||||||
import com.velocitypowered.api.proxy.messages.ChannelIdentifier;
|
import com.velocitypowered.api.proxy.messages.ChannelIdentifier;
|
||||||
import com.velocitypowered.proxy.connection.MinecraftConnection;
|
import com.velocitypowered.proxy.connection.MinecraftConnection;
|
||||||
import com.velocitypowered.proxy.protocol.packet.LoginPluginMessage;
|
import com.velocitypowered.proxy.protocol.packet.LoginPluginMessagePacket;
|
||||||
import com.velocitypowered.proxy.protocol.packet.LoginPluginResponse;
|
import com.velocitypowered.proxy.protocol.packet.LoginPluginResponsePacket;
|
||||||
import io.netty.buffer.ByteBufUtil;
|
import io.netty.buffer.ByteBufUtil;
|
||||||
import io.netty.buffer.Unpooled;
|
import io.netty.buffer.Unpooled;
|
||||||
import it.unimi.dsi.fastutil.ints.Int2ObjectMap;
|
import it.unimi.dsi.fastutil.ints.Int2ObjectMap;
|
||||||
@ -48,7 +48,7 @@ public class LoginInboundConnection implements LoginPhaseConnection, KeyIdentifi
|
|||||||
private final InitialInboundConnection delegate;
|
private final InitialInboundConnection delegate;
|
||||||
private final Int2ObjectMap<MessageConsumer> outstandingResponses;
|
private final Int2ObjectMap<MessageConsumer> outstandingResponses;
|
||||||
private volatile int sequenceCounter;
|
private volatile int sequenceCounter;
|
||||||
private final Queue<LoginPluginMessage> loginMessagesToSend;
|
private final Queue<LoginPluginMessagePacket> loginMessagesToSend;
|
||||||
private volatile Runnable onAllMessagesHandled;
|
private volatile Runnable onAllMessagesHandled;
|
||||||
private volatile boolean loginEventFired;
|
private volatile boolean loginEventFired;
|
||||||
private @MonotonicNonNull IdentifiedKey playerKey;
|
private @MonotonicNonNull IdentifiedKey playerKey;
|
||||||
@ -100,7 +100,7 @@ public class LoginInboundConnection implements LoginPhaseConnection, KeyIdentifi
|
|||||||
final int id = SEQUENCE_UPDATER.incrementAndGet(this);
|
final int id = SEQUENCE_UPDATER.incrementAndGet(this);
|
||||||
this.outstandingResponses.put(id, consumer);
|
this.outstandingResponses.put(id, consumer);
|
||||||
|
|
||||||
final LoginPluginMessage message = new LoginPluginMessage(id, identifier.getId(),
|
final LoginPluginMessagePacket message = new LoginPluginMessagePacket(id, identifier.getId(),
|
||||||
Unpooled.wrappedBuffer(contents));
|
Unpooled.wrappedBuffer(contents));
|
||||||
if (!this.loginEventFired) {
|
if (!this.loginEventFired) {
|
||||||
this.loginMessagesToSend.add(message);
|
this.loginMessagesToSend.add(message);
|
||||||
@ -125,7 +125,7 @@ public class LoginInboundConnection implements LoginPhaseConnection, KeyIdentifi
|
|||||||
this.onAllMessagesHandled = null;
|
this.onAllMessagesHandled = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
void handleLoginPluginResponse(final LoginPluginResponse response) {
|
void handleLoginPluginResponse(final LoginPluginResponsePacket response) {
|
||||||
final MessageConsumer consumer = this.outstandingResponses.remove(response.getId());
|
final MessageConsumer consumer = this.outstandingResponses.remove(response.getId());
|
||||||
if (consumer != null) {
|
if (consumer != null) {
|
||||||
try {
|
try {
|
||||||
@ -144,7 +144,7 @@ public class LoginInboundConnection implements LoginPhaseConnection, KeyIdentifi
|
|||||||
this.loginEventFired = true;
|
this.loginEventFired = true;
|
||||||
this.onAllMessagesHandled = onAllMessagesHandled;
|
this.onAllMessagesHandled = onAllMessagesHandled;
|
||||||
if (!this.loginMessagesToSend.isEmpty()) {
|
if (!this.loginMessagesToSend.isEmpty()) {
|
||||||
LoginPluginMessage message;
|
LoginPluginMessagePacket message;
|
||||||
while ((message = this.loginMessagesToSend.poll()) != null) {
|
while ((message = this.loginMessagesToSend.poll()) != null) {
|
||||||
this.delegate.getConnection().delayedWrite(message);
|
this.delegate.getConnection().delayedWrite(message);
|
||||||
}
|
}
|
||||||
|
@ -23,10 +23,10 @@ import com.velocitypowered.proxy.connection.MinecraftConnection;
|
|||||||
import com.velocitypowered.proxy.connection.MinecraftSessionHandler;
|
import com.velocitypowered.proxy.connection.MinecraftSessionHandler;
|
||||||
import com.velocitypowered.proxy.connection.util.VelocityInboundConnection;
|
import com.velocitypowered.proxy.connection.util.VelocityInboundConnection;
|
||||||
import com.velocitypowered.proxy.protocol.packet.LegacyDisconnect;
|
import com.velocitypowered.proxy.protocol.packet.LegacyDisconnect;
|
||||||
import com.velocitypowered.proxy.protocol.packet.LegacyPing;
|
import com.velocitypowered.proxy.protocol.packet.LegacyPingPacket;
|
||||||
import com.velocitypowered.proxy.protocol.packet.StatusPing;
|
import com.velocitypowered.proxy.protocol.packet.StatusPingPacket;
|
||||||
import com.velocitypowered.proxy.protocol.packet.StatusRequest;
|
import com.velocitypowered.proxy.protocol.packet.StatusRequestPacket;
|
||||||
import com.velocitypowered.proxy.protocol.packet.StatusResponse;
|
import com.velocitypowered.proxy.protocol.packet.StatusResponsePacket;
|
||||||
import com.velocitypowered.proxy.util.except.QuietRuntimeException;
|
import com.velocitypowered.proxy.util.except.QuietRuntimeException;
|
||||||
import io.netty.buffer.ByteBuf;
|
import io.netty.buffer.ByteBuf;
|
||||||
import org.apache.logging.log4j.LogManager;
|
import org.apache.logging.log4j.LogManager;
|
||||||
@ -61,7 +61,7 @@ public class StatusSessionHandler implements MinecraftSessionHandler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean handle(LegacyPing packet) {
|
public boolean handle(LegacyPingPacket packet) {
|
||||||
if (this.pingReceived) {
|
if (this.pingReceived) {
|
||||||
throw EXPECTED_AWAITING_REQUEST;
|
throw EXPECTED_AWAITING_REQUEST;
|
||||||
}
|
}
|
||||||
@ -79,13 +79,13 @@ public class StatusSessionHandler implements MinecraftSessionHandler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean handle(StatusPing packet) {
|
public boolean handle(StatusPingPacket packet) {
|
||||||
connection.closeWith(packet);
|
connection.closeWith(packet);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean handle(StatusRequest packet) {
|
public boolean handle(StatusRequestPacket packet) {
|
||||||
if (this.pingReceived) {
|
if (this.pingReceived) {
|
||||||
throw EXPECTED_AWAITING_REQUEST;
|
throw EXPECTED_AWAITING_REQUEST;
|
||||||
}
|
}
|
||||||
@ -98,7 +98,7 @@ public class StatusSessionHandler implements MinecraftSessionHandler {
|
|||||||
StringBuilder json = new StringBuilder();
|
StringBuilder json = new StringBuilder();
|
||||||
VelocityServer.getPingGsonInstance(connection.getProtocolVersion())
|
VelocityServer.getPingGsonInstance(connection.getProtocolVersion())
|
||||||
.toJson(event.getPing(), json);
|
.toJson(event.getPing(), json);
|
||||||
connection.write(new StatusResponse(json));
|
connection.write(new StatusResponsePacket(json));
|
||||||
},
|
},
|
||||||
connection.eventLoop())
|
connection.eventLoop())
|
||||||
.exceptionally((ex) -> {
|
.exceptionally((ex) -> {
|
||||||
|
@ -23,7 +23,7 @@ import com.velocitypowered.proxy.connection.backend.BackendConnectionPhase;
|
|||||||
import com.velocitypowered.proxy.connection.backend.BackendConnectionPhases;
|
import com.velocitypowered.proxy.connection.backend.BackendConnectionPhases;
|
||||||
import com.velocitypowered.proxy.connection.backend.VelocityServerConnection;
|
import com.velocitypowered.proxy.connection.backend.VelocityServerConnection;
|
||||||
import com.velocitypowered.proxy.connection.client.ConnectedPlayer;
|
import com.velocitypowered.proxy.connection.client.ConnectedPlayer;
|
||||||
import com.velocitypowered.proxy.protocol.packet.PluginMessage;
|
import com.velocitypowered.proxy.protocol.packet.PluginMessagePacket;
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -123,7 +123,7 @@ public enum LegacyForgeHandshakeBackendPhase implements BackendConnectionPhase {
|
|||||||
@Override
|
@Override
|
||||||
public final boolean handle(VelocityServerConnection serverConnection,
|
public final boolean handle(VelocityServerConnection serverConnection,
|
||||||
ConnectedPlayer player,
|
ConnectedPlayer player,
|
||||||
PluginMessage message) {
|
PluginMessagePacket message) {
|
||||||
if (message.getChannel().equals(LegacyForgeConstants.FORGE_LEGACY_HANDSHAKE_CHANNEL)) {
|
if (message.getChannel().equals(LegacyForgeConstants.FORGE_LEGACY_HANDSHAKE_CHANNEL)) {
|
||||||
// Get the phase and check if we need to start the next phase.
|
// Get the phase and check if we need to start the next phase.
|
||||||
LegacyForgeHandshakeBackendPhase newPhase = getNewPhase(serverConnection, message);
|
LegacyForgeHandshakeBackendPhase newPhase = getNewPhase(serverConnection, message);
|
||||||
@ -177,7 +177,7 @@ public enum LegacyForgeHandshakeBackendPhase implements BackendConnectionPhase {
|
|||||||
* @return The phase to transition to, which may be the same as before.
|
* @return The phase to transition to, which may be the same as before.
|
||||||
*/
|
*/
|
||||||
private LegacyForgeHandshakeBackendPhase getNewPhase(VelocityServerConnection serverConnection,
|
private LegacyForgeHandshakeBackendPhase getNewPhase(VelocityServerConnection serverConnection,
|
||||||
PluginMessage packet) {
|
PluginMessagePacket packet) {
|
||||||
if (packetToAdvanceOn != null
|
if (packetToAdvanceOn != null
|
||||||
&& LegacyForgeUtil.getHandshakePacketDiscriminator(packet) == packetToAdvanceOn) {
|
&& LegacyForgeUtil.getHandshakePacketDiscriminator(packet) == packetToAdvanceOn) {
|
||||||
LegacyForgeHandshakeBackendPhase phaseToTransitionTo = nextPhase();
|
LegacyForgeHandshakeBackendPhase phaseToTransitionTo = nextPhase();
|
||||||
|
@ -24,7 +24,7 @@ import com.velocitypowered.proxy.connection.backend.VelocityServerConnection;
|
|||||||
import com.velocitypowered.proxy.connection.client.ClientConnectionPhase;
|
import com.velocitypowered.proxy.connection.client.ClientConnectionPhase;
|
||||||
import com.velocitypowered.proxy.connection.client.ClientPlaySessionHandler;
|
import com.velocitypowered.proxy.connection.client.ClientPlaySessionHandler;
|
||||||
import com.velocitypowered.proxy.connection.client.ConnectedPlayer;
|
import com.velocitypowered.proxy.connection.client.ConnectedPlayer;
|
||||||
import com.velocitypowered.proxy.protocol.packet.PluginMessage;
|
import com.velocitypowered.proxy.protocol.packet.PluginMessagePacket;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
|
|
||||||
@ -56,7 +56,7 @@ public enum LegacyForgeHandshakeClientPhase implements ClientConnectionPhase {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
boolean onHandle(ConnectedPlayer player,
|
boolean onHandle(ConnectedPlayer player,
|
||||||
PluginMessage message,
|
PluginMessagePacket message,
|
||||||
MinecraftConnection backendConn) {
|
MinecraftConnection backendConn) {
|
||||||
// If we stay in this phase, we do nothing because it means the packet wasn't handled.
|
// If we stay in this phase, we do nothing because it means the packet wasn't handled.
|
||||||
// Returning false indicates this
|
// Returning false indicates this
|
||||||
@ -88,7 +88,7 @@ public enum LegacyForgeHandshakeClientPhase implements ClientConnectionPhase {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
boolean onHandle(ConnectedPlayer player,
|
boolean onHandle(ConnectedPlayer player,
|
||||||
PluginMessage message,
|
PluginMessagePacket message,
|
||||||
MinecraftConnection backendConn) {
|
MinecraftConnection backendConn) {
|
||||||
// Read the mod list if we haven't already.
|
// Read the mod list if we haven't already.
|
||||||
if (!player.getModInfo().isPresent()) {
|
if (!player.getModInfo().isPresent()) {
|
||||||
@ -157,7 +157,7 @@ public enum LegacyForgeHandshakeClientPhase implements ClientConnectionPhase {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
boolean onHandle(ConnectedPlayer player,
|
boolean onHandle(ConnectedPlayer player,
|
||||||
PluginMessage message,
|
PluginMessagePacket message,
|
||||||
MinecraftConnection backendConn) {
|
MinecraftConnection backendConn) {
|
||||||
super.onHandle(player, message, backendConn);
|
super.onHandle(player, message, backendConn);
|
||||||
|
|
||||||
@ -190,7 +190,7 @@ public enum LegacyForgeHandshakeClientPhase implements ClientConnectionPhase {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public final boolean handle(ConnectedPlayer player,
|
public final boolean handle(ConnectedPlayer player,
|
||||||
PluginMessage message,
|
PluginMessagePacket message,
|
||||||
VelocityServerConnection server) {
|
VelocityServerConnection server) {
|
||||||
if (server != null) {
|
if (server != null) {
|
||||||
MinecraftConnection backendConn = server.getConnection();
|
MinecraftConnection backendConn = server.getConnection();
|
||||||
@ -220,7 +220,7 @@ public enum LegacyForgeHandshakeClientPhase implements ClientConnectionPhase {
|
|||||||
* @return true if handled, false otherwise.
|
* @return true if handled, false otherwise.
|
||||||
*/
|
*/
|
||||||
boolean onHandle(ConnectedPlayer player,
|
boolean onHandle(ConnectedPlayer player,
|
||||||
PluginMessage message,
|
PluginMessagePacket message,
|
||||||
MinecraftConnection backendConn) {
|
MinecraftConnection backendConn) {
|
||||||
// Send the packet on to the server.
|
// Send the packet on to the server.
|
||||||
backendConn.write(message.retain());
|
backendConn.write(message.retain());
|
||||||
@ -249,7 +249,7 @@ public enum LegacyForgeHandshakeClientPhase implements ClientConnectionPhase {
|
|||||||
* @param packet The packet
|
* @param packet The packet
|
||||||
* @return The phase to transition to, which may be the same as before.
|
* @return The phase to transition to, which may be the same as before.
|
||||||
*/
|
*/
|
||||||
private LegacyForgeHandshakeClientPhase getNewPhase(PluginMessage packet) {
|
private LegacyForgeHandshakeClientPhase getNewPhase(PluginMessagePacket packet) {
|
||||||
if (packetToAdvanceOn != null
|
if (packetToAdvanceOn != null
|
||||||
&& LegacyForgeUtil.getHandshakePacketDiscriminator(packet) == packetToAdvanceOn) {
|
&& LegacyForgeUtil.getHandshakePacketDiscriminator(packet) == packetToAdvanceOn) {
|
||||||
return nextPhase();
|
return nextPhase();
|
||||||
|
@ -25,7 +25,7 @@ import com.google.common.base.Preconditions;
|
|||||||
import com.google.common.collect.ImmutableList;
|
import com.google.common.collect.ImmutableList;
|
||||||
import com.velocitypowered.api.util.ModInfo;
|
import com.velocitypowered.api.util.ModInfo;
|
||||||
import com.velocitypowered.proxy.protocol.ProtocolUtils;
|
import com.velocitypowered.proxy.protocol.ProtocolUtils;
|
||||||
import com.velocitypowered.proxy.protocol.packet.PluginMessage;
|
import com.velocitypowered.proxy.protocol.packet.PluginMessagePacket;
|
||||||
import io.netty.buffer.ByteBuf;
|
import io.netty.buffer.ByteBuf;
|
||||||
import io.netty.buffer.Unpooled;
|
import io.netty.buffer.Unpooled;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@ -42,7 +42,7 @@ class LegacyForgeUtil {
|
|||||||
* @param message The message to analyse
|
* @param message The message to analyse
|
||||||
* @return The discriminator
|
* @return The discriminator
|
||||||
*/
|
*/
|
||||||
static byte getHandshakePacketDiscriminator(PluginMessage message) {
|
static byte getHandshakePacketDiscriminator(PluginMessagePacket message) {
|
||||||
Preconditions.checkArgument(message.getChannel().equals(FORGE_LEGACY_HANDSHAKE_CHANNEL));
|
Preconditions.checkArgument(message.getChannel().equals(FORGE_LEGACY_HANDSHAKE_CHANNEL));
|
||||||
Preconditions.checkArgument(message.content().isReadable());
|
Preconditions.checkArgument(message.content().isReadable());
|
||||||
return message.content().getByte(0);
|
return message.content().getByte(0);
|
||||||
@ -54,7 +54,7 @@ class LegacyForgeUtil {
|
|||||||
* @param message The message
|
* @param message The message
|
||||||
* @return The list of mods. May be empty.
|
* @return The list of mods. May be empty.
|
||||||
*/
|
*/
|
||||||
static List<ModInfo.Mod> readModList(PluginMessage message) {
|
static List<ModInfo.Mod> readModList(PluginMessagePacket message) {
|
||||||
Preconditions.checkNotNull(message, "message");
|
Preconditions.checkNotNull(message, "message");
|
||||||
Preconditions.checkArgument(message.getChannel().equals(FORGE_LEGACY_HANDSHAKE_CHANNEL),
|
Preconditions.checkArgument(message.getChannel().equals(FORGE_LEGACY_HANDSHAKE_CHANNEL),
|
||||||
"message is not a FML HS plugin message");
|
"message is not a FML HS plugin message");
|
||||||
@ -82,8 +82,8 @@ class LegacyForgeUtil {
|
|||||||
*
|
*
|
||||||
* @return A copy of the reset packet
|
* @return A copy of the reset packet
|
||||||
*/
|
*/
|
||||||
static PluginMessage resetPacket() {
|
static PluginMessagePacket resetPacket() {
|
||||||
PluginMessage msg = new PluginMessage();
|
PluginMessagePacket msg = new PluginMessagePacket();
|
||||||
msg.setChannel(FORGE_LEGACY_HANDSHAKE_CHANNEL);
|
msg.setChannel(FORGE_LEGACY_HANDSHAKE_CHANNEL);
|
||||||
msg.replace(Unpooled.wrappedBuffer(FORGE_LEGACY_HANDSHAKE_RESET_DATA.clone()));
|
msg.replace(Unpooled.wrappedBuffer(FORGE_LEGACY_HANDSHAKE_RESET_DATA.clone()));
|
||||||
return msg;
|
return msg;
|
||||||
|
@ -20,7 +20,7 @@ package com.velocitypowered.proxy.connection.util;
|
|||||||
import com.velocitypowered.api.proxy.ConnectionRequestBuilder;
|
import com.velocitypowered.api.proxy.ConnectionRequestBuilder;
|
||||||
import com.velocitypowered.api.proxy.ConnectionRequestBuilder.Status;
|
import com.velocitypowered.api.proxy.ConnectionRequestBuilder.Status;
|
||||||
import com.velocitypowered.api.proxy.server.RegisteredServer;
|
import com.velocitypowered.api.proxy.server.RegisteredServer;
|
||||||
import com.velocitypowered.proxy.protocol.packet.Disconnect;
|
import com.velocitypowered.proxy.protocol.packet.DisconnectPacket;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
import net.kyori.adventure.text.Component;
|
import net.kyori.adventure.text.Component;
|
||||||
@ -62,11 +62,11 @@ public class ConnectionRequestResults {
|
|||||||
return new Impl(Status.SERVER_DISCONNECTED, component, server, true);
|
return new Impl(Status.SERVER_DISCONNECTED, component, server, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Impl forDisconnect(Disconnect disconnect, RegisteredServer server) {
|
public static Impl forDisconnect(DisconnectPacket disconnect, RegisteredServer server) {
|
||||||
return forDisconnect(disconnect.getReason().getComponent(), server);
|
return forDisconnect(disconnect.getReason().getComponent(), server);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Impl forUnsafeDisconnect(Disconnect disconnect, RegisteredServer server) {
|
public static Impl forUnsafeDisconnect(DisconnectPacket disconnect, RegisteredServer server) {
|
||||||
return new Impl(Status.SERVER_DISCONNECTED, disconnect.getReason().getComponent(), server,
|
return new Impl(Status.SERVER_DISCONNECTED, disconnect.getReason().getComponent(), server,
|
||||||
false);
|
false);
|
||||||
}
|
}
|
||||||
|
@ -46,50 +46,50 @@ import static com.velocitypowered.proxy.protocol.ProtocolUtils.Direction.CLIENTB
|
|||||||
import static com.velocitypowered.proxy.protocol.ProtocolUtils.Direction.SERVERBOUND;
|
import static com.velocitypowered.proxy.protocol.ProtocolUtils.Direction.SERVERBOUND;
|
||||||
|
|
||||||
import com.velocitypowered.api.network.ProtocolVersion;
|
import com.velocitypowered.api.network.ProtocolVersion;
|
||||||
import com.velocitypowered.proxy.protocol.packet.AvailableCommands;
|
import com.velocitypowered.proxy.protocol.packet.AvailableCommandsPacket;
|
||||||
import com.velocitypowered.proxy.protocol.packet.BossBar;
|
import com.velocitypowered.proxy.protocol.packet.BossBarPacket;
|
||||||
import com.velocitypowered.proxy.protocol.packet.ClientSettings;
|
import com.velocitypowered.proxy.protocol.packet.ClientSettingsPacket;
|
||||||
import com.velocitypowered.proxy.protocol.packet.Disconnect;
|
import com.velocitypowered.proxy.protocol.packet.DisconnectPacket;
|
||||||
import com.velocitypowered.proxy.protocol.packet.EncryptionRequest;
|
import com.velocitypowered.proxy.protocol.packet.EncryptionRequestPacket;
|
||||||
import com.velocitypowered.proxy.protocol.packet.EncryptionResponse;
|
import com.velocitypowered.proxy.protocol.packet.EncryptionResponsePacket;
|
||||||
import com.velocitypowered.proxy.protocol.packet.Handshake;
|
import com.velocitypowered.proxy.protocol.packet.HandshakePacket;
|
||||||
import com.velocitypowered.proxy.protocol.packet.HeaderAndFooter;
|
import com.velocitypowered.proxy.protocol.packet.HeaderAndFooterPacket;
|
||||||
import com.velocitypowered.proxy.protocol.packet.JoinGame;
|
import com.velocitypowered.proxy.protocol.packet.JoinGamePacket;
|
||||||
import com.velocitypowered.proxy.protocol.packet.KeepAlive;
|
import com.velocitypowered.proxy.protocol.packet.KeepAlivePacket;
|
||||||
import com.velocitypowered.proxy.protocol.packet.LegacyPlayerListItem;
|
import com.velocitypowered.proxy.protocol.packet.LegacyPlayerListItemPacket;
|
||||||
import com.velocitypowered.proxy.protocol.packet.LoginAcknowledged;
|
import com.velocitypowered.proxy.protocol.packet.LoginAcknowledgedPacket;
|
||||||
import com.velocitypowered.proxy.protocol.packet.LoginPluginMessage;
|
import com.velocitypowered.proxy.protocol.packet.LoginPluginMessagePacket;
|
||||||
import com.velocitypowered.proxy.protocol.packet.LoginPluginResponse;
|
import com.velocitypowered.proxy.protocol.packet.LoginPluginResponsePacket;
|
||||||
import com.velocitypowered.proxy.protocol.packet.PingIdentify;
|
import com.velocitypowered.proxy.protocol.packet.PingIdentifyPacket;
|
||||||
import com.velocitypowered.proxy.protocol.packet.PluginMessage;
|
import com.velocitypowered.proxy.protocol.packet.PluginMessagePacket;
|
||||||
import com.velocitypowered.proxy.protocol.packet.RemovePlayerInfo;
|
import com.velocitypowered.proxy.protocol.packet.RemovePlayerInfoPacket;
|
||||||
import com.velocitypowered.proxy.protocol.packet.RemoveResourcePack;
|
import com.velocitypowered.proxy.protocol.packet.RemoveResourcePackPacket;
|
||||||
import com.velocitypowered.proxy.protocol.packet.ResourcePackRequest;
|
import com.velocitypowered.proxy.protocol.packet.ResourcePackRequestPacket;
|
||||||
import com.velocitypowered.proxy.protocol.packet.ResourcePackResponse;
|
import com.velocitypowered.proxy.protocol.packet.ResourcePackResponsePacket;
|
||||||
import com.velocitypowered.proxy.protocol.packet.Respawn;
|
import com.velocitypowered.proxy.protocol.packet.RespawnPacket;
|
||||||
import com.velocitypowered.proxy.protocol.packet.ServerData;
|
import com.velocitypowered.proxy.protocol.packet.ServerDataPacket;
|
||||||
import com.velocitypowered.proxy.protocol.packet.ServerLogin;
|
import com.velocitypowered.proxy.protocol.packet.ServerLoginPacket;
|
||||||
import com.velocitypowered.proxy.protocol.packet.ServerLoginSuccess;
|
import com.velocitypowered.proxy.protocol.packet.ServerLoginSuccessPacket;
|
||||||
import com.velocitypowered.proxy.protocol.packet.SetCompression;
|
import com.velocitypowered.proxy.protocol.packet.SetCompressionPacket;
|
||||||
import com.velocitypowered.proxy.protocol.packet.StatusPing;
|
import com.velocitypowered.proxy.protocol.packet.StatusPingPacket;
|
||||||
import com.velocitypowered.proxy.protocol.packet.StatusRequest;
|
import com.velocitypowered.proxy.protocol.packet.StatusRequestPacket;
|
||||||
import com.velocitypowered.proxy.protocol.packet.StatusResponse;
|
import com.velocitypowered.proxy.protocol.packet.StatusResponsePacket;
|
||||||
import com.velocitypowered.proxy.protocol.packet.TabCompleteRequest;
|
import com.velocitypowered.proxy.protocol.packet.TabCompleteRequestPacket;
|
||||||
import com.velocitypowered.proxy.protocol.packet.TabCompleteResponse;
|
import com.velocitypowered.proxy.protocol.packet.TabCompleteResponsePacket;
|
||||||
import com.velocitypowered.proxy.protocol.packet.UpsertPlayerInfo;
|
import com.velocitypowered.proxy.protocol.packet.UpsertPlayerInfoPacket;
|
||||||
import com.velocitypowered.proxy.protocol.packet.chat.ChatAcknowledgement;
|
import com.velocitypowered.proxy.protocol.packet.chat.ChatAcknowledgementPacket;
|
||||||
import com.velocitypowered.proxy.protocol.packet.chat.PlayerChatCompletion;
|
import com.velocitypowered.proxy.protocol.packet.chat.PlayerChatCompletionPacket;
|
||||||
import com.velocitypowered.proxy.protocol.packet.chat.SystemChat;
|
import com.velocitypowered.proxy.protocol.packet.chat.SystemChatPacket;
|
||||||
import com.velocitypowered.proxy.protocol.packet.chat.keyed.KeyedPlayerChat;
|
import com.velocitypowered.proxy.protocol.packet.chat.keyed.KeyedPlayerChatPacket;
|
||||||
import com.velocitypowered.proxy.protocol.packet.chat.keyed.KeyedPlayerCommand;
|
import com.velocitypowered.proxy.protocol.packet.chat.keyed.KeyedPlayerCommandPacket;
|
||||||
import com.velocitypowered.proxy.protocol.packet.chat.legacy.LegacyChat;
|
import com.velocitypowered.proxy.protocol.packet.chat.legacy.LegacyChatPacket;
|
||||||
import com.velocitypowered.proxy.protocol.packet.chat.session.SessionPlayerChat;
|
import com.velocitypowered.proxy.protocol.packet.chat.session.SessionPlayerChatPacket;
|
||||||
import com.velocitypowered.proxy.protocol.packet.chat.session.SessionPlayerCommand;
|
import com.velocitypowered.proxy.protocol.packet.chat.session.SessionPlayerCommandPacket;
|
||||||
import com.velocitypowered.proxy.protocol.packet.config.ActiveFeatures;
|
import com.velocitypowered.proxy.protocol.packet.config.ActiveFeaturesPacket;
|
||||||
import com.velocitypowered.proxy.protocol.packet.config.FinishedUpdate;
|
import com.velocitypowered.proxy.protocol.packet.config.FinishedUpdatePacket;
|
||||||
import com.velocitypowered.proxy.protocol.packet.config.RegistrySync;
|
import com.velocitypowered.proxy.protocol.packet.config.RegistrySyncPacket;
|
||||||
import com.velocitypowered.proxy.protocol.packet.config.StartUpdate;
|
import com.velocitypowered.proxy.protocol.packet.config.StartUpdatePacket;
|
||||||
import com.velocitypowered.proxy.protocol.packet.config.TagsUpdate;
|
import com.velocitypowered.proxy.protocol.packet.config.TagsUpdatePacket;
|
||||||
import com.velocitypowered.proxy.protocol.packet.title.LegacyTitlePacket;
|
import com.velocitypowered.proxy.protocol.packet.title.LegacyTitlePacket;
|
||||||
import com.velocitypowered.proxy.protocol.packet.title.TitleActionbarPacket;
|
import com.velocitypowered.proxy.protocol.packet.title.TitleActionbarPacket;
|
||||||
import com.velocitypowered.proxy.protocol.packet.title.TitleClearPacket;
|
import com.velocitypowered.proxy.protocol.packet.title.TitleClearPacket;
|
||||||
@ -116,57 +116,73 @@ public enum StateRegistry {
|
|||||||
|
|
||||||
HANDSHAKE {
|
HANDSHAKE {
|
||||||
{
|
{
|
||||||
serverbound.register(Handshake.class, Handshake::new,
|
serverbound.register(HandshakePacket.class, HandshakePacket::new,
|
||||||
map(0x00, MINECRAFT_1_7_2, false));
|
map(0x00, MINECRAFT_1_7_2, false));
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
STATUS {
|
STATUS {
|
||||||
{
|
{
|
||||||
serverbound.register(
|
serverbound.register(
|
||||||
StatusRequest.class, () -> StatusRequest.INSTANCE, map(0x00, MINECRAFT_1_7_2, false));
|
StatusRequestPacket.class, () -> StatusRequestPacket.INSTANCE,
|
||||||
serverbound.register(StatusPing.class, StatusPing::new, map(0x01, MINECRAFT_1_7_2, false));
|
map(0x00, MINECRAFT_1_7_2, false));
|
||||||
|
serverbound.register(StatusPingPacket.class, StatusPingPacket::new,
|
||||||
|
map(0x01, MINECRAFT_1_7_2, false));
|
||||||
|
|
||||||
clientbound.register(
|
clientbound.register(
|
||||||
StatusResponse.class, StatusResponse::new, map(0x00, MINECRAFT_1_7_2, false));
|
StatusResponsePacket.class, StatusResponsePacket::new,
|
||||||
clientbound.register(StatusPing.class, StatusPing::new, map(0x01, MINECRAFT_1_7_2, false));
|
map(0x00, MINECRAFT_1_7_2, false));
|
||||||
|
clientbound.register(StatusPingPacket.class, StatusPingPacket::new,
|
||||||
|
map(0x01, MINECRAFT_1_7_2, false));
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
CONFIG {
|
CONFIG {
|
||||||
{
|
{
|
||||||
serverbound.register(
|
serverbound.register(
|
||||||
ClientSettings.class, ClientSettings::new, map(0x00, MINECRAFT_1_20_2, false));
|
ClientSettingsPacket.class, ClientSettingsPacket::new,
|
||||||
|
map(0x00, MINECRAFT_1_20_2, false));
|
||||||
serverbound.register(
|
serverbound.register(
|
||||||
PluginMessage.class, PluginMessage::new, map(0x01, MINECRAFT_1_20_2, false));
|
PluginMessagePacket.class, PluginMessagePacket::new,
|
||||||
|
map(0x01, MINECRAFT_1_20_2, false));
|
||||||
serverbound.register(
|
serverbound.register(
|
||||||
FinishedUpdate.class, FinishedUpdate::new, map(0x02, MINECRAFT_1_20_2, false));
|
FinishedUpdatePacket.class, FinishedUpdatePacket::new,
|
||||||
serverbound.register(KeepAlive.class, KeepAlive::new, map(0x03, MINECRAFT_1_20_2, false));
|
map(0x02, MINECRAFT_1_20_2, false));
|
||||||
|
serverbound.register(KeepAlivePacket.class, KeepAlivePacket::new,
|
||||||
|
map(0x03, MINECRAFT_1_20_2, false));
|
||||||
serverbound.register(
|
serverbound.register(
|
||||||
PingIdentify.class, PingIdentify::new, map(0x04, MINECRAFT_1_20_2, false));
|
PingIdentifyPacket.class, PingIdentifyPacket::new,
|
||||||
|
map(0x04, MINECRAFT_1_20_2, false));
|
||||||
serverbound.register(
|
serverbound.register(
|
||||||
ResourcePackResponse.class,
|
ResourcePackResponsePacket.class,
|
||||||
ResourcePackResponse::new,
|
ResourcePackResponsePacket::new,
|
||||||
map(0x05, MINECRAFT_1_20_2, false));
|
map(0x05, MINECRAFT_1_20_2, false));
|
||||||
|
|
||||||
clientbound.register(
|
clientbound.register(
|
||||||
PluginMessage.class, PluginMessage::new, map(0x00, MINECRAFT_1_20_2, false));
|
PluginMessagePacket.class, PluginMessagePacket::new,
|
||||||
|
map(0x00, MINECRAFT_1_20_2, false));
|
||||||
clientbound.register(
|
clientbound.register(
|
||||||
Disconnect.class, () -> new Disconnect(false), map(0x01, MINECRAFT_1_20_2, false));
|
DisconnectPacket.class, () -> new DisconnectPacket(false),
|
||||||
|
map(0x01, MINECRAFT_1_20_2, false));
|
||||||
clientbound.register(
|
clientbound.register(
|
||||||
FinishedUpdate.class, FinishedUpdate::new, map(0x02, MINECRAFT_1_20_2, false));
|
FinishedUpdatePacket.class, FinishedUpdatePacket::new,
|
||||||
clientbound.register(KeepAlive.class, KeepAlive::new, map(0x03, MINECRAFT_1_20_2, false));
|
map(0x02, MINECRAFT_1_20_2, false));
|
||||||
|
clientbound.register(KeepAlivePacket.class, KeepAlivePacket::new,
|
||||||
|
map(0x03, MINECRAFT_1_20_2, false));
|
||||||
clientbound.register(
|
clientbound.register(
|
||||||
PingIdentify.class, PingIdentify::new, map(0x04, MINECRAFT_1_20_2, false));
|
PingIdentifyPacket.class, PingIdentifyPacket::new,
|
||||||
|
map(0x04, MINECRAFT_1_20_2, false));
|
||||||
clientbound.register(
|
clientbound.register(
|
||||||
RegistrySync.class, RegistrySync::new, map(0x05, MINECRAFT_1_20_2, false));
|
RegistrySyncPacket.class, RegistrySyncPacket::new,
|
||||||
|
map(0x05, MINECRAFT_1_20_2, false));
|
||||||
clientbound.register(
|
clientbound.register(
|
||||||
RemoveResourcePack.class, RemoveResourcePack::new, map(0x06, MINECRAFT_1_20_3, false));
|
RemoveResourcePackPacket.class, RemoveResourcePackPacket::new,
|
||||||
clientbound.register(ResourcePackRequest.class, ResourcePackRequest::new,
|
map(0x06, MINECRAFT_1_20_3, false));
|
||||||
|
clientbound.register(ResourcePackRequestPacket.class, ResourcePackRequestPacket::new,
|
||||||
map(0x06, MINECRAFT_1_20_2, false),
|
map(0x06, MINECRAFT_1_20_2, false),
|
||||||
map(0x07, MINECRAFT_1_20_3, false));
|
map(0x07, MINECRAFT_1_20_3, false));
|
||||||
clientbound.register(ActiveFeatures.class, ActiveFeatures::new,
|
clientbound.register(ActiveFeaturesPacket.class, ActiveFeaturesPacket::new,
|
||||||
map(0x07, MINECRAFT_1_20_2, false),
|
map(0x07, MINECRAFT_1_20_2, false),
|
||||||
map(0x08, MINECRAFT_1_20_3, false));
|
map(0x08, MINECRAFT_1_20_3, false));
|
||||||
clientbound.register(TagsUpdate.class, TagsUpdate::new,
|
clientbound.register(TagsUpdatePacket.class, TagsUpdatePacket::new,
|
||||||
map(0x08, MINECRAFT_1_20_2, false),
|
map(0x08, MINECRAFT_1_20_2, false),
|
||||||
map(0x09, MINECRAFT_1_20_3, false));
|
map(0x09, MINECRAFT_1_20_3, false));
|
||||||
}
|
}
|
||||||
@ -176,7 +192,7 @@ public enum StateRegistry {
|
|||||||
serverbound.fallback = false;
|
serverbound.fallback = false;
|
||||||
clientbound.fallback = false;
|
clientbound.fallback = false;
|
||||||
|
|
||||||
serverbound.register(TabCompleteRequest.class, TabCompleteRequest::new,
|
serverbound.register(TabCompleteRequestPacket.class, TabCompleteRequestPacket::new,
|
||||||
map(0x14, MINECRAFT_1_7_2, false),
|
map(0x14, MINECRAFT_1_7_2, false),
|
||||||
map(0x01, MINECRAFT_1_9, false),
|
map(0x01, MINECRAFT_1_9, false),
|
||||||
map(0x02, MINECRAFT_1_12, false),
|
map(0x02, MINECRAFT_1_12, false),
|
||||||
@ -189,32 +205,32 @@ public enum StateRegistry {
|
|||||||
map(0x09, MINECRAFT_1_19_4, false),
|
map(0x09, MINECRAFT_1_19_4, false),
|
||||||
map(0x0A, MINECRAFT_1_20_2, false));
|
map(0x0A, MINECRAFT_1_20_2, false));
|
||||||
serverbound.register(
|
serverbound.register(
|
||||||
LegacyChat.class,
|
LegacyChatPacket.class,
|
||||||
LegacyChat::new,
|
LegacyChatPacket::new,
|
||||||
map(0x01, MINECRAFT_1_7_2, false),
|
map(0x01, MINECRAFT_1_7_2, false),
|
||||||
map(0x02, MINECRAFT_1_9, false),
|
map(0x02, MINECRAFT_1_9, false),
|
||||||
map(0x03, MINECRAFT_1_12, false),
|
map(0x03, MINECRAFT_1_12, false),
|
||||||
map(0x02, MINECRAFT_1_12_1, false),
|
map(0x02, MINECRAFT_1_12_1, false),
|
||||||
map(0x03, MINECRAFT_1_14, MINECRAFT_1_18_2, false));
|
map(0x03, MINECRAFT_1_14, MINECRAFT_1_18_2, false));
|
||||||
serverbound.register(
|
serverbound.register(
|
||||||
ChatAcknowledgement.class,
|
ChatAcknowledgementPacket.class,
|
||||||
ChatAcknowledgement::new,
|
ChatAcknowledgementPacket::new,
|
||||||
map(0x03, MINECRAFT_1_19_3, false));
|
map(0x03, MINECRAFT_1_19_3, false));
|
||||||
serverbound.register(KeyedPlayerCommand.class, KeyedPlayerCommand::new,
|
serverbound.register(KeyedPlayerCommandPacket.class, KeyedPlayerCommandPacket::new,
|
||||||
map(0x03, MINECRAFT_1_19, false),
|
map(0x03, MINECRAFT_1_19, false),
|
||||||
map(0x04, MINECRAFT_1_19_1, MINECRAFT_1_19_1, false));
|
map(0x04, MINECRAFT_1_19_1, MINECRAFT_1_19_1, false));
|
||||||
serverbound.register(KeyedPlayerChat.class, KeyedPlayerChat::new,
|
serverbound.register(KeyedPlayerChatPacket.class, KeyedPlayerChatPacket::new,
|
||||||
map(0x04, MINECRAFT_1_19, false),
|
map(0x04, MINECRAFT_1_19, false),
|
||||||
map(0x05, MINECRAFT_1_19_1, MINECRAFT_1_19_1, false));
|
map(0x05, MINECRAFT_1_19_1, MINECRAFT_1_19_1, false));
|
||||||
serverbound.register(SessionPlayerCommand.class, SessionPlayerCommand::new,
|
serverbound.register(SessionPlayerCommandPacket.class, SessionPlayerCommandPacket::new,
|
||||||
map(0x04, MINECRAFT_1_19_3, false));
|
map(0x04, MINECRAFT_1_19_3, false));
|
||||||
serverbound.register(
|
serverbound.register(
|
||||||
SessionPlayerChat.class,
|
SessionPlayerChatPacket.class,
|
||||||
SessionPlayerChat::new,
|
SessionPlayerChatPacket::new,
|
||||||
map(0x05, MINECRAFT_1_19_3, false));
|
map(0x05, MINECRAFT_1_19_3, false));
|
||||||
serverbound.register(
|
serverbound.register(
|
||||||
ClientSettings.class,
|
ClientSettingsPacket.class,
|
||||||
ClientSettings::new,
|
ClientSettingsPacket::new,
|
||||||
map(0x15, MINECRAFT_1_7_2, false),
|
map(0x15, MINECRAFT_1_7_2, false),
|
||||||
map(0x04, MINECRAFT_1_9, false),
|
map(0x04, MINECRAFT_1_9, false),
|
||||||
map(0x05, MINECRAFT_1_12, false),
|
map(0x05, MINECRAFT_1_12, false),
|
||||||
@ -226,8 +242,8 @@ public enum StateRegistry {
|
|||||||
map(0x08, MINECRAFT_1_19_4, false),
|
map(0x08, MINECRAFT_1_19_4, false),
|
||||||
map(0x09, MINECRAFT_1_20_2, false));
|
map(0x09, MINECRAFT_1_20_2, false));
|
||||||
serverbound.register(
|
serverbound.register(
|
||||||
PluginMessage.class,
|
PluginMessagePacket.class,
|
||||||
PluginMessage::new,
|
PluginMessagePacket::new,
|
||||||
map(0x17, MINECRAFT_1_7_2, false),
|
map(0x17, MINECRAFT_1_7_2, false),
|
||||||
map(0x09, MINECRAFT_1_9, false),
|
map(0x09, MINECRAFT_1_9, false),
|
||||||
map(0x0A, MINECRAFT_1_12, false),
|
map(0x0A, MINECRAFT_1_12, false),
|
||||||
@ -242,8 +258,8 @@ public enum StateRegistry {
|
|||||||
map(0x0F, MINECRAFT_1_20_2, false),
|
map(0x0F, MINECRAFT_1_20_2, false),
|
||||||
map(0x10, MINECRAFT_1_20_3, false));
|
map(0x10, MINECRAFT_1_20_3, false));
|
||||||
serverbound.register(
|
serverbound.register(
|
||||||
KeepAlive.class,
|
KeepAlivePacket.class,
|
||||||
KeepAlive::new,
|
KeepAlivePacket::new,
|
||||||
map(0x00, MINECRAFT_1_7_2, false),
|
map(0x00, MINECRAFT_1_7_2, false),
|
||||||
map(0x0B, MINECRAFT_1_9, false),
|
map(0x0B, MINECRAFT_1_9, false),
|
||||||
map(0x0C, MINECRAFT_1_12, false),
|
map(0x0C, MINECRAFT_1_12, false),
|
||||||
@ -259,8 +275,8 @@ public enum StateRegistry {
|
|||||||
map(0x14, MINECRAFT_1_20_2, false),
|
map(0x14, MINECRAFT_1_20_2, false),
|
||||||
map(0x15, MINECRAFT_1_20_3, false));
|
map(0x15, MINECRAFT_1_20_3, false));
|
||||||
serverbound.register(
|
serverbound.register(
|
||||||
ResourcePackResponse.class,
|
ResourcePackResponsePacket.class,
|
||||||
ResourcePackResponse::new,
|
ResourcePackResponsePacket::new,
|
||||||
map(0x19, MINECRAFT_1_8, false),
|
map(0x19, MINECRAFT_1_8, false),
|
||||||
map(0x16, MINECRAFT_1_9, false),
|
map(0x16, MINECRAFT_1_9, false),
|
||||||
map(0x18, MINECRAFT_1_12, false),
|
map(0x18, MINECRAFT_1_12, false),
|
||||||
@ -273,11 +289,12 @@ public enum StateRegistry {
|
|||||||
map(0x27, MINECRAFT_1_20_2, false),
|
map(0x27, MINECRAFT_1_20_2, false),
|
||||||
map(0x28, MINECRAFT_1_20_3, false));
|
map(0x28, MINECRAFT_1_20_3, false));
|
||||||
serverbound.register(
|
serverbound.register(
|
||||||
FinishedUpdate.class, FinishedUpdate::new, map(0x0B, MINECRAFT_1_20_2, false));
|
FinishedUpdatePacket.class, FinishedUpdatePacket::new,
|
||||||
|
map(0x0B, MINECRAFT_1_20_2, false));
|
||||||
|
|
||||||
clientbound.register(
|
clientbound.register(
|
||||||
BossBar.class,
|
BossBarPacket.class,
|
||||||
BossBar::new,
|
BossBarPacket::new,
|
||||||
map(0x0C, MINECRAFT_1_9, false),
|
map(0x0C, MINECRAFT_1_9, false),
|
||||||
map(0x0D, MINECRAFT_1_15, false),
|
map(0x0D, MINECRAFT_1_15, false),
|
||||||
map(0x0C, MINECRAFT_1_16, false),
|
map(0x0C, MINECRAFT_1_16, false),
|
||||||
@ -286,15 +303,15 @@ public enum StateRegistry {
|
|||||||
map(0x0B, MINECRAFT_1_19_4, false),
|
map(0x0B, MINECRAFT_1_19_4, false),
|
||||||
map(0x0A, MINECRAFT_1_20_2, false));
|
map(0x0A, MINECRAFT_1_20_2, false));
|
||||||
clientbound.register(
|
clientbound.register(
|
||||||
LegacyChat.class,
|
LegacyChatPacket.class,
|
||||||
LegacyChat::new,
|
LegacyChatPacket::new,
|
||||||
map(0x02, MINECRAFT_1_7_2, true),
|
map(0x02, MINECRAFT_1_7_2, true),
|
||||||
map(0x0F, MINECRAFT_1_9, true),
|
map(0x0F, MINECRAFT_1_9, true),
|
||||||
map(0x0E, MINECRAFT_1_13, true),
|
map(0x0E, MINECRAFT_1_13, true),
|
||||||
map(0x0F, MINECRAFT_1_15, true),
|
map(0x0F, MINECRAFT_1_15, true),
|
||||||
map(0x0E, MINECRAFT_1_16, true),
|
map(0x0E, MINECRAFT_1_16, true),
|
||||||
map(0x0F, MINECRAFT_1_17, MINECRAFT_1_18_2, true));
|
map(0x0F, MINECRAFT_1_17, MINECRAFT_1_18_2, true));
|
||||||
clientbound.register(TabCompleteResponse.class, TabCompleteResponse::new,
|
clientbound.register(TabCompleteResponsePacket.class, TabCompleteResponsePacket::new,
|
||||||
map(0x3A, MINECRAFT_1_7_2, false),
|
map(0x3A, MINECRAFT_1_7_2, false),
|
||||||
map(0x0E, MINECRAFT_1_9, false),
|
map(0x0E, MINECRAFT_1_9, false),
|
||||||
map(0x10, MINECRAFT_1_13, false),
|
map(0x10, MINECRAFT_1_13, false),
|
||||||
@ -307,8 +324,8 @@ public enum StateRegistry {
|
|||||||
map(0x0F, MINECRAFT_1_19_4, false),
|
map(0x0F, MINECRAFT_1_19_4, false),
|
||||||
map(0x10, MINECRAFT_1_20_2, false));
|
map(0x10, MINECRAFT_1_20_2, false));
|
||||||
clientbound.register(
|
clientbound.register(
|
||||||
AvailableCommands.class,
|
AvailableCommandsPacket.class,
|
||||||
AvailableCommands::new,
|
AvailableCommandsPacket::new,
|
||||||
map(0x11, MINECRAFT_1_13, false),
|
map(0x11, MINECRAFT_1_13, false),
|
||||||
map(0x12, MINECRAFT_1_15, false),
|
map(0x12, MINECRAFT_1_15, false),
|
||||||
map(0x11, MINECRAFT_1_16, false),
|
map(0x11, MINECRAFT_1_16, false),
|
||||||
@ -319,8 +336,8 @@ public enum StateRegistry {
|
|||||||
map(0x10, MINECRAFT_1_19_4, false),
|
map(0x10, MINECRAFT_1_19_4, false),
|
||||||
map(0x11, MINECRAFT_1_20_2, false));
|
map(0x11, MINECRAFT_1_20_2, false));
|
||||||
clientbound.register(
|
clientbound.register(
|
||||||
PluginMessage.class,
|
PluginMessagePacket.class,
|
||||||
PluginMessage::new,
|
PluginMessagePacket::new,
|
||||||
map(0x3F, MINECRAFT_1_7_2, false),
|
map(0x3F, MINECRAFT_1_7_2, false),
|
||||||
map(0x18, MINECRAFT_1_9, false),
|
map(0x18, MINECRAFT_1_9, false),
|
||||||
map(0x19, MINECRAFT_1_13, false),
|
map(0x19, MINECRAFT_1_13, false),
|
||||||
@ -335,8 +352,8 @@ public enum StateRegistry {
|
|||||||
map(0x17, MINECRAFT_1_19_4, false),
|
map(0x17, MINECRAFT_1_19_4, false),
|
||||||
map(0x18, MINECRAFT_1_20_2, false));
|
map(0x18, MINECRAFT_1_20_2, false));
|
||||||
clientbound.register(
|
clientbound.register(
|
||||||
Disconnect.class,
|
DisconnectPacket.class,
|
||||||
() -> new Disconnect(false),
|
() -> new DisconnectPacket(false),
|
||||||
map(0x40, MINECRAFT_1_7_2, false),
|
map(0x40, MINECRAFT_1_7_2, false),
|
||||||
map(0x1A, MINECRAFT_1_9, false),
|
map(0x1A, MINECRAFT_1_9, false),
|
||||||
map(0x1B, MINECRAFT_1_13, false),
|
map(0x1B, MINECRAFT_1_13, false),
|
||||||
@ -351,8 +368,8 @@ public enum StateRegistry {
|
|||||||
map(0x1A, MINECRAFT_1_19_4, false),
|
map(0x1A, MINECRAFT_1_19_4, false),
|
||||||
map(0x1B, MINECRAFT_1_20_2, false));
|
map(0x1B, MINECRAFT_1_20_2, false));
|
||||||
clientbound.register(
|
clientbound.register(
|
||||||
KeepAlive.class,
|
KeepAlivePacket.class,
|
||||||
KeepAlive::new,
|
KeepAlivePacket::new,
|
||||||
map(0x00, MINECRAFT_1_7_2, false),
|
map(0x00, MINECRAFT_1_7_2, false),
|
||||||
map(0x1F, MINECRAFT_1_9, false),
|
map(0x1F, MINECRAFT_1_9, false),
|
||||||
map(0x21, MINECRAFT_1_13, false),
|
map(0x21, MINECRAFT_1_13, false),
|
||||||
@ -367,8 +384,8 @@ public enum StateRegistry {
|
|||||||
map(0x23, MINECRAFT_1_19_4, false),
|
map(0x23, MINECRAFT_1_19_4, false),
|
||||||
map(0x24, MINECRAFT_1_20_2, false));
|
map(0x24, MINECRAFT_1_20_2, false));
|
||||||
clientbound.register(
|
clientbound.register(
|
||||||
JoinGame.class,
|
JoinGamePacket.class,
|
||||||
JoinGame::new,
|
JoinGamePacket::new,
|
||||||
map(0x01, MINECRAFT_1_7_2, false),
|
map(0x01, MINECRAFT_1_7_2, false),
|
||||||
map(0x23, MINECRAFT_1_9, false),
|
map(0x23, MINECRAFT_1_9, false),
|
||||||
map(0x25, MINECRAFT_1_13, false),
|
map(0x25, MINECRAFT_1_13, false),
|
||||||
@ -383,8 +400,8 @@ public enum StateRegistry {
|
|||||||
map(0x28, MINECRAFT_1_19_4, false),
|
map(0x28, MINECRAFT_1_19_4, false),
|
||||||
map(0x29, MINECRAFT_1_20_2, false));
|
map(0x29, MINECRAFT_1_20_2, false));
|
||||||
clientbound.register(
|
clientbound.register(
|
||||||
Respawn.class,
|
RespawnPacket.class,
|
||||||
Respawn::new,
|
RespawnPacket::new,
|
||||||
map(0x07, MINECRAFT_1_7_2, true),
|
map(0x07, MINECRAFT_1_7_2, true),
|
||||||
map(0x33, MINECRAFT_1_9, true),
|
map(0x33, MINECRAFT_1_9, true),
|
||||||
map(0x34, MINECRAFT_1_12, true),
|
map(0x34, MINECRAFT_1_12, true),
|
||||||
@ -402,12 +419,12 @@ public enum StateRegistry {
|
|||||||
map(0x43, MINECRAFT_1_20_2, true),
|
map(0x43, MINECRAFT_1_20_2, true),
|
||||||
map(0x45, MINECRAFT_1_20_3, true));
|
map(0x45, MINECRAFT_1_20_3, true));
|
||||||
clientbound.register(
|
clientbound.register(
|
||||||
RemoveResourcePack.class,
|
RemoveResourcePackPacket.class,
|
||||||
RemoveResourcePack::new,
|
RemoveResourcePackPacket::new,
|
||||||
map(0x43, MINECRAFT_1_20_3, false));
|
map(0x43, MINECRAFT_1_20_3, false));
|
||||||
clientbound.register(
|
clientbound.register(
|
||||||
ResourcePackRequest.class,
|
ResourcePackRequestPacket.class,
|
||||||
ResourcePackRequest::new,
|
ResourcePackRequestPacket::new,
|
||||||
map(0x48, MINECRAFT_1_8, false),
|
map(0x48, MINECRAFT_1_8, false),
|
||||||
map(0x32, MINECRAFT_1_9, false),
|
map(0x32, MINECRAFT_1_9, false),
|
||||||
map(0x33, MINECRAFT_1_12, false),
|
map(0x33, MINECRAFT_1_12, false),
|
||||||
@ -425,8 +442,8 @@ public enum StateRegistry {
|
|||||||
map(0x42, MINECRAFT_1_20_2, false),
|
map(0x42, MINECRAFT_1_20_2, false),
|
||||||
map(0x44, MINECRAFT_1_20_3, false));
|
map(0x44, MINECRAFT_1_20_3, false));
|
||||||
clientbound.register(
|
clientbound.register(
|
||||||
HeaderAndFooter.class,
|
HeaderAndFooterPacket.class,
|
||||||
HeaderAndFooter::new,
|
HeaderAndFooterPacket::new,
|
||||||
map(0x47, MINECRAFT_1_8, true),
|
map(0x47, MINECRAFT_1_8, true),
|
||||||
map(0x48, MINECRAFT_1_9, true),
|
map(0x48, MINECRAFT_1_9, true),
|
||||||
map(0x47, MINECRAFT_1_9_4, true),
|
map(0x47, MINECRAFT_1_9_4, true),
|
||||||
@ -502,8 +519,8 @@ public enum StateRegistry {
|
|||||||
map(0x0E, MINECRAFT_1_19_4, true),
|
map(0x0E, MINECRAFT_1_19_4, true),
|
||||||
map(0x0F, MINECRAFT_1_20_2, true));
|
map(0x0F, MINECRAFT_1_20_2, true));
|
||||||
clientbound.register(
|
clientbound.register(
|
||||||
LegacyPlayerListItem.class,
|
LegacyPlayerListItemPacket.class,
|
||||||
LegacyPlayerListItem::new,
|
LegacyPlayerListItemPacket::new,
|
||||||
map(0x38, MINECRAFT_1_7_2, false),
|
map(0x38, MINECRAFT_1_7_2, false),
|
||||||
map(0x2D, MINECRAFT_1_9, false),
|
map(0x2D, MINECRAFT_1_9, false),
|
||||||
map(0x2E, MINECRAFT_1_12_1, false),
|
map(0x2E, MINECRAFT_1_12_1, false),
|
||||||
@ -515,19 +532,19 @@ public enum StateRegistry {
|
|||||||
map(0x36, MINECRAFT_1_17, false),
|
map(0x36, MINECRAFT_1_17, false),
|
||||||
map(0x34, MINECRAFT_1_19, false),
|
map(0x34, MINECRAFT_1_19, false),
|
||||||
map(0x37, MINECRAFT_1_19_1, MINECRAFT_1_19_1, false));
|
map(0x37, MINECRAFT_1_19_1, MINECRAFT_1_19_1, false));
|
||||||
clientbound.register(RemovePlayerInfo.class, RemovePlayerInfo::new,
|
clientbound.register(RemovePlayerInfoPacket.class, RemovePlayerInfoPacket::new,
|
||||||
map(0x35, MINECRAFT_1_19_3, false),
|
map(0x35, MINECRAFT_1_19_3, false),
|
||||||
map(0x39, MINECRAFT_1_19_4, false),
|
map(0x39, MINECRAFT_1_19_4, false),
|
||||||
map(0x3B, MINECRAFT_1_20_2, false));
|
map(0x3B, MINECRAFT_1_20_2, false));
|
||||||
clientbound.register(
|
clientbound.register(
|
||||||
UpsertPlayerInfo.class,
|
UpsertPlayerInfoPacket.class,
|
||||||
UpsertPlayerInfo::new,
|
UpsertPlayerInfoPacket::new,
|
||||||
map(0x36, MINECRAFT_1_19_3, false),
|
map(0x36, MINECRAFT_1_19_3, false),
|
||||||
map(0x3A, MINECRAFT_1_19_4, false),
|
map(0x3A, MINECRAFT_1_19_4, false),
|
||||||
map(0x3C, MINECRAFT_1_20_2, false));
|
map(0x3C, MINECRAFT_1_20_2, false));
|
||||||
clientbound.register(
|
clientbound.register(
|
||||||
SystemChat.class,
|
SystemChatPacket.class,
|
||||||
SystemChat::new,
|
SystemChatPacket::new,
|
||||||
map(0x5F, MINECRAFT_1_19, true),
|
map(0x5F, MINECRAFT_1_19, true),
|
||||||
map(0x62, MINECRAFT_1_19_1, true),
|
map(0x62, MINECRAFT_1_19_1, true),
|
||||||
map(0x60, MINECRAFT_1_19_3, true),
|
map(0x60, MINECRAFT_1_19_3, true),
|
||||||
@ -535,15 +552,15 @@ public enum StateRegistry {
|
|||||||
map(0x67, MINECRAFT_1_20_2, true),
|
map(0x67, MINECRAFT_1_20_2, true),
|
||||||
map(0x69, MINECRAFT_1_20_3, true));
|
map(0x69, MINECRAFT_1_20_3, true));
|
||||||
clientbound.register(
|
clientbound.register(
|
||||||
PlayerChatCompletion.class,
|
PlayerChatCompletionPacket.class,
|
||||||
PlayerChatCompletion::new,
|
PlayerChatCompletionPacket::new,
|
||||||
map(0x15, MINECRAFT_1_19_1, true),
|
map(0x15, MINECRAFT_1_19_1, true),
|
||||||
map(0x14, MINECRAFT_1_19_3, true),
|
map(0x14, MINECRAFT_1_19_3, true),
|
||||||
map(0x16, MINECRAFT_1_19_4, true),
|
map(0x16, MINECRAFT_1_19_4, true),
|
||||||
map(0x17, MINECRAFT_1_20_2, true));
|
map(0x17, MINECRAFT_1_20_2, true));
|
||||||
clientbound.register(
|
clientbound.register(
|
||||||
ServerData.class,
|
ServerDataPacket.class,
|
||||||
ServerData::new,
|
ServerDataPacket::new,
|
||||||
map(0x3F, MINECRAFT_1_19, false),
|
map(0x3F, MINECRAFT_1_19, false),
|
||||||
map(0x42, MINECRAFT_1_19_1, false),
|
map(0x42, MINECRAFT_1_19_1, false),
|
||||||
map(0x41, MINECRAFT_1_19_3, false),
|
map(0x41, MINECRAFT_1_19_3, false),
|
||||||
@ -551,32 +568,43 @@ public enum StateRegistry {
|
|||||||
map(0x47, MINECRAFT_1_20_2, false),
|
map(0x47, MINECRAFT_1_20_2, false),
|
||||||
map(0x49, MINECRAFT_1_20_3, false));
|
map(0x49, MINECRAFT_1_20_3, false));
|
||||||
clientbound.register(
|
clientbound.register(
|
||||||
StartUpdate.class,
|
StartUpdatePacket.class,
|
||||||
StartUpdate::new,
|
StartUpdatePacket::new,
|
||||||
map(0x65, MINECRAFT_1_20_2, false),
|
map(0x65, MINECRAFT_1_20_2, false),
|
||||||
map(0x67, MINECRAFT_1_20_3, false));
|
map(0x67, MINECRAFT_1_20_3, false));
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
LOGIN {
|
LOGIN {
|
||||||
{
|
{
|
||||||
serverbound.register(ServerLogin.class, ServerLogin::new, map(0x00, MINECRAFT_1_7_2, false));
|
serverbound.register(ServerLoginPacket.class,
|
||||||
|
ServerLoginPacket::new,
|
||||||
|
map(0x00, MINECRAFT_1_7_2, false));
|
||||||
serverbound.register(
|
serverbound.register(
|
||||||
EncryptionResponse.class, EncryptionResponse::new, map(0x01, MINECRAFT_1_7_2, false));
|
EncryptionResponsePacket.class, EncryptionResponsePacket::new,
|
||||||
|
map(0x01, MINECRAFT_1_7_2, false));
|
||||||
serverbound.register(
|
serverbound.register(
|
||||||
LoginPluginResponse.class, LoginPluginResponse::new, map(0x02, MINECRAFT_1_13, false));
|
LoginPluginResponsePacket.class, LoginPluginResponsePacket::new,
|
||||||
|
map(0x02, MINECRAFT_1_13, false));
|
||||||
serverbound.register(
|
serverbound.register(
|
||||||
LoginAcknowledged.class, LoginAcknowledged::new, map(0x03, MINECRAFT_1_20_2, false));
|
LoginAcknowledgedPacket.class, LoginAcknowledgedPacket::new,
|
||||||
|
map(0x03, MINECRAFT_1_20_2, false));
|
||||||
|
|
||||||
clientbound.register(
|
clientbound.register(
|
||||||
Disconnect.class, () -> new Disconnect(true), map(0x00, MINECRAFT_1_7_2, false));
|
DisconnectPacket.class, () -> new DisconnectPacket(true),
|
||||||
|
map(0x00, MINECRAFT_1_7_2, false));
|
||||||
clientbound.register(
|
clientbound.register(
|
||||||
EncryptionRequest.class, EncryptionRequest::new, map(0x01, MINECRAFT_1_7_2, false));
|
EncryptionRequestPacket.class, EncryptionRequestPacket::new,
|
||||||
|
map(0x01, MINECRAFT_1_7_2, false));
|
||||||
clientbound.register(
|
clientbound.register(
|
||||||
ServerLoginSuccess.class, ServerLoginSuccess::new, map(0x02, MINECRAFT_1_7_2, false));
|
ServerLoginSuccessPacket.class, ServerLoginSuccessPacket::new,
|
||||||
|
map(0x02, MINECRAFT_1_7_2, false));
|
||||||
clientbound.register(
|
clientbound.register(
|
||||||
SetCompression.class, SetCompression::new, map(0x03, MINECRAFT_1_8, false));
|
SetCompressionPacket.class, SetCompressionPacket::new,
|
||||||
|
map(0x03, MINECRAFT_1_8, false));
|
||||||
clientbound.register(
|
clientbound.register(
|
||||||
LoginPluginMessage.class, LoginPluginMessage::new, map(0x04, MINECRAFT_1_13, false));
|
LoginPluginMessagePacket.class,
|
||||||
|
LoginPluginMessagePacket::new,
|
||||||
|
map(0x04, MINECRAFT_1_13, false));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -19,8 +19,8 @@ package com.velocitypowered.proxy.protocol.netty;
|
|||||||
|
|
||||||
import static com.velocitypowered.proxy.protocol.util.NettyPreconditions.checkFrame;
|
import static com.velocitypowered.proxy.protocol.util.NettyPreconditions.checkFrame;
|
||||||
|
|
||||||
import com.velocitypowered.proxy.protocol.packet.LegacyHandshake;
|
import com.velocitypowered.proxy.protocol.packet.LegacyHandshakePacket;
|
||||||
import com.velocitypowered.proxy.protocol.packet.LegacyPing;
|
import com.velocitypowered.proxy.protocol.packet.LegacyPingPacket;
|
||||||
import com.velocitypowered.proxy.protocol.packet.legacyping.LegacyMinecraftPingVersion;
|
import com.velocitypowered.proxy.protocol.packet.legacyping.LegacyMinecraftPingVersion;
|
||||||
import io.netty.buffer.ByteBuf;
|
import io.netty.buffer.ByteBuf;
|
||||||
import io.netty.channel.ChannelHandlerContext;
|
import io.netty.channel.ChannelHandlerContext;
|
||||||
@ -52,13 +52,13 @@ public class LegacyPingDecoder extends ByteToMessageDecoder {
|
|||||||
if (first == 0xfe) {
|
if (first == 0xfe) {
|
||||||
// possibly a ping
|
// possibly a ping
|
||||||
if (!in.isReadable()) {
|
if (!in.isReadable()) {
|
||||||
out.add(new LegacyPing(LegacyMinecraftPingVersion.MINECRAFT_1_3));
|
out.add(new LegacyPingPacket(LegacyMinecraftPingVersion.MINECRAFT_1_3));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
short next = in.readUnsignedByte();
|
short next = in.readUnsignedByte();
|
||||||
if (next == 1 && !in.isReadable()) {
|
if (next == 1 && !in.isReadable()) {
|
||||||
out.add(new LegacyPing(LegacyMinecraftPingVersion.MINECRAFT_1_4));
|
out.add(new LegacyPingPacket(LegacyMinecraftPingVersion.MINECRAFT_1_4));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -66,14 +66,14 @@ public class LegacyPingDecoder extends ByteToMessageDecoder {
|
|||||||
out.add(readExtended16Data(in));
|
out.add(readExtended16Data(in));
|
||||||
} else if (first == 0x02 && in.isReadable()) {
|
} else if (first == 0x02 && in.isReadable()) {
|
||||||
in.skipBytes(in.readableBytes());
|
in.skipBytes(in.readableBytes());
|
||||||
out.add(new LegacyHandshake());
|
out.add(new LegacyHandshakePacket());
|
||||||
} else {
|
} else {
|
||||||
in.readerIndex(originalReaderIndex);
|
in.readerIndex(originalReaderIndex);
|
||||||
ctx.pipeline().remove(this);
|
ctx.pipeline().remove(this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static LegacyPing readExtended16Data(ByteBuf in) {
|
private static LegacyPingPacket readExtended16Data(ByteBuf in) {
|
||||||
in.skipBytes(1);
|
in.skipBytes(1);
|
||||||
String channelName = readLegacyString(in);
|
String channelName = readLegacyString(in);
|
||||||
if (!channelName.equals(MC_1_6_CHANNEL)) {
|
if (!channelName.equals(MC_1_6_CHANNEL)) {
|
||||||
@ -83,7 +83,7 @@ public class LegacyPingDecoder extends ByteToMessageDecoder {
|
|||||||
String hostname = readLegacyString(in);
|
String hostname = readLegacyString(in);
|
||||||
int port = in.readInt();
|
int port = in.readInt();
|
||||||
|
|
||||||
return new LegacyPing(LegacyMinecraftPingVersion.MINECRAFT_1_6, InetSocketAddress
|
return new LegacyPingPacket(LegacyMinecraftPingVersion.MINECRAFT_1_6, InetSocketAddress
|
||||||
.createUnresolved(hostname, port));
|
.createUnresolved(hostname, port));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -53,7 +53,7 @@ import java.util.concurrent.CompletableFuture;
|
|||||||
import org.checkerframework.checker.nullness.qual.MonotonicNonNull;
|
import org.checkerframework.checker.nullness.qual.MonotonicNonNull;
|
||||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||||
|
|
||||||
public class AvailableCommands implements MinecraftPacket {
|
public class AvailableCommandsPacket implements MinecraftPacket {
|
||||||
|
|
||||||
private static final Command<CommandSource> PLACEHOLDER_COMMAND = source -> 0;
|
private static final Command<CommandSource> PLACEHOLDER_COMMAND = source -> 0;
|
||||||
|
|
@ -26,7 +26,7 @@ import io.netty.buffer.ByteBuf;
|
|||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||||
|
|
||||||
public class BossBar implements MinecraftPacket {
|
public class BossBarPacket implements MinecraftPacket {
|
||||||
|
|
||||||
public static final int ADD = 0;
|
public static final int ADD = 0;
|
||||||
public static final int REMOVE = 1;
|
public static final int REMOVE = 1;
|
||||||
@ -192,8 +192,8 @@ public class BossBar implements MinecraftPacket {
|
|||||||
return handler.handle(this);
|
return handler.handle(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static BossBar createRemovePacket(UUID id) {
|
public static BossBarPacket createRemovePacket(UUID id) {
|
||||||
BossBar packet = new BossBar();
|
BossBarPacket packet = new BossBarPacket();
|
||||||
packet.setUuid(id);
|
packet.setUuid(id);
|
||||||
packet.setAction(REMOVE);
|
packet.setAction(REMOVE);
|
||||||
return packet;
|
return packet;
|
@ -26,7 +26,7 @@ import java.util.Objects;
|
|||||||
|
|
||||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||||
|
|
||||||
public class ClientSettings implements MinecraftPacket {
|
public class ClientSettingsPacket implements MinecraftPacket {
|
||||||
private @Nullable String locale;
|
private @Nullable String locale;
|
||||||
private byte viewDistance;
|
private byte viewDistance;
|
||||||
private int chatVisibility;
|
private int chatVisibility;
|
||||||
@ -37,11 +37,11 @@ public class ClientSettings implements MinecraftPacket {
|
|||||||
private boolean chatFilteringEnabled; // Added in 1.17
|
private boolean chatFilteringEnabled; // Added in 1.17
|
||||||
private boolean clientListingAllowed; // Added in 1.18, overwrites server-list "anonymous" mode
|
private boolean clientListingAllowed; // Added in 1.18, overwrites server-list "anonymous" mode
|
||||||
|
|
||||||
public ClientSettings() {
|
public ClientSettingsPacket() {
|
||||||
}
|
}
|
||||||
|
|
||||||
public ClientSettings(String locale, byte viewDistance, int chatVisibility, boolean chatColors,
|
public ClientSettingsPacket(String locale, byte viewDistance, int chatVisibility, boolean chatColors,
|
||||||
short skinParts, int mainHand, boolean chatFilteringEnabled, boolean clientListingAllowed) {
|
short skinParts, int mainHand, boolean chatFilteringEnabled, boolean clientListingAllowed) {
|
||||||
this.locale = locale;
|
this.locale = locale;
|
||||||
this.viewDistance = viewDistance;
|
this.viewDistance = viewDistance;
|
||||||
this.chatVisibility = chatVisibility;
|
this.chatVisibility = chatVisibility;
|
||||||
@ -194,7 +194,7 @@ public class ClientSettings implements MinecraftPacket {
|
|||||||
if (o == null || getClass() != o.getClass()) {
|
if (o == null || getClass() != o.getClass()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
final ClientSettings that = (ClientSettings) o;
|
final ClientSettingsPacket that = (ClientSettingsPacket) o;
|
||||||
return viewDistance == that.viewDistance
|
return viewDistance == that.viewDistance
|
||||||
&& chatVisibility == that.chatVisibility
|
&& chatVisibility == that.chatVisibility
|
||||||
&& chatColors == that.chatColors
|
&& chatColors == that.chatColors
|
@ -27,16 +27,16 @@ import io.netty.buffer.ByteBuf;
|
|||||||
import net.kyori.adventure.text.Component;
|
import net.kyori.adventure.text.Component;
|
||||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||||
|
|
||||||
public class Disconnect implements MinecraftPacket {
|
public class DisconnectPacket implements MinecraftPacket {
|
||||||
|
|
||||||
private @Nullable ComponentHolder reason;
|
private @Nullable ComponentHolder reason;
|
||||||
private final boolean login;
|
private final boolean login;
|
||||||
|
|
||||||
public Disconnect(boolean login) {
|
public DisconnectPacket(boolean login) {
|
||||||
this.login = login;
|
this.login = login;
|
||||||
}
|
}
|
||||||
|
|
||||||
private Disconnect(boolean login, ComponentHolder reason) {
|
private DisconnectPacket(boolean login, ComponentHolder reason) {
|
||||||
this.login = login;
|
this.login = login;
|
||||||
this.reason = Preconditions.checkNotNull(reason, "reason");
|
this.reason = Preconditions.checkNotNull(reason, "reason");
|
||||||
}
|
}
|
||||||
@ -74,8 +74,8 @@ public class Disconnect implements MinecraftPacket {
|
|||||||
return handler.handle(this);
|
return handler.handle(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Disconnect create(Component component, ProtocolVersion version, boolean login) {
|
public static DisconnectPacket create(Component component, ProtocolVersion version, boolean login) {
|
||||||
Preconditions.checkNotNull(component, "component");
|
Preconditions.checkNotNull(component, "component");
|
||||||
return new Disconnect(login, new ComponentHolder(login ? ProtocolVersion.MINECRAFT_1_20_2 : version, component));
|
return new DisconnectPacket(login, new ComponentHolder(login ? ProtocolVersion.MINECRAFT_1_20_2 : version, component));
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -26,7 +26,7 @@ import com.velocitypowered.proxy.protocol.ProtocolUtils;
|
|||||||
import io.netty.buffer.ByteBuf;
|
import io.netty.buffer.ByteBuf;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
|
|
||||||
public class EncryptionRequest implements MinecraftPacket {
|
public class EncryptionRequestPacket implements MinecraftPacket {
|
||||||
|
|
||||||
private String serverId = "";
|
private String serverId = "";
|
||||||
private byte[] publicKey = EMPTY_BYTE_ARRAY;
|
private byte[] publicKey = EMPTY_BYTE_ARRAY;
|
@ -30,9 +30,9 @@ import org.checkerframework.checker.nullness.qual.Nullable;
|
|||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
|
|
||||||
public class EncryptionResponse implements MinecraftPacket {
|
public class EncryptionResponsePacket implements MinecraftPacket {
|
||||||
|
|
||||||
private final static QuietDecoderException NO_SALT = new QuietDecoderException(
|
private static final QuietDecoderException NO_SALT = new QuietDecoderException(
|
||||||
"Encryption response didn't contain salt");
|
"Encryption response didn't contain salt");
|
||||||
|
|
||||||
private byte[] sharedSecret = EMPTY_BYTE_ARRAY;
|
private byte[] sharedSecret = EMPTY_BYTE_ARRAY;
|
@ -25,7 +25,7 @@ import com.velocitypowered.proxy.protocol.MinecraftPacket;
|
|||||||
import com.velocitypowered.proxy.protocol.ProtocolUtils;
|
import com.velocitypowered.proxy.protocol.ProtocolUtils;
|
||||||
import io.netty.buffer.ByteBuf;
|
import io.netty.buffer.ByteBuf;
|
||||||
|
|
||||||
public class Handshake implements MinecraftPacket {
|
public class HandshakePacket implements MinecraftPacket {
|
||||||
|
|
||||||
// This size was chosen to ensure Forge clients can still connect even with very long hostnames.
|
// This size was chosen to ensure Forge clients can still connect even with very long hostnames.
|
||||||
// While DNS technically allows any character to be used, in practice ASCII is used.
|
// While DNS technically allows any character to be used, in practice ASCII is used.
|
@ -26,16 +26,16 @@ import com.velocitypowered.proxy.protocol.packet.chat.ComponentHolder;
|
|||||||
import io.netty.buffer.ByteBuf;
|
import io.netty.buffer.ByteBuf;
|
||||||
import net.kyori.adventure.text.Component;
|
import net.kyori.adventure.text.Component;
|
||||||
|
|
||||||
public class HeaderAndFooter implements MinecraftPacket {
|
public class HeaderAndFooterPacket implements MinecraftPacket {
|
||||||
|
|
||||||
private final ComponentHolder header;
|
private final ComponentHolder header;
|
||||||
private final ComponentHolder footer;
|
private final ComponentHolder footer;
|
||||||
|
|
||||||
public HeaderAndFooter() {
|
public HeaderAndFooterPacket() {
|
||||||
throw new UnsupportedOperationException("Decode is not implemented");
|
throw new UnsupportedOperationException("Decode is not implemented");
|
||||||
}
|
}
|
||||||
|
|
||||||
public HeaderAndFooter(ComponentHolder header, ComponentHolder footer) {
|
public HeaderAndFooterPacket(ComponentHolder header, ComponentHolder footer) {
|
||||||
this.header = Preconditions.checkNotNull(header, "header");
|
this.header = Preconditions.checkNotNull(header, "header");
|
||||||
this.footer = Preconditions.checkNotNull(footer, "footer");
|
this.footer = Preconditions.checkNotNull(footer, "footer");
|
||||||
}
|
}
|
||||||
@ -64,14 +64,14 @@ public class HeaderAndFooter implements MinecraftPacket {
|
|||||||
return handler.handle(this);
|
return handler.handle(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static HeaderAndFooter create(Component header,
|
public static HeaderAndFooterPacket create(Component header,
|
||||||
Component footer, ProtocolVersion protocolVersion) {
|
Component footer, ProtocolVersion protocolVersion) {
|
||||||
return new HeaderAndFooter(new ComponentHolder(protocolVersion, header),
|
return new HeaderAndFooterPacket(new ComponentHolder(protocolVersion, header),
|
||||||
new ComponentHolder(protocolVersion, footer));
|
new ComponentHolder(protocolVersion, footer));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static HeaderAndFooter reset(ProtocolVersion version) {
|
public static HeaderAndFooterPacket reset(ProtocolVersion version) {
|
||||||
ComponentHolder empty = new ComponentHolder(version, Component.empty());
|
ComponentHolder empty = new ComponentHolder(version, Component.empty());
|
||||||
return new HeaderAndFooter(empty, empty);
|
return new HeaderAndFooterPacket(empty, empty);
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -28,7 +28,7 @@ import net.kyori.adventure.nbt.BinaryTagIO;
|
|||||||
import net.kyori.adventure.nbt.CompoundBinaryTag;
|
import net.kyori.adventure.nbt.CompoundBinaryTag;
|
||||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||||
|
|
||||||
public class JoinGame implements MinecraftPacket {
|
public class JoinGamePacket implements MinecraftPacket {
|
||||||
|
|
||||||
private static final BinaryTagIO.Reader JOINGAME_READER = BinaryTagIO.reader(4 * 1024 * 1024);
|
private static final BinaryTagIO.Reader JOINGAME_READER = BinaryTagIO.reader(4 * 1024 * 1024);
|
||||||
private int entityId;
|
private int entityId;
|
@ -23,7 +23,7 @@ import com.velocitypowered.proxy.protocol.MinecraftPacket;
|
|||||||
import com.velocitypowered.proxy.protocol.ProtocolUtils;
|
import com.velocitypowered.proxy.protocol.ProtocolUtils;
|
||||||
import io.netty.buffer.ByteBuf;
|
import io.netty.buffer.ByteBuf;
|
||||||
|
|
||||||
public class KeepAlive implements MinecraftPacket {
|
public class KeepAlivePacket implements MinecraftPacket {
|
||||||
|
|
||||||
private long randomId;
|
private long randomId;
|
||||||
|
|
@ -23,7 +23,7 @@ import com.velocitypowered.proxy.protocol.MinecraftPacket;
|
|||||||
import com.velocitypowered.proxy.protocol.ProtocolUtils;
|
import com.velocitypowered.proxy.protocol.ProtocolUtils;
|
||||||
import io.netty.buffer.ByteBuf;
|
import io.netty.buffer.ByteBuf;
|
||||||
|
|
||||||
public class LegacyHandshake implements MinecraftPacket {
|
public class LegacyHandshakePacket implements MinecraftPacket {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void decode(ByteBuf buf, ProtocolUtils.Direction direction, ProtocolVersion version) {
|
public void decode(ByteBuf buf, ProtocolUtils.Direction direction, ProtocolVersion version) {
|
@ -26,17 +26,17 @@ import io.netty.buffer.ByteBuf;
|
|||||||
import java.net.InetSocketAddress;
|
import java.net.InetSocketAddress;
|
||||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||||
|
|
||||||
public class LegacyPing implements MinecraftPacket {
|
public class LegacyPingPacket implements MinecraftPacket {
|
||||||
|
|
||||||
private final LegacyMinecraftPingVersion version;
|
private final LegacyMinecraftPingVersion version;
|
||||||
private final @Nullable InetSocketAddress vhost;
|
private final @Nullable InetSocketAddress vhost;
|
||||||
|
|
||||||
public LegacyPing(LegacyMinecraftPingVersion version) {
|
public LegacyPingPacket(LegacyMinecraftPingVersion version) {
|
||||||
this.version = version;
|
this.version = version;
|
||||||
this.vhost = null;
|
this.vhost = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public LegacyPing(LegacyMinecraftPingVersion version, InetSocketAddress vhost) {
|
public LegacyPingPacket(LegacyMinecraftPingVersion version, InetSocketAddress vhost) {
|
||||||
this.version = version;
|
this.version = version;
|
||||||
this.vhost = vhost;
|
this.vhost = vhost;
|
||||||
}
|
}
|
@ -33,7 +33,7 @@ import net.kyori.adventure.text.Component;
|
|||||||
import net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer;
|
import net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer;
|
||||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||||
|
|
||||||
public class LegacyPlayerListItem implements MinecraftPacket {
|
public class LegacyPlayerListItemPacket implements MinecraftPacket {
|
||||||
|
|
||||||
public static final int ADD_PLAYER = 0;
|
public static final int ADD_PLAYER = 0;
|
||||||
public static final int UPDATE_GAMEMODE = 1;
|
public static final int UPDATE_GAMEMODE = 1;
|
||||||
@ -43,12 +43,12 @@ public class LegacyPlayerListItem implements MinecraftPacket {
|
|||||||
private int action;
|
private int action;
|
||||||
private final List<Item> items = new ArrayList<>();
|
private final List<Item> items = new ArrayList<>();
|
||||||
|
|
||||||
public LegacyPlayerListItem(int action, List<Item> items) {
|
public LegacyPlayerListItemPacket(int action, List<Item> items) {
|
||||||
this.action = action;
|
this.action = action;
|
||||||
this.items.addAll(items);
|
this.items.addAll(items);
|
||||||
}
|
}
|
||||||
|
|
||||||
public LegacyPlayerListItem() {
|
public LegacyPlayerListItemPacket() {
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getAction() {
|
public int getAction() {
|
@ -23,7 +23,7 @@ import com.velocitypowered.proxy.protocol.MinecraftPacket;
|
|||||||
import com.velocitypowered.proxy.protocol.ProtocolUtils;
|
import com.velocitypowered.proxy.protocol.ProtocolUtils;
|
||||||
import io.netty.buffer.ByteBuf;
|
import io.netty.buffer.ByteBuf;
|
||||||
|
|
||||||
public class LoginAcknowledged implements MinecraftPacket {
|
public class LoginAcknowledgedPacket implements MinecraftPacket {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void decode(ByteBuf buf, ProtocolUtils.Direction direction,
|
public void decode(ByteBuf buf, ProtocolUtils.Direction direction,
|
@ -26,16 +26,16 @@ import io.netty.buffer.ByteBuf;
|
|||||||
import io.netty.buffer.Unpooled;
|
import io.netty.buffer.Unpooled;
|
||||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||||
|
|
||||||
public class LoginPluginMessage extends DeferredByteBufHolder implements MinecraftPacket {
|
public class LoginPluginMessagePacket extends DeferredByteBufHolder implements MinecraftPacket {
|
||||||
|
|
||||||
private int id;
|
private int id;
|
||||||
private @Nullable String channel;
|
private @Nullable String channel;
|
||||||
|
|
||||||
public LoginPluginMessage() {
|
public LoginPluginMessagePacket() {
|
||||||
super(null);
|
super(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
public LoginPluginMessage(int id, @Nullable String channel, ByteBuf data) {
|
public LoginPluginMessagePacket(int id, @Nullable String channel, ByteBuf data) {
|
||||||
super(data);
|
super(data);
|
||||||
this.id = id;
|
this.id = id;
|
||||||
this.channel = channel;
|
this.channel = channel;
|
@ -26,16 +26,16 @@ import io.netty.buffer.ByteBuf;
|
|||||||
import io.netty.buffer.Unpooled;
|
import io.netty.buffer.Unpooled;
|
||||||
import org.checkerframework.checker.nullness.qual.MonotonicNonNull;
|
import org.checkerframework.checker.nullness.qual.MonotonicNonNull;
|
||||||
|
|
||||||
public class LoginPluginResponse extends DeferredByteBufHolder implements MinecraftPacket {
|
public class LoginPluginResponsePacket extends DeferredByteBufHolder implements MinecraftPacket {
|
||||||
|
|
||||||
private int id;
|
private int id;
|
||||||
private boolean success;
|
private boolean success;
|
||||||
|
|
||||||
public LoginPluginResponse() {
|
public LoginPluginResponsePacket() {
|
||||||
super(Unpooled.EMPTY_BUFFER);
|
super(Unpooled.EMPTY_BUFFER);
|
||||||
}
|
}
|
||||||
|
|
||||||
public LoginPluginResponse(int id, boolean success, @MonotonicNonNull ByteBuf buf) {
|
public LoginPluginResponsePacket(int id, boolean success, @MonotonicNonNull ByteBuf buf) {
|
||||||
super(buf);
|
super(buf);
|
||||||
this.id = id;
|
this.id = id;
|
||||||
this.success = success;
|
this.success = success;
|
@ -23,7 +23,7 @@ import com.velocitypowered.proxy.protocol.MinecraftPacket;
|
|||||||
import com.velocitypowered.proxy.protocol.ProtocolUtils;
|
import com.velocitypowered.proxy.protocol.ProtocolUtils;
|
||||||
import io.netty.buffer.ByteBuf;
|
import io.netty.buffer.ByteBuf;
|
||||||
|
|
||||||
public class PingIdentify implements MinecraftPacket {
|
public class PingIdentifyPacket implements MinecraftPacket {
|
||||||
|
|
||||||
private int id;
|
private int id;
|
||||||
|
|
@ -28,16 +28,16 @@ import io.netty.buffer.ByteBuf;
|
|||||||
import org.checkerframework.checker.nullness.qual.MonotonicNonNull;
|
import org.checkerframework.checker.nullness.qual.MonotonicNonNull;
|
||||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||||
|
|
||||||
public class PluginMessage extends DeferredByteBufHolder implements MinecraftPacket {
|
public class PluginMessagePacket extends DeferredByteBufHolder implements MinecraftPacket {
|
||||||
|
|
||||||
private @Nullable String channel;
|
private @Nullable String channel;
|
||||||
|
|
||||||
public PluginMessage() {
|
public PluginMessagePacket() {
|
||||||
super(null);
|
super(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
public PluginMessage(String channel,
|
public PluginMessagePacket(String channel,
|
||||||
@MonotonicNonNull ByteBuf backing) {
|
@MonotonicNonNull ByteBuf backing) {
|
||||||
super(backing);
|
super(backing);
|
||||||
this.channel = channel;
|
this.channel = channel;
|
||||||
}
|
}
|
||||||
@ -105,42 +105,42 @@ public class PluginMessage extends DeferredByteBufHolder implements MinecraftPac
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public PluginMessage copy() {
|
public PluginMessagePacket copy() {
|
||||||
return (PluginMessage) super.copy();
|
return (PluginMessagePacket) super.copy();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public PluginMessage duplicate() {
|
public PluginMessagePacket duplicate() {
|
||||||
return (PluginMessage) super.duplicate();
|
return (PluginMessagePacket) super.duplicate();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public PluginMessage retainedDuplicate() {
|
public PluginMessagePacket retainedDuplicate() {
|
||||||
return (PluginMessage) super.retainedDuplicate();
|
return (PluginMessagePacket) super.retainedDuplicate();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public PluginMessage replace(ByteBuf content) {
|
public PluginMessagePacket replace(ByteBuf content) {
|
||||||
return (PluginMessage) super.replace(content);
|
return (PluginMessagePacket) super.replace(content);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public PluginMessage retain() {
|
public PluginMessagePacket retain() {
|
||||||
return (PluginMessage) super.retain();
|
return (PluginMessagePacket) super.retain();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public PluginMessage retain(int increment) {
|
public PluginMessagePacket retain(int increment) {
|
||||||
return (PluginMessage) super.retain(increment);
|
return (PluginMessagePacket) super.retain(increment);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public PluginMessage touch() {
|
public PluginMessagePacket touch() {
|
||||||
return (PluginMessage) super.touch();
|
return (PluginMessagePacket) super.touch();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public PluginMessage touch(Object hint) {
|
public PluginMessagePacket touch(Object hint) {
|
||||||
return (PluginMessage) super.touch(hint);
|
return (PluginMessagePacket) super.touch(hint);
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -27,15 +27,15 @@ import java.util.ArrayList;
|
|||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
public class RemovePlayerInfo implements MinecraftPacket {
|
public class RemovePlayerInfoPacket implements MinecraftPacket {
|
||||||
|
|
||||||
private Collection<UUID> profilesToRemove;
|
private Collection<UUID> profilesToRemove;
|
||||||
|
|
||||||
public RemovePlayerInfo() {
|
public RemovePlayerInfoPacket() {
|
||||||
this.profilesToRemove = new ArrayList<>();
|
this.profilesToRemove = new ArrayList<>();
|
||||||
}
|
}
|
||||||
|
|
||||||
public RemovePlayerInfo(Collection<UUID> profilesToRemove) {
|
public RemovePlayerInfoPacket(Collection<UUID> profilesToRemove) {
|
||||||
this.profilesToRemove = profilesToRemove;
|
this.profilesToRemove = profilesToRemove;
|
||||||
}
|
}
|
||||||
|
|
@ -26,14 +26,14 @@ import io.netty.buffer.ByteBuf;
|
|||||||
|
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
public class RemoveResourcePack implements MinecraftPacket {
|
public class RemoveResourcePackPacket implements MinecraftPacket {
|
||||||
|
|
||||||
private UUID id;
|
private UUID id;
|
||||||
|
|
||||||
public RemoveResourcePack() {
|
public RemoveResourcePackPacket() {
|
||||||
}
|
}
|
||||||
|
|
||||||
public RemoveResourcePack(UUID id) {
|
public RemoveResourcePackPacket(UUID id) {
|
||||||
this.id = id;
|
this.id = id;
|
||||||
}
|
}
|
||||||
|
|
@ -34,7 +34,7 @@ import org.checkerframework.checker.nullness.qual.Nullable;
|
|||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
public class ResourcePackRequest implements MinecraftPacket {
|
public class ResourcePackRequestPacket implements MinecraftPacket {
|
||||||
|
|
||||||
private @MonotonicNonNull UUID id; // 1.20.3+
|
private @MonotonicNonNull UUID id; // 1.20.3+
|
||||||
private @MonotonicNonNull String url;
|
private @MonotonicNonNull String url;
|
@ -28,16 +28,16 @@ import org.checkerframework.checker.nullness.qual.MonotonicNonNull;
|
|||||||
|
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
public class ResourcePackResponse implements MinecraftPacket {
|
public class ResourcePackResponsePacket implements MinecraftPacket {
|
||||||
|
|
||||||
private UUID id;
|
private UUID id;
|
||||||
private String hash = "";
|
private String hash = "";
|
||||||
private @MonotonicNonNull Status status;
|
private @MonotonicNonNull Status status;
|
||||||
|
|
||||||
public ResourcePackResponse() {
|
public ResourcePackResponsePacket() {
|
||||||
}
|
}
|
||||||
|
|
||||||
public ResourcePackResponse(UUID id, String hash, @MonotonicNonNull Status status) {
|
public ResourcePackResponsePacket(UUID id, String hash, @MonotonicNonNull Status status) {
|
||||||
this.id = id;
|
this.id = id;
|
||||||
this.hash = hash;
|
this.hash = hash;
|
||||||
this.status = status;
|
this.status = status;
|
@ -28,7 +28,7 @@ import net.kyori.adventure.nbt.BinaryTagIO;
|
|||||||
import net.kyori.adventure.nbt.CompoundBinaryTag;
|
import net.kyori.adventure.nbt.CompoundBinaryTag;
|
||||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||||
|
|
||||||
public class Respawn implements MinecraftPacket {
|
public class RespawnPacket implements MinecraftPacket {
|
||||||
|
|
||||||
private int dimension;
|
private int dimension;
|
||||||
private long partialHashedSeed;
|
private long partialHashedSeed;
|
||||||
@ -42,13 +42,13 @@ public class Respawn implements MinecraftPacket {
|
|||||||
private @Nullable Pair<String, Long> lastDeathPosition; // 1.19+
|
private @Nullable Pair<String, Long> lastDeathPosition; // 1.19+
|
||||||
private int portalCooldown; // 1.20+
|
private int portalCooldown; // 1.20+
|
||||||
|
|
||||||
public Respawn() {
|
public RespawnPacket() {
|
||||||
}
|
}
|
||||||
|
|
||||||
public Respawn(int dimension, long partialHashedSeed, short difficulty, short gamemode,
|
public RespawnPacket(int dimension, long partialHashedSeed, short difficulty, short gamemode,
|
||||||
String levelType, byte dataToKeep, DimensionInfo dimensionInfo,
|
String levelType, byte dataToKeep, DimensionInfo dimensionInfo,
|
||||||
short previousGamemode, CompoundBinaryTag currentDimensionData,
|
short previousGamemode, CompoundBinaryTag currentDimensionData,
|
||||||
@Nullable Pair<String, Long> lastDeathPosition, int portalCooldown) {
|
@Nullable Pair<String, Long> lastDeathPosition, int portalCooldown) {
|
||||||
this.dimension = dimension;
|
this.dimension = dimension;
|
||||||
this.partialHashedSeed = partialHashedSeed;
|
this.partialHashedSeed = partialHashedSeed;
|
||||||
this.difficulty = difficulty;
|
this.difficulty = difficulty;
|
||||||
@ -62,8 +62,8 @@ public class Respawn implements MinecraftPacket {
|
|||||||
this.portalCooldown = portalCooldown;
|
this.portalCooldown = portalCooldown;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Respawn fromJoinGame(JoinGame joinGame) {
|
public static RespawnPacket fromJoinGame(JoinGamePacket joinGame) {
|
||||||
return new Respawn(joinGame.getDimension(), joinGame.getPartialHashedSeed(),
|
return new RespawnPacket(joinGame.getDimension(), joinGame.getPartialHashedSeed(),
|
||||||
joinGame.getDifficulty(), joinGame.getGamemode(), joinGame.getLevelType(),
|
joinGame.getDifficulty(), joinGame.getGamemode(), joinGame.getLevelType(),
|
||||||
(byte) 0, joinGame.getDimensionInfo(), joinGame.getPreviousGamemode(),
|
(byte) 0, joinGame.getDimensionInfo(), joinGame.getPreviousGamemode(),
|
||||||
joinGame.getCurrentDimensionData(), joinGame.getLastDeathPosition(), joinGame.getPortalCooldown());
|
joinGame.getCurrentDimensionData(), joinGame.getLastDeathPosition(), joinGame.getPortalCooldown());
|
@ -28,17 +28,17 @@ import org.jetbrains.annotations.Nullable;
|
|||||||
import java.nio.charset.StandardCharsets;
|
import java.nio.charset.StandardCharsets;
|
||||||
import java.util.Base64;
|
import java.util.Base64;
|
||||||
|
|
||||||
public class ServerData implements MinecraftPacket {
|
public class ServerDataPacket implements MinecraftPacket {
|
||||||
|
|
||||||
private @Nullable ComponentHolder description;
|
private @Nullable ComponentHolder description;
|
||||||
private @Nullable Favicon favicon;
|
private @Nullable Favicon favicon;
|
||||||
private boolean secureChatEnforced; // Added in 1.19.1
|
private boolean secureChatEnforced; // Added in 1.19.1
|
||||||
|
|
||||||
public ServerData() {
|
public ServerDataPacket() {
|
||||||
}
|
}
|
||||||
|
|
||||||
public ServerData(@Nullable ComponentHolder description, @Nullable Favicon favicon,
|
public ServerDataPacket(@Nullable ComponentHolder description, @Nullable Favicon favicon,
|
||||||
boolean secureChatEnforced) {
|
boolean secureChatEnforced) {
|
||||||
this.description = description;
|
this.description = description;
|
||||||
this.favicon = favicon;
|
this.favicon = favicon;
|
||||||
this.secureChatEnforced = secureChatEnforced;
|
this.secureChatEnforced = secureChatEnforced;
|
@ -30,7 +30,7 @@ import org.checkerframework.checker.nullness.qual.Nullable;
|
|||||||
|
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
public class ServerLogin implements MinecraftPacket {
|
public class ServerLoginPacket implements MinecraftPacket {
|
||||||
|
|
||||||
private static final QuietDecoderException EMPTY_USERNAME = new QuietDecoderException(
|
private static final QuietDecoderException EMPTY_USERNAME = new QuietDecoderException(
|
||||||
"Empty username!");
|
"Empty username!");
|
||||||
@ -39,15 +39,15 @@ public class ServerLogin implements MinecraftPacket {
|
|||||||
private @Nullable IdentifiedKey playerKey; // Introduced in 1.19.3
|
private @Nullable IdentifiedKey playerKey; // Introduced in 1.19.3
|
||||||
private @Nullable UUID holderUuid; // Used for key revision 2
|
private @Nullable UUID holderUuid; // Used for key revision 2
|
||||||
|
|
||||||
public ServerLogin() {
|
public ServerLoginPacket() {
|
||||||
}
|
}
|
||||||
|
|
||||||
public ServerLogin(String username, @Nullable IdentifiedKey playerKey) {
|
public ServerLoginPacket(String username, @Nullable IdentifiedKey playerKey) {
|
||||||
this.username = Preconditions.checkNotNull(username, "username");
|
this.username = Preconditions.checkNotNull(username, "username");
|
||||||
this.playerKey = playerKey;
|
this.playerKey = playerKey;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ServerLogin(String username, @Nullable UUID holderUuid) {
|
public ServerLoginPacket(String username, @Nullable UUID holderUuid) {
|
||||||
this.username = Preconditions.checkNotNull(username, "username");
|
this.username = Preconditions.checkNotNull(username, "username");
|
||||||
this.holderUuid = holderUuid;
|
this.holderUuid = holderUuid;
|
||||||
this.playerKey = null;
|
this.playerKey = null;
|
@ -29,7 +29,7 @@ import java.util.List;
|
|||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||||
|
|
||||||
public class ServerLoginSuccess implements MinecraftPacket {
|
public class ServerLoginSuccessPacket implements MinecraftPacket {
|
||||||
|
|
||||||
private @Nullable UUID uuid;
|
private @Nullable UUID uuid;
|
||||||
private @Nullable String username;
|
private @Nullable String username;
|
@ -23,14 +23,14 @@ import com.velocitypowered.proxy.protocol.MinecraftPacket;
|
|||||||
import com.velocitypowered.proxy.protocol.ProtocolUtils;
|
import com.velocitypowered.proxy.protocol.ProtocolUtils;
|
||||||
import io.netty.buffer.ByteBuf;
|
import io.netty.buffer.ByteBuf;
|
||||||
|
|
||||||
public class SetCompression implements MinecraftPacket {
|
public class SetCompressionPacket implements MinecraftPacket {
|
||||||
|
|
||||||
private int threshold;
|
private int threshold;
|
||||||
|
|
||||||
public SetCompression() {
|
public SetCompressionPacket() {
|
||||||
}
|
}
|
||||||
|
|
||||||
public SetCompression(int threshold) {
|
public SetCompressionPacket(int threshold) {
|
||||||
this.threshold = threshold;
|
this.threshold = threshold;
|
||||||
}
|
}
|
||||||
|
|
@ -24,7 +24,7 @@ import com.velocitypowered.proxy.protocol.ProtocolUtils;
|
|||||||
import com.velocitypowered.proxy.protocol.ProtocolUtils.Direction;
|
import com.velocitypowered.proxy.protocol.ProtocolUtils.Direction;
|
||||||
import io.netty.buffer.ByteBuf;
|
import io.netty.buffer.ByteBuf;
|
||||||
|
|
||||||
public class StatusPing implements MinecraftPacket {
|
public class StatusPingPacket implements MinecraftPacket {
|
||||||
|
|
||||||
private long randomId;
|
private long randomId;
|
||||||
|
|
@ -24,11 +24,11 @@ import com.velocitypowered.proxy.protocol.ProtocolUtils;
|
|||||||
import com.velocitypowered.proxy.protocol.ProtocolUtils.Direction;
|
import com.velocitypowered.proxy.protocol.ProtocolUtils.Direction;
|
||||||
import io.netty.buffer.ByteBuf;
|
import io.netty.buffer.ByteBuf;
|
||||||
|
|
||||||
public class StatusRequest implements MinecraftPacket {
|
public class StatusRequestPacket implements MinecraftPacket {
|
||||||
|
|
||||||
public static final StatusRequest INSTANCE = new StatusRequest();
|
public static final StatusRequestPacket INSTANCE = new StatusRequestPacket();
|
||||||
|
|
||||||
private StatusRequest() {
|
private StatusRequestPacket() {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
@ -24,14 +24,14 @@ import com.velocitypowered.proxy.protocol.ProtocolUtils;
|
|||||||
import io.netty.buffer.ByteBuf;
|
import io.netty.buffer.ByteBuf;
|
||||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||||
|
|
||||||
public class StatusResponse implements MinecraftPacket {
|
public class StatusResponsePacket implements MinecraftPacket {
|
||||||
|
|
||||||
private @Nullable CharSequence status;
|
private @Nullable CharSequence status;
|
||||||
|
|
||||||
public StatusResponse() {
|
public StatusResponsePacket() {
|
||||||
}
|
}
|
||||||
|
|
||||||
public StatusResponse(CharSequence status) {
|
public StatusResponsePacket(CharSequence status) {
|
||||||
this.status = status;
|
this.status = status;
|
||||||
}
|
}
|
||||||
|
|
@ -29,7 +29,7 @@ import com.velocitypowered.proxy.protocol.ProtocolUtils;
|
|||||||
import io.netty.buffer.ByteBuf;
|
import io.netty.buffer.ByteBuf;
|
||||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||||
|
|
||||||
public class TabCompleteRequest implements MinecraftPacket {
|
public class TabCompleteRequestPacket implements MinecraftPacket {
|
||||||
|
|
||||||
private static final int VANILLA_MAX_TAB_COMPLETE_LEN = 2048;
|
private static final int VANILLA_MAX_TAB_COMPLETE_LEN = 2048;
|
||||||
|
|
@ -30,7 +30,7 @@ import java.util.ArrayList;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||||
|
|
||||||
public class TabCompleteResponse implements MinecraftPacket {
|
public class TabCompleteResponsePacket implements MinecraftPacket {
|
||||||
|
|
||||||
private int transactionId;
|
private int transactionId;
|
||||||
private int start;
|
private int start;
|
@ -34,22 +34,22 @@ import java.util.List;
|
|||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
public class UpsertPlayerInfo implements MinecraftPacket {
|
public class UpsertPlayerInfoPacket implements MinecraftPacket {
|
||||||
|
|
||||||
private final EnumSet<Action> actions;
|
private final EnumSet<Action> actions;
|
||||||
private final List<Entry> entries;
|
private final List<Entry> entries;
|
||||||
|
|
||||||
public UpsertPlayerInfo() {
|
public UpsertPlayerInfoPacket() {
|
||||||
this.actions = EnumSet.noneOf(Action.class);
|
this.actions = EnumSet.noneOf(Action.class);
|
||||||
this.entries = new ArrayList<>();
|
this.entries = new ArrayList<>();
|
||||||
}
|
}
|
||||||
|
|
||||||
public UpsertPlayerInfo(Action action) {
|
public UpsertPlayerInfoPacket(Action action) {
|
||||||
this.actions = EnumSet.of(action);
|
this.actions = EnumSet.of(action);
|
||||||
this.entries = new ArrayList<>();
|
this.entries = new ArrayList<>();
|
||||||
}
|
}
|
||||||
|
|
||||||
public UpsertPlayerInfo(EnumSet<Action> actions, List<Entry> entries) {
|
public UpsertPlayerInfoPacket(EnumSet<Action> actions, List<Entry> entries) {
|
||||||
this.actions = actions;
|
this.actions = actions;
|
||||||
this.entries = entries;
|
this.entries = entries;
|
||||||
}
|
}
|
@ -23,14 +23,14 @@ import com.velocitypowered.proxy.protocol.MinecraftPacket;
|
|||||||
import com.velocitypowered.proxy.protocol.ProtocolUtils;
|
import com.velocitypowered.proxy.protocol.ProtocolUtils;
|
||||||
import io.netty.buffer.ByteBuf;
|
import io.netty.buffer.ByteBuf;
|
||||||
|
|
||||||
public class ChatAcknowledgement implements MinecraftPacket {
|
public class ChatAcknowledgementPacket implements MinecraftPacket {
|
||||||
int offset;
|
int offset;
|
||||||
|
|
||||||
public ChatAcknowledgement(int offset) {
|
public ChatAcknowledgementPacket(int offset) {
|
||||||
this.offset = offset;
|
this.offset = offset;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ChatAcknowledgement() {
|
public ChatAcknowledgementPacket() {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
@ -23,7 +23,7 @@ import com.velocitypowered.proxy.protocol.MinecraftPacket;
|
|||||||
import com.velocitypowered.proxy.protocol.ProtocolUtils;
|
import com.velocitypowered.proxy.protocol.ProtocolUtils;
|
||||||
import io.netty.buffer.ByteBuf;
|
import io.netty.buffer.ByteBuf;
|
||||||
|
|
||||||
public class PlayerChatCompletion implements MinecraftPacket {
|
public class PlayerChatCompletionPacket implements MinecraftPacket {
|
||||||
|
|
||||||
private String[] completions;
|
private String[] completions;
|
||||||
private Action action;
|
private Action action;
|
@ -23,12 +23,12 @@ import com.velocitypowered.proxy.protocol.MinecraftPacket;
|
|||||||
import com.velocitypowered.proxy.protocol.ProtocolUtils;
|
import com.velocitypowered.proxy.protocol.ProtocolUtils;
|
||||||
import io.netty.buffer.ByteBuf;
|
import io.netty.buffer.ByteBuf;
|
||||||
|
|
||||||
public class SystemChat implements MinecraftPacket {
|
public class SystemChatPacket implements MinecraftPacket {
|
||||||
|
|
||||||
public SystemChat() {
|
public SystemChatPacket() {
|
||||||
}
|
}
|
||||||
|
|
||||||
public SystemChat(ComponentHolder component, ChatType type) {
|
public SystemChatPacket(ComponentHolder component, ChatType type) {
|
||||||
this.component = component;
|
this.component = component;
|
||||||
this.type = type;
|
this.type = type;
|
||||||
}
|
}
|
@ -22,7 +22,7 @@ import com.velocitypowered.api.network.ProtocolVersion;
|
|||||||
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.ComponentHolder;
|
import com.velocitypowered.proxy.protocol.packet.chat.ComponentHolder;
|
||||||
import com.velocitypowered.proxy.protocol.packet.chat.SystemChat;
|
import com.velocitypowered.proxy.protocol.packet.chat.SystemChatPacket;
|
||||||
import com.velocitypowered.proxy.protocol.packet.chat.builder.ChatBuilderV2;
|
import com.velocitypowered.proxy.protocol.packet.chat.builder.ChatBuilderV2;
|
||||||
import net.kyori.adventure.text.Component;
|
import net.kyori.adventure.text.Component;
|
||||||
|
|
||||||
@ -36,16 +36,16 @@ public class KeyedChatBuilder extends ChatBuilderV2 {
|
|||||||
public MinecraftPacket toClient() {
|
public MinecraftPacket toClient() {
|
||||||
// This is temporary
|
// This is temporary
|
||||||
Component msg = component == null ? Component.text(message) : component;
|
Component msg = component == null ? Component.text(message) : component;
|
||||||
return new SystemChat(new ComponentHolder(version, msg), type == ChatType.CHAT ? ChatType.SYSTEM : type);
|
return new SystemChatPacket(new ComponentHolder(version, msg), type == ChatType.CHAT ? ChatType.SYSTEM : type);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public MinecraftPacket toServer() {
|
public MinecraftPacket toServer() {
|
||||||
if (message.startsWith("/")) {
|
if (message.startsWith("/")) {
|
||||||
return new KeyedPlayerCommand(message.substring(1), ImmutableList.of(), timestamp);
|
return new KeyedPlayerCommandPacket(message.substring(1), ImmutableList.of(), timestamp);
|
||||||
} else {
|
} else {
|
||||||
// This will produce an error on the server, but needs to be here.
|
// This will produce an error on the server, but needs to be here.
|
||||||
KeyedPlayerChat v1Chat = new KeyedPlayerChat(message);
|
KeyedPlayerChatPacket v1Chat = new KeyedPlayerChatPacket(message);
|
||||||
v1Chat.setExpiry(this.timestamp);
|
v1Chat.setExpiry(this.timestamp);
|
||||||
return v1Chat;
|
return v1Chat;
|
||||||
}
|
}
|
||||||
|
@ -31,7 +31,7 @@ import org.apache.logging.log4j.LogManager;
|
|||||||
import org.apache.logging.log4j.Logger;
|
import org.apache.logging.log4j.Logger;
|
||||||
|
|
||||||
public class KeyedChatHandler implements
|
public class KeyedChatHandler implements
|
||||||
com.velocitypowered.proxy.protocol.packet.chat.ChatHandler<KeyedPlayerChat> {
|
com.velocitypowered.proxy.protocol.packet.chat.ChatHandler<KeyedPlayerChatPacket> {
|
||||||
|
|
||||||
private static final Logger logger = LogManager.getLogger(KeyedChatHandler.class);
|
private static final Logger logger = LogManager.getLogger(KeyedChatHandler.class);
|
||||||
|
|
||||||
@ -44,8 +44,8 @@ public class KeyedChatHandler implements
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Class<KeyedPlayerChat> packetClass() {
|
public Class<KeyedPlayerChatPacket> packetClass() {
|
||||||
return KeyedPlayerChat.class;
|
return KeyedPlayerChatPacket.class;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void invalidCancel(Logger logger, ConnectedPlayer player) {
|
public static void invalidCancel(Logger logger, ConnectedPlayer player) {
|
||||||
@ -65,7 +65,7 @@ public class KeyedChatHandler implements
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void handlePlayerChatInternal(KeyedPlayerChat packet) {
|
public void handlePlayerChatInternal(KeyedPlayerChatPacket packet) {
|
||||||
ChatQueue chatQueue = this.player.getChatQueue();
|
ChatQueue chatQueue = this.player.getChatQueue();
|
||||||
EventManager eventManager = this.server.getEventManager();
|
EventManager eventManager = this.server.getEventManager();
|
||||||
PlayerChatEvent toSend = new PlayerChatEvent(player, packet.getMessage());
|
PlayerChatEvent toSend = new PlayerChatEvent(player, packet.getMessage());
|
||||||
@ -99,7 +99,7 @@ public class KeyedChatHandler implements
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
private Function<PlayerChatEvent, MinecraftPacket> handleOldSignedChat(KeyedPlayerChat packet) {
|
private Function<PlayerChatEvent, MinecraftPacket> handleOldSignedChat(KeyedPlayerChatPacket packet) {
|
||||||
IdentifiedKey playerKey = this.player.getIdentifiedKey();
|
IdentifiedKey playerKey = this.player.getIdentifiedKey();
|
||||||
assert playerKey != null;
|
assert playerKey != null;
|
||||||
return pme -> {
|
return pme -> {
|
||||||
|
@ -26,7 +26,7 @@ import com.velocitypowered.proxy.protocol.packet.chat.builder.ChatBuilderV2;
|
|||||||
import java.util.concurrent.CompletableFuture;
|
import java.util.concurrent.CompletableFuture;
|
||||||
import net.kyori.adventure.text.Component;
|
import net.kyori.adventure.text.Component;
|
||||||
|
|
||||||
public class KeyedCommandHandler implements CommandHandler<KeyedPlayerCommand> {
|
public class KeyedCommandHandler implements CommandHandler<KeyedPlayerCommandPacket> {
|
||||||
|
|
||||||
private final ConnectedPlayer player;
|
private final ConnectedPlayer player;
|
||||||
private final VelocityServer server;
|
private final VelocityServer server;
|
||||||
@ -37,12 +37,12 @@ public class KeyedCommandHandler implements CommandHandler<KeyedPlayerCommand> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Class<KeyedPlayerCommand> packetClass() {
|
public Class<KeyedPlayerCommandPacket> packetClass() {
|
||||||
return KeyedPlayerCommand.class;
|
return KeyedPlayerCommandPacket.class;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void handlePlayerCommandInternal(KeyedPlayerCommand packet) {
|
public void handlePlayerCommandInternal(KeyedPlayerCommandPacket packet) {
|
||||||
queueCommandResult(this.server, this.player, event -> {
|
queueCommandResult(this.server, this.player, event -> {
|
||||||
CommandExecuteEvent.CommandResult result = event.getResult();
|
CommandExecuteEvent.CommandResult result = event.getResult();
|
||||||
IdentifiedKey playerKey = player.getIdentifiedKey();
|
IdentifiedKey playerKey = player.getIdentifiedKey();
|
||||||
|
@ -29,7 +29,7 @@ import io.netty.buffer.ByteBuf;
|
|||||||
import java.time.Instant;
|
import java.time.Instant;
|
||||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||||
|
|
||||||
public class KeyedPlayerChat implements MinecraftPacket {
|
public class KeyedPlayerChatPacket implements MinecraftPacket {
|
||||||
|
|
||||||
private String message;
|
private String message;
|
||||||
private boolean signedPreview;
|
private boolean signedPreview;
|
||||||
@ -45,10 +45,10 @@ public class KeyedPlayerChat implements MinecraftPacket {
|
|||||||
public static final QuietDecoderException INVALID_PREVIOUS_MESSAGES =
|
public static final QuietDecoderException INVALID_PREVIOUS_MESSAGES =
|
||||||
new QuietDecoderException("Invalid previous messages");
|
new QuietDecoderException("Invalid previous messages");
|
||||||
|
|
||||||
public KeyedPlayerChat() {
|
public KeyedPlayerChatPacket() {
|
||||||
}
|
}
|
||||||
|
|
||||||
public KeyedPlayerChat(String message) {
|
public KeyedPlayerChatPacket(String message) {
|
||||||
this.message = message;
|
this.message = message;
|
||||||
this.unsigned = true;
|
this.unsigned = true;
|
||||||
}
|
}
|
@ -17,8 +17,8 @@
|
|||||||
|
|
||||||
package com.velocitypowered.proxy.protocol.packet.chat.keyed;
|
package com.velocitypowered.proxy.protocol.packet.chat.keyed;
|
||||||
|
|
||||||
import static com.velocitypowered.proxy.protocol.packet.chat.keyed.KeyedPlayerChat.INVALID_PREVIOUS_MESSAGES;
|
import static com.velocitypowered.proxy.protocol.packet.chat.keyed.KeyedPlayerChatPacket.INVALID_PREVIOUS_MESSAGES;
|
||||||
import static com.velocitypowered.proxy.protocol.packet.chat.keyed.KeyedPlayerChat.MAXIMUM_PREVIOUS_MESSAGE_COUNT;
|
import static com.velocitypowered.proxy.protocol.packet.chat.keyed.KeyedPlayerChatPacket.MAXIMUM_PREVIOUS_MESSAGE_COUNT;
|
||||||
|
|
||||||
import com.google.common.collect.ImmutableMap;
|
import com.google.common.collect.ImmutableMap;
|
||||||
import com.velocitypowered.api.network.ProtocolVersion;
|
import com.velocitypowered.api.network.ProtocolVersion;
|
||||||
@ -35,7 +35,7 @@ import java.util.List;
|
|||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||||
|
|
||||||
public class KeyedPlayerCommand implements MinecraftPacket {
|
public class KeyedPlayerCommandPacket implements MinecraftPacket {
|
||||||
|
|
||||||
private static final int MAX_NUM_ARGUMENTS = 8;
|
private static final int MAX_NUM_ARGUMENTS = 8;
|
||||||
private static final int MAX_LENGTH_ARGUMENTS = 16;
|
private static final int MAX_LENGTH_ARGUMENTS = 16;
|
||||||
@ -63,17 +63,17 @@ public class KeyedPlayerCommand implements MinecraftPacket {
|
|||||||
return command;
|
return command;
|
||||||
}
|
}
|
||||||
|
|
||||||
public KeyedPlayerCommand() {
|
public KeyedPlayerCommandPacket() {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates an {@link KeyedPlayerCommand} packet based on a command and list of arguments.
|
* Creates an {@link KeyedPlayerCommandPacket} packet based on a command and list of arguments.
|
||||||
*
|
*
|
||||||
* @param command the command to run
|
* @param command the command to run
|
||||||
* @param arguments the arguments of the command
|
* @param arguments the arguments of the command
|
||||||
* @param timestamp the timestamp of the command execution
|
* @param timestamp the timestamp of the command execution
|
||||||
*/
|
*/
|
||||||
public KeyedPlayerCommand(String command, List<String> arguments, Instant timestamp) {
|
public KeyedPlayerCommandPacket(String command, List<String> arguments, Instant timestamp) {
|
||||||
this.unsigned = true;
|
this.unsigned = true;
|
||||||
ImmutableMap.Builder<String, byte[]> builder = ImmutableMap.builder();
|
ImmutableMap.Builder<String, byte[]> builder = ImmutableMap.builder();
|
||||||
arguments.forEach(entry -> builder.put(entry, EncryptionUtils.EMPTY));
|
arguments.forEach(entry -> builder.put(entry, EncryptionUtils.EMPTY));
|
@ -38,13 +38,13 @@ public class LegacyChatBuilder extends ChatBuilderV2 {
|
|||||||
: senderIdentity.uuid()) : sender.getUniqueId();
|
: senderIdentity.uuid()) : sender.getUniqueId();
|
||||||
Component msg = component == null ? Component.text(message) : component;
|
Component msg = component == null ? Component.text(message) : component;
|
||||||
|
|
||||||
return new LegacyChat(ProtocolUtils.getJsonChatSerializer(version).serialize(msg), type.getId(),
|
return new LegacyChatPacket(ProtocolUtils.getJsonChatSerializer(version).serialize(msg), type.getId(),
|
||||||
identity);
|
identity);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public MinecraftPacket toServer() {
|
public MinecraftPacket toServer() {
|
||||||
LegacyChat chat = new LegacyChat();
|
LegacyChatPacket chat = new LegacyChatPacket();
|
||||||
chat.setMessage(message);
|
chat.setMessage(message);
|
||||||
return chat;
|
return chat;
|
||||||
}
|
}
|
||||||
|
@ -23,7 +23,7 @@ import com.velocitypowered.proxy.connection.MinecraftConnection;
|
|||||||
import com.velocitypowered.proxy.connection.client.ConnectedPlayer;
|
import com.velocitypowered.proxy.connection.client.ConnectedPlayer;
|
||||||
import com.velocitypowered.proxy.protocol.packet.chat.ChatHandler;
|
import com.velocitypowered.proxy.protocol.packet.chat.ChatHandler;
|
||||||
|
|
||||||
public class LegacyChatHandler implements ChatHandler<LegacyChat> {
|
public class LegacyChatHandler implements ChatHandler<LegacyChatPacket> {
|
||||||
|
|
||||||
private final VelocityServer server;
|
private final VelocityServer server;
|
||||||
private final ConnectedPlayer player;
|
private final ConnectedPlayer player;
|
||||||
@ -34,12 +34,12 @@ public class LegacyChatHandler implements ChatHandler<LegacyChat> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Class<LegacyChat> packetClass() {
|
public Class<LegacyChatPacket> packetClass() {
|
||||||
return LegacyChat.class;
|
return LegacyChatPacket.class;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void handlePlayerChatInternal(LegacyChat packet) {
|
public void handlePlayerChatInternal(LegacyChatPacket packet) {
|
||||||
MinecraftConnection serverConnection = player.ensureAndGetCurrentServer().ensureConnected();
|
MinecraftConnection serverConnection = player.ensureAndGetCurrentServer().ensureConnected();
|
||||||
if (serverConnection == null) {
|
if (serverConnection == null) {
|
||||||
return;
|
return;
|
||||||
|
@ -25,7 +25,7 @@ import io.netty.buffer.ByteBuf;
|
|||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||||
|
|
||||||
public class LegacyChat implements MinecraftPacket {
|
public class LegacyChatPacket implements MinecraftPacket {
|
||||||
|
|
||||||
public static final byte CHAT_TYPE = (byte) 0;
|
public static final byte CHAT_TYPE = (byte) 0;
|
||||||
public static final byte SYSTEM_TYPE = (byte) 1;
|
public static final byte SYSTEM_TYPE = (byte) 1;
|
||||||
@ -38,13 +38,13 @@ public class LegacyChat implements MinecraftPacket {
|
|||||||
private byte type;
|
private byte type;
|
||||||
private @Nullable UUID sender;
|
private @Nullable UUID sender;
|
||||||
|
|
||||||
public LegacyChat() {
|
public LegacyChatPacket() {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a Chat packet.
|
* Creates a Chat packet.
|
||||||
*/
|
*/
|
||||||
public LegacyChat(String message, byte type, UUID sender) {
|
public LegacyChatPacket(String message, byte type, UUID sender) {
|
||||||
this.message = message;
|
this.message = message;
|
||||||
this.type = type;
|
this.type = type;
|
||||||
this.sender = sender;
|
this.sender = sender;
|
@ -24,7 +24,7 @@ import com.velocitypowered.proxy.protocol.packet.chat.CommandHandler;
|
|||||||
import java.time.Instant;
|
import java.time.Instant;
|
||||||
import java.util.concurrent.CompletableFuture;
|
import java.util.concurrent.CompletableFuture;
|
||||||
|
|
||||||
public class LegacyCommandHandler implements CommandHandler<LegacyChat> {
|
public class LegacyCommandHandler implements CommandHandler<LegacyChatPacket> {
|
||||||
|
|
||||||
private final ConnectedPlayer player;
|
private final ConnectedPlayer player;
|
||||||
private final VelocityServer server;
|
private final VelocityServer server;
|
||||||
@ -35,12 +35,12 @@ public class LegacyCommandHandler implements CommandHandler<LegacyChat> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Class<LegacyChat> packetClass() {
|
public Class<LegacyChatPacket> packetClass() {
|
||||||
return LegacyChat.class;
|
return LegacyChatPacket.class;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void handlePlayerCommandInternal(LegacyChat packet) {
|
public void handlePlayerCommandInternal(LegacyChatPacket packet) {
|
||||||
String command = packet.getMessage().substring(1);
|
String command = packet.getMessage().substring(1);
|
||||||
queueCommandResult(this.server, this.player, event -> {
|
queueCommandResult(this.server, this.player, event -> {
|
||||||
CommandExecuteEvent.CommandResult result = event.getResult();
|
CommandExecuteEvent.CommandResult result = event.getResult();
|
||||||
|
@ -22,7 +22,7 @@ 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.ComponentHolder;
|
import com.velocitypowered.proxy.protocol.packet.chat.ComponentHolder;
|
||||||
import com.velocitypowered.proxy.protocol.packet.chat.LastSeenMessages;
|
import com.velocitypowered.proxy.protocol.packet.chat.LastSeenMessages;
|
||||||
import com.velocitypowered.proxy.protocol.packet.chat.SystemChat;
|
import com.velocitypowered.proxy.protocol.packet.chat.SystemChatPacket;
|
||||||
import com.velocitypowered.proxy.protocol.packet.chat.builder.ChatBuilderV2;
|
import com.velocitypowered.proxy.protocol.packet.chat.builder.ChatBuilderV2;
|
||||||
import net.kyori.adventure.text.Component;
|
import net.kyori.adventure.text.Component;
|
||||||
|
|
||||||
@ -36,21 +36,21 @@ public class SessionChatBuilder extends ChatBuilderV2 {
|
|||||||
public MinecraftPacket toClient() {
|
public MinecraftPacket toClient() {
|
||||||
// This is temporary
|
// This is temporary
|
||||||
Component msg = component == null ? Component.text(message) : component;
|
Component msg = component == null ? Component.text(message) : component;
|
||||||
return new SystemChat(new ComponentHolder(version, msg), type == ChatType.CHAT ? ChatType.SYSTEM : type);
|
return new SystemChatPacket(new ComponentHolder(version, msg), type == ChatType.CHAT ? ChatType.SYSTEM : type);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public MinecraftPacket toServer() {
|
public MinecraftPacket toServer() {
|
||||||
if (message.startsWith("/")) {
|
if (message.startsWith("/")) {
|
||||||
SessionPlayerCommand command = new SessionPlayerCommand();
|
SessionPlayerCommandPacket command = new SessionPlayerCommandPacket();
|
||||||
command.command = message.substring(1);
|
command.command = message.substring(1);
|
||||||
command.salt = 0L;
|
command.salt = 0L;
|
||||||
command.timeStamp = timestamp;
|
command.timeStamp = timestamp;
|
||||||
command.argumentSignatures = new SessionPlayerCommand.ArgumentSignatures();
|
command.argumentSignatures = new SessionPlayerCommandPacket.ArgumentSignatures();
|
||||||
command.lastSeenMessages = new LastSeenMessages();
|
command.lastSeenMessages = new LastSeenMessages();
|
||||||
return command;
|
return command;
|
||||||
} else {
|
} else {
|
||||||
SessionPlayerChat chat = new SessionPlayerChat();
|
SessionPlayerChatPacket chat = new SessionPlayerChatPacket();
|
||||||
chat.message = message;
|
chat.message = message;
|
||||||
chat.signed = false;
|
chat.signed = false;
|
||||||
chat.signature = new byte[0];
|
chat.signature = new byte[0];
|
||||||
|
@ -29,7 +29,7 @@ import com.velocitypowered.proxy.protocol.packet.chat.ChatQueue;
|
|||||||
import org.apache.logging.log4j.LogManager;
|
import org.apache.logging.log4j.LogManager;
|
||||||
import org.apache.logging.log4j.Logger;
|
import org.apache.logging.log4j.Logger;
|
||||||
|
|
||||||
public class SessionChatHandler implements ChatHandler<SessionPlayerChat> {
|
public class SessionChatHandler implements ChatHandler<SessionPlayerChatPacket> {
|
||||||
|
|
||||||
private static final Logger logger = LogManager.getLogger(SessionChatHandler.class);
|
private static final Logger logger = LogManager.getLogger(SessionChatHandler.class);
|
||||||
|
|
||||||
@ -42,12 +42,12 @@ public class SessionChatHandler implements ChatHandler<SessionPlayerChat> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Class<SessionPlayerChat> packetClass() {
|
public Class<SessionPlayerChatPacket> packetClass() {
|
||||||
return SessionPlayerChat.class;
|
return SessionPlayerChatPacket.class;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void handlePlayerChatInternal(SessionPlayerChat packet) {
|
public void handlePlayerChatInternal(SessionPlayerChatPacket packet) {
|
||||||
ChatQueue chatQueue = this.player.getChatQueue();
|
ChatQueue chatQueue = this.player.getChatQueue();
|
||||||
EventManager eventManager = this.server.getEventManager();
|
EventManager eventManager = this.server.getEventManager();
|
||||||
PlayerChatEvent toSend = new PlayerChatEvent(player, packet.getMessage());
|
PlayerChatEvent toSend = new PlayerChatEvent(player, packet.getMessage());
|
||||||
|
@ -21,12 +21,12 @@ import com.velocitypowered.api.event.command.CommandExecuteEvent;
|
|||||||
import com.velocitypowered.api.network.ProtocolVersion;
|
import com.velocitypowered.api.network.ProtocolVersion;
|
||||||
import com.velocitypowered.proxy.VelocityServer;
|
import com.velocitypowered.proxy.VelocityServer;
|
||||||
import com.velocitypowered.proxy.connection.client.ConnectedPlayer;
|
import com.velocitypowered.proxy.connection.client.ConnectedPlayer;
|
||||||
import com.velocitypowered.proxy.protocol.packet.chat.ChatAcknowledgement;
|
import com.velocitypowered.proxy.protocol.packet.chat.ChatAcknowledgementPacket;
|
||||||
import com.velocitypowered.proxy.protocol.packet.chat.CommandHandler;
|
import com.velocitypowered.proxy.protocol.packet.chat.CommandHandler;
|
||||||
import java.util.concurrent.CompletableFuture;
|
import java.util.concurrent.CompletableFuture;
|
||||||
import net.kyori.adventure.text.Component;
|
import net.kyori.adventure.text.Component;
|
||||||
|
|
||||||
public class SessionCommandHandler implements CommandHandler<SessionPlayerCommand> {
|
public class SessionCommandHandler implements CommandHandler<SessionPlayerCommandPacket> {
|
||||||
|
|
||||||
private final ConnectedPlayer player;
|
private final ConnectedPlayer player;
|
||||||
private final VelocityServer server;
|
private final VelocityServer server;
|
||||||
@ -37,12 +37,12 @@ public class SessionCommandHandler implements CommandHandler<SessionPlayerComman
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Class<SessionPlayerCommand> packetClass() {
|
public Class<SessionPlayerCommandPacket> packetClass() {
|
||||||
return SessionPlayerCommand.class;
|
return SessionPlayerCommandPacket.class;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void handlePlayerCommandInternal(SessionPlayerCommand packet) {
|
public void handlePlayerCommandInternal(SessionPlayerCommandPacket packet) {
|
||||||
queueCommandResult(this.server, this.player, event -> {
|
queueCommandResult(this.server, this.player, event -> {
|
||||||
CommandExecuteEvent.CommandResult result = event.getResult();
|
CommandExecuteEvent.CommandResult result = event.getResult();
|
||||||
if (result == CommandExecuteEvent.CommandResult.denied()) {
|
if (result == CommandExecuteEvent.CommandResult.denied()) {
|
||||||
@ -56,7 +56,7 @@ public class SessionCommandHandler implements CommandHandler<SessionPlayerComman
|
|||||||
}
|
}
|
||||||
// We seemingly can't actually do this if signed args exist, if not, we can probs keep stuff happy
|
// 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) {
|
if (player.getProtocolVersion().compareTo(ProtocolVersion.MINECRAFT_1_19_3) >= 0) {
|
||||||
return CompletableFuture.completedFuture(new ChatAcknowledgement(packet.lastSeenMessages.getOffset()));
|
return CompletableFuture.completedFuture(new ChatAcknowledgementPacket(packet.lastSeenMessages.getOffset()));
|
||||||
}
|
}
|
||||||
return CompletableFuture.completedFuture(null);
|
return CompletableFuture.completedFuture(null);
|
||||||
}
|
}
|
||||||
@ -109,7 +109,7 @@ public class SessionCommandHandler implements CommandHandler<SessionPlayerComman
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (player.getProtocolVersion().compareTo(ProtocolVersion.MINECRAFT_1_19_3) >= 0) {
|
if (player.getProtocolVersion().compareTo(ProtocolVersion.MINECRAFT_1_19_3) >= 0) {
|
||||||
return new ChatAcknowledgement(packet.lastSeenMessages.getOffset());
|
return new ChatAcknowledgementPacket(packet.lastSeenMessages.getOffset());
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
});
|
});
|
||||||
|
@ -25,7 +25,7 @@ import com.velocitypowered.proxy.protocol.packet.chat.LastSeenMessages;
|
|||||||
import io.netty.buffer.ByteBuf;
|
import io.netty.buffer.ByteBuf;
|
||||||
import java.time.Instant;
|
import java.time.Instant;
|
||||||
|
|
||||||
public class SessionPlayerChat implements MinecraftPacket {
|
public class SessionPlayerChatPacket implements MinecraftPacket {
|
||||||
|
|
||||||
protected String message;
|
protected String message;
|
||||||
protected Instant timestamp;
|
protected Instant timestamp;
|
||||||
@ -34,7 +34,7 @@ public class SessionPlayerChat implements MinecraftPacket {
|
|||||||
protected byte[] signature;
|
protected byte[] signature;
|
||||||
protected LastSeenMessages lastSeenMessages;
|
protected LastSeenMessages lastSeenMessages;
|
||||||
|
|
||||||
public SessionPlayerChat() {
|
public SessionPlayerChatPacket() {
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getMessage() {
|
public String getMessage() {
|
@ -28,7 +28,7 @@ import io.netty.buffer.ByteBuf;
|
|||||||
import java.time.Instant;
|
import java.time.Instant;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class SessionPlayerCommand implements MinecraftPacket {
|
public class SessionPlayerCommandPacket implements MinecraftPacket {
|
||||||
|
|
||||||
protected String command;
|
protected String command;
|
||||||
protected Instant timeStamp;
|
protected Instant timeStamp;
|
||||||
@ -131,7 +131,7 @@ public class SessionPlayerCommand implements MinecraftPacket {
|
|||||||
|
|
||||||
public ArgumentSignature(ByteBuf buf) {
|
public ArgumentSignature(ByteBuf buf) {
|
||||||
name = ProtocolUtils.readString(buf, 16);
|
name = ProtocolUtils.readString(buf, 16);
|
||||||
signature = SessionPlayerChat.readMessageSignature(buf);
|
signature = SessionPlayerChatPacket.readMessageSignature(buf);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void encode(ByteBuf buf) {
|
public void encode(ByteBuf buf) {
|
@ -24,15 +24,15 @@ import com.velocitypowered.proxy.protocol.ProtocolUtils;
|
|||||||
import io.netty.buffer.ByteBuf;
|
import io.netty.buffer.ByteBuf;
|
||||||
import net.kyori.adventure.key.Key;
|
import net.kyori.adventure.key.Key;
|
||||||
|
|
||||||
public class ActiveFeatures implements MinecraftPacket {
|
public class ActiveFeaturesPacket implements MinecraftPacket {
|
||||||
|
|
||||||
private Key[] activeFeatures;
|
private Key[] activeFeatures;
|
||||||
|
|
||||||
public ActiveFeatures(Key[] activeFeatures) {
|
public ActiveFeaturesPacket(Key[] activeFeatures) {
|
||||||
this.activeFeatures = activeFeatures;
|
this.activeFeatures = activeFeatures;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ActiveFeatures() {
|
public ActiveFeaturesPacket() {
|
||||||
this.activeFeatures = new Key[0];
|
this.activeFeatures = new Key[0];
|
||||||
}
|
}
|
||||||
|
|
@ -23,7 +23,7 @@ import com.velocitypowered.proxy.protocol.MinecraftPacket;
|
|||||||
import com.velocitypowered.proxy.protocol.ProtocolUtils;
|
import com.velocitypowered.proxy.protocol.ProtocolUtils;
|
||||||
import io.netty.buffer.ByteBuf;
|
import io.netty.buffer.ByteBuf;
|
||||||
|
|
||||||
public class FinishedUpdate implements MinecraftPacket {
|
public class FinishedUpdatePacket implements MinecraftPacket {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void decode(ByteBuf buf, ProtocolUtils.Direction direction,
|
public void decode(ByteBuf buf, ProtocolUtils.Direction direction,
|
@ -24,9 +24,9 @@ import com.velocitypowered.proxy.protocol.ProtocolUtils;
|
|||||||
import com.velocitypowered.proxy.protocol.util.DeferredByteBufHolder;
|
import com.velocitypowered.proxy.protocol.util.DeferredByteBufHolder;
|
||||||
import io.netty.buffer.ByteBuf;
|
import io.netty.buffer.ByteBuf;
|
||||||
|
|
||||||
public class RegistrySync extends DeferredByteBufHolder implements MinecraftPacket {
|
public class RegistrySyncPacket extends DeferredByteBufHolder implements MinecraftPacket {
|
||||||
|
|
||||||
public RegistrySync() {
|
public RegistrySyncPacket() {
|
||||||
super(null);
|
super(null);
|
||||||
}
|
}
|
||||||
|
|
@ -23,7 +23,7 @@ import com.velocitypowered.proxy.protocol.MinecraftPacket;
|
|||||||
import com.velocitypowered.proxy.protocol.ProtocolUtils;
|
import com.velocitypowered.proxy.protocol.ProtocolUtils;
|
||||||
import io.netty.buffer.ByteBuf;
|
import io.netty.buffer.ByteBuf;
|
||||||
|
|
||||||
public class StartUpdate implements MinecraftPacket {
|
public class StartUpdatePacket implements MinecraftPacket {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void decode(ByteBuf buf, ProtocolUtils.Direction direction,
|
public void decode(ByteBuf buf, ProtocolUtils.Direction direction,
|
@ -26,15 +26,15 @@ import io.netty.buffer.ByteBuf;
|
|||||||
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
public class TagsUpdate implements MinecraftPacket {
|
public class TagsUpdatePacket implements MinecraftPacket {
|
||||||
|
|
||||||
private Map<String, Map<String, int[]>> tags;
|
private Map<String, Map<String, int[]>> tags;
|
||||||
|
|
||||||
public TagsUpdate(Map<String, Map<String, int[]>> tags) {
|
public TagsUpdatePacket(Map<String, Map<String, int[]>> tags) {
|
||||||
this.tags = tags;
|
this.tags = tags;
|
||||||
}
|
}
|
||||||
|
|
||||||
public TagsUpdate() {
|
public TagsUpdatePacket() {
|
||||||
this.tags = Map.of();
|
this.tags = Map.of();
|
||||||
}
|
}
|
||||||
|
|
@ -24,7 +24,7 @@ import com.google.common.collect.ImmutableList;
|
|||||||
import com.velocitypowered.api.network.ProtocolVersion;
|
import com.velocitypowered.api.network.ProtocolVersion;
|
||||||
import com.velocitypowered.api.util.ProxyVersion;
|
import com.velocitypowered.api.util.ProxyVersion;
|
||||||
import com.velocitypowered.proxy.protocol.ProtocolUtils;
|
import com.velocitypowered.proxy.protocol.ProtocolUtils;
|
||||||
import com.velocitypowered.proxy.protocol.packet.PluginMessage;
|
import com.velocitypowered.proxy.protocol.packet.PluginMessagePacket;
|
||||||
import io.netty.buffer.ByteBuf;
|
import io.netty.buffer.ByteBuf;
|
||||||
import io.netty.buffer.Unpooled;
|
import io.netty.buffer.Unpooled;
|
||||||
import java.nio.charset.StandardCharsets;
|
import java.nio.charset.StandardCharsets;
|
||||||
@ -55,7 +55,7 @@ public final class PluginMessageUtil {
|
|||||||
* @param message the plugin message
|
* @param message the plugin message
|
||||||
* @return whether or not this is a brand plugin message
|
* @return whether or not this is a brand plugin message
|
||||||
*/
|
*/
|
||||||
public static boolean isMcBrand(PluginMessage message) {
|
public static boolean isMcBrand(PluginMessagePacket message) {
|
||||||
checkNotNull(message, "message");
|
checkNotNull(message, "message");
|
||||||
return message.getChannel().equals(BRAND_CHANNEL_LEGACY) || message.getChannel()
|
return message.getChannel().equals(BRAND_CHANNEL_LEGACY) || message.getChannel()
|
||||||
.equals(BRAND_CHANNEL);
|
.equals(BRAND_CHANNEL);
|
||||||
@ -67,7 +67,7 @@ public final class PluginMessageUtil {
|
|||||||
* @param message the plugin message
|
* @param message the plugin message
|
||||||
* @return whether we are registering plugin channels or not
|
* @return whether we are registering plugin channels or not
|
||||||
*/
|
*/
|
||||||
public static boolean isRegister(PluginMessage message) {
|
public static boolean isRegister(PluginMessagePacket message) {
|
||||||
checkNotNull(message, "message");
|
checkNotNull(message, "message");
|
||||||
return message.getChannel().equals(REGISTER_CHANNEL_LEGACY) || message.getChannel()
|
return message.getChannel().equals(REGISTER_CHANNEL_LEGACY) || message.getChannel()
|
||||||
.equals(REGISTER_CHANNEL);
|
.equals(REGISTER_CHANNEL);
|
||||||
@ -79,7 +79,7 @@ public final class PluginMessageUtil {
|
|||||||
* @param message the plugin message
|
* @param message the plugin message
|
||||||
* @return whether we are unregistering plugin channels or not
|
* @return whether we are unregistering plugin channels or not
|
||||||
*/
|
*/
|
||||||
public static boolean isUnregister(PluginMessage message) {
|
public static boolean isUnregister(PluginMessagePacket message) {
|
||||||
checkNotNull(message, "message");
|
checkNotNull(message, "message");
|
||||||
return message.getChannel().equals(UNREGISTER_CHANNEL_LEGACY) || message.getChannel()
|
return message.getChannel().equals(UNREGISTER_CHANNEL_LEGACY) || message.getChannel()
|
||||||
.equals(UNREGISTER_CHANNEL);
|
.equals(UNREGISTER_CHANNEL);
|
||||||
@ -91,7 +91,7 @@ public final class PluginMessageUtil {
|
|||||||
* @param message the message to get the channels from
|
* @param message the message to get the channels from
|
||||||
* @return the channels, as an immutable list
|
* @return the channels, as an immutable list
|
||||||
*/
|
*/
|
||||||
public static List<String> getChannels(PluginMessage message) {
|
public static List<String> getChannels(PluginMessagePacket message) {
|
||||||
checkNotNull(message, "message");
|
checkNotNull(message, "message");
|
||||||
checkArgument(isRegister(message) || isUnregister(message), "Unknown channel type %s",
|
checkArgument(isRegister(message) || isUnregister(message), "Unknown channel type %s",
|
||||||
message.getChannel());
|
message.getChannel());
|
||||||
@ -111,15 +111,15 @@ public final class PluginMessageUtil {
|
|||||||
* @param channels the channels to register
|
* @param channels the channels to register
|
||||||
* @return the plugin message to send
|
* @return the plugin message to send
|
||||||
*/
|
*/
|
||||||
public static PluginMessage constructChannelsPacket(ProtocolVersion protocolVersion,
|
public static PluginMessagePacket constructChannelsPacket(ProtocolVersion protocolVersion,
|
||||||
Collection<String> channels) {
|
Collection<String> channels) {
|
||||||
checkNotNull(channels, "channels");
|
checkNotNull(channels, "channels");
|
||||||
checkArgument(!channels.isEmpty(), "no channels specified");
|
checkArgument(!channels.isEmpty(), "no channels specified");
|
||||||
String channelName = protocolVersion.compareTo(ProtocolVersion.MINECRAFT_1_13) >= 0
|
String channelName = protocolVersion.compareTo(ProtocolVersion.MINECRAFT_1_13) >= 0
|
||||||
? REGISTER_CHANNEL : REGISTER_CHANNEL_LEGACY;
|
? REGISTER_CHANNEL : REGISTER_CHANNEL_LEGACY;
|
||||||
ByteBuf contents = Unpooled.buffer();
|
ByteBuf contents = Unpooled.buffer();
|
||||||
contents.writeCharSequence(String.join("\0", channels), StandardCharsets.UTF_8);
|
contents.writeCharSequence(String.join("\0", channels), StandardCharsets.UTF_8);
|
||||||
return new PluginMessage(channelName, contents);
|
return new PluginMessagePacket(channelName, contents);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -129,8 +129,9 @@ public final class PluginMessageUtil {
|
|||||||
* @param version the proxy version
|
* @param version the proxy version
|
||||||
* @return the rewritten plugin message
|
* @return the rewritten plugin message
|
||||||
*/
|
*/
|
||||||
public static PluginMessage rewriteMinecraftBrand(PluginMessage message, ProxyVersion version,
|
public static PluginMessagePacket rewriteMinecraftBrand(PluginMessagePacket message,
|
||||||
ProtocolVersion protocolVersion) {
|
ProxyVersion version,
|
||||||
|
ProtocolVersion protocolVersion) {
|
||||||
checkNotNull(message, "message");
|
checkNotNull(message, "message");
|
||||||
checkNotNull(version, "version");
|
checkNotNull(version, "version");
|
||||||
checkArgument(isMcBrand(message), "message is not a brand plugin message");
|
checkArgument(isMcBrand(message), "message is not a brand plugin message");
|
||||||
@ -145,7 +146,7 @@ public final class PluginMessageUtil {
|
|||||||
rewrittenBuf.writeCharSequence(rewrittenBrand, StandardCharsets.UTF_8);
|
rewrittenBuf.writeCharSequence(rewrittenBrand, StandardCharsets.UTF_8);
|
||||||
}
|
}
|
||||||
|
|
||||||
return new PluginMessage(message.getChannel(), rewrittenBuf);
|
return new PluginMessagePacket(message.getChannel(), rewrittenBuf);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -24,9 +24,9 @@ import com.velocitypowered.proxy.VelocityServer;
|
|||||||
import com.velocitypowered.proxy.connection.MinecraftConnection;
|
import com.velocitypowered.proxy.connection.MinecraftConnection;
|
||||||
import com.velocitypowered.proxy.connection.MinecraftSessionHandler;
|
import com.velocitypowered.proxy.connection.MinecraftSessionHandler;
|
||||||
import com.velocitypowered.proxy.protocol.StateRegistry;
|
import com.velocitypowered.proxy.protocol.StateRegistry;
|
||||||
import com.velocitypowered.proxy.protocol.packet.Handshake;
|
import com.velocitypowered.proxy.protocol.packet.HandshakePacket;
|
||||||
import com.velocitypowered.proxy.protocol.packet.StatusRequest;
|
import com.velocitypowered.proxy.protocol.packet.StatusRequestPacket;
|
||||||
import com.velocitypowered.proxy.protocol.packet.StatusResponse;
|
import com.velocitypowered.proxy.protocol.packet.StatusResponsePacket;
|
||||||
import io.netty.channel.EventLoop;
|
import io.netty.channel.EventLoop;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.concurrent.CompletableFuture;
|
import java.util.concurrent.CompletableFuture;
|
||||||
@ -53,7 +53,7 @@ public class PingSessionHandler implements MinecraftSessionHandler {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void activated() {
|
public void activated() {
|
||||||
Handshake handshake = new Handshake();
|
HandshakePacket handshake = new HandshakePacket();
|
||||||
handshake.setNextStatus(StateRegistry.STATUS_ID);
|
handshake.setNextStatus(StateRegistry.STATUS_ID);
|
||||||
handshake.setServerAddress(server.getServerInfo().getAddress().getHostString());
|
handshake.setServerAddress(server.getServerInfo().getAddress().getHostString());
|
||||||
handshake.setPort(server.getServerInfo().getAddress().getPort());
|
handshake.setPort(server.getServerInfo().getAddress().getPort());
|
||||||
@ -62,13 +62,13 @@ public class PingSessionHandler implements MinecraftSessionHandler {
|
|||||||
|
|
||||||
connection.setActiveSessionHandler(StateRegistry.STATUS);
|
connection.setActiveSessionHandler(StateRegistry.STATUS);
|
||||||
connection.setState(StateRegistry.STATUS);
|
connection.setState(StateRegistry.STATUS);
|
||||||
connection.delayedWrite(StatusRequest.INSTANCE);
|
connection.delayedWrite(StatusRequestPacket.INSTANCE);
|
||||||
|
|
||||||
connection.flush();
|
connection.flush();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean handle(StatusResponse packet) {
|
public boolean handle(StatusResponsePacket packet) {
|
||||||
// All good!
|
// All good!
|
||||||
completed = true;
|
completed = true;
|
||||||
connection.close(true);
|
connection.close(true);
|
||||||
|
@ -19,9 +19,9 @@ package com.velocitypowered.proxy.tablist;
|
|||||||
|
|
||||||
import com.velocitypowered.api.proxy.Player;
|
import com.velocitypowered.api.proxy.Player;
|
||||||
import com.velocitypowered.api.proxy.player.TabList;
|
import com.velocitypowered.api.proxy.player.TabList;
|
||||||
import com.velocitypowered.proxy.protocol.packet.LegacyPlayerListItem;
|
import com.velocitypowered.proxy.protocol.packet.LegacyPlayerListItemPacket;
|
||||||
import com.velocitypowered.proxy.protocol.packet.RemovePlayerInfo;
|
import com.velocitypowered.proxy.protocol.packet.RemovePlayerInfoPacket;
|
||||||
import com.velocitypowered.proxy.protocol.packet.UpsertPlayerInfo;
|
import com.velocitypowered.proxy.protocol.packet.UpsertPlayerInfoPacket;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tab list interface with methods for handling player info packets.
|
* Tab list interface with methods for handling player info packets.
|
||||||
@ -30,13 +30,13 @@ public interface InternalTabList extends TabList {
|
|||||||
|
|
||||||
Player getPlayer();
|
Player getPlayer();
|
||||||
|
|
||||||
default void processLegacy(LegacyPlayerListItem packet) {
|
default void processLegacy(LegacyPlayerListItemPacket packet) {
|
||||||
}
|
}
|
||||||
|
|
||||||
default void processUpdate(UpsertPlayerInfo infoPacket) {
|
default void processUpdate(UpsertPlayerInfoPacket infoPacket) {
|
||||||
}
|
}
|
||||||
|
|
||||||
default void processRemove(RemovePlayerInfo infoPacket) {
|
default void processRemove(RemovePlayerInfoPacket infoPacket) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void clearAllSilent();
|
void clearAllSilent();
|
||||||
|
@ -26,7 +26,7 @@ import com.velocitypowered.api.proxy.player.TabListEntry;
|
|||||||
import com.velocitypowered.api.util.GameProfile;
|
import com.velocitypowered.api.util.GameProfile;
|
||||||
import com.velocitypowered.proxy.connection.MinecraftConnection;
|
import com.velocitypowered.proxy.connection.MinecraftConnection;
|
||||||
import com.velocitypowered.proxy.connection.client.ConnectedPlayer;
|
import com.velocitypowered.proxy.connection.client.ConnectedPlayer;
|
||||||
import com.velocitypowered.proxy.protocol.packet.LegacyPlayerListItem;
|
import com.velocitypowered.proxy.protocol.packet.LegacyPlayerListItemPacket;
|
||||||
import com.velocitypowered.proxy.protocol.packet.chat.RemoteChatSession;
|
import com.velocitypowered.proxy.protocol.packet.chat.RemoteChatSession;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
@ -87,9 +87,9 @@ public class KeyedVelocityTabList implements InternalTabList {
|
|||||||
Preconditions.checkArgument(entry instanceof KeyedVelocityTabListEntry,
|
Preconditions.checkArgument(entry instanceof KeyedVelocityTabListEntry,
|
||||||
"Not a Velocity tab list entry");
|
"Not a Velocity tab list entry");
|
||||||
|
|
||||||
LegacyPlayerListItem.Item packetItem = LegacyPlayerListItem.Item.from(entry);
|
LegacyPlayerListItemPacket.Item packetItem = LegacyPlayerListItemPacket.Item.from(entry);
|
||||||
connection.write(
|
connection.write(
|
||||||
new LegacyPlayerListItem(LegacyPlayerListItem.ADD_PLAYER,
|
new LegacyPlayerListItemPacket(LegacyPlayerListItemPacket.ADD_PLAYER,
|
||||||
Collections.singletonList(packetItem)));
|
Collections.singletonList(packetItem)));
|
||||||
entries.put(entry.getProfile().getId(), (KeyedVelocityTabListEntry) entry);
|
entries.put(entry.getProfile().getId(), (KeyedVelocityTabListEntry) entry);
|
||||||
}
|
}
|
||||||
@ -100,9 +100,9 @@ public class KeyedVelocityTabList implements InternalTabList {
|
|||||||
|
|
||||||
TabListEntry entry = entries.remove(uuid);
|
TabListEntry entry = entries.remove(uuid);
|
||||||
if (entry != null) {
|
if (entry != null) {
|
||||||
LegacyPlayerListItem.Item packetItem = LegacyPlayerListItem.Item.from(entry);
|
LegacyPlayerListItemPacket.Item packetItem = LegacyPlayerListItemPacket.Item.from(entry);
|
||||||
connection.write(
|
connection.write(
|
||||||
new LegacyPlayerListItem(LegacyPlayerListItem.REMOVE_PLAYER,
|
new LegacyPlayerListItemPacket(LegacyPlayerListItemPacket.REMOVE_PLAYER,
|
||||||
Collections.singletonList(packetItem)));
|
Collections.singletonList(packetItem)));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -131,12 +131,13 @@ public class KeyedVelocityTabList implements InternalTabList {
|
|||||||
if (listEntries.isEmpty()) {
|
if (listEntries.isEmpty()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
List<LegacyPlayerListItem.Item> items = new ArrayList<>(listEntries.size());
|
List<LegacyPlayerListItemPacket.Item> items = new ArrayList<>(listEntries.size());
|
||||||
for (TabListEntry value : listEntries) {
|
for (TabListEntry value : listEntries) {
|
||||||
items.add(LegacyPlayerListItem.Item.from(value));
|
items.add(LegacyPlayerListItemPacket.Item.from(value));
|
||||||
}
|
}
|
||||||
clearAllSilent();
|
clearAllSilent();
|
||||||
connection.delayedWrite(new LegacyPlayerListItem(LegacyPlayerListItem.REMOVE_PLAYER, items));
|
connection.delayedWrite(new LegacyPlayerListItemPacket(
|
||||||
|
LegacyPlayerListItemPacket.REMOVE_PLAYER, items));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -165,19 +166,20 @@ public class KeyedVelocityTabList implements InternalTabList {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void processLegacy(LegacyPlayerListItem packet) {
|
public void processLegacy(LegacyPlayerListItemPacket packet) {
|
||||||
// Packets are already forwarded on, so no need to do that here
|
// Packets are already forwarded on, so no need to do that here
|
||||||
for (LegacyPlayerListItem.Item item : packet.getItems()) {
|
for (LegacyPlayerListItemPacket.Item item : packet.getItems()) {
|
||||||
UUID uuid = item.getUuid();
|
UUID uuid = item.getUuid();
|
||||||
assert uuid != null : "1.7 tab list entry given to modern tab list handler!";
|
assert uuid != null : "1.7 tab list entry given to modern tab list handler!";
|
||||||
|
|
||||||
if (packet.getAction() != LegacyPlayerListItem.ADD_PLAYER && !entries.containsKey(uuid)) {
|
if (packet.getAction() != LegacyPlayerListItemPacket.ADD_PLAYER
|
||||||
|
&& !entries.containsKey(uuid)) {
|
||||||
// Sometimes UPDATE_GAMEMODE is sent before ADD_PLAYER so don't want to warn here
|
// Sometimes UPDATE_GAMEMODE is sent before ADD_PLAYER so don't want to warn here
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (packet.getAction()) {
|
switch (packet.getAction()) {
|
||||||
case LegacyPlayerListItem.ADD_PLAYER: {
|
case LegacyPlayerListItemPacket.ADD_PLAYER: {
|
||||||
// ensure that name and properties are available
|
// ensure that name and properties are available
|
||||||
String name = item.getName();
|
String name = item.getName();
|
||||||
List<GameProfile.Property> properties = item.getProperties();
|
List<GameProfile.Property> properties = item.getProperties();
|
||||||
@ -195,24 +197,24 @@ public class KeyedVelocityTabList implements InternalTabList {
|
|||||||
.build());
|
.build());
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case LegacyPlayerListItem.REMOVE_PLAYER:
|
case LegacyPlayerListItemPacket.REMOVE_PLAYER:
|
||||||
entries.remove(uuid);
|
entries.remove(uuid);
|
||||||
break;
|
break;
|
||||||
case LegacyPlayerListItem.UPDATE_DISPLAY_NAME: {
|
case LegacyPlayerListItemPacket.UPDATE_DISPLAY_NAME: {
|
||||||
KeyedVelocityTabListEntry entry = entries.get(uuid);
|
KeyedVelocityTabListEntry entry = entries.get(uuid);
|
||||||
if (entry != null) {
|
if (entry != null) {
|
||||||
entry.setDisplayNameInternal(item.getDisplayName());
|
entry.setDisplayNameInternal(item.getDisplayName());
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case LegacyPlayerListItem.UPDATE_LATENCY: {
|
case LegacyPlayerListItemPacket.UPDATE_LATENCY: {
|
||||||
KeyedVelocityTabListEntry entry = entries.get(uuid);
|
KeyedVelocityTabListEntry entry = entries.get(uuid);
|
||||||
if (entry != null) {
|
if (entry != null) {
|
||||||
entry.setLatencyInternal(item.getLatency());
|
entry.setLatencyInternal(item.getLatency());
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case LegacyPlayerListItem.UPDATE_GAMEMODE: {
|
case LegacyPlayerListItemPacket.UPDATE_GAMEMODE: {
|
||||||
KeyedVelocityTabListEntry entry = entries.get(uuid);
|
KeyedVelocityTabListEntry entry = entries.get(uuid);
|
||||||
if (entry != null) {
|
if (entry != null) {
|
||||||
entry.setGameModeInternal(item.getGameMode());
|
entry.setGameModeInternal(item.getGameMode());
|
||||||
@ -228,7 +230,7 @@ public class KeyedVelocityTabList implements InternalTabList {
|
|||||||
|
|
||||||
void updateEntry(int action, TabListEntry entry) {
|
void updateEntry(int action, TabListEntry entry) {
|
||||||
if (entries.containsKey(entry.getProfile().getId())) {
|
if (entries.containsKey(entry.getProfile().getId())) {
|
||||||
LegacyPlayerListItem.Item packetItem = LegacyPlayerListItem.Item.from(entry);
|
LegacyPlayerListItemPacket.Item packetItem = LegacyPlayerListItemPacket.Item.from(entry);
|
||||||
|
|
||||||
IdentifiedKey selectedKey = packetItem.getPlayerKey();
|
IdentifiedKey selectedKey = packetItem.getPlayerKey();
|
||||||
Optional<Player> existing = proxyServer.getPlayer(entry.getProfile().getId());
|
Optional<Player> existing = proxyServer.getPlayer(entry.getProfile().getId());
|
||||||
@ -245,7 +247,7 @@ public class KeyedVelocityTabList implements InternalTabList {
|
|||||||
packetItem.setPlayerKey(null);
|
packetItem.setPlayerKey(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
connection.write(new LegacyPlayerListItem(action, Collections.singletonList(packetItem)));
|
connection.write(new LegacyPlayerListItemPacket(action, List.of(packetItem)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -22,7 +22,7 @@ import com.velocitypowered.api.proxy.player.ChatSession;
|
|||||||
import com.velocitypowered.api.proxy.player.TabList;
|
import com.velocitypowered.api.proxy.player.TabList;
|
||||||
import com.velocitypowered.api.proxy.player.TabListEntry;
|
import com.velocitypowered.api.proxy.player.TabListEntry;
|
||||||
import com.velocitypowered.api.util.GameProfile;
|
import com.velocitypowered.api.util.GameProfile;
|
||||||
import com.velocitypowered.proxy.protocol.packet.LegacyPlayerListItem;
|
import com.velocitypowered.proxy.protocol.packet.LegacyPlayerListItemPacket;
|
||||||
import com.velocitypowered.proxy.protocol.packet.chat.RemoteChatSession;
|
import com.velocitypowered.proxy.protocol.packet.chat.RemoteChatSession;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||||
@ -68,7 +68,7 @@ public class KeyedVelocityTabListEntry implements TabListEntry {
|
|||||||
@Override
|
@Override
|
||||||
public TabListEntry setDisplayName(net.kyori.adventure.text.@Nullable Component displayName) {
|
public TabListEntry setDisplayName(net.kyori.adventure.text.@Nullable Component displayName) {
|
||||||
this.displayName = displayName;
|
this.displayName = displayName;
|
||||||
tabList.updateEntry(LegacyPlayerListItem.UPDATE_DISPLAY_NAME, this);
|
tabList.updateEntry(LegacyPlayerListItemPacket.UPDATE_DISPLAY_NAME, this);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -84,7 +84,7 @@ public class KeyedVelocityTabListEntry implements TabListEntry {
|
|||||||
@Override
|
@Override
|
||||||
public TabListEntry setLatency(int latency) {
|
public TabListEntry setLatency(int latency) {
|
||||||
this.latency = latency;
|
this.latency = latency;
|
||||||
tabList.updateEntry(LegacyPlayerListItem.UPDATE_LATENCY, this);
|
tabList.updateEntry(LegacyPlayerListItemPacket.UPDATE_LATENCY, this);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -100,7 +100,7 @@ public class KeyedVelocityTabListEntry implements TabListEntry {
|
|||||||
@Override
|
@Override
|
||||||
public TabListEntry setGameMode(int gameMode) {
|
public TabListEntry setGameMode(int gameMode) {
|
||||||
this.gameMode = gameMode;
|
this.gameMode = gameMode;
|
||||||
tabList.updateEntry(LegacyPlayerListItem.UPDATE_GAMEMODE, this);
|
tabList.updateEntry(LegacyPlayerListItemPacket.UPDATE_GAMEMODE, this);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -26,13 +26,12 @@ import com.velocitypowered.api.util.GameProfile;
|
|||||||
import com.velocitypowered.proxy.connection.MinecraftConnection;
|
import com.velocitypowered.proxy.connection.MinecraftConnection;
|
||||||
import com.velocitypowered.proxy.connection.client.ConnectedPlayer;
|
import com.velocitypowered.proxy.connection.client.ConnectedPlayer;
|
||||||
import com.velocitypowered.proxy.console.VelocityConsole;
|
import com.velocitypowered.proxy.console.VelocityConsole;
|
||||||
import com.velocitypowered.proxy.protocol.packet.RemovePlayerInfo;
|
import com.velocitypowered.proxy.protocol.packet.RemovePlayerInfoPacket;
|
||||||
import com.velocitypowered.proxy.protocol.packet.UpsertPlayerInfo;
|
import com.velocitypowered.proxy.protocol.packet.UpsertPlayerInfoPacket;
|
||||||
import com.velocitypowered.proxy.protocol.packet.chat.ComponentHolder;
|
import com.velocitypowered.proxy.protocol.packet.chat.ComponentHolder;
|
||||||
import com.velocitypowered.proxy.protocol.packet.chat.RemoteChatSession;
|
import com.velocitypowered.proxy.protocol.packet.chat.RemoteChatSession;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.EnumSet;
|
import java.util.EnumSet;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
@ -94,8 +93,10 @@ public class VelocityTabList implements InternalTabList {
|
|||||||
entry1.getLatency(), entry1.getGameMode(), entry1.getChatSession(), entry1.isListed());
|
entry1.getLatency(), entry1.getGameMode(), entry1.getChatSession(), entry1.isListed());
|
||||||
}
|
}
|
||||||
|
|
||||||
EnumSet<UpsertPlayerInfo.Action> actions = EnumSet.noneOf(UpsertPlayerInfo.Action.class);
|
EnumSet<UpsertPlayerInfoPacket.Action> actions = EnumSet
|
||||||
UpsertPlayerInfo.Entry playerInfoEntry = new UpsertPlayerInfo.Entry(entry.getProfile().getId());
|
.noneOf(UpsertPlayerInfoPacket.Action.class);
|
||||||
|
UpsertPlayerInfoPacket.Entry playerInfoEntry = new UpsertPlayerInfoPacket
|
||||||
|
.Entry(entry.getProfile().getId());
|
||||||
|
|
||||||
Preconditions.checkNotNull(entry.getProfile(), "Profile cannot be null");
|
Preconditions.checkNotNull(entry.getProfile(), "Profile cannot be null");
|
||||||
Preconditions.checkNotNull(entry.getProfile().getId(), "Profile ID cannot be null");
|
Preconditions.checkNotNull(entry.getProfile().getId(), "Profile ID cannot be null");
|
||||||
@ -109,7 +110,7 @@ public class VelocityTabList implements InternalTabList {
|
|||||||
}
|
}
|
||||||
if (!Objects.equals(previousEntry.getDisplayNameComponent().orElse(null),
|
if (!Objects.equals(previousEntry.getDisplayNameComponent().orElse(null),
|
||||||
entry.getDisplayNameComponent().orElse(null))) {
|
entry.getDisplayNameComponent().orElse(null))) {
|
||||||
actions.add(UpsertPlayerInfo.Action.UPDATE_DISPLAY_NAME);
|
actions.add(UpsertPlayerInfoPacket.Action.UPDATE_DISPLAY_NAME);
|
||||||
playerInfoEntry.setDisplayName(entry.getDisplayNameComponent().isEmpty()
|
playerInfoEntry.setDisplayName(entry.getDisplayNameComponent().isEmpty()
|
||||||
?
|
?
|
||||||
null :
|
null :
|
||||||
@ -118,32 +119,32 @@ public class VelocityTabList implements InternalTabList {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
if (!Objects.equals(previousEntry.getLatency(), entry.getLatency())) {
|
if (!Objects.equals(previousEntry.getLatency(), entry.getLatency())) {
|
||||||
actions.add(UpsertPlayerInfo.Action.UPDATE_LATENCY);
|
actions.add(UpsertPlayerInfoPacket.Action.UPDATE_LATENCY);
|
||||||
playerInfoEntry.setLatency(entry.getLatency());
|
playerInfoEntry.setLatency(entry.getLatency());
|
||||||
}
|
}
|
||||||
if (!Objects.equals(previousEntry.getGameMode(), entry.getGameMode())) {
|
if (!Objects.equals(previousEntry.getGameMode(), entry.getGameMode())) {
|
||||||
actions.add(UpsertPlayerInfo.Action.UPDATE_GAME_MODE);
|
actions.add(UpsertPlayerInfoPacket.Action.UPDATE_GAME_MODE);
|
||||||
playerInfoEntry.setGameMode(entry.getGameMode());
|
playerInfoEntry.setGameMode(entry.getGameMode());
|
||||||
}
|
}
|
||||||
if (!Objects.equals(previousEntry.isListed(), entry.isListed())) {
|
if (!Objects.equals(previousEntry.isListed(), entry.isListed())) {
|
||||||
actions.add(UpsertPlayerInfo.Action.UPDATE_LISTED);
|
actions.add(UpsertPlayerInfoPacket.Action.UPDATE_LISTED);
|
||||||
playerInfoEntry.setListed(entry.isListed());
|
playerInfoEntry.setListed(entry.isListed());
|
||||||
}
|
}
|
||||||
if (!Objects.equals(previousEntry.getChatSession(), entry.getChatSession())) {
|
if (!Objects.equals(previousEntry.getChatSession(), entry.getChatSession())) {
|
||||||
ChatSession from = entry.getChatSession();
|
ChatSession from = entry.getChatSession();
|
||||||
if (from != null) {
|
if (from != null) {
|
||||||
actions.add(UpsertPlayerInfo.Action.INITIALIZE_CHAT);
|
actions.add(UpsertPlayerInfoPacket.Action.INITIALIZE_CHAT);
|
||||||
playerInfoEntry.setChatSession(
|
playerInfoEntry.setChatSession(
|
||||||
new RemoteChatSession(from.getSessionId(), from.getIdentifiedKey()));
|
new RemoteChatSession(from.getSessionId(), from.getIdentifiedKey()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
actions.addAll(EnumSet.of(UpsertPlayerInfo.Action.ADD_PLAYER,
|
actions.addAll(EnumSet.of(UpsertPlayerInfoPacket.Action.ADD_PLAYER,
|
||||||
UpsertPlayerInfo.Action.UPDATE_LATENCY,
|
UpsertPlayerInfoPacket.Action.UPDATE_LATENCY,
|
||||||
UpsertPlayerInfo.Action.UPDATE_LISTED));
|
UpsertPlayerInfoPacket.Action.UPDATE_LISTED));
|
||||||
playerInfoEntry.setProfile(entry.getProfile());
|
playerInfoEntry.setProfile(entry.getProfile());
|
||||||
if (entry.getDisplayNameComponent().isPresent()) {
|
if (entry.getDisplayNameComponent().isPresent()) {
|
||||||
actions.add(UpsertPlayerInfo.Action.UPDATE_DISPLAY_NAME);
|
actions.add(UpsertPlayerInfoPacket.Action.UPDATE_DISPLAY_NAME);
|
||||||
playerInfoEntry.setDisplayName(entry.getDisplayNameComponent().isEmpty()
|
playerInfoEntry.setDisplayName(entry.getDisplayNameComponent().isEmpty()
|
||||||
?
|
?
|
||||||
null :
|
null :
|
||||||
@ -152,24 +153,24 @@ public class VelocityTabList implements InternalTabList {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
if (entry.getChatSession() != null) {
|
if (entry.getChatSession() != null) {
|
||||||
actions.add(UpsertPlayerInfo.Action.INITIALIZE_CHAT);
|
actions.add(UpsertPlayerInfoPacket.Action.INITIALIZE_CHAT);
|
||||||
ChatSession from = entry.getChatSession();
|
ChatSession from = entry.getChatSession();
|
||||||
playerInfoEntry.setChatSession(
|
playerInfoEntry.setChatSession(
|
||||||
new RemoteChatSession(from.getSessionId(), from.getIdentifiedKey()));
|
new RemoteChatSession(from.getSessionId(), from.getIdentifiedKey()));
|
||||||
}
|
}
|
||||||
if (entry.getGameMode() != -1 && entry.getGameMode() != 256) {
|
if (entry.getGameMode() != -1 && entry.getGameMode() != 256) {
|
||||||
actions.add(UpsertPlayerInfo.Action.UPDATE_GAME_MODE);
|
actions.add(UpsertPlayerInfoPacket.Action.UPDATE_GAME_MODE);
|
||||||
playerInfoEntry.setGameMode(entry.getGameMode());
|
playerInfoEntry.setGameMode(entry.getGameMode());
|
||||||
}
|
}
|
||||||
playerInfoEntry.setLatency(entry.getLatency());
|
playerInfoEntry.setLatency(entry.getLatency());
|
||||||
playerInfoEntry.setListed(entry.isListed());
|
playerInfoEntry.setListed(entry.isListed());
|
||||||
}
|
}
|
||||||
this.connection.write(new UpsertPlayerInfo(actions, List.of(playerInfoEntry)));
|
this.connection.write(new UpsertPlayerInfoPacket(actions, List.of(playerInfoEntry)));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Optional<TabListEntry> removeEntry(UUID uuid) {
|
public Optional<TabListEntry> removeEntry(UUID uuid) {
|
||||||
this.connection.write(new RemovePlayerInfo(List.of(uuid)));
|
this.connection.write(new RemovePlayerInfoPacket(List.of(uuid)));
|
||||||
return Optional.ofNullable(this.entries.remove(uuid));
|
return Optional.ofNullable(this.entries.remove(uuid));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -190,7 +191,8 @@ public class VelocityTabList implements InternalTabList {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void clearAll() {
|
public void clearAll() {
|
||||||
this.connection.delayedWrite(new RemovePlayerInfo(new ArrayList<>(this.entries.keySet())));
|
this.connection.delayedWrite(new RemovePlayerInfoPacket(
|
||||||
|
new ArrayList<>(this.entries.keySet())));
|
||||||
clearAllSilent();
|
clearAllSilent();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -208,30 +210,30 @@ public class VelocityTabList implements InternalTabList {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void processUpdate(UpsertPlayerInfo infoPacket) {
|
public void processUpdate(UpsertPlayerInfoPacket infoPacket) {
|
||||||
for (UpsertPlayerInfo.Entry entry : infoPacket.getEntries()) {
|
for (UpsertPlayerInfoPacket.Entry entry : infoPacket.getEntries()) {
|
||||||
processUpsert(infoPacket.getActions(), entry);
|
processUpsert(infoPacket.getActions(), entry);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected UpsertPlayerInfo.Entry createRawEntry(VelocityTabListEntry entry) {
|
protected UpsertPlayerInfoPacket.Entry createRawEntry(VelocityTabListEntry entry) {
|
||||||
Preconditions.checkNotNull(entry, "entry");
|
Preconditions.checkNotNull(entry, "entry");
|
||||||
Preconditions.checkNotNull(entry.getProfile(), "Profile cannot be null");
|
Preconditions.checkNotNull(entry.getProfile(), "Profile cannot be null");
|
||||||
Preconditions.checkNotNull(entry.getProfile().getId(), "Profile ID cannot be null");
|
Preconditions.checkNotNull(entry.getProfile().getId(), "Profile ID cannot be null");
|
||||||
return new UpsertPlayerInfo.Entry(entry.getProfile().getId());
|
return new UpsertPlayerInfoPacket.Entry(entry.getProfile().getId());
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void emitActionRaw(UpsertPlayerInfo.Action action, UpsertPlayerInfo.Entry entry) {
|
protected void emitActionRaw(UpsertPlayerInfoPacket.Action action,
|
||||||
this.connection.write(
|
UpsertPlayerInfoPacket.Entry entry) {
|
||||||
new UpsertPlayerInfo(EnumSet.of(action), Collections.singletonList(entry)));
|
this.connection.write(new UpsertPlayerInfoPacket(EnumSet.of(action), List.of(entry)));
|
||||||
}
|
}
|
||||||
|
|
||||||
private void processUpsert(EnumSet<UpsertPlayerInfo.Action> actions,
|
private void processUpsert(EnumSet<UpsertPlayerInfoPacket.Action> actions,
|
||||||
UpsertPlayerInfo.Entry entry) {
|
UpsertPlayerInfoPacket.Entry entry) {
|
||||||
Preconditions.checkNotNull(entry.getProfileId(), "Profile ID cannot be null");
|
Preconditions.checkNotNull(entry.getProfileId(), "Profile ID cannot be null");
|
||||||
UUID profileId = entry.getProfileId();
|
UUID profileId = entry.getProfileId();
|
||||||
VelocityTabListEntry currentEntry = this.entries.get(profileId);
|
VelocityTabListEntry currentEntry = this.entries.get(profileId);
|
||||||
if (actions.contains(UpsertPlayerInfo.Action.ADD_PLAYER)) {
|
if (actions.contains(UpsertPlayerInfoPacket.Action.ADD_PLAYER)) {
|
||||||
if (currentEntry == null) {
|
if (currentEntry == null) {
|
||||||
this.entries.put(profileId,
|
this.entries.put(profileId,
|
||||||
currentEntry = new VelocityTabListEntry(
|
currentEntry = new VelocityTabListEntry(
|
||||||
@ -253,26 +255,26 @@ public class VelocityTabList implements InternalTabList {
|
|||||||
entry);
|
entry);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (actions.contains(UpsertPlayerInfo.Action.UPDATE_GAME_MODE)) {
|
if (actions.contains(UpsertPlayerInfoPacket.Action.UPDATE_GAME_MODE)) {
|
||||||
currentEntry.setGameModeWithoutUpdate(entry.getGameMode());
|
currentEntry.setGameModeWithoutUpdate(entry.getGameMode());
|
||||||
}
|
}
|
||||||
if (actions.contains(UpsertPlayerInfo.Action.UPDATE_LATENCY)) {
|
if (actions.contains(UpsertPlayerInfoPacket.Action.UPDATE_LATENCY)) {
|
||||||
currentEntry.setLatencyWithoutUpdate(entry.getLatency());
|
currentEntry.setLatencyWithoutUpdate(entry.getLatency());
|
||||||
}
|
}
|
||||||
if (actions.contains(UpsertPlayerInfo.Action.UPDATE_DISPLAY_NAME)) {
|
if (actions.contains(UpsertPlayerInfoPacket.Action.UPDATE_DISPLAY_NAME)) {
|
||||||
currentEntry.setDisplayNameWithoutUpdate(entry.getDisplayName() != null
|
currentEntry.setDisplayNameWithoutUpdate(entry.getDisplayName() != null
|
||||||
? entry.getDisplayName().getComponent() : null);
|
? entry.getDisplayName().getComponent() : null);
|
||||||
}
|
}
|
||||||
if (actions.contains(UpsertPlayerInfo.Action.INITIALIZE_CHAT)) {
|
if (actions.contains(UpsertPlayerInfoPacket.Action.INITIALIZE_CHAT)) {
|
||||||
currentEntry.setChatSession(entry.getChatSession());
|
currentEntry.setChatSession(entry.getChatSession());
|
||||||
}
|
}
|
||||||
if (actions.contains(UpsertPlayerInfo.Action.UPDATE_LISTED)) {
|
if (actions.contains(UpsertPlayerInfoPacket.Action.UPDATE_LISTED)) {
|
||||||
currentEntry.setListedWithoutUpdate(entry.isListed());
|
currentEntry.setListedWithoutUpdate(entry.isListed());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void processRemove(RemovePlayerInfo infoPacket) {
|
public void processRemove(RemovePlayerInfoPacket infoPacket) {
|
||||||
for (UUID uuid : infoPacket.getProfilesToRemove()) {
|
for (UUID uuid : infoPacket.getProfilesToRemove()) {
|
||||||
this.entries.remove(uuid);
|
this.entries.remove(uuid);
|
||||||
}
|
}
|
||||||
|
@ -21,7 +21,7 @@ import com.velocitypowered.api.proxy.player.ChatSession;
|
|||||||
import com.velocitypowered.api.proxy.player.TabList;
|
import com.velocitypowered.api.proxy.player.TabList;
|
||||||
import com.velocitypowered.api.proxy.player.TabListEntry;
|
import com.velocitypowered.api.proxy.player.TabListEntry;
|
||||||
import com.velocitypowered.api.util.GameProfile;
|
import com.velocitypowered.api.util.GameProfile;
|
||||||
import com.velocitypowered.proxy.protocol.packet.UpsertPlayerInfo;
|
import com.velocitypowered.proxy.protocol.packet.UpsertPlayerInfoPacket;
|
||||||
import com.velocitypowered.proxy.protocol.packet.chat.ComponentHolder;
|
import com.velocitypowered.proxy.protocol.packet.chat.ComponentHolder;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
import net.kyori.adventure.text.Component;
|
import net.kyori.adventure.text.Component;
|
||||||
@ -78,14 +78,14 @@ public class VelocityTabListEntry implements TabListEntry {
|
|||||||
@Override
|
@Override
|
||||||
public TabListEntry setDisplayName(@Nullable Component displayName) {
|
public TabListEntry setDisplayName(@Nullable Component displayName) {
|
||||||
this.displayName = displayName;
|
this.displayName = displayName;
|
||||||
UpsertPlayerInfo.Entry upsertEntry = this.tabList.createRawEntry(this);
|
UpsertPlayerInfoPacket.Entry upsertEntry = this.tabList.createRawEntry(this);
|
||||||
upsertEntry.setDisplayName(
|
upsertEntry.setDisplayName(
|
||||||
displayName == null
|
displayName == null
|
||||||
?
|
?
|
||||||
null :
|
null :
|
||||||
new ComponentHolder(this.tabList.getPlayer().getProtocolVersion(), displayName)
|
new ComponentHolder(this.tabList.getPlayer().getProtocolVersion(), displayName)
|
||||||
);
|
);
|
||||||
this.tabList.emitActionRaw(UpsertPlayerInfo.Action.UPDATE_DISPLAY_NAME, upsertEntry);
|
this.tabList.emitActionRaw(UpsertPlayerInfoPacket.Action.UPDATE_DISPLAY_NAME, upsertEntry);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -101,9 +101,9 @@ public class VelocityTabListEntry implements TabListEntry {
|
|||||||
@Override
|
@Override
|
||||||
public TabListEntry setLatency(int latency) {
|
public TabListEntry setLatency(int latency) {
|
||||||
this.latency = latency;
|
this.latency = latency;
|
||||||
UpsertPlayerInfo.Entry upsertEntry = this.tabList.createRawEntry(this);
|
UpsertPlayerInfoPacket.Entry upsertEntry = this.tabList.createRawEntry(this);
|
||||||
upsertEntry.setLatency(latency);
|
upsertEntry.setLatency(latency);
|
||||||
this.tabList.emitActionRaw(UpsertPlayerInfo.Action.UPDATE_LATENCY, upsertEntry);
|
this.tabList.emitActionRaw(UpsertPlayerInfoPacket.Action.UPDATE_LATENCY, upsertEntry);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -119,9 +119,9 @@ public class VelocityTabListEntry implements TabListEntry {
|
|||||||
@Override
|
@Override
|
||||||
public TabListEntry setGameMode(int gameMode) {
|
public TabListEntry setGameMode(int gameMode) {
|
||||||
this.gameMode = gameMode;
|
this.gameMode = gameMode;
|
||||||
UpsertPlayerInfo.Entry upsertEntry = this.tabList.createRawEntry(this);
|
UpsertPlayerInfoPacket.Entry upsertEntry = this.tabList.createRawEntry(this);
|
||||||
upsertEntry.setGameMode(gameMode);
|
upsertEntry.setGameMode(gameMode);
|
||||||
this.tabList.emitActionRaw(UpsertPlayerInfo.Action.UPDATE_GAME_MODE, upsertEntry);
|
this.tabList.emitActionRaw(UpsertPlayerInfoPacket.Action.UPDATE_GAME_MODE, upsertEntry);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -141,9 +141,9 @@ public class VelocityTabListEntry implements TabListEntry {
|
|||||||
@Override
|
@Override
|
||||||
public VelocityTabListEntry setListed(boolean listed) {
|
public VelocityTabListEntry setListed(boolean listed) {
|
||||||
this.listed = listed;
|
this.listed = listed;
|
||||||
UpsertPlayerInfo.Entry upsertEntry = this.tabList.createRawEntry(this);
|
UpsertPlayerInfoPacket.Entry upsertEntry = this.tabList.createRawEntry(this);
|
||||||
upsertEntry.setListed(listed);
|
upsertEntry.setListed(listed);
|
||||||
this.tabList.emitActionRaw(UpsertPlayerInfo.Action.UPDATE_LISTED, upsertEntry);
|
this.tabList.emitActionRaw(UpsertPlayerInfoPacket.Action.UPDATE_LISTED, upsertEntry);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -22,8 +22,8 @@ import com.velocitypowered.api.proxy.ProxyServer;
|
|||||||
import com.velocitypowered.api.proxy.player.TabListEntry;
|
import com.velocitypowered.api.proxy.player.TabListEntry;
|
||||||
import com.velocitypowered.api.util.GameProfile;
|
import com.velocitypowered.api.util.GameProfile;
|
||||||
import com.velocitypowered.proxy.connection.client.ConnectedPlayer;
|
import com.velocitypowered.proxy.connection.client.ConnectedPlayer;
|
||||||
import com.velocitypowered.proxy.protocol.packet.LegacyPlayerListItem;
|
import com.velocitypowered.proxy.protocol.packet.LegacyPlayerListItemPacket;
|
||||||
import com.velocitypowered.proxy.protocol.packet.LegacyPlayerListItem.Item;
|
import com.velocitypowered.proxy.protocol.packet.LegacyPlayerListItemPacket.Item;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
@ -68,8 +68,9 @@ public class VelocityTabListLegacy extends KeyedVelocityTabList {
|
|||||||
@Override
|
@Override
|
||||||
public void clearAll() {
|
public void clearAll() {
|
||||||
for (TabListEntry value : entries.values()) {
|
for (TabListEntry value : entries.values()) {
|
||||||
connection.delayedWrite(new LegacyPlayerListItem(LegacyPlayerListItem.REMOVE_PLAYER,
|
connection.delayedWrite(new LegacyPlayerListItemPacket(
|
||||||
Collections.singletonList(LegacyPlayerListItem.Item.from(value))));
|
LegacyPlayerListItemPacket.REMOVE_PLAYER,
|
||||||
|
Collections.singletonList(LegacyPlayerListItemPacket.Item.from(value))));
|
||||||
}
|
}
|
||||||
clearAllSilent();
|
clearAllSilent();
|
||||||
}
|
}
|
||||||
@ -81,11 +82,11 @@ public class VelocityTabListLegacy extends KeyedVelocityTabList {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void processLegacy(LegacyPlayerListItem packet) {
|
public void processLegacy(LegacyPlayerListItemPacket packet) {
|
||||||
Item item = packet.getItems().get(0); // Only one item per packet in 1.7
|
Item item = packet.getItems().get(0); // Only one item per packet in 1.7
|
||||||
|
|
||||||
switch (packet.getAction()) {
|
switch (packet.getAction()) {
|
||||||
case LegacyPlayerListItem.ADD_PLAYER:
|
case LegacyPlayerListItemPacket.ADD_PLAYER:
|
||||||
if (nameMapping.containsKey(item.getName())) { // ADD_PLAYER also used for updating ping
|
if (nameMapping.containsKey(item.getName())) { // ADD_PLAYER also used for updating ping
|
||||||
KeyedVelocityTabListEntry entry = entries.get(nameMapping.get(item.getName()));
|
KeyedVelocityTabListEntry entry = entries.get(nameMapping.get(item.getName()));
|
||||||
if (entry != null) {
|
if (entry != null) {
|
||||||
@ -101,7 +102,7 @@ public class VelocityTabListLegacy extends KeyedVelocityTabList {
|
|||||||
.build());
|
.build());
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case LegacyPlayerListItem.REMOVE_PLAYER:
|
case LegacyPlayerListItemPacket.REMOVE_PLAYER:
|
||||||
UUID removedUuid = nameMapping.remove(item.getName());
|
UUID removedUuid = nameMapping.remove(item.getName());
|
||||||
if (removedUuid != null) {
|
if (removedUuid != null) {
|
||||||
entries.remove(removedUuid);
|
entries.remove(removedUuid);
|
||||||
@ -117,12 +118,13 @@ public class VelocityTabListLegacy extends KeyedVelocityTabList {
|
|||||||
void updateEntry(int action, TabListEntry entry) {
|
void updateEntry(int action, TabListEntry entry) {
|
||||||
if (entries.containsKey(entry.getProfile().getId())) {
|
if (entries.containsKey(entry.getProfile().getId())) {
|
||||||
switch (action) {
|
switch (action) {
|
||||||
case LegacyPlayerListItem.UPDATE_LATENCY:
|
case LegacyPlayerListItemPacket.UPDATE_LATENCY:
|
||||||
case LegacyPlayerListItem.UPDATE_DISPLAY_NAME: // Add here because we removed beforehand
|
// Add here because we removed beforehand
|
||||||
|
case LegacyPlayerListItemPacket.UPDATE_DISPLAY_NAME:
|
||||||
connection
|
connection
|
||||||
.write(new LegacyPlayerListItem(LegacyPlayerListItem.ADD_PLAYER,
|
.write(new LegacyPlayerListItemPacket(LegacyPlayerListItemPacket.ADD_PLAYER,
|
||||||
// ADD_PLAYER also updates ping
|
// ADD_PLAYER also updates ping
|
||||||
Collections.singletonList(LegacyPlayerListItem.Item.from(entry))));
|
Collections.singletonList(LegacyPlayerListItemPacket.Item.from(entry))));
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
// Can't do anything else
|
// Can't do anything else
|
||||||
|
@ -20,6 +20,7 @@ package com.velocitypowered.proxy.util.bossbar;
|
|||||||
import com.google.common.collect.MapMaker;
|
import com.google.common.collect.MapMaker;
|
||||||
import com.velocitypowered.api.network.ProtocolVersion;
|
import com.velocitypowered.api.network.ProtocolVersion;
|
||||||
import com.velocitypowered.proxy.connection.client.ConnectedPlayer;
|
import com.velocitypowered.proxy.connection.client.ConnectedPlayer;
|
||||||
|
import com.velocitypowered.proxy.protocol.packet.BossBarPacket;
|
||||||
import com.velocitypowered.proxy.protocol.packet.chat.ComponentHolder;
|
import com.velocitypowered.proxy.protocol.packet.chat.ComponentHolder;
|
||||||
import com.velocitypowered.proxy.util.collect.Enum2IntMap;
|
import com.velocitypowered.proxy.util.collect.Enum2IntMap;
|
||||||
import com.velocitypowered.proxy.util.concurrent.Once;
|
import com.velocitypowered.proxy.util.concurrent.Once;
|
||||||
@ -128,7 +129,7 @@ public class AdventureBossBarManager implements BossBar.Listener {
|
|||||||
}
|
}
|
||||||
for (ConnectedPlayer player : holder.subscribers) {
|
for (ConnectedPlayer player : holder.subscribers) {
|
||||||
Component translated = player.translateMessage(newName);
|
Component translated = player.translateMessage(newName);
|
||||||
com.velocitypowered.proxy.protocol.packet.BossBar packet = holder.createTitleUpdate(
|
BossBarPacket packet = holder.createTitleUpdate(
|
||||||
translated, player.getProtocolVersion());
|
translated, player.getProtocolVersion());
|
||||||
player.getConnection().write(packet);
|
player.getConnection().write(packet);
|
||||||
}
|
}
|
||||||
@ -140,7 +141,7 @@ public class AdventureBossBarManager implements BossBar.Listener {
|
|||||||
if (holder == null) {
|
if (holder == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
com.velocitypowered.proxy.protocol.packet.BossBar packet = holder
|
BossBarPacket packet = holder
|
||||||
.createPercentUpdate(newPercent);
|
.createPercentUpdate(newPercent);
|
||||||
for (ConnectedPlayer player : holder.subscribers) {
|
for (ConnectedPlayer player : holder.subscribers) {
|
||||||
player.getConnection().write(packet);
|
player.getConnection().write(packet);
|
||||||
@ -154,7 +155,7 @@ public class AdventureBossBarManager implements BossBar.Listener {
|
|||||||
if (holder == null) {
|
if (holder == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
com.velocitypowered.proxy.protocol.packet.BossBar packet = holder.createColorUpdate(newColor);
|
BossBarPacket packet = holder.createColorUpdate(newColor);
|
||||||
for (ConnectedPlayer player : holder.subscribers) {
|
for (ConnectedPlayer player : holder.subscribers) {
|
||||||
player.getConnection().write(packet);
|
player.getConnection().write(packet);
|
||||||
}
|
}
|
||||||
@ -167,7 +168,7 @@ public class AdventureBossBarManager implements BossBar.Listener {
|
|||||||
if (holder == null) {
|
if (holder == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
com.velocitypowered.proxy.protocol.packet.BossBar packet = holder
|
BossBarPacket packet = holder
|
||||||
.createOverlayUpdate(newOverlay);
|
.createOverlayUpdate(newOverlay);
|
||||||
for (ConnectedPlayer player : holder.subscribers) {
|
for (ConnectedPlayer player : holder.subscribers) {
|
||||||
player.getConnection().write(packet);
|
player.getConnection().write(packet);
|
||||||
@ -181,7 +182,7 @@ public class AdventureBossBarManager implements BossBar.Listener {
|
|||||||
if (holder == null) {
|
if (holder == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
com.velocitypowered.proxy.protocol.packet.BossBar packet = holder.createFlagsUpdate();
|
BossBarPacket packet = holder.createFlagsUpdate();
|
||||||
for (ConnectedPlayer player : holder.subscribers) {
|
for (ConnectedPlayer player : holder.subscribers) {
|
||||||
player.getConnection().write(packet);
|
player.getConnection().write(packet);
|
||||||
}
|
}
|
||||||
@ -203,15 +204,14 @@ public class AdventureBossBarManager implements BossBar.Listener {
|
|||||||
registrationOnce.run(() -> this.bar.addListener(AdventureBossBarManager.this));
|
registrationOnce.run(() -> this.bar.addListener(AdventureBossBarManager.this));
|
||||||
}
|
}
|
||||||
|
|
||||||
com.velocitypowered.proxy.protocol.packet.BossBar createRemovePacket() {
|
BossBarPacket createRemovePacket() {
|
||||||
return com.velocitypowered.proxy.protocol.packet.BossBar.createRemovePacket(this.id);
|
return BossBarPacket.createRemovePacket(this.id);
|
||||||
}
|
}
|
||||||
|
|
||||||
com.velocitypowered.proxy.protocol.packet.BossBar createAddPacket(ConnectedPlayer player) {
|
BossBarPacket createAddPacket(ConnectedPlayer player) {
|
||||||
com.velocitypowered.proxy.protocol.packet.BossBar packet = new com.velocitypowered
|
BossBarPacket packet = new BossBarPacket();
|
||||||
.proxy.protocol.packet.BossBar();
|
|
||||||
packet.setUuid(this.id);
|
packet.setUuid(this.id);
|
||||||
packet.setAction(com.velocitypowered.proxy.protocol.packet.BossBar.ADD);
|
packet.setAction(BossBarPacket.ADD);
|
||||||
packet.setName(
|
packet.setName(
|
||||||
new ComponentHolder(player.getProtocolVersion(), player.translateMessage(bar.name())));
|
new ComponentHolder(player.getProtocolVersion(), player.translateMessage(bar.name())));
|
||||||
packet.setColor(COLORS_TO_PROTOCOL.get(bar.color()));
|
packet.setColor(COLORS_TO_PROTOCOL.get(bar.color()));
|
||||||
@ -221,55 +221,50 @@ public class AdventureBossBarManager implements BossBar.Listener {
|
|||||||
return packet;
|
return packet;
|
||||||
}
|
}
|
||||||
|
|
||||||
com.velocitypowered.proxy.protocol.packet.BossBar createPercentUpdate(float newPercent) {
|
BossBarPacket createPercentUpdate(float newPercent) {
|
||||||
com.velocitypowered.proxy.protocol.packet.BossBar packet = new com.velocitypowered
|
BossBarPacket packet = new BossBarPacket();
|
||||||
.proxy.protocol.packet.BossBar();
|
|
||||||
packet.setUuid(this.id);
|
packet.setUuid(this.id);
|
||||||
packet.setAction(com.velocitypowered.proxy.protocol.packet.BossBar.UPDATE_PERCENT);
|
packet.setAction(BossBarPacket.UPDATE_PERCENT);
|
||||||
packet.setPercent(newPercent);
|
packet.setPercent(newPercent);
|
||||||
return packet;
|
return packet;
|
||||||
}
|
}
|
||||||
|
|
||||||
com.velocitypowered.proxy.protocol.packet.BossBar createColorUpdate(Color color) {
|
BossBarPacket createColorUpdate(Color color) {
|
||||||
com.velocitypowered.proxy.protocol.packet.BossBar packet = new com.velocitypowered
|
BossBarPacket packet = new BossBarPacket();
|
||||||
.proxy.protocol.packet.BossBar();
|
|
||||||
packet.setUuid(this.id);
|
packet.setUuid(this.id);
|
||||||
packet.setAction(com.velocitypowered.proxy.protocol.packet.BossBar.UPDATE_STYLE);
|
packet.setAction(BossBarPacket.UPDATE_STYLE);
|
||||||
packet.setColor(COLORS_TO_PROTOCOL.get(color));
|
packet.setColor(COLORS_TO_PROTOCOL.get(color));
|
||||||
packet.setOverlay(OVERLAY_TO_PROTOCOL.get(bar.overlay()));
|
packet.setOverlay(OVERLAY_TO_PROTOCOL.get(bar.overlay()));
|
||||||
packet.setFlags(serializeFlags(bar.flags()));
|
packet.setFlags(serializeFlags(bar.flags()));
|
||||||
return packet;
|
return packet;
|
||||||
}
|
}
|
||||||
|
|
||||||
com.velocitypowered.proxy.protocol.packet.BossBar createTitleUpdate(Component name,
|
BossBarPacket createTitleUpdate(Component name,
|
||||||
ProtocolVersion version) {
|
ProtocolVersion version) {
|
||||||
com.velocitypowered.proxy.protocol.packet.BossBar packet = new com.velocitypowered
|
BossBarPacket packet = new BossBarPacket();
|
||||||
.proxy.protocol.packet.BossBar();
|
|
||||||
packet.setUuid(this.id);
|
packet.setUuid(this.id);
|
||||||
packet.setAction(com.velocitypowered.proxy.protocol.packet.BossBar.UPDATE_NAME);
|
packet.setAction(BossBarPacket.UPDATE_NAME);
|
||||||
packet.setName(new ComponentHolder(version, name));
|
packet.setName(new ComponentHolder(version, name));
|
||||||
return packet;
|
return packet;
|
||||||
}
|
}
|
||||||
|
|
||||||
com.velocitypowered.proxy.protocol.packet.BossBar createFlagsUpdate() {
|
BossBarPacket createFlagsUpdate() {
|
||||||
return createFlagsUpdate(bar.flags());
|
return createFlagsUpdate(bar.flags());
|
||||||
}
|
}
|
||||||
|
|
||||||
com.velocitypowered.proxy.protocol.packet.BossBar createFlagsUpdate(Set<Flag> newFlags) {
|
BossBarPacket createFlagsUpdate(Set<Flag> newFlags) {
|
||||||
com.velocitypowered.proxy.protocol.packet.BossBar packet = new com.velocitypowered
|
BossBarPacket packet = new BossBarPacket();
|
||||||
.proxy.protocol.packet.BossBar();
|
|
||||||
packet.setUuid(this.id);
|
packet.setUuid(this.id);
|
||||||
packet.setAction(com.velocitypowered.proxy.protocol.packet.BossBar.UPDATE_PROPERTIES);
|
packet.setAction(BossBarPacket.UPDATE_PROPERTIES);
|
||||||
packet.setColor(COLORS_TO_PROTOCOL.get(this.bar.color()));
|
packet.setColor(COLORS_TO_PROTOCOL.get(this.bar.color()));
|
||||||
packet.setFlags(this.serializeFlags(newFlags));
|
packet.setFlags(this.serializeFlags(newFlags));
|
||||||
return packet;
|
return packet;
|
||||||
}
|
}
|
||||||
|
|
||||||
com.velocitypowered.proxy.protocol.packet.BossBar createOverlayUpdate(Overlay overlay) {
|
BossBarPacket createOverlayUpdate(Overlay overlay) {
|
||||||
com.velocitypowered.proxy.protocol.packet.BossBar packet = new com.velocitypowered
|
BossBarPacket packet = new BossBarPacket();
|
||||||
.proxy.protocol.packet.BossBar();
|
|
||||||
packet.setUuid(this.id);
|
packet.setUuid(this.id);
|
||||||
packet.setAction(com.velocitypowered.proxy.protocol.packet.BossBar.UPDATE_STYLE);
|
packet.setAction(BossBarPacket.UPDATE_STYLE);
|
||||||
packet.setColor(COLORS_TO_PROTOCOL.get(bar.color()));
|
packet.setColor(COLORS_TO_PROTOCOL.get(bar.color()));
|
||||||
packet.setOverlay(OVERLAY_TO_PROTOCOL.get(overlay));
|
packet.setOverlay(OVERLAY_TO_PROTOCOL.get(overlay));
|
||||||
return packet;
|
return packet;
|
||||||
|
@ -36,8 +36,8 @@ import static org.junit.jupiter.api.Assertions.assertNull;
|
|||||||
import static org.junit.jupiter.api.Assertions.assertThrows;
|
import static org.junit.jupiter.api.Assertions.assertThrows;
|
||||||
|
|
||||||
import com.velocitypowered.api.network.ProtocolVersion;
|
import com.velocitypowered.api.network.ProtocolVersion;
|
||||||
import com.velocitypowered.proxy.protocol.packet.Handshake;
|
import com.velocitypowered.proxy.protocol.packet.HandshakePacket;
|
||||||
import com.velocitypowered.proxy.protocol.packet.StatusPing;
|
import com.velocitypowered.proxy.protocol.packet.StatusPingPacket;
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
class PacketRegistryTest {
|
class PacketRegistryTest {
|
||||||
@ -45,7 +45,7 @@ class PacketRegistryTest {
|
|||||||
private StateRegistry.PacketRegistry setupRegistry() {
|
private StateRegistry.PacketRegistry setupRegistry() {
|
||||||
StateRegistry.PacketRegistry registry = new StateRegistry.PacketRegistry(
|
StateRegistry.PacketRegistry registry = new StateRegistry.PacketRegistry(
|
||||||
ProtocolUtils.Direction.CLIENTBOUND, StateRegistry.PLAY);
|
ProtocolUtils.Direction.CLIENTBOUND, StateRegistry.PLAY);
|
||||||
registry.register(Handshake.class, Handshake::new,
|
registry.register(HandshakePacket.class, HandshakePacket::new,
|
||||||
new StateRegistry.PacketMapping(0x01, MINECRAFT_1_8, null, false),
|
new StateRegistry.PacketMapping(0x01, MINECRAFT_1_8, null, false),
|
||||||
new StateRegistry.PacketMapping(0x00, MINECRAFT_1_12, null, false),
|
new StateRegistry.PacketMapping(0x00, MINECRAFT_1_12, null, false),
|
||||||
new StateRegistry.PacketMapping(0x00, MINECRAFT_1_15, MINECRAFT_1_16, false));
|
new StateRegistry.PacketMapping(0x00, MINECRAFT_1_15, MINECRAFT_1_16, false));
|
||||||
@ -57,7 +57,7 @@ class PacketRegistryTest {
|
|||||||
StateRegistry.PacketRegistry registry = setupRegistry();
|
StateRegistry.PacketRegistry registry = setupRegistry();
|
||||||
MinecraftPacket packet = registry.getProtocolRegistry(MINECRAFT_1_12).createPacket(0);
|
MinecraftPacket packet = registry.getProtocolRegistry(MINECRAFT_1_12).createPacket(0);
|
||||||
assertNotNull(packet, "Packet was not found in registry");
|
assertNotNull(packet, "Packet was not found in registry");
|
||||||
assertEquals(Handshake.class, packet.getClass(), "Registry returned wrong class");
|
assertEquals(HandshakePacket.class, packet.getClass(), "Registry returned wrong class");
|
||||||
|
|
||||||
assertEquals(0, registry.getProtocolRegistry(MINECRAFT_1_12).getPacketId(packet),
|
assertEquals(0, registry.getProtocolRegistry(MINECRAFT_1_12).getPacketId(packet),
|
||||||
"Registry did not return the correct packet ID");
|
"Registry did not return the correct packet ID");
|
||||||
@ -68,7 +68,7 @@ class PacketRegistryTest {
|
|||||||
StateRegistry.PacketRegistry registry = setupRegistry();
|
StateRegistry.PacketRegistry registry = setupRegistry();
|
||||||
MinecraftPacket packet = registry.getProtocolRegistry(MINECRAFT_1_12_1).createPacket(0);
|
MinecraftPacket packet = registry.getProtocolRegistry(MINECRAFT_1_12_1).createPacket(0);
|
||||||
assertNotNull(packet, "Packet was not found in registry");
|
assertNotNull(packet, "Packet was not found in registry");
|
||||||
assertEquals(Handshake.class, packet.getClass(), "Registry returned wrong class");
|
assertEquals(HandshakePacket.class, packet.getClass(), "Registry returned wrong class");
|
||||||
assertEquals(0, registry.getProtocolRegistry(MINECRAFT_1_12_1).getPacketId(packet),
|
assertEquals(0, registry.getProtocolRegistry(MINECRAFT_1_12_1).getPacketId(packet),
|
||||||
"Registry did not return the correct packet ID");
|
"Registry did not return the correct packet ID");
|
||||||
assertEquals(0, registry.getProtocolRegistry(MINECRAFT_1_14_2).getPacketId(packet),
|
assertEquals(0, registry.getProtocolRegistry(MINECRAFT_1_14_2).getPacketId(packet),
|
||||||
@ -86,9 +86,10 @@ class PacketRegistryTest {
|
|||||||
StateRegistry.PacketRegistry registry = new StateRegistry.PacketRegistry(
|
StateRegistry.PacketRegistry registry = new StateRegistry.PacketRegistry(
|
||||||
ProtocolUtils.Direction.CLIENTBOUND, StateRegistry.PLAY);
|
ProtocolUtils.Direction.CLIENTBOUND, StateRegistry.PLAY);
|
||||||
assertThrows(IllegalArgumentException.class,
|
assertThrows(IllegalArgumentException.class,
|
||||||
() -> registry.register(Handshake.class, Handshake::new));
|
() -> registry.register(HandshakePacket.class, HandshakePacket::new));
|
||||||
assertThrows(IllegalArgumentException.class,
|
assertThrows(IllegalArgumentException.class,
|
||||||
() -> registry.getProtocolRegistry(ProtocolVersion.UNKNOWN).getPacketId(new Handshake()));
|
() -> registry.getProtocolRegistry(ProtocolVersion.UNKNOWN)
|
||||||
|
.getPacketId(new HandshakePacket()));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@ -96,18 +97,18 @@ class PacketRegistryTest {
|
|||||||
StateRegistry.PacketRegistry registry = new StateRegistry.PacketRegistry(
|
StateRegistry.PacketRegistry registry = new StateRegistry.PacketRegistry(
|
||||||
ProtocolUtils.Direction.CLIENTBOUND, StateRegistry.PLAY);
|
ProtocolUtils.Direction.CLIENTBOUND, StateRegistry.PLAY);
|
||||||
assertThrows(IllegalArgumentException.class,
|
assertThrows(IllegalArgumentException.class,
|
||||||
() -> registry.register(Handshake.class, Handshake::new,
|
() -> registry.register(HandshakePacket.class, HandshakePacket::new,
|
||||||
new StateRegistry.PacketMapping(0x01, MINECRAFT_1_13, null, false),
|
new StateRegistry.PacketMapping(0x01, MINECRAFT_1_13, null, false),
|
||||||
new StateRegistry.PacketMapping(0x00, MINECRAFT_1_8, null, false)));
|
new StateRegistry.PacketMapping(0x00, MINECRAFT_1_8, null, false)));
|
||||||
assertThrows(IllegalArgumentException.class,
|
assertThrows(IllegalArgumentException.class,
|
||||||
() -> registry.register(Handshake.class, Handshake::new,
|
() -> registry.register(HandshakePacket.class, HandshakePacket::new,
|
||||||
new StateRegistry.PacketMapping(0x01, MINECRAFT_1_13, null, false),
|
new StateRegistry.PacketMapping(0x01, MINECRAFT_1_13, null, false),
|
||||||
new StateRegistry.PacketMapping(0x01, MINECRAFT_1_13, null, false)));
|
new StateRegistry.PacketMapping(0x01, MINECRAFT_1_13, null, false)));
|
||||||
assertThrows(IllegalArgumentException.class,
|
assertThrows(IllegalArgumentException.class,
|
||||||
() -> registry.register(Handshake.class, Handshake::new,
|
() -> registry.register(HandshakePacket.class, HandshakePacket::new,
|
||||||
new StateRegistry.PacketMapping(0x01, MINECRAFT_1_13, MINECRAFT_1_8, false)));
|
new StateRegistry.PacketMapping(0x01, MINECRAFT_1_13, MINECRAFT_1_8, false)));
|
||||||
assertThrows(IllegalArgumentException.class,
|
assertThrows(IllegalArgumentException.class,
|
||||||
() -> registry.register(Handshake.class, Handshake::new,
|
() -> registry.register(HandshakePacket.class, HandshakePacket::new,
|
||||||
new StateRegistry.PacketMapping(0x01, MINECRAFT_1_8, MINECRAFT_1_14, false),
|
new StateRegistry.PacketMapping(0x01, MINECRAFT_1_8, MINECRAFT_1_14, false),
|
||||||
new StateRegistry.PacketMapping(0x00, MINECRAFT_1_16, null, false)));
|
new StateRegistry.PacketMapping(0x00, MINECRAFT_1_16, null, false)));
|
||||||
}
|
}
|
||||||
@ -116,13 +117,13 @@ class PacketRegistryTest {
|
|||||||
void failOnDuplicate() {
|
void failOnDuplicate() {
|
||||||
StateRegistry.PacketRegistry registry = new StateRegistry.PacketRegistry(
|
StateRegistry.PacketRegistry registry = new StateRegistry.PacketRegistry(
|
||||||
ProtocolUtils.Direction.CLIENTBOUND, StateRegistry.PLAY);
|
ProtocolUtils.Direction.CLIENTBOUND, StateRegistry.PLAY);
|
||||||
registry.register(Handshake.class, Handshake::new,
|
registry.register(HandshakePacket.class, HandshakePacket::new,
|
||||||
new StateRegistry.PacketMapping(0x00, MINECRAFT_1_8, null, false));
|
new StateRegistry.PacketMapping(0x00, MINECRAFT_1_8, null, false));
|
||||||
assertThrows(IllegalArgumentException.class,
|
assertThrows(IllegalArgumentException.class,
|
||||||
() -> registry.register(Handshake.class, Handshake::new,
|
() -> registry.register(HandshakePacket.class, HandshakePacket::new,
|
||||||
new StateRegistry.PacketMapping(0x01, MINECRAFT_1_12, null, false)));
|
new StateRegistry.PacketMapping(0x01, MINECRAFT_1_12, null, false)));
|
||||||
assertThrows(IllegalArgumentException.class,
|
assertThrows(IllegalArgumentException.class,
|
||||||
() -> registry.register(StatusPing.class, StatusPing::new,
|
() -> registry.register(StatusPingPacket.class, StatusPingPacket::new,
|
||||||
new StateRegistry.PacketMapping(0x00, MINECRAFT_1_13, null, false)));
|
new StateRegistry.PacketMapping(0x00, MINECRAFT_1_13, null, false)));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -130,7 +131,7 @@ class PacketRegistryTest {
|
|||||||
void shouldNotFailWhenRegisterLatestProtocolVersion() {
|
void shouldNotFailWhenRegisterLatestProtocolVersion() {
|
||||||
StateRegistry.PacketRegistry registry = new StateRegistry.PacketRegistry(
|
StateRegistry.PacketRegistry registry = new StateRegistry.PacketRegistry(
|
||||||
ProtocolUtils.Direction.CLIENTBOUND, StateRegistry.PLAY);
|
ProtocolUtils.Direction.CLIENTBOUND, StateRegistry.PLAY);
|
||||||
assertDoesNotThrow(() -> registry.register(Handshake.class, Handshake::new,
|
assertDoesNotThrow(() -> registry.register(HandshakePacket.class, HandshakePacket::new,
|
||||||
new StateRegistry.PacketMapping(0x00, MINECRAFT_1_8, null, false),
|
new StateRegistry.PacketMapping(0x00, MINECRAFT_1_8, null, false),
|
||||||
new StateRegistry.PacketMapping(0x01, getLast(ProtocolVersion.SUPPORTED_VERSIONS),
|
new StateRegistry.PacketMapping(0x01, getLast(ProtocolVersion.SUPPORTED_VERSIONS),
|
||||||
null, false)));
|
null, false)));
|
||||||
@ -140,19 +141,19 @@ class PacketRegistryTest {
|
|||||||
void registrySuppliesCorrectPacketsByProtocol() {
|
void registrySuppliesCorrectPacketsByProtocol() {
|
||||||
StateRegistry.PacketRegistry registry = new StateRegistry.PacketRegistry(
|
StateRegistry.PacketRegistry registry = new StateRegistry.PacketRegistry(
|
||||||
ProtocolUtils.Direction.CLIENTBOUND, StateRegistry.PLAY);
|
ProtocolUtils.Direction.CLIENTBOUND, StateRegistry.PLAY);
|
||||||
registry.register(Handshake.class, Handshake::new,
|
registry.register(HandshakePacket.class, HandshakePacket::new,
|
||||||
new StateRegistry.PacketMapping(0x00, MINECRAFT_1_12, null, false),
|
new StateRegistry.PacketMapping(0x00, MINECRAFT_1_12, null, false),
|
||||||
new StateRegistry.PacketMapping(0x01, MINECRAFT_1_12_1, null, false),
|
new StateRegistry.PacketMapping(0x01, MINECRAFT_1_12_1, null, false),
|
||||||
new StateRegistry.PacketMapping(0x02, MINECRAFT_1_13, null, false));
|
new StateRegistry.PacketMapping(0x02, MINECRAFT_1_13, null, false));
|
||||||
assertEquals(Handshake.class,
|
assertEquals(HandshakePacket.class,
|
||||||
registry.getProtocolRegistry(MINECRAFT_1_12).createPacket(0x00).getClass());
|
registry.getProtocolRegistry(MINECRAFT_1_12).createPacket(0x00).getClass());
|
||||||
assertEquals(Handshake.class,
|
assertEquals(HandshakePacket.class,
|
||||||
registry.getProtocolRegistry(MINECRAFT_1_12_1).createPacket(0x01).getClass());
|
registry.getProtocolRegistry(MINECRAFT_1_12_1).createPacket(0x01).getClass());
|
||||||
assertEquals(Handshake.class,
|
assertEquals(HandshakePacket.class,
|
||||||
registry.getProtocolRegistry(MINECRAFT_1_12_2).createPacket(0x01).getClass());
|
registry.getProtocolRegistry(MINECRAFT_1_12_2).createPacket(0x01).getClass());
|
||||||
assertEquals(Handshake.class,
|
assertEquals(HandshakePacket.class,
|
||||||
registry.getProtocolRegistry(MINECRAFT_1_13).createPacket(0x02).getClass());
|
registry.getProtocolRegistry(MINECRAFT_1_13).createPacket(0x02).getClass());
|
||||||
assertEquals(Handshake.class,
|
assertEquals(HandshakePacket.class,
|
||||||
registry.getProtocolRegistry(MINECRAFT_1_14_2).createPacket(0x02).getClass());
|
registry.getProtocolRegistry(MINECRAFT_1_14_2).createPacket(0x02).getClass());
|
||||||
}
|
}
|
||||||
}
|
}
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren