Mirror von
https://github.com/PaperMC/Velocity.git
synchronisiert 2024-11-16 21:10:30 +01:00
lots more
Dieser Commit ist enthalten in:
Ursprung
f873debb72
Commit
7ca40094cb
@ -27,6 +27,10 @@
|
||||
<property name="eachLine" value="true"/>
|
||||
</module>
|
||||
|
||||
<module name="SuppressionFilter">
|
||||
<property name="file" value="${configDirectory}/suppressions.xml"/>
|
||||
</module>
|
||||
|
||||
<module name="TreeWalker">
|
||||
<module name="OuterTypeFilename"/>
|
||||
<!-- <module name="IllegalTokenText">
|
||||
@ -42,7 +46,7 @@
|
||||
<property name="allowNonPrintableEscapes" value="true"/>
|
||||
</module>
|
||||
<module name="LineLength">
|
||||
<property name="max" value="100"/>
|
||||
<property name="max" value="150"/>
|
||||
<property name="ignorePattern"
|
||||
value="^package.*|^import.*|a href|href|http://|https://|ftp://"/>
|
||||
</module>
|
||||
|
6
config/checkstyle/suppressions.xml
Normale Datei
6
config/checkstyle/suppressions.xml
Normale Datei
@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE suppressions PUBLIC "-//Checkstyle//DTD SuppressionFilter Configuration 1.2//EN" "http://checkstyle.org/dtds/suppressions_1_2.dtd">
|
||||
<suppressions>
|
||||
<!-- no javadoc warning for implementation -->
|
||||
<suppress files="src[\\/]main[\\/]java[\\/]com[\\/]velocitypowered[\\/]proxy[\\/].*" checks="JavadocMethod"/>
|
||||
</suppressions>
|
@ -1,8 +1,11 @@
|
||||
checkstyle {
|
||||
def configDirectory = new File(project.rootDir, ["config", "checkstyle"].join(File.separator))
|
||||
|
||||
toolVersion '8.14'
|
||||
configFile new File(project.rootDir, ['config', 'checkstyle', 'checkstyle.xml'].join(File.separator))
|
||||
configFile new File(configDirectory, "checkstyle.xml")
|
||||
configProperties = [configDirectory: configDirectory.getAbsolutePath()]
|
||||
|
||||
// The build should immediately fail if we have errors.
|
||||
maxErrors = 0
|
||||
maxWarnings = 0
|
||||
}
|
||||
}
|
||||
|
@ -27,11 +27,11 @@ import com.velocitypowered.proxy.config.VelocityConfiguration;
|
||||
import com.velocitypowered.proxy.connection.client.ConnectedPlayer;
|
||||
import com.velocitypowered.proxy.console.VelocityConsole;
|
||||
import com.velocitypowered.proxy.network.ConnectionManager;
|
||||
import com.velocitypowered.proxy.network.ProtocolUtils;
|
||||
import com.velocitypowered.proxy.network.serialization.FaviconSerializer;
|
||||
import com.velocitypowered.proxy.network.serialization.GameProfileSerializer;
|
||||
import com.velocitypowered.proxy.plugin.VelocityEventManager;
|
||||
import com.velocitypowered.proxy.plugin.VelocityPluginManager;
|
||||
import com.velocitypowered.proxy.protocol.ProtocolUtils;
|
||||
import com.velocitypowered.proxy.protocol.util.FaviconSerializer;
|
||||
import com.velocitypowered.proxy.protocol.util.GameProfileSerializer;
|
||||
import com.velocitypowered.proxy.scheduler.VelocityScheduler;
|
||||
import com.velocitypowered.proxy.server.ServerMap;
|
||||
import com.velocitypowered.proxy.util.AddressUtil;
|
||||
|
@ -19,15 +19,15 @@ import com.velocitypowered.proxy.VelocityServer;
|
||||
import com.velocitypowered.proxy.connection.client.HandshakeSessionHandler;
|
||||
import com.velocitypowered.proxy.connection.client.LoginSessionHandler;
|
||||
import com.velocitypowered.proxy.connection.client.StatusSessionHandler;
|
||||
import com.velocitypowered.proxy.protocol.Packet;
|
||||
import com.velocitypowered.proxy.protocol.StateRegistry;
|
||||
import com.velocitypowered.proxy.protocol.netty.MinecraftCipherDecoder;
|
||||
import com.velocitypowered.proxy.protocol.netty.MinecraftCipherEncoder;
|
||||
import com.velocitypowered.proxy.protocol.netty.MinecraftCompressDecoder;
|
||||
import com.velocitypowered.proxy.protocol.netty.MinecraftCompressEncoder;
|
||||
import com.velocitypowered.proxy.protocol.netty.MinecraftDecoder;
|
||||
import com.velocitypowered.proxy.protocol.netty.MinecraftEncoder;
|
||||
import com.velocitypowered.proxy.protocol.packet.SetCompressionPacket;
|
||||
import com.velocitypowered.proxy.network.StateRegistry;
|
||||
import com.velocitypowered.proxy.network.packet.Packet;
|
||||
import com.velocitypowered.proxy.network.packet.clientbound.ClientboundSetCompressionPacket;
|
||||
import com.velocitypowered.proxy.network.pipeline.MinecraftCipherDecoder;
|
||||
import com.velocitypowered.proxy.network.pipeline.MinecraftCipherEncoder;
|
||||
import com.velocitypowered.proxy.network.pipeline.MinecraftCompressDecoder;
|
||||
import com.velocitypowered.proxy.network.pipeline.MinecraftCompressEncoder;
|
||||
import com.velocitypowered.proxy.network.pipeline.MinecraftDecoder;
|
||||
import com.velocitypowered.proxy.network.pipeline.MinecraftEncoder;
|
||||
import com.velocitypowered.proxy.util.except.QuietDecoderException;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty.channel.Channel;
|
||||
@ -369,7 +369,7 @@ public class MinecraftConnection extends ChannelInboundHandlerAdapter {
|
||||
|
||||
/**
|
||||
* Sets the compression threshold on the connection. You are responsible for sending
|
||||
* {@link SetCompressionPacket} beforehand.
|
||||
* {@link ClientboundSetCompressionPacket} beforehand.
|
||||
* @param threshold the compression threshold to use
|
||||
*/
|
||||
public void setCompressionThreshold(int threshold) {
|
||||
|
@ -1,39 +1,10 @@
|
||||
package com.velocitypowered.proxy.connection;
|
||||
|
||||
import com.velocitypowered.proxy.protocol.Packet;
|
||||
import com.velocitypowered.proxy.protocol.packet.AvailableCommandsPacket;
|
||||
import com.velocitypowered.proxy.protocol.packet.BossBarPacket;
|
||||
import com.velocitypowered.proxy.protocol.packet.ClientSettingsPacket;
|
||||
import com.velocitypowered.proxy.protocol.packet.ClientboundChatPacket;
|
||||
import com.velocitypowered.proxy.protocol.packet.DisconnectPacket;
|
||||
import com.velocitypowered.proxy.protocol.packet.EncryptionRequestPacket;
|
||||
import com.velocitypowered.proxy.protocol.packet.EncryptionResponsePacket;
|
||||
import com.velocitypowered.proxy.protocol.packet.HandshakePacket;
|
||||
import com.velocitypowered.proxy.protocol.packet.HeaderAndFooterPacket;
|
||||
import com.velocitypowered.proxy.protocol.packet.JoinGamePacket;
|
||||
import com.velocitypowered.proxy.protocol.packet.KeepAlivePacket;
|
||||
import com.velocitypowered.proxy.protocol.packet.LoginPluginMessagePacket;
|
||||
import com.velocitypowered.proxy.protocol.packet.LoginPluginResponsePacket;
|
||||
import com.velocitypowered.proxy.protocol.packet.PlayerListItemPacket;
|
||||
import com.velocitypowered.proxy.protocol.packet.PluginMessagePacket;
|
||||
import com.velocitypowered.proxy.protocol.packet.ResourcePackRequestPacket;
|
||||
import com.velocitypowered.proxy.protocol.packet.ResourcePackResponsePacket;
|
||||
import com.velocitypowered.proxy.protocol.packet.RespawnPacket;
|
||||
import com.velocitypowered.proxy.protocol.packet.ServerLoginPacket;
|
||||
import com.velocitypowered.proxy.protocol.packet.ServerLoginSuccessPacket;
|
||||
import com.velocitypowered.proxy.protocol.packet.ServerboundChatPacket;
|
||||
import com.velocitypowered.proxy.protocol.packet.SetCompressionPacket;
|
||||
import com.velocitypowered.proxy.protocol.packet.StatusPingPacket;
|
||||
import com.velocitypowered.proxy.protocol.packet.StatusRequestPacket;
|
||||
import com.velocitypowered.proxy.protocol.packet.StatusResponsePacket;
|
||||
import com.velocitypowered.proxy.protocol.packet.TabCompleteRequestPacket;
|
||||
import com.velocitypowered.proxy.protocol.packet.TabCompleteResponsePacket;
|
||||
import com.velocitypowered.proxy.protocol.packet.TitlePacket;
|
||||
import com.velocitypowered.proxy.protocol.packet.legacy.LegacyHandshakePacket;
|
||||
import com.velocitypowered.proxy.protocol.packet.legacy.LegacyPingPacket;
|
||||
import com.velocitypowered.proxy.network.packet.Packet;
|
||||
import com.velocitypowered.proxy.network.packet.PacketHandler;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
|
||||
public interface MinecraftSessionHandler {
|
||||
public interface MinecraftSessionHandler extends PacketHandler {
|
||||
|
||||
default boolean beforeHandle() {
|
||||
return false;
|
||||
@ -65,126 +36,4 @@ public interface MinecraftSessionHandler {
|
||||
|
||||
default void readCompleted() {
|
||||
}
|
||||
|
||||
default boolean handle(AvailableCommandsPacket commands) {
|
||||
return false;
|
||||
}
|
||||
|
||||
default boolean handle(BossBarPacket packet) {
|
||||
return false;
|
||||
}
|
||||
|
||||
default boolean handle(ClientboundChatPacket packet) {
|
||||
return false;
|
||||
}
|
||||
|
||||
default boolean handle(ServerboundChatPacket packet) {
|
||||
return false;
|
||||
}
|
||||
|
||||
default boolean handle(ClientSettingsPacket packet) {
|
||||
return false;
|
||||
}
|
||||
|
||||
default boolean handle(DisconnectPacket packet) {
|
||||
return false;
|
||||
}
|
||||
|
||||
default boolean handle(EncryptionRequestPacket packet) {
|
||||
return false;
|
||||
}
|
||||
|
||||
default boolean handle(EncryptionResponsePacket packet) {
|
||||
return false;
|
||||
}
|
||||
|
||||
default boolean handle(HandshakePacket packet) {
|
||||
return false;
|
||||
}
|
||||
|
||||
default boolean handle(HeaderAndFooterPacket packet) {
|
||||
return false;
|
||||
}
|
||||
|
||||
default boolean handle(JoinGamePacket packet) {
|
||||
return false;
|
||||
}
|
||||
|
||||
default boolean handle(KeepAlivePacket packet) {
|
||||
return false;
|
||||
}
|
||||
|
||||
default boolean handle(LoginPluginMessagePacket packet) {
|
||||
return false;
|
||||
}
|
||||
|
||||
default boolean handle(LoginPluginResponsePacket packet) {
|
||||
return false;
|
||||
}
|
||||
|
||||
default boolean handle(PluginMessagePacket packet) {
|
||||
return false;
|
||||
}
|
||||
|
||||
default boolean handle(RespawnPacket packet) {
|
||||
return false;
|
||||
}
|
||||
|
||||
default boolean handle(ServerLoginPacket packet) {
|
||||
return false;
|
||||
}
|
||||
|
||||
default boolean handle(ServerLoginSuccessPacket packet) {
|
||||
return false;
|
||||
}
|
||||
|
||||
default boolean handle(SetCompressionPacket packet) {
|
||||
return false;
|
||||
}
|
||||
|
||||
default boolean handle(StatusPingPacket packet) {
|
||||
return false;
|
||||
}
|
||||
|
||||
default boolean handle(StatusRequestPacket packet) {
|
||||
return false;
|
||||
}
|
||||
|
||||
default boolean handle(StatusResponsePacket packet) {
|
||||
return false;
|
||||
}
|
||||
|
||||
default boolean handle(TabCompleteRequestPacket packet) {
|
||||
return false;
|
||||
}
|
||||
|
||||
default boolean handle(TabCompleteResponsePacket packet) {
|
||||
return false;
|
||||
}
|
||||
|
||||
default boolean handle(TitlePacket packet) {
|
||||
return false;
|
||||
}
|
||||
|
||||
default boolean handle(PlayerListItemPacket packet) {
|
||||
return false;
|
||||
}
|
||||
|
||||
default boolean handle(ResourcePackRequestPacket packet) {
|
||||
return false;
|
||||
}
|
||||
|
||||
default boolean handle(ResourcePackResponsePacket packet) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Legacy
|
||||
|
||||
default boolean handle(LegacyHandshakePacket packet) {
|
||||
return false;
|
||||
}
|
||||
|
||||
default boolean handle(LegacyPingPacket packet) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -2,7 +2,7 @@ package com.velocitypowered.proxy.connection.backend;
|
||||
|
||||
import com.velocitypowered.proxy.connection.client.ConnectedPlayer;
|
||||
import com.velocitypowered.proxy.connection.forge.legacy.LegacyForgeHandshakeBackendPhase;
|
||||
import com.velocitypowered.proxy.protocol.packet.PluginMessagePacket;
|
||||
import com.velocitypowered.proxy.network.packet.shared.PluginMessagePacket;
|
||||
|
||||
/**
|
||||
* Provides connection phase specific actions.
|
||||
|
@ -2,7 +2,7 @@ package com.velocitypowered.proxy.connection.backend;
|
||||
|
||||
import com.velocitypowered.proxy.connection.client.ConnectedPlayer;
|
||||
import com.velocitypowered.proxy.connection.forge.legacy.LegacyForgeHandshakeBackendPhase;
|
||||
import com.velocitypowered.proxy.protocol.packet.PluginMessagePacket;
|
||||
import com.velocitypowered.proxy.network.packet.shared.PluginMessagePacket;
|
||||
|
||||
/**
|
||||
* Contains Vanilla {@link BackendConnectionPhase}s.
|
||||
|
@ -16,15 +16,15 @@ import com.velocitypowered.proxy.connection.MinecraftConnection;
|
||||
import com.velocitypowered.proxy.connection.MinecraftSessionHandler;
|
||||
import com.velocitypowered.proxy.connection.client.ClientPlaySessionHandler;
|
||||
import com.velocitypowered.proxy.connection.util.ConnectionMessages;
|
||||
import com.velocitypowered.proxy.protocol.Packet;
|
||||
import com.velocitypowered.proxy.protocol.packet.AvailableCommandsPacket;
|
||||
import com.velocitypowered.proxy.protocol.packet.BossBarPacket;
|
||||
import com.velocitypowered.proxy.protocol.packet.DisconnectPacket;
|
||||
import com.velocitypowered.proxy.protocol.packet.KeepAlivePacket;
|
||||
import com.velocitypowered.proxy.protocol.packet.PlayerListItemPacket;
|
||||
import com.velocitypowered.proxy.protocol.packet.PluginMessagePacket;
|
||||
import com.velocitypowered.proxy.protocol.packet.TabCompleteResponsePacket;
|
||||
import com.velocitypowered.proxy.protocol.util.PluginMessageUtil;
|
||||
import com.velocitypowered.proxy.network.PluginMessageUtil;
|
||||
import com.velocitypowered.proxy.network.packet.Packet;
|
||||
import com.velocitypowered.proxy.network.packet.clientbound.ClientboundAvailableCommandsPacket;
|
||||
import com.velocitypowered.proxy.network.packet.clientbound.ClientboundBossBarPacket;
|
||||
import com.velocitypowered.proxy.network.packet.clientbound.ClientboundKeepAlivePacket;
|
||||
import com.velocitypowered.proxy.network.packet.clientbound.ClientboundPlayerListItemPacket;
|
||||
import com.velocitypowered.proxy.network.packet.clientbound.ClientboundTabCompleteResponsePacket;
|
||||
import com.velocitypowered.proxy.network.packet.clientbound.ClientboundDisconnectPacket;
|
||||
import com.velocitypowered.proxy.network.packet.shared.PluginMessagePacket;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty.buffer.ByteBufUtil;
|
||||
import io.netty.buffer.Unpooled;
|
||||
@ -79,23 +79,23 @@ public class BackendPlaySessionHandler implements MinecraftSessionHandler {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean handle(KeepAlivePacket packet) {
|
||||
public boolean handle(ClientboundKeepAlivePacket packet) {
|
||||
serverConn.setLastPingId(packet.getRandomId());
|
||||
return false; // forwards on
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean handle(DisconnectPacket packet) {
|
||||
public boolean handle(ClientboundDisconnectPacket packet) {
|
||||
serverConn.disconnect();
|
||||
serverConn.getPlayer().handleConnectionException(serverConn.getServer(), packet, true);
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean handle(BossBarPacket packet) {
|
||||
if (packet.getAction() == BossBarPacket.ADD) {
|
||||
public boolean handle(ClientboundBossBarPacket packet) {
|
||||
if (packet.getAction() == ClientboundBossBarPacket.ADD) {
|
||||
playerSessionHandler.getServerBossBars().add(packet.getUuid());
|
||||
} else if (packet.getAction() == BossBarPacket.REMOVE) {
|
||||
} else if (packet.getAction() == ClientboundBossBarPacket.REMOVE) {
|
||||
playerSessionHandler.getServerBossBars().remove(packet.getUuid());
|
||||
}
|
||||
return false; // forward
|
||||
@ -158,19 +158,19 @@ public class BackendPlaySessionHandler implements MinecraftSessionHandler {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean handle(TabCompleteResponsePacket packet) {
|
||||
public boolean handle(ClientboundTabCompleteResponsePacket packet) {
|
||||
playerSessionHandler.handleTabCompleteResponse(packet);
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean handle(PlayerListItemPacket packet) {
|
||||
public boolean handle(ClientboundPlayerListItemPacket packet) {
|
||||
serverConn.getPlayer().getTabList().processBackendPacket(packet);
|
||||
return false; //Forward packet to player
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean handle(AvailableCommandsPacket commands) {
|
||||
public boolean handle(ClientboundAvailableCommandsPacket commands) {
|
||||
RootCommandNode<CommandSource> rootNode = commands.getRootNode();
|
||||
if (server.getConfiguration().isAnnounceProxyCommands()) {
|
||||
// Inject commands from the proxy.
|
||||
@ -277,7 +277,7 @@ public class BackendPlaySessionHandler implements MinecraftSessionHandler {
|
||||
if (!serverConn.isGracefulDisconnect() && !exceptionTriggered) {
|
||||
if (server.getConfiguration().isFailoverOnUnexpectedServerDisconnect()) {
|
||||
serverConn.getPlayer().handleConnectionException(serverConn.getServer(),
|
||||
DisconnectPacket.create(ConnectionMessages.INTERNAL_SERVER_CONNECTION_ERROR,
|
||||
ClientboundDisconnectPacket.create(ConnectionMessages.INTERNAL_SERVER_CONNECTION_ERROR,
|
||||
ProtocolVersion.MINECRAFT_1_16), true);
|
||||
} else {
|
||||
serverConn.getPlayer().disconnect(ConnectionMessages.INTERNAL_SERVER_CONNECTION_ERROR);
|
||||
|
@ -9,9 +9,9 @@ import com.velocitypowered.api.util.UuidUtils;
|
||||
import com.velocitypowered.proxy.VelocityServer;
|
||||
import com.velocitypowered.proxy.connection.MinecraftConnection;
|
||||
import com.velocitypowered.proxy.connection.client.ConnectedPlayer;
|
||||
import com.velocitypowered.proxy.protocol.packet.PluginMessagePacket;
|
||||
import com.velocitypowered.proxy.protocol.util.ByteBufDataInput;
|
||||
import com.velocitypowered.proxy.protocol.util.ByteBufDataOutput;
|
||||
import com.velocitypowered.proxy.network.buffer.ByteBufDataInput;
|
||||
import com.velocitypowered.proxy.network.buffer.ByteBufDataOutput;
|
||||
import com.velocitypowered.proxy.network.packet.shared.PluginMessagePacket;
|
||||
import com.velocitypowered.proxy.server.VelocityRegisteredServer;
|
||||
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
|
@ -9,14 +9,14 @@ import com.velocitypowered.proxy.connection.MinecraftSessionHandler;
|
||||
import com.velocitypowered.proxy.connection.VelocityConstants;
|
||||
import com.velocitypowered.proxy.connection.util.ConnectionRequestResults;
|
||||
import com.velocitypowered.proxy.connection.util.ConnectionRequestResults.Impl;
|
||||
import com.velocitypowered.proxy.protocol.ProtocolUtils;
|
||||
import com.velocitypowered.proxy.protocol.StateRegistry;
|
||||
import com.velocitypowered.proxy.protocol.packet.DisconnectPacket;
|
||||
import com.velocitypowered.proxy.protocol.packet.EncryptionRequestPacket;
|
||||
import com.velocitypowered.proxy.protocol.packet.LoginPluginMessagePacket;
|
||||
import com.velocitypowered.proxy.protocol.packet.LoginPluginResponsePacket;
|
||||
import com.velocitypowered.proxy.protocol.packet.ServerLoginSuccessPacket;
|
||||
import com.velocitypowered.proxy.protocol.packet.SetCompressionPacket;
|
||||
import com.velocitypowered.proxy.network.ProtocolUtils;
|
||||
import com.velocitypowered.proxy.network.StateRegistry;
|
||||
import com.velocitypowered.proxy.network.packet.clientbound.ClientboundEncryptionRequestPacket;
|
||||
import com.velocitypowered.proxy.network.packet.clientbound.ClientboundLoginPluginMessagePacket;
|
||||
import com.velocitypowered.proxy.network.packet.clientbound.ClientboundServerLoginSuccessPacket;
|
||||
import com.velocitypowered.proxy.network.packet.clientbound.ClientboundSetCompressionPacket;
|
||||
import com.velocitypowered.proxy.network.packet.serverbound.ServerboundLoginPluginResponsePacket;
|
||||
import com.velocitypowered.proxy.network.packet.clientbound.ClientboundDisconnectPacket;
|
||||
import com.velocitypowered.proxy.util.except.QuietRuntimeException;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty.buffer.Unpooled;
|
||||
@ -49,12 +49,12 @@ public class LoginSessionHandler implements MinecraftSessionHandler {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean handle(EncryptionRequestPacket packet) {
|
||||
public boolean handle(ClientboundEncryptionRequestPacket packet) {
|
||||
throw new IllegalStateException("Backend server is online-mode!");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean handle(LoginPluginMessagePacket packet) {
|
||||
public boolean handle(ClientboundLoginPluginMessagePacket packet) {
|
||||
MinecraftConnection mc = serverConn.ensureConnected();
|
||||
VelocityConfiguration configuration = server.getConfiguration();
|
||||
if (configuration.getPlayerInfoForwardingMode() == PlayerInfoForwarding.MODERN && packet
|
||||
@ -62,32 +62,33 @@ public class LoginSessionHandler implements MinecraftSessionHandler {
|
||||
ByteBuf forwardingData = createForwardingData(configuration.getForwardingSecret(),
|
||||
cleanRemoteAddress(serverConn.getPlayer().getRemoteAddress()),
|
||||
serverConn.getPlayer().getGameProfile());
|
||||
LoginPluginResponsePacket response = new LoginPluginResponsePacket(packet.getId(), true,
|
||||
forwardingData);
|
||||
ServerboundLoginPluginResponsePacket response = new ServerboundLoginPluginResponsePacket(
|
||||
packet.getId(), true, forwardingData);
|
||||
mc.write(response);
|
||||
informationForwarded = true;
|
||||
} else {
|
||||
// Don't understand
|
||||
mc.write(new LoginPluginResponsePacket(packet.getId(), false, Unpooled.EMPTY_BUFFER));
|
||||
mc.write(new ServerboundLoginPluginResponsePacket(packet.getId(), false,
|
||||
Unpooled.EMPTY_BUFFER));
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean handle(DisconnectPacket packet) {
|
||||
public boolean handle(ClientboundDisconnectPacket packet) {
|
||||
resultFuture.complete(ConnectionRequestResults.forDisconnect(packet, serverConn.getServer()));
|
||||
serverConn.disconnect();
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean handle(SetCompressionPacket packet) {
|
||||
public boolean handle(ClientboundSetCompressionPacket packet) {
|
||||
serverConn.ensureConnected().setCompressionThreshold(packet.getThreshold());
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean handle(ServerLoginSuccessPacket packet) {
|
||||
public boolean handle(ClientboundServerLoginSuccessPacket packet) {
|
||||
if (server.getConfiguration().getPlayerInfoForwardingMode() == PlayerInfoForwarding.MODERN
|
||||
&& !informationForwarded) {
|
||||
resultFuture.complete(ConnectionRequestResults.forDisconnect(MODERN_IP_FORWARDING_FAILURE,
|
||||
|
@ -14,11 +14,11 @@ import com.velocitypowered.proxy.connection.client.ConnectedPlayer;
|
||||
import com.velocitypowered.proxy.connection.util.ConnectionMessages;
|
||||
import com.velocitypowered.proxy.connection.util.ConnectionRequestResults;
|
||||
import com.velocitypowered.proxy.connection.util.ConnectionRequestResults.Impl;
|
||||
import com.velocitypowered.proxy.protocol.packet.DisconnectPacket;
|
||||
import com.velocitypowered.proxy.protocol.packet.JoinGamePacket;
|
||||
import com.velocitypowered.proxy.protocol.packet.KeepAlivePacket;
|
||||
import com.velocitypowered.proxy.protocol.packet.PluginMessagePacket;
|
||||
import com.velocitypowered.proxy.protocol.util.PluginMessageUtil;
|
||||
import com.velocitypowered.proxy.network.PluginMessageUtil;
|
||||
import com.velocitypowered.proxy.network.packet.clientbound.ClientboundJoinGamePacket;
|
||||
import com.velocitypowered.proxy.network.packet.clientbound.ClientboundDisconnectPacket;
|
||||
import com.velocitypowered.proxy.network.packet.clientbound.ClientboundKeepAlivePacket;
|
||||
import com.velocitypowered.proxy.network.packet.shared.PluginMessagePacket;
|
||||
import java.io.IOException;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
@ -60,13 +60,13 @@ public class TransitionSessionHandler implements MinecraftSessionHandler {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean handle(KeepAlivePacket packet) {
|
||||
public boolean handle(ClientboundKeepAlivePacket packet) {
|
||||
serverConn.ensureConnected().write(packet);
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean handle(JoinGamePacket packet) {
|
||||
public boolean handle(ClientboundJoinGamePacket packet) {
|
||||
MinecraftConnection smc = serverConn.ensureConnected();
|
||||
VelocityServerConnection existingConnection = serverConn.getPlayer().getConnectedServer();
|
||||
|
||||
@ -132,7 +132,7 @@ public class TransitionSessionHandler implements MinecraftSessionHandler {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean handle(DisconnectPacket packet) {
|
||||
public boolean handle(ClientboundDisconnectPacket packet) {
|
||||
final MinecraftConnection connection = serverConn.ensureConnected();
|
||||
serverConn.disconnect();
|
||||
|
||||
|
@ -20,11 +20,11 @@ import com.velocitypowered.proxy.connection.MinecraftConnectionAssociation;
|
||||
import com.velocitypowered.proxy.connection.client.ConnectedPlayer;
|
||||
import com.velocitypowered.proxy.connection.registry.DimensionRegistry;
|
||||
import com.velocitypowered.proxy.connection.util.ConnectionRequestResults.Impl;
|
||||
import com.velocitypowered.proxy.protocol.StateRegistry;
|
||||
import com.velocitypowered.proxy.protocol.packet.HandshakePacket;
|
||||
import com.velocitypowered.proxy.protocol.packet.JoinGamePacket;
|
||||
import com.velocitypowered.proxy.protocol.packet.PluginMessagePacket;
|
||||
import com.velocitypowered.proxy.protocol.packet.ServerLoginPacket;
|
||||
import com.velocitypowered.proxy.network.StateRegistry;
|
||||
import com.velocitypowered.proxy.network.packet.clientbound.ClientboundJoinGamePacket;
|
||||
import com.velocitypowered.proxy.network.packet.serverbound.ServerboundHandshakePacket;
|
||||
import com.velocitypowered.proxy.network.packet.serverbound.ServerboundServerLoginPacket;
|
||||
import com.velocitypowered.proxy.network.packet.shared.PluginMessagePacket;
|
||||
import com.velocitypowered.proxy.server.VelocityRegisteredServer;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty.buffer.Unpooled;
|
||||
@ -143,7 +143,7 @@ public class VelocityServerConnection implements MinecraftConnectionAssociation,
|
||||
|
||||
// Initiate the handshake.
|
||||
ProtocolVersion protocolVersion = proxyPlayer.getConnection().getProtocolVersion();
|
||||
HandshakePacket handshake = new HandshakePacket();
|
||||
ServerboundHandshakePacket handshake = new ServerboundHandshakePacket();
|
||||
handshake.setNextStatus(StateRegistry.LOGIN_ID);
|
||||
handshake.setProtocolVersion(protocolVersion);
|
||||
if (forwardingMode == PlayerInfoForwarding.LEGACY) {
|
||||
@ -165,7 +165,7 @@ public class VelocityServerConnection implements MinecraftConnectionAssociation,
|
||||
|
||||
mc.setProtocolVersion(protocolVersion);
|
||||
mc.setState(StateRegistry.LOGIN);
|
||||
mc.delayedWrite(new ServerLoginPacket(proxyPlayer.getUsername()));
|
||||
mc.delayedWrite(new ServerboundServerLoginPacket(proxyPlayer.getUsername()));
|
||||
mc.flush();
|
||||
}
|
||||
|
||||
@ -308,7 +308,7 @@ public class VelocityServerConnection implements MinecraftConnectionAssociation,
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets whether the {@link JoinGamePacket}
|
||||
* Gets whether the {@link ClientboundJoinGamePacket}
|
||||
* packet has been sent by this server.
|
||||
*
|
||||
* @return Whether the join has been completed.
|
||||
|
@ -2,7 +2,7 @@ package com.velocitypowered.proxy.connection.client;
|
||||
|
||||
import com.velocitypowered.proxy.connection.backend.VelocityServerConnection;
|
||||
import com.velocitypowered.proxy.connection.forge.legacy.LegacyForgeHandshakeClientPhase;
|
||||
import com.velocitypowered.proxy.protocol.packet.PluginMessagePacket;
|
||||
import com.velocitypowered.proxy.network.packet.shared.PluginMessagePacket;
|
||||
|
||||
/**
|
||||
* Provides connection phase specific actions.
|
||||
|
@ -3,7 +3,7 @@ package com.velocitypowered.proxy.connection.client;
|
||||
import static com.velocitypowered.api.network.ProtocolVersion.MINECRAFT_1_13;
|
||||
import static com.velocitypowered.api.network.ProtocolVersion.MINECRAFT_1_16;
|
||||
import static com.velocitypowered.api.network.ProtocolVersion.MINECRAFT_1_8;
|
||||
import static com.velocitypowered.proxy.protocol.util.PluginMessageUtil.constructChannelsPacket;
|
||||
import static com.velocitypowered.proxy.network.PluginMessageUtil.constructChannelsPacket;
|
||||
|
||||
import com.velocitypowered.api.event.command.CommandExecuteEvent.CommandResult;
|
||||
import com.velocitypowered.api.event.connection.PluginMessageEvent;
|
||||
@ -19,22 +19,21 @@ import com.velocitypowered.proxy.connection.MinecraftSessionHandler;
|
||||
import com.velocitypowered.proxy.connection.backend.BackendConnectionPhases;
|
||||
import com.velocitypowered.proxy.connection.backend.BungeeCordMessageResponder;
|
||||
import com.velocitypowered.proxy.connection.backend.VelocityServerConnection;
|
||||
import com.velocitypowered.proxy.protocol.Packet;
|
||||
import com.velocitypowered.proxy.protocol.StateRegistry;
|
||||
import com.velocitypowered.proxy.protocol.packet.BossBarPacket;
|
||||
import com.velocitypowered.proxy.protocol.packet.ClientSettingsPacket;
|
||||
import com.velocitypowered.proxy.protocol.packet.ClientboundChatPacket;
|
||||
import com.velocitypowered.proxy.protocol.packet.JoinGamePacket;
|
||||
import com.velocitypowered.proxy.protocol.packet.KeepAlivePacket;
|
||||
import com.velocitypowered.proxy.protocol.packet.PluginMessagePacket;
|
||||
import com.velocitypowered.proxy.protocol.packet.ResourcePackResponsePacket;
|
||||
import com.velocitypowered.proxy.protocol.packet.RespawnPacket;
|
||||
import com.velocitypowered.proxy.protocol.packet.ServerboundChatPacket;
|
||||
import com.velocitypowered.proxy.protocol.packet.TabCompleteRequestPacket;
|
||||
import com.velocitypowered.proxy.protocol.packet.TabCompleteResponsePacket;
|
||||
import com.velocitypowered.proxy.protocol.packet.TabCompleteResponsePacket.Offer;
|
||||
import com.velocitypowered.proxy.protocol.packet.TitlePacket;
|
||||
import com.velocitypowered.proxy.protocol.util.PluginMessageUtil;
|
||||
import com.velocitypowered.proxy.network.PluginMessageUtil;
|
||||
import com.velocitypowered.proxy.network.StateRegistry;
|
||||
import com.velocitypowered.proxy.network.packet.Packet;
|
||||
import com.velocitypowered.proxy.network.packet.clientbound.ClientboundBossBarPacket;
|
||||
import com.velocitypowered.proxy.network.packet.clientbound.ClientboundJoinGamePacket;
|
||||
import com.velocitypowered.proxy.network.packet.clientbound.ClientboundRespawnPacket;
|
||||
import com.velocitypowered.proxy.network.packet.clientbound.ClientboundTabCompleteResponsePacket;
|
||||
import com.velocitypowered.proxy.network.packet.clientbound.ClientboundTabCompleteResponsePacket.Offer;
|
||||
import com.velocitypowered.proxy.network.packet.clientbound.ClientboundTitlePacket;
|
||||
import com.velocitypowered.proxy.network.packet.serverbound.ServerboundChatPacket;
|
||||
import com.velocitypowered.proxy.network.packet.serverbound.ServerboundClientSettingsPacket;
|
||||
import com.velocitypowered.proxy.network.packet.serverbound.ServerboundKeepAlivePacket;
|
||||
import com.velocitypowered.proxy.network.packet.serverbound.ServerboundResourcePackResponsePacket;
|
||||
import com.velocitypowered.proxy.network.packet.serverbound.ServerboundTabCompleteRequestPacket;
|
||||
import com.velocitypowered.proxy.network.packet.shared.PluginMessagePacket;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty.buffer.ByteBufUtil;
|
||||
import io.netty.buffer.Unpooled;
|
||||
@ -67,7 +66,7 @@ public class ClientPlaySessionHandler implements MinecraftSessionHandler {
|
||||
private final List<UUID> serverBossBars = new ArrayList<>();
|
||||
private final Queue<PluginMessagePacket> loginPluginMessages = new ArrayDeque<>();
|
||||
private final VelocityServer server;
|
||||
private @Nullable TabCompleteRequestPacket outstandingTabComplete;
|
||||
private @Nullable ServerboundTabCompleteRequestPacket outstandingTabComplete;
|
||||
|
||||
/**
|
||||
* Constructs a client play session handler.
|
||||
@ -98,7 +97,7 @@ public class ClientPlaySessionHandler implements MinecraftSessionHandler {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean handle(KeepAlivePacket packet) {
|
||||
public boolean handle(ServerboundKeepAlivePacket packet) {
|
||||
VelocityServerConnection serverConnection = player.getConnectedServer();
|
||||
if (serverConnection != null && packet.getRandomId() == serverConnection.getLastPingId()) {
|
||||
MinecraftConnection smc = serverConnection.getConnection();
|
||||
@ -112,13 +111,13 @@ public class ClientPlaySessionHandler implements MinecraftSessionHandler {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean handle(ClientSettingsPacket packet) {
|
||||
public boolean handle(ServerboundClientSettingsPacket packet) {
|
||||
player.setPlayerSettings(packet);
|
||||
return false; // will forward onto the server
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean handle(ClientboundChatPacket packet) {
|
||||
public boolean handle(ServerboundChatPacket packet) {
|
||||
VelocityServerConnection serverConnection = player.getConnectedServer();
|
||||
if (serverConnection == null) {
|
||||
return true;
|
||||
@ -170,7 +169,7 @@ public class ClientPlaySessionHandler implements MinecraftSessionHandler {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean handle(TabCompleteRequestPacket packet) {
|
||||
public boolean handle(ServerboundTabCompleteRequestPacket packet) {
|
||||
boolean isCommand = !packet.isAssumeCommand() && packet.getCommand().startsWith("/");
|
||||
|
||||
if (isCommand) {
|
||||
@ -250,7 +249,7 @@ public class ClientPlaySessionHandler implements MinecraftSessionHandler {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean handle(ResourcePackResponsePacket packet) {
|
||||
public boolean handle(ServerboundResourcePackResponsePacket packet) {
|
||||
server.getEventManager().fireAndForget(new PlayerResourcePackStatusEvent(player,
|
||||
packet.getStatus()));
|
||||
return false;
|
||||
@ -321,7 +320,8 @@ public class ClientPlaySessionHandler implements MinecraftSessionHandler {
|
||||
* @param joinGame the join game packet
|
||||
* @param destination the new server we are connecting to
|
||||
*/
|
||||
public void handleBackendJoinGame(JoinGamePacket joinGame, VelocityServerConnection destination) {
|
||||
public void handleBackendJoinGame(ClientboundJoinGamePacket joinGame,
|
||||
VelocityServerConnection destination) {
|
||||
final MinecraftConnection serverMc = destination.ensureConnected();
|
||||
|
||||
if (!spawned) {
|
||||
@ -346,9 +346,9 @@ public class ClientPlaySessionHandler implements MinecraftSessionHandler {
|
||||
// Remove previous boss bars. These don't get cleared when sending JoinGame, thus the need to
|
||||
// track them.
|
||||
for (UUID serverBossBar : serverBossBars) {
|
||||
BossBarPacket deletePacket = new BossBarPacket();
|
||||
ClientboundBossBarPacket deletePacket = new ClientboundBossBarPacket();
|
||||
deletePacket.setUuid(serverBossBar);
|
||||
deletePacket.setAction(BossBarPacket.REMOVE);
|
||||
deletePacket.setAction(ClientboundBossBarPacket.REMOVE);
|
||||
player.getConnection().delayedWrite(deletePacket);
|
||||
}
|
||||
serverBossBars.clear();
|
||||
@ -368,7 +368,7 @@ public class ClientPlaySessionHandler implements MinecraftSessionHandler {
|
||||
// Clear any title from the previous server.
|
||||
if (player.getProtocolVersion().gte(MINECRAFT_1_8)) {
|
||||
player.getConnection()
|
||||
.delayedWrite(TitlePacket.reset(player.getProtocolVersion()));
|
||||
.delayedWrite(ClientboundTitlePacket.reset(player.getProtocolVersion()));
|
||||
}
|
||||
|
||||
// Flush everything
|
||||
@ -377,7 +377,7 @@ public class ClientPlaySessionHandler implements MinecraftSessionHandler {
|
||||
destination.completeJoin();
|
||||
}
|
||||
|
||||
private void doFastClientServerSwitch(JoinGamePacket joinGame) {
|
||||
private void doFastClientServerSwitch(ClientboundJoinGamePacket joinGame) {
|
||||
// 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
|
||||
@ -396,13 +396,13 @@ public class ClientPlaySessionHandler implements MinecraftSessionHandler {
|
||||
player.getConnection().delayedWrite(joinGame);
|
||||
|
||||
player.getConnection().delayedWrite(
|
||||
new RespawnPacket(sentOldDim, joinGame.getPartialHashedSeed(),
|
||||
new ClientboundRespawnPacket(sentOldDim, joinGame.getPartialHashedSeed(),
|
||||
joinGame.getDifficulty(), joinGame.getGamemode(), joinGame.getLevelType(),
|
||||
false, joinGame.getDimensionInfo(), joinGame.getPreviousGamemode(),
|
||||
joinGame.getCurrentDimensionData()));
|
||||
}
|
||||
|
||||
private void doSafeClientServerSwitch(JoinGamePacket joinGame) {
|
||||
private void doSafeClientServerSwitch(ClientboundJoinGamePacket joinGame) {
|
||||
// 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
|
||||
// same effect but tend to work better with buggier clients (Forge 1.8 in particular).
|
||||
@ -413,14 +413,14 @@ public class ClientPlaySessionHandler implements MinecraftSessionHandler {
|
||||
// Send a respawn packet in a different dimension.
|
||||
int tempDim = joinGame.getDimension() == 0 ? -1 : 0;
|
||||
player.getConnection().delayedWrite(
|
||||
new RespawnPacket(tempDim, joinGame.getPartialHashedSeed(), joinGame.getDifficulty(),
|
||||
joinGame.getGamemode(), joinGame.getLevelType(),
|
||||
new ClientboundRespawnPacket(tempDim, joinGame.getPartialHashedSeed(),
|
||||
joinGame.getDifficulty(), joinGame.getGamemode(), joinGame.getLevelType(),
|
||||
false, joinGame.getDimensionInfo(), joinGame.getPreviousGamemode(),
|
||||
joinGame.getCurrentDimensionData()));
|
||||
|
||||
// Now send a respawn packet in the correct dimension.
|
||||
player.getConnection().delayedWrite(
|
||||
new RespawnPacket(joinGame.getDimension(), joinGame.getPartialHashedSeed(),
|
||||
new ClientboundRespawnPacket(joinGame.getDimension(), joinGame.getPartialHashedSeed(),
|
||||
joinGame.getDifficulty(), joinGame.getGamemode(), joinGame.getLevelType(),
|
||||
false, joinGame.getDimensionInfo(), joinGame.getPreviousGamemode(),
|
||||
joinGame.getCurrentDimensionData()));
|
||||
@ -430,7 +430,7 @@ public class ClientPlaySessionHandler implements MinecraftSessionHandler {
|
||||
return serverBossBars;
|
||||
}
|
||||
|
||||
private boolean handleCommandTabComplete(TabCompleteRequestPacket packet) {
|
||||
private boolean handleCommandTabComplete(ServerboundTabCompleteRequestPacket packet) {
|
||||
// In 1.13+, we need to do additional work for the richer suggestions available.
|
||||
String command = packet.getCommand().substring(1);
|
||||
int commandEndPosition = command.indexOf(' ');
|
||||
@ -460,7 +460,7 @@ public class ClientPlaySessionHandler implements MinecraftSessionHandler {
|
||||
}
|
||||
int startPos = packet.getCommand().lastIndexOf(' ') + 1;
|
||||
if (startPos > 0) {
|
||||
TabCompleteResponsePacket resp = new TabCompleteResponsePacket();
|
||||
ClientboundTabCompleteResponsePacket resp = new ClientboundTabCompleteResponsePacket();
|
||||
resp.setTransactionId(packet.getTransactionId());
|
||||
resp.setStart(startPos);
|
||||
resp.setLength(packet.getCommand().length() - startPos);
|
||||
@ -476,7 +476,7 @@ public class ClientPlaySessionHandler implements MinecraftSessionHandler {
|
||||
return true; // Sorry, handler; we're just gonna have to lie to you here.
|
||||
}
|
||||
|
||||
private boolean handleRegularTabComplete(TabCompleteRequestPacket packet) {
|
||||
private boolean handleRegularTabComplete(ServerboundTabCompleteRequestPacket packet) {
|
||||
if (player.getProtocolVersion().lt(MINECRAFT_1_13)) {
|
||||
// Outstanding tab completes are recorded for use with 1.12 clients and below to provide
|
||||
// additional tab completion support.
|
||||
@ -490,7 +490,7 @@ public class ClientPlaySessionHandler implements MinecraftSessionHandler {
|
||||
*
|
||||
* @param response the tab complete response from the backend
|
||||
*/
|
||||
public void handleTabCompleteResponse(TabCompleteResponsePacket response) {
|
||||
public void handleTabCompleteResponse(ClientboundTabCompleteResponsePacket response) {
|
||||
if (outstandingTabComplete != null && !outstandingTabComplete.isAssumeCommand()) {
|
||||
if (outstandingTabComplete.getCommand().startsWith("/")) {
|
||||
this.finishCommandTabComplete(outstandingTabComplete, response);
|
||||
@ -504,8 +504,8 @@ public class ClientPlaySessionHandler implements MinecraftSessionHandler {
|
||||
}
|
||||
}
|
||||
|
||||
private void finishCommandTabComplete(TabCompleteRequestPacket request,
|
||||
TabCompleteResponsePacket response) {
|
||||
private void finishCommandTabComplete(ServerboundTabCompleteRequestPacket request,
|
||||
ClientboundTabCompleteResponsePacket response) {
|
||||
String command = request.getCommand().substring(1);
|
||||
server.getCommandManager().offerSuggestions(player, command)
|
||||
.thenAcceptAsync(offers -> {
|
||||
@ -534,8 +534,8 @@ public class ClientPlaySessionHandler implements MinecraftSessionHandler {
|
||||
});
|
||||
}
|
||||
|
||||
private void finishRegularTabComplete(TabCompleteRequestPacket request,
|
||||
TabCompleteResponsePacket response) {
|
||||
private void finishRegularTabComplete(ServerboundTabCompleteRequestPacket request,
|
||||
ClientboundTabCompleteResponsePacket response) {
|
||||
List<String> offers = new ArrayList<>();
|
||||
for (Offer offer : response.getOffers()) {
|
||||
offers.add(offer.getText());
|
||||
|
@ -2,20 +2,20 @@ package com.velocitypowered.proxy.connection.client;
|
||||
|
||||
import com.velocitypowered.api.proxy.player.PlayerSettings;
|
||||
import com.velocitypowered.api.proxy.player.SkinParts;
|
||||
import com.velocitypowered.proxy.protocol.packet.ClientSettingsPacket;
|
||||
import com.velocitypowered.proxy.network.packet.serverbound.ServerboundClientSettingsPacket;
|
||||
import java.util.Locale;
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
|
||||
public class ClientSettingsWrapper implements PlayerSettings {
|
||||
|
||||
static final PlayerSettings DEFAULT = new ClientSettingsWrapper(
|
||||
new ClientSettingsPacket("en_US", (byte) 10, 0, true, (short) 127, 1));
|
||||
new ServerboundClientSettingsPacket("en_US", (byte) 10, 0, true, (short) 127, 1));
|
||||
|
||||
private final ClientSettingsPacket settings;
|
||||
private final ServerboundClientSettingsPacket settings;
|
||||
private final SkinParts parts;
|
||||
private @Nullable Locale locale;
|
||||
|
||||
ClientSettingsWrapper(ClientSettingsPacket settings) {
|
||||
ClientSettingsWrapper(ServerboundClientSettingsPacket settings) {
|
||||
this.settings = settings;
|
||||
this.parts = new SkinParts((byte) settings.getSkinParts());
|
||||
}
|
||||
|
@ -36,17 +36,17 @@ import com.velocitypowered.proxy.connection.backend.VelocityServerConnection;
|
||||
import com.velocitypowered.proxy.connection.forge.legacy.LegacyForgeConstants;
|
||||
import com.velocitypowered.proxy.connection.util.ConnectionMessages;
|
||||
import com.velocitypowered.proxy.connection.util.ConnectionRequestResults.Impl;
|
||||
import com.velocitypowered.proxy.protocol.ProtocolUtils;
|
||||
import com.velocitypowered.proxy.protocol.StateRegistry;
|
||||
import com.velocitypowered.proxy.protocol.packet.ClientSettingsPacket;
|
||||
import com.velocitypowered.proxy.protocol.packet.ClientboundChatPacket;
|
||||
import com.velocitypowered.proxy.protocol.packet.DisconnectPacket;
|
||||
import com.velocitypowered.proxy.protocol.packet.KeepAlivePacket;
|
||||
import com.velocitypowered.proxy.protocol.packet.PluginMessagePacket;
|
||||
import com.velocitypowered.proxy.protocol.packet.ResourcePackRequestPacket;
|
||||
import com.velocitypowered.proxy.protocol.packet.ServerboundChatPacket;
|
||||
import com.velocitypowered.proxy.protocol.packet.TitlePacket;
|
||||
import com.velocitypowered.proxy.protocol.util.PluginMessageUtil;
|
||||
import com.velocitypowered.proxy.network.PluginMessageUtil;
|
||||
import com.velocitypowered.proxy.network.ProtocolUtils;
|
||||
import com.velocitypowered.proxy.network.StateRegistry;
|
||||
import com.velocitypowered.proxy.network.packet.clientbound.ClientboundChatPacket;
|
||||
import com.velocitypowered.proxy.network.packet.clientbound.ClientboundKeepAlivePacket;
|
||||
import com.velocitypowered.proxy.network.packet.clientbound.ClientboundResourcePackRequestPacket;
|
||||
import com.velocitypowered.proxy.network.packet.clientbound.ClientboundTitlePacket;
|
||||
import com.velocitypowered.proxy.network.packet.serverbound.ServerboundChatPacket;
|
||||
import com.velocitypowered.proxy.network.packet.serverbound.ServerboundClientSettingsPacket;
|
||||
import com.velocitypowered.proxy.network.packet.clientbound.ClientboundDisconnectPacket;
|
||||
import com.velocitypowered.proxy.network.packet.shared.PluginMessagePacket;
|
||||
import com.velocitypowered.proxy.server.VelocityRegisteredServer;
|
||||
import com.velocitypowered.proxy.tablist.VelocityTabList;
|
||||
import com.velocitypowered.proxy.tablist.VelocityTabListLegacy;
|
||||
@ -186,7 +186,7 @@ public class ConnectedPlayer implements MinecraftConnectionAssociation, Player {
|
||||
return settings == null ? ClientSettingsWrapper.DEFAULT : this.settings;
|
||||
}
|
||||
|
||||
void setPlayerSettings(ClientSettingsPacket settings) {
|
||||
void setPlayerSettings(ServerboundClientSettingsPacket settings) {
|
||||
ClientSettingsWrapper cs = new ClientSettingsWrapper(settings);
|
||||
this.settings = cs;
|
||||
server.getEventManager().fireAndForget(new PlayerSettingsChangedEvent(this, cs));
|
||||
@ -246,8 +246,8 @@ public class ConnectedPlayer implements MinecraftConnectionAssociation, Player {
|
||||
ProtocolVersion playerVersion = getProtocolVersion();
|
||||
if (playerVersion.gte(ProtocolVersion.MINECRAFT_1_11)) {
|
||||
// Use the title packet instead.
|
||||
connection.write(new TitlePacket(
|
||||
TitlePacket.SET_ACTION_BAR,
|
||||
connection.write(new ClientboundTitlePacket(
|
||||
ClientboundTitlePacket.SET_ACTION_BAR,
|
||||
ProtocolUtils.getJsonChatSerializer(playerVersion).serialize(message)
|
||||
));
|
||||
} else {
|
||||
@ -268,19 +268,19 @@ public class ConnectedPlayer implements MinecraftConnectionAssociation, Player {
|
||||
GsonComponentSerializer serializer = ProtocolUtils.getJsonChatSerializer(this
|
||||
.getProtocolVersion());
|
||||
|
||||
connection.delayedWrite(new TitlePacket(
|
||||
TitlePacket.SET_TITLE,
|
||||
connection.delayedWrite(new ClientboundTitlePacket(
|
||||
ClientboundTitlePacket.SET_TITLE,
|
||||
serializer.serialize(title.title())
|
||||
));
|
||||
|
||||
connection.delayedWrite(new TitlePacket(
|
||||
TitlePacket.SET_SUBTITLE,
|
||||
connection.delayedWrite(new ClientboundTitlePacket(
|
||||
ClientboundTitlePacket.SET_SUBTITLE,
|
||||
serializer.serialize(title.subtitle())
|
||||
));
|
||||
|
||||
net.kyori.adventure.title.Title.Times times = title.times();
|
||||
if (times != null) {
|
||||
connection.delayedWrite(TitlePacket.times(this.getProtocolVersion(), times));
|
||||
connection.delayedWrite(ClientboundTitlePacket.times(this.getProtocolVersion(), times));
|
||||
}
|
||||
|
||||
connection.flush();
|
||||
@ -288,12 +288,12 @@ public class ConnectedPlayer implements MinecraftConnectionAssociation, Player {
|
||||
|
||||
@Override
|
||||
public void clearTitle() {
|
||||
connection.write(TitlePacket.hide(this.getProtocolVersion()));
|
||||
connection.write(ClientboundTitlePacket.hide(this.getProtocolVersion()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void resetTitle() {
|
||||
connection.write(TitlePacket.reset(this.getProtocolVersion()));
|
||||
connection.write(ClientboundTitlePacket.reset(this.getProtocolVersion()));
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -338,7 +338,7 @@ public class ConnectedPlayer implements MinecraftConnectionAssociation, Player {
|
||||
public void disconnect0(Component reason, boolean duringLogin) {
|
||||
logger.info("{} has disconnected: {}", this,
|
||||
LegacyComponentSerializer.legacySection().serialize(reason));
|
||||
connection.closeWith(DisconnectPacket.create(reason, this.getProtocolVersion()));
|
||||
connection.closeWith(ClientboundDisconnectPacket.create(reason, this.getProtocolVersion()));
|
||||
}
|
||||
|
||||
public @Nullable VelocityServerConnection getConnectedServer() {
|
||||
@ -397,7 +397,7 @@ public class ConnectedPlayer implements MinecraftConnectionAssociation, Player {
|
||||
* @param disconnect the disconnect packet
|
||||
* @param safe whether or not we can safely reconnect to a new server
|
||||
*/
|
||||
public void handleConnectionException(RegisteredServer server, DisconnectPacket disconnect,
|
||||
public void handleConnectionException(RegisteredServer server, ClientboundDisconnectPacket disconnect,
|
||||
boolean safe) {
|
||||
if (!isActive()) {
|
||||
// If the connection is no longer active, it makes no sense to try and recover it.
|
||||
@ -502,7 +502,7 @@ public class ConnectedPlayer implements MinecraftConnectionAssociation, Player {
|
||||
case SERVER_DISCONNECTED:
|
||||
Component reason = status.getReason()
|
||||
.orElse(ConnectionMessages.INTERNAL_SERVER_CONNECTION_ERROR);
|
||||
handleConnectionException(res.getServer(), DisconnectPacket.create(reason,
|
||||
handleConnectionException(res.getServer(), ClientboundDisconnectPacket.create(reason,
|
||||
getProtocolVersion()), ((Impl) status).isSafe());
|
||||
break;
|
||||
case SUCCESS:
|
||||
@ -677,10 +677,7 @@ public class ConnectedPlayer implements MinecraftConnectionAssociation, Player {
|
||||
public void sendResourcePack(String url) {
|
||||
Preconditions.checkNotNull(url, "url");
|
||||
|
||||
ResourcePackRequestPacket request = new ResourcePackRequestPacket();
|
||||
request.setUrl(url);
|
||||
request.setHash("");
|
||||
connection.write(request);
|
||||
connection.write(new ClientboundResourcePackRequestPacket(url, ""));
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -689,20 +686,17 @@ public class ConnectedPlayer implements MinecraftConnectionAssociation, Player {
|
||||
Preconditions.checkNotNull(hash, "hash");
|
||||
Preconditions.checkArgument(hash.length == 20, "Hash length is not 20");
|
||||
|
||||
ResourcePackRequestPacket request = new ResourcePackRequestPacket();
|
||||
request.setUrl(url);
|
||||
request.setHash(ByteBufUtil.hexDump(hash));
|
||||
connection.write(request);
|
||||
connection.write(new ClientboundResourcePackRequestPacket(url, ByteBufUtil.hexDump(hash)));
|
||||
}
|
||||
|
||||
/**
|
||||
* Sends a {@link KeepAlivePacket} packet to the player with a random ID.
|
||||
* Sends a {@link ClientboundKeepAlivePacket} packet to the player with a random ID.
|
||||
* The response will be ignored by Velocity as it will not match the
|
||||
* ID last sent by the server.
|
||||
*/
|
||||
public void sendKeepAlive() {
|
||||
if (connection.getState() == StateRegistry.PLAY) {
|
||||
connection.write(new KeepAlivePacket(ThreadLocalRandom.current().nextLong()));
|
||||
connection.write(new ClientboundKeepAlivePacket(ThreadLocalRandom.current().nextLong()));
|
||||
}
|
||||
}
|
||||
|
||||
@ -873,7 +867,7 @@ public class ConnectedPlayer implements MinecraftConnectionAssociation, Player {
|
||||
case SERVER_DISCONNECTED:
|
||||
Component reason = status.getReason()
|
||||
.orElse(ConnectionMessages.INTERNAL_SERVER_CONNECTION_ERROR);
|
||||
handleConnectionException(toConnect, DisconnectPacket.create(reason,
|
||||
handleConnectionException(toConnect, ClientboundDisconnectPacket.create(reason,
|
||||
getProtocolVersion()), status.isSafe());
|
||||
break;
|
||||
default:
|
||||
|
@ -12,12 +12,12 @@ import com.velocitypowered.proxy.connection.ConnectionTypes;
|
||||
import com.velocitypowered.proxy.connection.MinecraftConnection;
|
||||
import com.velocitypowered.proxy.connection.MinecraftSessionHandler;
|
||||
import com.velocitypowered.proxy.connection.forge.legacy.LegacyForgeConstants;
|
||||
import com.velocitypowered.proxy.protocol.Packet;
|
||||
import com.velocitypowered.proxy.protocol.StateRegistry;
|
||||
import com.velocitypowered.proxy.protocol.packet.HandshakePacket;
|
||||
import com.velocitypowered.proxy.protocol.packet.legacy.LegacyDisconnectPacket;
|
||||
import com.velocitypowered.proxy.protocol.packet.legacy.LegacyHandshakePacket;
|
||||
import com.velocitypowered.proxy.protocol.packet.legacy.LegacyPingPacket;
|
||||
import com.velocitypowered.proxy.network.StateRegistry;
|
||||
import com.velocitypowered.proxy.network.packet.Packet;
|
||||
import com.velocitypowered.proxy.network.packet.legacy.LegacyDisconnectPacket;
|
||||
import com.velocitypowered.proxy.network.packet.legacy.LegacyHandshakePacket;
|
||||
import com.velocitypowered.proxy.network.packet.legacy.LegacyPingPacket;
|
||||
import com.velocitypowered.proxy.network.packet.serverbound.ServerboundHandshakePacket;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import java.net.InetAddress;
|
||||
import java.net.InetSocketAddress;
|
||||
@ -58,7 +58,7 @@ public class HandshakeSessionHandler implements MinecraftSessionHandler {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean handle(HandshakePacket handshake) {
|
||||
public boolean handle(ServerboundHandshakePacket handshake) {
|
||||
InitialInboundConnection ic = new InitialInboundConnection(connection,
|
||||
cleanVhost(handshake.getServerAddress()), handshake);
|
||||
StateRegistry nextState = getStateForProtocol(handshake.getNextStatus());
|
||||
@ -97,7 +97,7 @@ public class HandshakeSessionHandler implements MinecraftSessionHandler {
|
||||
}
|
||||
}
|
||||
|
||||
private void handleLogin(HandshakePacket handshake, InitialInboundConnection ic) {
|
||||
private void handleLogin(ServerboundHandshakePacket handshake, InitialInboundConnection ic) {
|
||||
if (!ProtocolVersion.isSupported(handshake.getProtocolVersion())) {
|
||||
ic.disconnectQuietly(Component.translatable("multiplayer.disconnect.outdated_client"));
|
||||
return;
|
||||
@ -123,7 +123,7 @@ public class HandshakeSessionHandler implements MinecraftSessionHandler {
|
||||
connection.setSessionHandler(new LoginSessionHandler(server, connection, ic));
|
||||
}
|
||||
|
||||
private ConnectionType getHandshakeConnectionType(HandshakePacket handshake) {
|
||||
private ConnectionType getHandshakeConnectionType(ServerboundHandshakePacket handshake) {
|
||||
// Determine if we're using Forge (1.8 to 1.12, may not be the case in 1.13).
|
||||
if (handshake.getServerAddress().endsWith(LegacyForgeConstants.HANDSHAKE_HOSTNAME_TOKEN)
|
||||
&& handshake.getProtocolVersion().lt(ProtocolVersion.MINECRAFT_1_13)) {
|
||||
|
@ -3,8 +3,8 @@ package com.velocitypowered.proxy.connection.client;
|
||||
import com.velocitypowered.proxy.connection.MinecraftSessionHandler;
|
||||
import com.velocitypowered.proxy.connection.backend.BungeeCordMessageResponder;
|
||||
import com.velocitypowered.proxy.connection.backend.VelocityServerConnection;
|
||||
import com.velocitypowered.proxy.protocol.packet.PluginMessagePacket;
|
||||
import com.velocitypowered.proxy.protocol.util.PluginMessageUtil;
|
||||
import com.velocitypowered.proxy.network.PluginMessageUtil;
|
||||
import com.velocitypowered.proxy.network.packet.shared.PluginMessagePacket;
|
||||
|
||||
public class InitialConnectSessionHandler implements MinecraftSessionHandler {
|
||||
|
||||
|
@ -4,8 +4,8 @@ import com.velocitypowered.api.network.ProtocolVersion;
|
||||
import com.velocitypowered.api.proxy.connection.InboundConnection;
|
||||
import com.velocitypowered.proxy.connection.MinecraftConnection;
|
||||
import com.velocitypowered.proxy.connection.MinecraftConnectionAssociation;
|
||||
import com.velocitypowered.proxy.protocol.packet.DisconnectPacket;
|
||||
import com.velocitypowered.proxy.protocol.packet.HandshakePacket;
|
||||
import com.velocitypowered.proxy.network.packet.serverbound.ServerboundHandshakePacket;
|
||||
import com.velocitypowered.proxy.network.packet.clientbound.ClientboundDisconnectPacket;
|
||||
import java.net.InetSocketAddress;
|
||||
import java.util.Optional;
|
||||
import net.kyori.adventure.text.Component;
|
||||
@ -20,10 +20,10 @@ public final class InitialInboundConnection implements InboundConnection,
|
||||
|
||||
private final MinecraftConnection connection;
|
||||
private final String cleanedAddress;
|
||||
private final HandshakePacket handshake;
|
||||
private final ServerboundHandshakePacket handshake;
|
||||
|
||||
InitialInboundConnection(MinecraftConnection connection, String cleanedAddress,
|
||||
HandshakePacket handshake) {
|
||||
ServerboundHandshakePacket handshake) {
|
||||
this.connection = connection;
|
||||
this.cleanedAddress = cleanedAddress;
|
||||
this.handshake = handshake;
|
||||
@ -61,7 +61,7 @@ public final class InitialInboundConnection implements InboundConnection,
|
||||
public void disconnect(Component reason) {
|
||||
logger.info("{} has disconnected: {}", this,
|
||||
LegacyComponentSerializer.legacySection().serialize(reason));
|
||||
connection.closeWith(DisconnectPacket.create(reason, getProtocolVersion()));
|
||||
connection.closeWith(ClientboundDisconnectPacket.create(reason, getProtocolVersion()));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -69,6 +69,6 @@ public final class InitialInboundConnection implements InboundConnection,
|
||||
* @param reason the reason for disconnecting
|
||||
*/
|
||||
public void disconnectQuietly(Component reason) {
|
||||
connection.closeWith(DisconnectPacket.create(reason, getProtocolVersion()));
|
||||
connection.closeWith(ClientboundDisconnectPacket.create(reason, getProtocolVersion()));
|
||||
}
|
||||
}
|
||||
|
@ -25,13 +25,13 @@ import com.velocitypowered.proxy.config.PlayerInfoForwarding;
|
||||
import com.velocitypowered.proxy.config.VelocityConfiguration;
|
||||
import com.velocitypowered.proxy.connection.MinecraftConnection;
|
||||
import com.velocitypowered.proxy.connection.MinecraftSessionHandler;
|
||||
import com.velocitypowered.proxy.protocol.StateRegistry;
|
||||
import com.velocitypowered.proxy.protocol.packet.DisconnectPacket;
|
||||
import com.velocitypowered.proxy.protocol.packet.EncryptionRequestPacket;
|
||||
import com.velocitypowered.proxy.protocol.packet.EncryptionResponsePacket;
|
||||
import com.velocitypowered.proxy.protocol.packet.ServerLoginPacket;
|
||||
import com.velocitypowered.proxy.protocol.packet.ServerLoginSuccessPacket;
|
||||
import com.velocitypowered.proxy.protocol.packet.SetCompressionPacket;
|
||||
import com.velocitypowered.proxy.network.StateRegistry;
|
||||
import com.velocitypowered.proxy.network.packet.clientbound.ClientboundEncryptionRequestPacket;
|
||||
import com.velocitypowered.proxy.network.packet.clientbound.ClientboundServerLoginSuccessPacket;
|
||||
import com.velocitypowered.proxy.network.packet.clientbound.ClientboundSetCompressionPacket;
|
||||
import com.velocitypowered.proxy.network.packet.serverbound.ServerboundEncryptionResponsePacket;
|
||||
import com.velocitypowered.proxy.network.packet.serverbound.ServerboundServerLoginPacket;
|
||||
import com.velocitypowered.proxy.network.packet.clientbound.ClientboundDisconnectPacket;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import java.net.InetSocketAddress;
|
||||
import java.security.GeneralSecurityException;
|
||||
@ -58,7 +58,7 @@ public class LoginSessionHandler implements MinecraftSessionHandler {
|
||||
private final VelocityServer server;
|
||||
private final MinecraftConnection mcConnection;
|
||||
private final InitialInboundConnection inbound;
|
||||
private @MonotonicNonNull ServerLoginPacket login;
|
||||
private @MonotonicNonNull ServerboundServerLoginPacket login;
|
||||
private byte[] verify = EMPTY_BYTE_ARRAY;
|
||||
private @MonotonicNonNull ConnectedPlayer connectedPlayer;
|
||||
|
||||
@ -70,15 +70,15 @@ public class LoginSessionHandler implements MinecraftSessionHandler {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean handle(ServerLoginPacket packet) {
|
||||
public boolean handle(ServerboundServerLoginPacket packet) {
|
||||
this.login = packet;
|
||||
beginPreLogin();
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean handle(EncryptionResponsePacket packet) {
|
||||
ServerLoginPacket login = this.login;
|
||||
public boolean handle(ServerboundEncryptionResponsePacket packet) {
|
||||
ServerboundServerLoginPacket login = this.login;
|
||||
if (login == null) {
|
||||
throw new IllegalStateException("No ServerLogin packet received yet.");
|
||||
}
|
||||
@ -153,7 +153,7 @@ public class LoginSessionHandler implements MinecraftSessionHandler {
|
||||
}
|
||||
|
||||
private void beginPreLogin() {
|
||||
ServerLoginPacket login = this.login;
|
||||
ServerboundServerLoginPacket login = this.login;
|
||||
if (login == null) {
|
||||
throw new IllegalStateException("No ServerLogin packet received yet.");
|
||||
}
|
||||
@ -169,7 +169,7 @@ public class LoginSessionHandler implements MinecraftSessionHandler {
|
||||
Optional<Component> disconnectReason = result.getReason();
|
||||
if (disconnectReason.isPresent()) {
|
||||
// The component is guaranteed to be provided if the connection was denied.
|
||||
mcConnection.closeWith(DisconnectPacket.create(disconnectReason.get(),
|
||||
mcConnection.closeWith(ClientboundDisconnectPacket.create(disconnectReason.get(),
|
||||
inbound.getProtocolVersion()));
|
||||
return;
|
||||
}
|
||||
@ -177,7 +177,7 @@ public class LoginSessionHandler implements MinecraftSessionHandler {
|
||||
if (!result.isForceOfflineMode() && (server.getConfiguration().isOnlineMode() || result
|
||||
.isOnlineModeAllowed())) {
|
||||
// Request encryption.
|
||||
EncryptionRequestPacket request = generateEncryptionRequest();
|
||||
ClientboundEncryptionRequestPacket request = generateEncryptionRequest();
|
||||
this.verify = Arrays.copyOf(request.getVerifyToken(), 4);
|
||||
mcConnection.write(request);
|
||||
} else {
|
||||
@ -190,11 +190,11 @@ public class LoginSessionHandler implements MinecraftSessionHandler {
|
||||
});
|
||||
}
|
||||
|
||||
private EncryptionRequestPacket generateEncryptionRequest() {
|
||||
private ClientboundEncryptionRequestPacket generateEncryptionRequest() {
|
||||
byte[] verify = new byte[4];
|
||||
ThreadLocalRandom.current().nextBytes(verify);
|
||||
|
||||
EncryptionRequestPacket request = new EncryptionRequestPacket();
|
||||
ClientboundEncryptionRequestPacket request = new ClientboundEncryptionRequestPacket();
|
||||
request.setPublicKey(server.getServerKeyPair().getPublic().getEncoded());
|
||||
request.setVerifyToken(verify);
|
||||
return request;
|
||||
@ -243,7 +243,7 @@ public class LoginSessionHandler implements MinecraftSessionHandler {
|
||||
private void completeLoginProtocolPhaseAndInitialize(ConnectedPlayer player) {
|
||||
int threshold = server.getConfiguration().getCompressionThreshold();
|
||||
if (threshold >= 0 && mcConnection.getProtocolVersion().gte(MINECRAFT_1_8)) {
|
||||
mcConnection.write(new SetCompressionPacket(threshold));
|
||||
mcConnection.write(new ClientboundSetCompressionPacket(threshold));
|
||||
mcConnection.setCompressionThreshold(threshold);
|
||||
}
|
||||
VelocityConfiguration configuration = server.getConfiguration();
|
||||
@ -251,10 +251,7 @@ public class LoginSessionHandler implements MinecraftSessionHandler {
|
||||
if (configuration.getPlayerInfoForwardingMode() == PlayerInfoForwarding.NONE) {
|
||||
playerUniqueId = UuidUtils.generateOfflinePlayerUuid(player.getUsername());
|
||||
}
|
||||
ServerLoginSuccessPacket success = new ServerLoginSuccessPacket();
|
||||
success.setUsername(player.getUsername());
|
||||
success.setUuid(playerUniqueId);
|
||||
mcConnection.write(success);
|
||||
mcConnection.write(new ClientboundServerLoginSuccessPacket(playerUniqueId, player.getUsername()));
|
||||
|
||||
mcConnection.setAssociation(player);
|
||||
mcConnection.setState(StateRegistry.PLAY);
|
||||
|
@ -13,11 +13,11 @@ import com.velocitypowered.proxy.config.PingPassthroughMode;
|
||||
import com.velocitypowered.proxy.config.VelocityConfiguration;
|
||||
import com.velocitypowered.proxy.connection.MinecraftConnection;
|
||||
import com.velocitypowered.proxy.connection.MinecraftSessionHandler;
|
||||
import com.velocitypowered.proxy.protocol.packet.StatusPingPacket;
|
||||
import com.velocitypowered.proxy.protocol.packet.StatusRequestPacket;
|
||||
import com.velocitypowered.proxy.protocol.packet.StatusResponsePacket;
|
||||
import com.velocitypowered.proxy.protocol.packet.legacy.LegacyDisconnectPacket;
|
||||
import com.velocitypowered.proxy.protocol.packet.legacy.LegacyPingPacket;
|
||||
import com.velocitypowered.proxy.network.packet.clientbound.ClientboundStatusResponsePacket;
|
||||
import com.velocitypowered.proxy.network.packet.legacy.LegacyDisconnectPacket;
|
||||
import com.velocitypowered.proxy.network.packet.legacy.LegacyPingPacket;
|
||||
import com.velocitypowered.proxy.network.packet.serverbound.ServerboundStatusPingPacket;
|
||||
import com.velocitypowered.proxy.network.packet.serverbound.ServerboundStatusRequestPacket;
|
||||
import com.velocitypowered.proxy.server.VelocityRegisteredServer;
|
||||
import com.velocitypowered.proxy.util.except.QuietRuntimeException;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
@ -176,13 +176,13 @@ public class StatusSessionHandler implements MinecraftSessionHandler {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean handle(StatusPingPacket packet) {
|
||||
public boolean handle(ServerboundStatusPingPacket packet) {
|
||||
connection.closeWith(packet);
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean handle(StatusRequestPacket packet) {
|
||||
public boolean handle(ServerboundStatusRequestPacket packet) {
|
||||
if (this.pingReceived) {
|
||||
throw EXPECTED_AWAITING_REQUEST;
|
||||
}
|
||||
@ -195,7 +195,7 @@ public class StatusSessionHandler implements MinecraftSessionHandler {
|
||||
StringBuilder json = new StringBuilder();
|
||||
VelocityServer.getPingGsonInstance(connection.getProtocolVersion())
|
||||
.toJson(event.getPing(), json);
|
||||
connection.write(new StatusResponsePacket(json));
|
||||
connection.write(new ClientboundStatusResponsePacket(json));
|
||||
},
|
||||
connection.eventLoop())
|
||||
.exceptionally((ex) -> {
|
||||
|
@ -6,7 +6,7 @@ import com.velocitypowered.proxy.connection.backend.BackendConnectionPhase;
|
||||
import com.velocitypowered.proxy.connection.backend.BackendConnectionPhases;
|
||||
import com.velocitypowered.proxy.connection.backend.VelocityServerConnection;
|
||||
import com.velocitypowered.proxy.connection.client.ConnectedPlayer;
|
||||
import com.velocitypowered.proxy.protocol.packet.PluginMessagePacket;
|
||||
import com.velocitypowered.proxy.network.packet.shared.PluginMessagePacket;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
/**
|
||||
|
@ -7,7 +7,7 @@ import com.velocitypowered.proxy.connection.backend.VelocityServerConnection;
|
||||
import com.velocitypowered.proxy.connection.client.ClientConnectionPhase;
|
||||
import com.velocitypowered.proxy.connection.client.ClientPlaySessionHandler;
|
||||
import com.velocitypowered.proxy.connection.client.ConnectedPlayer;
|
||||
import com.velocitypowered.proxy.protocol.packet.PluginMessagePacket;
|
||||
import com.velocitypowered.proxy.network.packet.shared.PluginMessagePacket;
|
||||
import java.util.List;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
|
@ -7,8 +7,8 @@ import static com.velocitypowered.proxy.connection.forge.legacy.LegacyForgeConst
|
||||
import com.google.common.base.Preconditions;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.velocitypowered.api.util.ModInfo;
|
||||
import com.velocitypowered.proxy.protocol.ProtocolUtils;
|
||||
import com.velocitypowered.proxy.protocol.packet.PluginMessagePacket;
|
||||
import com.velocitypowered.proxy.network.ProtocolUtils;
|
||||
import com.velocitypowered.proxy.network.packet.shared.PluginMessagePacket;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty.buffer.Unpooled;
|
||||
import java.util.List;
|
||||
|
@ -3,7 +3,7 @@ package com.velocitypowered.proxy.connection.util;
|
||||
import com.velocitypowered.api.proxy.player.ConnectionRequestBuilder;
|
||||
import com.velocitypowered.api.proxy.player.ConnectionRequestBuilder.Status;
|
||||
import com.velocitypowered.api.proxy.server.RegisteredServer;
|
||||
import com.velocitypowered.proxy.protocol.packet.DisconnectPacket;
|
||||
import com.velocitypowered.proxy.network.packet.clientbound.ClientboundDisconnectPacket;
|
||||
import java.util.Optional;
|
||||
import javax.annotation.Nullable;
|
||||
import net.kyori.adventure.text.Component;
|
||||
@ -41,12 +41,12 @@ public class ConnectionRequestResults {
|
||||
return new Impl(Status.SERVER_DISCONNECTED, component, server, true);
|
||||
}
|
||||
|
||||
public static Impl forDisconnect(DisconnectPacket disconnect, RegisteredServer server) {
|
||||
public static Impl forDisconnect(ClientboundDisconnectPacket disconnect, RegisteredServer server) {
|
||||
Component deserialized = GsonComponentSerializer.gson().deserialize(disconnect.getReason());
|
||||
return forDisconnect(deserialized, server);
|
||||
}
|
||||
|
||||
public static Impl forUnsafeDisconnect(DisconnectPacket disconnect, RegisteredServer server) {
|
||||
public static Impl forUnsafeDisconnect(ClientboundDisconnectPacket disconnect, RegisteredServer server) {
|
||||
Component deserialized = GsonComponentSerializer.gson().deserialize(disconnect.getReason());
|
||||
return new Impl(Status.SERVER_DISCONNECTED, deserialized, server, false);
|
||||
}
|
||||
|
@ -8,12 +8,12 @@ import static com.velocitypowered.proxy.network.Connections.MINECRAFT_ENCODER;
|
||||
import static com.velocitypowered.proxy.network.Connections.READ_TIMEOUT;
|
||||
|
||||
import com.velocitypowered.proxy.VelocityServer;
|
||||
import com.velocitypowered.proxy.protocol.ProtocolDirection;
|
||||
import com.velocitypowered.proxy.protocol.netty.AutoReadHolderHandler;
|
||||
import com.velocitypowered.proxy.protocol.netty.MinecraftDecoder;
|
||||
import com.velocitypowered.proxy.protocol.netty.MinecraftEncoder;
|
||||
import com.velocitypowered.proxy.protocol.netty.MinecraftVarintFrameDecoder;
|
||||
import com.velocitypowered.proxy.protocol.netty.MinecraftVarintLengthEncoder;
|
||||
import com.velocitypowered.proxy.network.packet.PacketDirection;
|
||||
import com.velocitypowered.proxy.network.pipeline.AutoReadHolderHandler;
|
||||
import com.velocitypowered.proxy.network.pipeline.MinecraftDecoder;
|
||||
import com.velocitypowered.proxy.network.pipeline.MinecraftEncoder;
|
||||
import com.velocitypowered.proxy.network.pipeline.MinecraftVarintFrameDecoder;
|
||||
import com.velocitypowered.proxy.network.pipeline.MinecraftVarintLengthEncoder;
|
||||
import io.netty.channel.Channel;
|
||||
import io.netty.channel.ChannelInitializer;
|
||||
import io.netty.handler.timeout.ReadTimeoutHandler;
|
||||
@ -37,9 +37,9 @@ public class BackendChannelInitializer extends ChannelInitializer<Channel> {
|
||||
.addLast(FRAME_DECODER, new MinecraftVarintFrameDecoder())
|
||||
.addLast(FRAME_ENCODER, MinecraftVarintLengthEncoder.INSTANCE)
|
||||
.addLast(MINECRAFT_DECODER,
|
||||
new MinecraftDecoder(ProtocolDirection.CLIENTBOUND))
|
||||
new MinecraftDecoder(PacketDirection.CLIENTBOUND))
|
||||
.addLast(FLOW_HANDLER, new AutoReadHolderHandler())
|
||||
.addLast(MINECRAFT_ENCODER,
|
||||
new MinecraftEncoder(ProtocolDirection.SERVERBOUND));
|
||||
new MinecraftEncoder(PacketDirection.SERVERBOUND));
|
||||
}
|
||||
}
|
||||
|
@ -1,11 +0,0 @@
|
||||
package com.velocitypowered.proxy.network;
|
||||
|
||||
import io.netty.channel.Channel;
|
||||
import io.netty.channel.ChannelInitializer;
|
||||
|
||||
final class BackendChannelInitializerHolder extends ChannelInitializerHolder<Channel> {
|
||||
|
||||
BackendChannelInitializerHolder(final ChannelInitializer<Channel> initializer) {
|
||||
super("backend channel", initializer);
|
||||
}
|
||||
}
|
@ -6,8 +6,7 @@ import java.util.function.Supplier;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
||||
public abstract class ChannelInitializerHolder<C extends Channel>
|
||||
implements Supplier<ChannelInitializer<C>> {
|
||||
public class ChannelInitializerHolder<C extends Channel> implements Supplier<ChannelInitializer<C>> {
|
||||
private static final Logger LOGGER = LogManager.getLogger(ChannelInitializerHolder.class);
|
||||
private final String name;
|
||||
private ChannelInitializer<C> initializer;
|
||||
|
@ -6,8 +6,8 @@ import static org.asynchttpclient.Dsl.config;
|
||||
import com.google.common.base.Preconditions;
|
||||
import com.velocitypowered.natives.util.Natives;
|
||||
import com.velocitypowered.proxy.VelocityServer;
|
||||
import com.velocitypowered.proxy.network.netty.SeparatePoolInetNameResolver;
|
||||
import com.velocitypowered.proxy.protocol.netty.GS4QueryHandler;
|
||||
import com.velocitypowered.proxy.network.pipeline.GS4QueryHandler;
|
||||
import com.velocitypowered.proxy.network.resolver.SeparatePoolInetNameResolver;
|
||||
import io.netty.bootstrap.Bootstrap;
|
||||
import io.netty.bootstrap.ServerBootstrap;
|
||||
import io.netty.channel.Channel;
|
||||
@ -60,9 +60,9 @@ public final class ConnectionManager {
|
||||
this.transportType = TransportType.bestType();
|
||||
this.bossGroup = this.transportType.createEventLoopGroup(TransportType.Type.BOSS);
|
||||
this.workerGroup = this.transportType.createEventLoopGroup(TransportType.Type.WORKER);
|
||||
this.serverChannelInitializer = new ServerChannelInitializerHolder(
|
||||
this.serverChannelInitializer = new ChannelInitializerHolder<>("server channel",
|
||||
new ServerChannelInitializer(this.server));
|
||||
this.backendChannelInitializer = new BackendChannelInitializerHolder(
|
||||
this.backendChannelInitializer = new ChannelInitializerHolder<>("backend channel",
|
||||
new BackendChannelInitializer(this.server));
|
||||
this.resolver = new SeparatePoolInetNameResolver(GlobalEventExecutor.INSTANCE);
|
||||
this.httpClient = asyncHttpClient(config()
|
||||
|
@ -1,7 +1,7 @@
|
||||
package com.velocitypowered.proxy.protocol.util;
|
||||
package com.velocitypowered.proxy.network;
|
||||
|
||||
import com.google.common.base.Strings;
|
||||
import com.velocitypowered.proxy.protocol.netty.MinecraftDecoder;
|
||||
import com.velocitypowered.proxy.network.pipeline.MinecraftDecoder;
|
||||
import com.velocitypowered.proxy.util.except.QuietDecoderException;
|
||||
import io.netty.handler.codec.CorruptedFrameException;
|
||||
|
@ -1,4 +1,4 @@
|
||||
package com.velocitypowered.proxy.protocol.util;
|
||||
package com.velocitypowered.proxy.network;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkArgument;
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
@ -6,8 +6,7 @@ import static com.google.common.base.Preconditions.checkNotNull;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.velocitypowered.api.network.ProtocolVersion;
|
||||
import com.velocitypowered.api.util.ProxyVersion;
|
||||
import com.velocitypowered.proxy.protocol.ProtocolUtils;
|
||||
import com.velocitypowered.proxy.protocol.packet.PluginMessagePacket;
|
||||
import com.velocitypowered.proxy.network.packet.shared.PluginMessagePacket;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty.buffer.Unpooled;
|
||||
import java.nio.charset.StandardCharsets;
|
@ -1,12 +1,12 @@
|
||||
package com.velocitypowered.proxy.protocol;
|
||||
package com.velocitypowered.proxy.network;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkArgument;
|
||||
import static com.velocitypowered.proxy.protocol.util.NettyPreconditions.checkFrame;
|
||||
import static com.velocitypowered.proxy.network.NettyPreconditions.checkFrame;
|
||||
|
||||
import com.velocitypowered.api.network.ProtocolVersion;
|
||||
import com.velocitypowered.api.util.GameProfile;
|
||||
import com.velocitypowered.proxy.protocol.netty.MinecraftDecoder;
|
||||
import com.velocitypowered.proxy.protocol.util.VelocityLegacyHoverEventSerializer;
|
||||
import com.velocitypowered.proxy.network.pipeline.MinecraftDecoder;
|
||||
import com.velocitypowered.proxy.network.serialization.VelocityLegacyHoverEventSerializer;
|
||||
import com.velocitypowered.proxy.util.except.QuietDecoderException;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty.buffer.ByteBufInputStream;
|
@ -11,13 +11,13 @@ import static com.velocitypowered.proxy.network.Connections.READ_TIMEOUT;
|
||||
import com.velocitypowered.proxy.VelocityServer;
|
||||
import com.velocitypowered.proxy.connection.MinecraftConnection;
|
||||
import com.velocitypowered.proxy.connection.client.HandshakeSessionHandler;
|
||||
import com.velocitypowered.proxy.protocol.ProtocolDirection;
|
||||
import com.velocitypowered.proxy.protocol.netty.LegacyPingDecoder;
|
||||
import com.velocitypowered.proxy.protocol.netty.LegacyPingEncoder;
|
||||
import com.velocitypowered.proxy.protocol.netty.MinecraftDecoder;
|
||||
import com.velocitypowered.proxy.protocol.netty.MinecraftEncoder;
|
||||
import com.velocitypowered.proxy.protocol.netty.MinecraftVarintFrameDecoder;
|
||||
import com.velocitypowered.proxy.protocol.netty.MinecraftVarintLengthEncoder;
|
||||
import com.velocitypowered.proxy.network.packet.PacketDirection;
|
||||
import com.velocitypowered.proxy.network.pipeline.LegacyPingDecoder;
|
||||
import com.velocitypowered.proxy.network.pipeline.LegacyPingEncoder;
|
||||
import com.velocitypowered.proxy.network.pipeline.MinecraftDecoder;
|
||||
import com.velocitypowered.proxy.network.pipeline.MinecraftEncoder;
|
||||
import com.velocitypowered.proxy.network.pipeline.MinecraftVarintFrameDecoder;
|
||||
import com.velocitypowered.proxy.network.pipeline.MinecraftVarintLengthEncoder;
|
||||
import io.netty.channel.Channel;
|
||||
import io.netty.channel.ChannelInitializer;
|
||||
import io.netty.handler.codec.haproxy.HAProxyMessageDecoder;
|
||||
@ -43,8 +43,8 @@ public class ServerChannelInitializer extends ChannelInitializer<Channel> {
|
||||
.addLast(FRAME_DECODER, new MinecraftVarintFrameDecoder())
|
||||
.addLast(LEGACY_PING_ENCODER, LegacyPingEncoder.INSTANCE)
|
||||
.addLast(FRAME_ENCODER, MinecraftVarintLengthEncoder.INSTANCE)
|
||||
.addLast(MINECRAFT_DECODER, new MinecraftDecoder(ProtocolDirection.SERVERBOUND))
|
||||
.addLast(MINECRAFT_ENCODER, new MinecraftEncoder(ProtocolDirection.CLIENTBOUND));
|
||||
.addLast(MINECRAFT_DECODER, new MinecraftDecoder(PacketDirection.SERVERBOUND))
|
||||
.addLast(MINECRAFT_ENCODER, new MinecraftEncoder(PacketDirection.CLIENTBOUND));
|
||||
|
||||
final MinecraftConnection connection = new MinecraftConnection(ch, this.server);
|
||||
connection.setSessionHandler(new HandshakeSessionHandler(connection, this.server));
|
||||
|
@ -1,11 +0,0 @@
|
||||
package com.velocitypowered.proxy.network;
|
||||
|
||||
import io.netty.channel.Channel;
|
||||
import io.netty.channel.ChannelInitializer;
|
||||
|
||||
final class ServerChannelInitializerHolder extends ChannelInitializerHolder<Channel> {
|
||||
|
||||
ServerChannelInitializerHolder(final ChannelInitializer<Channel> initializer) {
|
||||
super("server channel", initializer);
|
||||
}
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
package com.velocitypowered.proxy.protocol;
|
||||
package com.velocitypowered.proxy.network;
|
||||
|
||||
import static com.google.common.collect.Iterables.getLast;
|
||||
import static com.velocitypowered.api.network.ProtocolVersion.MINECRAFT_1_12;
|
||||
@ -16,34 +16,38 @@ import static com.velocitypowered.api.network.ProtocolVersion.MINIMUM_VERSION;
|
||||
import static com.velocitypowered.api.network.ProtocolVersion.SUPPORTED_VERSIONS;
|
||||
|
||||
import com.velocitypowered.api.network.ProtocolVersion;
|
||||
import com.velocitypowered.proxy.protocol.packet.AvailableCommandsPacket;
|
||||
import com.velocitypowered.proxy.protocol.packet.BossBarPacket;
|
||||
import com.velocitypowered.proxy.protocol.packet.ClientSettingsPacket;
|
||||
import com.velocitypowered.proxy.protocol.packet.ClientboundChatPacket;
|
||||
import com.velocitypowered.proxy.protocol.packet.DisconnectPacket;
|
||||
import com.velocitypowered.proxy.protocol.packet.EncryptionRequestPacket;
|
||||
import com.velocitypowered.proxy.protocol.packet.EncryptionResponsePacket;
|
||||
import com.velocitypowered.proxy.protocol.packet.HandshakePacket;
|
||||
import com.velocitypowered.proxy.protocol.packet.HeaderAndFooterPacket;
|
||||
import com.velocitypowered.proxy.protocol.packet.JoinGamePacket;
|
||||
import com.velocitypowered.proxy.protocol.packet.KeepAlivePacket;
|
||||
import com.velocitypowered.proxy.protocol.packet.LoginPluginMessagePacket;
|
||||
import com.velocitypowered.proxy.protocol.packet.LoginPluginResponsePacket;
|
||||
import com.velocitypowered.proxy.protocol.packet.PlayerListItemPacket;
|
||||
import com.velocitypowered.proxy.protocol.packet.PluginMessagePacket;
|
||||
import com.velocitypowered.proxy.protocol.packet.ResourcePackRequestPacket;
|
||||
import com.velocitypowered.proxy.protocol.packet.ResourcePackResponsePacket;
|
||||
import com.velocitypowered.proxy.protocol.packet.RespawnPacket;
|
||||
import com.velocitypowered.proxy.protocol.packet.ServerLoginPacket;
|
||||
import com.velocitypowered.proxy.protocol.packet.ServerLoginSuccessPacket;
|
||||
import com.velocitypowered.proxy.protocol.packet.ServerboundChatPacket;
|
||||
import com.velocitypowered.proxy.protocol.packet.SetCompressionPacket;
|
||||
import com.velocitypowered.proxy.protocol.packet.StatusPingPacket;
|
||||
import com.velocitypowered.proxy.protocol.packet.StatusRequestPacket;
|
||||
import com.velocitypowered.proxy.protocol.packet.StatusResponsePacket;
|
||||
import com.velocitypowered.proxy.protocol.packet.TabCompleteRequestPacket;
|
||||
import com.velocitypowered.proxy.protocol.packet.TabCompleteResponsePacket;
|
||||
import com.velocitypowered.proxy.protocol.packet.TitlePacket;
|
||||
import com.velocitypowered.proxy.network.packet.Packet;
|
||||
import com.velocitypowered.proxy.network.packet.PacketDirection;
|
||||
import com.velocitypowered.proxy.network.packet.clientbound.ClientboundAvailableCommandsPacket;
|
||||
import com.velocitypowered.proxy.network.packet.clientbound.ClientboundBossBarPacket;
|
||||
import com.velocitypowered.proxy.network.packet.clientbound.ClientboundChatPacket;
|
||||
import com.velocitypowered.proxy.network.packet.clientbound.ClientboundEncryptionRequestPacket;
|
||||
import com.velocitypowered.proxy.network.packet.clientbound.ClientboundHeaderAndFooterPacket;
|
||||
import com.velocitypowered.proxy.network.packet.clientbound.ClientboundJoinGamePacket;
|
||||
import com.velocitypowered.proxy.network.packet.clientbound.ClientboundKeepAlivePacket;
|
||||
import com.velocitypowered.proxy.network.packet.clientbound.ClientboundLoginPluginMessagePacket;
|
||||
import com.velocitypowered.proxy.network.packet.clientbound.ClientboundPlayerListItemPacket;
|
||||
import com.velocitypowered.proxy.network.packet.clientbound.ClientboundResourcePackRequestPacket;
|
||||
import com.velocitypowered.proxy.network.packet.clientbound.ClientboundRespawnPacket;
|
||||
import com.velocitypowered.proxy.network.packet.clientbound.ClientboundServerLoginSuccessPacket;
|
||||
import com.velocitypowered.proxy.network.packet.clientbound.ClientboundSetCompressionPacket;
|
||||
import com.velocitypowered.proxy.network.packet.clientbound.ClientboundStatusPingPacket;
|
||||
import com.velocitypowered.proxy.network.packet.clientbound.ClientboundStatusResponsePacket;
|
||||
import com.velocitypowered.proxy.network.packet.clientbound.ClientboundTabCompleteResponsePacket;
|
||||
import com.velocitypowered.proxy.network.packet.clientbound.ClientboundTitlePacket;
|
||||
import com.velocitypowered.proxy.network.packet.serverbound.ServerboundChatPacket;
|
||||
import com.velocitypowered.proxy.network.packet.serverbound.ServerboundClientSettingsPacket;
|
||||
import com.velocitypowered.proxy.network.packet.serverbound.ServerboundEncryptionResponsePacket;
|
||||
import com.velocitypowered.proxy.network.packet.serverbound.ServerboundHandshakePacket;
|
||||
import com.velocitypowered.proxy.network.packet.serverbound.ServerboundKeepAlivePacket;
|
||||
import com.velocitypowered.proxy.network.packet.serverbound.ServerboundLoginPluginResponsePacket;
|
||||
import com.velocitypowered.proxy.network.packet.serverbound.ServerboundResourcePackResponsePacket;
|
||||
import com.velocitypowered.proxy.network.packet.serverbound.ServerboundServerLoginPacket;
|
||||
import com.velocitypowered.proxy.network.packet.serverbound.ServerboundStatusPingPacket;
|
||||
import com.velocitypowered.proxy.network.packet.serverbound.ServerboundStatusRequestPacket;
|
||||
import com.velocitypowered.proxy.network.packet.serverbound.ServerboundTabCompleteRequestPacket;
|
||||
import com.velocitypowered.proxy.network.packet.clientbound.ClientboundDisconnectPacket;
|
||||
import com.velocitypowered.proxy.network.packet.shared.PluginMessagePacket;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty.util.collection.IntObjectHashMap;
|
||||
import io.netty.util.collection.IntObjectMap;
|
||||
@ -61,123 +65,182 @@ public enum StateRegistry {
|
||||
|
||||
HANDSHAKE(true) {
|
||||
{
|
||||
serverbound.register(HandshakePacket.class, HandshakePacket.DECODER,
|
||||
map(0x00, MINECRAFT_1_7_2, false));
|
||||
serverbound.register(
|
||||
ServerboundHandshakePacket.class,
|
||||
ServerboundHandshakePacket.DECODER,
|
||||
map(0x00, MINECRAFT_1_7_2, false)
|
||||
);
|
||||
}
|
||||
},
|
||||
STATUS(true) {
|
||||
{
|
||||
serverbound.register(StatusRequestPacket.class, StatusRequestPacket.DECODER,
|
||||
map(0x00, MINECRAFT_1_7_2, false));
|
||||
serverbound.register(StatusPingPacket.class, StatusPingPacket.DECODER,
|
||||
map(0x01, MINECRAFT_1_7_2, false));
|
||||
serverbound.register(
|
||||
ServerboundStatusRequestPacket.class,
|
||||
ServerboundStatusRequestPacket.DECODER,
|
||||
map(0x00, MINECRAFT_1_7_2, false)
|
||||
);
|
||||
serverbound.register(
|
||||
ServerboundStatusPingPacket.class,
|
||||
ServerboundStatusPingPacket.DECODER,
|
||||
map(0x01, MINECRAFT_1_7_2, false)
|
||||
);
|
||||
|
||||
clientbound.register(StatusResponsePacket.class, StatusResponsePacket.DECODER,
|
||||
map(0x00, MINECRAFT_1_7_2, false));
|
||||
clientbound.register(StatusPingPacket.class, StatusPingPacket.DECODER,
|
||||
map(0x01, MINECRAFT_1_7_2, false));
|
||||
clientbound.register(
|
||||
ClientboundStatusResponsePacket.class,
|
||||
ClientboundStatusResponsePacket.DECODER,
|
||||
map(0x00, MINECRAFT_1_7_2, false)
|
||||
);
|
||||
clientbound.register(
|
||||
ClientboundStatusPingPacket.class,
|
||||
ClientboundStatusPingPacket.DECODER,
|
||||
map(0x01, MINECRAFT_1_7_2, false)
|
||||
);
|
||||
}
|
||||
},
|
||||
PLAY(false) {
|
||||
{
|
||||
serverbound.register(TabCompleteRequestPacket.class, TabCompleteRequestPacket.DECODER,
|
||||
serverbound.register(
|
||||
ServerboundTabCompleteRequestPacket.class,
|
||||
ServerboundTabCompleteRequestPacket.DECODER,
|
||||
map(0x14, MINECRAFT_1_7_2, false),
|
||||
map(0x01, MINECRAFT_1_9, false),
|
||||
map(0x02, MINECRAFT_1_12, false),
|
||||
map(0x01, MINECRAFT_1_12_1, false),
|
||||
map(0x05, MINECRAFT_1_13, false),
|
||||
map(0x06, MINECRAFT_1_14, false));
|
||||
serverbound.register(ServerboundChatPacket.class, ServerboundChatPacket.DECODER,
|
||||
map(0x06, MINECRAFT_1_14, false)
|
||||
);
|
||||
serverbound.register(
|
||||
ServerboundChatPacket.class,
|
||||
ServerboundChatPacket.DECODER,
|
||||
map(0x01, MINECRAFT_1_7_2, false),
|
||||
map(0x02, MINECRAFT_1_9, false),
|
||||
map(0x03, MINECRAFT_1_12, false),
|
||||
map(0x02, MINECRAFT_1_12_1, false),
|
||||
map(0x03, MINECRAFT_1_14, false));
|
||||
serverbound.register(ClientSettingsPacket.class, ClientSettingsPacket.DECODER,
|
||||
map(0x03, MINECRAFT_1_14, false)
|
||||
);
|
||||
serverbound.register(
|
||||
ServerboundClientSettingsPacket.class,
|
||||
ServerboundClientSettingsPacket.DECODER,
|
||||
map(0x15, MINECRAFT_1_7_2, false),
|
||||
map(0x04, MINECRAFT_1_9, false),
|
||||
map(0x05, MINECRAFT_1_12, false),
|
||||
map(0x04, MINECRAFT_1_12_1, false),
|
||||
map(0x05, MINECRAFT_1_14, false));
|
||||
serverbound.register(PluginMessagePacket.class, PluginMessagePacket.DECODER,
|
||||
map(0x05, MINECRAFT_1_14, false)
|
||||
);
|
||||
serverbound.register(
|
||||
PluginMessagePacket.class,
|
||||
PluginMessagePacket.DECODER,
|
||||
map(0x17, MINECRAFT_1_7_2, false),
|
||||
map(0x09, MINECRAFT_1_9, false),
|
||||
map(0x0A, MINECRAFT_1_12, false),
|
||||
map(0x09, MINECRAFT_1_12_1, false),
|
||||
map(0x0A, MINECRAFT_1_13, false),
|
||||
map(0x0B, MINECRAFT_1_14, false));
|
||||
serverbound.register(KeepAlivePacket.class, KeepAlivePacket.DECODER,
|
||||
map(0x0B, MINECRAFT_1_14, false)
|
||||
);
|
||||
serverbound.register(
|
||||
ServerboundKeepAlivePacket.class,
|
||||
ServerboundKeepAlivePacket.DECODER,
|
||||
map(0x00, MINECRAFT_1_7_2, false),
|
||||
map(0x0B, MINECRAFT_1_9, false),
|
||||
map(0x0C, MINECRAFT_1_12, false),
|
||||
map(0x0B, MINECRAFT_1_12_1, false),
|
||||
map(0x0E, MINECRAFT_1_13, false),
|
||||
map(0x0F, MINECRAFT_1_14, false),
|
||||
map(0x10, MINECRAFT_1_16, false));
|
||||
serverbound.register(ResourcePackResponsePacket.class, ResourcePackResponsePacket.DECODER,
|
||||
map(0x10, MINECRAFT_1_16, false)
|
||||
);
|
||||
serverbound.register(
|
||||
ServerboundResourcePackResponsePacket.class,
|
||||
ServerboundResourcePackResponsePacket.DECODER,
|
||||
map(0x19, MINECRAFT_1_8, false),
|
||||
map(0x16, MINECRAFT_1_9, false),
|
||||
map(0x18, MINECRAFT_1_12, false),
|
||||
map(0x1D, MINECRAFT_1_13, false),
|
||||
map(0x1F, MINECRAFT_1_14, false),
|
||||
map(0x20, MINECRAFT_1_16, false),
|
||||
map(0x21, MINECRAFT_1_16_2, false));
|
||||
map(0x21, MINECRAFT_1_16_2, false)
|
||||
);
|
||||
|
||||
clientbound.register(BossBarPacket.class, BossBarPacket.DECODER,
|
||||
clientbound.register(
|
||||
ClientboundBossBarPacket.class,
|
||||
ClientboundBossBarPacket.DECODER,
|
||||
map(0x0C, MINECRAFT_1_9, false),
|
||||
map(0x0D, MINECRAFT_1_15, false),
|
||||
map(0x0C, MINECRAFT_1_16, false));
|
||||
clientbound.register(ClientboundChatPacket.class, ClientboundChatPacket.DECODER,
|
||||
map(0x0C, MINECRAFT_1_16, false)
|
||||
);
|
||||
clientbound.register(
|
||||
ClientboundChatPacket.class,
|
||||
ClientboundChatPacket.DECODER,
|
||||
map(0x02, MINECRAFT_1_7_2, true),
|
||||
map(0x0F, MINECRAFT_1_9, true),
|
||||
map(0x0E, MINECRAFT_1_13, true),
|
||||
map(0x0F, MINECRAFT_1_15, true),
|
||||
map(0x0E, MINECRAFT_1_16, true));
|
||||
clientbound.register(TabCompleteResponsePacket.class, TabCompleteResponsePacket.DECODER,
|
||||
map(0x0E, MINECRAFT_1_16, true)
|
||||
);
|
||||
clientbound.register(
|
||||
ClientboundTabCompleteResponsePacket.class,
|
||||
ClientboundTabCompleteResponsePacket.DECODER,
|
||||
map(0x3A, MINECRAFT_1_7_2, false),
|
||||
map(0x0E, MINECRAFT_1_9, false),
|
||||
map(0x10, MINECRAFT_1_13, false),
|
||||
map(0x11, MINECRAFT_1_15, false),
|
||||
map(0x10, MINECRAFT_1_16, false),
|
||||
map(0x0F, MINECRAFT_1_16_2, false));
|
||||
clientbound.register(AvailableCommandsPacket.class, AvailableCommandsPacket.DECODER,
|
||||
map(0x0F, MINECRAFT_1_16_2, false)
|
||||
);
|
||||
clientbound.register(
|
||||
ClientboundAvailableCommandsPacket.class,
|
||||
ClientboundAvailableCommandsPacket.DECODER,
|
||||
map(0x11, MINECRAFT_1_13, false),
|
||||
map(0x12, MINECRAFT_1_15, false),
|
||||
map(0x11, MINECRAFT_1_16, false),
|
||||
map(0x10, MINECRAFT_1_16_2, false));
|
||||
clientbound.register(PluginMessagePacket.class, PluginMessagePacket.DECODER,
|
||||
map(0x10, MINECRAFT_1_16_2, false)
|
||||
);
|
||||
clientbound.register(
|
||||
PluginMessagePacket.class,
|
||||
PluginMessagePacket.DECODER,
|
||||
map(0x3F, MINECRAFT_1_7_2, false),
|
||||
map(0x18, MINECRAFT_1_9, false),
|
||||
map(0x19, MINECRAFT_1_13, false),
|
||||
map(0x18, MINECRAFT_1_14, false),
|
||||
map(0x19, MINECRAFT_1_15, false),
|
||||
map(0x18, MINECRAFT_1_16, false),
|
||||
map(0x17, MINECRAFT_1_16_2, false));
|
||||
clientbound.register(DisconnectPacket.class, DisconnectPacket.DECODER,
|
||||
map(0x17, MINECRAFT_1_16_2, false)
|
||||
);
|
||||
clientbound.register(
|
||||
ClientboundDisconnectPacket.class,
|
||||
ClientboundDisconnectPacket.DECODER,
|
||||
map(0x40, MINECRAFT_1_7_2, false),
|
||||
map(0x1A, MINECRAFT_1_9, false),
|
||||
map(0x1B, MINECRAFT_1_13, false),
|
||||
map(0x1A, MINECRAFT_1_14, false),
|
||||
map(0x1B, MINECRAFT_1_15, false),
|
||||
map(0x1A, MINECRAFT_1_16, false),
|
||||
map(0x19, MINECRAFT_1_16_2, false));
|
||||
clientbound.register(KeepAlivePacket.class, KeepAlivePacket.DECODER,
|
||||
map(0x19, MINECRAFT_1_16_2, false)
|
||||
);
|
||||
clientbound.register(
|
||||
ClientboundKeepAlivePacket.class,
|
||||
ClientboundKeepAlivePacket.DECODER,
|
||||
map(0x00, MINECRAFT_1_7_2, false),
|
||||
map(0x1F, MINECRAFT_1_9, false),
|
||||
map(0x21, MINECRAFT_1_13, false),
|
||||
map(0x20, MINECRAFT_1_14, false),
|
||||
map(0x21, MINECRAFT_1_15, false),
|
||||
map(0x20, MINECRAFT_1_16, false),
|
||||
map(0x1F, MINECRAFT_1_16_2, false));
|
||||
clientbound.register(JoinGamePacket.class, JoinGamePacket.DECODER,
|
||||
map(0x1F, MINECRAFT_1_16_2, false)
|
||||
);
|
||||
clientbound.register(
|
||||
ClientboundJoinGamePacket.class,
|
||||
ClientboundJoinGamePacket.DECODER,
|
||||
map(0x01, MINECRAFT_1_7_2, false),
|
||||
map(0x23, MINECRAFT_1_9, false),
|
||||
map(0x25, MINECRAFT_1_13, false),
|
||||
map(0x25, MINECRAFT_1_14, false),
|
||||
map(0x26, MINECRAFT_1_15, false),
|
||||
map(0x25, MINECRAFT_1_16, false),
|
||||
map(0x24, MINECRAFT_1_16_2, false));
|
||||
clientbound.register(RespawnPacket.class, RespawnPacket.DECODER,
|
||||
map(0x24, MINECRAFT_1_16_2, false)
|
||||
);
|
||||
clientbound.register(
|
||||
ClientboundRespawnPacket.class,
|
||||
ClientboundRespawnPacket.DECODER,
|
||||
map(0x07, MINECRAFT_1_7_2, true),
|
||||
map(0x33, MINECRAFT_1_9, true),
|
||||
map(0x34, MINECRAFT_1_12, true),
|
||||
@ -186,8 +249,11 @@ public enum StateRegistry {
|
||||
map(0x3A, MINECRAFT_1_14, true),
|
||||
map(0x3B, MINECRAFT_1_15, true),
|
||||
map(0x3A, MINECRAFT_1_16, true),
|
||||
map(0x39, MINECRAFT_1_16_2, true));
|
||||
clientbound.register(ResourcePackRequestPacket.class, ResourcePackRequestPacket.DECODER,
|
||||
map(0x39, MINECRAFT_1_16_2, true)
|
||||
);
|
||||
clientbound.register(
|
||||
ClientboundResourcePackRequestPacket.class,
|
||||
ClientboundResourcePackRequestPacket.DECODER,
|
||||
map(0x48, MINECRAFT_1_8, true),
|
||||
map(0x32, MINECRAFT_1_9, true),
|
||||
map(0x33, MINECRAFT_1_12, true),
|
||||
@ -196,8 +262,11 @@ public enum StateRegistry {
|
||||
map(0x39, MINECRAFT_1_14, true),
|
||||
map(0x3A, MINECRAFT_1_15, true),
|
||||
map(0x39, MINECRAFT_1_16, true),
|
||||
map(0x38, MINECRAFT_1_16_2, true));
|
||||
clientbound.register(HeaderAndFooterPacket.class, HeaderAndFooterPacket.DECODER,
|
||||
map(0x38, MINECRAFT_1_16_2, true)
|
||||
);
|
||||
clientbound.register(
|
||||
ClientboundHeaderAndFooterPacket.class,
|
||||
ClientboundHeaderAndFooterPacket.DECODER,
|
||||
map(0x47, MINECRAFT_1_8, true),
|
||||
map(0x48, MINECRAFT_1_9, true),
|
||||
map(0x47, MINECRAFT_1_9_4, true),
|
||||
@ -206,8 +275,11 @@ public enum StateRegistry {
|
||||
map(0x4E, MINECRAFT_1_13, true),
|
||||
map(0x53, MINECRAFT_1_14, true),
|
||||
map(0x54, MINECRAFT_1_15, true),
|
||||
map(0x53, MINECRAFT_1_16, true));
|
||||
clientbound.register(TitlePacket.class, TitlePacket.DECODER,
|
||||
map(0x53, MINECRAFT_1_16, true)
|
||||
);
|
||||
clientbound.register(
|
||||
ClientboundTitlePacket.class,
|
||||
ClientboundTitlePacket.DECODER,
|
||||
map(0x45, MINECRAFT_1_8, true),
|
||||
map(0x45, MINECRAFT_1_9, true),
|
||||
map(0x47, MINECRAFT_1_12, true),
|
||||
@ -215,8 +287,11 @@ public enum StateRegistry {
|
||||
map(0x4B, MINECRAFT_1_13, true),
|
||||
map(0x4F, MINECRAFT_1_14, true),
|
||||
map(0x50, MINECRAFT_1_15, true),
|
||||
map(0x4F, MINECRAFT_1_16, true));
|
||||
clientbound.register(PlayerListItemPacket.class, PlayerListItemPacket.DECODER,
|
||||
map(0x4F, MINECRAFT_1_16, true)
|
||||
);
|
||||
clientbound.register(
|
||||
ClientboundPlayerListItemPacket.class,
|
||||
ClientboundPlayerListItemPacket.DECODER,
|
||||
map(0x38, MINECRAFT_1_7_2, false),
|
||||
map(0x2D, MINECRAFT_1_9, false),
|
||||
map(0x2E, MINECRAFT_1_12_1, false),
|
||||
@ -224,27 +299,53 @@ public enum StateRegistry {
|
||||
map(0x33, MINECRAFT_1_14, false),
|
||||
map(0x34, MINECRAFT_1_15, false),
|
||||
map(0x33, MINECRAFT_1_16, false),
|
||||
map(0x32, MINECRAFT_1_16_2, false));
|
||||
map(0x32, MINECRAFT_1_16_2, false)
|
||||
);
|
||||
}
|
||||
},
|
||||
LOGIN(true) {
|
||||
{
|
||||
serverbound.register(ServerLoginPacket.class, ServerLoginPacket.DECODER,
|
||||
map(0x00, MINECRAFT_1_7_2, false));
|
||||
serverbound.register(EncryptionResponsePacket.class, EncryptionResponsePacket.DECODER,
|
||||
map(0x01, MINECRAFT_1_7_2, false));
|
||||
serverbound.register(LoginPluginResponsePacket.class, LoginPluginResponsePacket.DECODER,
|
||||
map(0x02, MINECRAFT_1_13, false));
|
||||
clientbound.register(DisconnectPacket.class, DisconnectPacket.DECODER,
|
||||
map(0x00, MINECRAFT_1_7_2, false));
|
||||
clientbound.register(EncryptionRequestPacket.class, EncryptionRequestPacket.DECODER,
|
||||
map(0x01, MINECRAFT_1_7_2, false));
|
||||
clientbound.register(ServerLoginSuccessPacket.class, ServerLoginSuccessPacket.DECODER,
|
||||
map(0x02, MINECRAFT_1_7_2, false));
|
||||
clientbound.register(SetCompressionPacket.class, SetCompressionPacket.DECODER,
|
||||
map(0x03, MINECRAFT_1_8, false));
|
||||
clientbound.register(LoginPluginMessagePacket.class, LoginPluginMessagePacket.DECODER,
|
||||
map(0x04, MINECRAFT_1_13, false));
|
||||
serverbound.register(
|
||||
ServerboundServerLoginPacket.class,
|
||||
ServerboundServerLoginPacket.DECODER,
|
||||
map(0x00, MINECRAFT_1_7_2, false)
|
||||
);
|
||||
serverbound.register(
|
||||
ServerboundEncryptionResponsePacket.class,
|
||||
ServerboundEncryptionResponsePacket.DECODER,
|
||||
map(0x01, MINECRAFT_1_7_2, false)
|
||||
);
|
||||
serverbound.register(
|
||||
ServerboundLoginPluginResponsePacket.class,
|
||||
ServerboundLoginPluginResponsePacket.DECODER,
|
||||
map(0x02, MINECRAFT_1_13, false)
|
||||
);
|
||||
|
||||
clientbound.register(
|
||||
ClientboundDisconnectPacket.class,
|
||||
ClientboundDisconnectPacket.DECODER,
|
||||
map(0x00, MINECRAFT_1_7_2, false)
|
||||
);
|
||||
clientbound.register(
|
||||
ClientboundEncryptionRequestPacket.class,
|
||||
ClientboundEncryptionRequestPacket.DECODER,
|
||||
map(0x01, MINECRAFT_1_7_2, false)
|
||||
);
|
||||
clientbound.register(
|
||||
ClientboundServerLoginSuccessPacket.class,
|
||||
ClientboundServerLoginSuccessPacket.DECODER,
|
||||
map(0x02, MINECRAFT_1_7_2, false)
|
||||
);
|
||||
clientbound.register(
|
||||
ClientboundSetCompressionPacket.class,
|
||||
ClientboundSetCompressionPacket.DECODER,
|
||||
map(0x03, MINECRAFT_1_8, false)
|
||||
);
|
||||
clientbound.register(
|
||||
ClientboundLoginPluginMessagePacket.class,
|
||||
ClientboundLoginPluginMessagePacket.DECODER,
|
||||
map(0x04, MINECRAFT_1_13, false)
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
@ -253,30 +354,30 @@ public enum StateRegistry {
|
||||
public final PacketRegistry clientbound;
|
||||
public final PacketRegistry serverbound;
|
||||
|
||||
StateRegistry(boolean fallback) {
|
||||
this.clientbound = new PacketRegistry(ProtocolDirection.CLIENTBOUND, fallback);
|
||||
this.serverbound = new PacketRegistry(ProtocolDirection.SERVERBOUND, fallback);
|
||||
StateRegistry(boolean useMinimumIfVersionNotFound) {
|
||||
this.clientbound = new PacketRegistry(PacketDirection.CLIENTBOUND, useMinimumIfVersionNotFound);
|
||||
this.serverbound = new PacketRegistry(PacketDirection.SERVERBOUND, useMinimumIfVersionNotFound);
|
||||
}
|
||||
|
||||
public PacketRegistry.ProtocolRegistry getProtocolRegistry(ProtocolDirection direction,
|
||||
ProtocolVersion version) {
|
||||
return (direction == ProtocolDirection.SERVERBOUND ? this.serverbound : this.clientbound)
|
||||
public PacketRegistry.ProtocolRegistry getProtocolRegistry(PacketDirection direction,
|
||||
ProtocolVersion version) {
|
||||
return (direction == PacketDirection.SERVERBOUND ? this.serverbound : this.clientbound)
|
||||
.getProtocolRegistry(version);
|
||||
}
|
||||
|
||||
public static class PacketRegistry {
|
||||
|
||||
private final ProtocolDirection direction;
|
||||
private final PacketDirection direction;
|
||||
private final Map<ProtocolVersion, ProtocolRegistry> versions;
|
||||
private final boolean fallback;
|
||||
private final boolean useMinimumIfVersionNotFound;
|
||||
|
||||
PacketRegistry(ProtocolDirection direction) {
|
||||
PacketRegistry(PacketDirection direction) {
|
||||
this(direction, true);
|
||||
}
|
||||
|
||||
PacketRegistry(ProtocolDirection direction, boolean fallback) {
|
||||
PacketRegistry(PacketDirection direction, boolean useMinimumIfVersionNotFound) {
|
||||
this.direction = direction;
|
||||
this.fallback = fallback;
|
||||
this.useMinimumIfVersionNotFound = useMinimumIfVersionNotFound;
|
||||
|
||||
Map<ProtocolVersion, ProtocolRegistry> mutableVersions = new EnumMap<>(ProtocolVersion.class);
|
||||
for (ProtocolVersion version : ProtocolVersion.values()) {
|
||||
@ -291,7 +392,7 @@ public enum StateRegistry {
|
||||
ProtocolRegistry getProtocolRegistry(final ProtocolVersion version) {
|
||||
ProtocolRegistry registry = versions.get(version);
|
||||
if (registry == null) {
|
||||
if (fallback) {
|
||||
if (useMinimumIfVersionNotFound) {
|
||||
return getProtocolRegistry(MINIMUM_VERSION);
|
||||
}
|
||||
throw new IllegalArgumentException("Could not find data for protocol version " + version);
|
||||
@ -385,7 +486,7 @@ public enum StateRegistry {
|
||||
* @param version the protocol version
|
||||
* @return the packet instance, or {@code null} if the ID is not registered
|
||||
*/
|
||||
public @Nullable Packet decodePacket(final int id, ByteBuf buf, ProtocolDirection direction,
|
||||
public @Nullable Packet decodePacket(final int id, ByteBuf buf, PacketDirection direction,
|
||||
ProtocolVersion version) {
|
||||
final Packet.Decoder<? extends Packet> decoder = this.packetIdToDecoder.get(id);
|
||||
if (decoder == null) {
|
@ -1,4 +1,4 @@
|
||||
package com.velocitypowered.proxy.protocol.util;
|
||||
package com.velocitypowered.proxy.network.buffer;
|
||||
|
||||
import com.google.common.io.ByteArrayDataInput;
|
||||
import io.netty.buffer.ByteBuf;
|
@ -1,9 +1,8 @@
|
||||
package com.velocitypowered.proxy.protocol.util;
|
||||
package com.velocitypowered.proxy.network.buffer;
|
||||
|
||||
import com.google.common.io.ByteArrayDataOutput;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty.buffer.ByteBufUtil;
|
||||
import java.io.DataOutput;
|
||||
import java.io.DataOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.OutputStream;
|
@ -1,4 +1,4 @@
|
||||
package com.velocitypowered.proxy.protocol.util;
|
||||
package com.velocitypowered.proxy.network.buffer;
|
||||
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty.buffer.ByteBufHolder;
|
@ -0,0 +1,51 @@
|
||||
package com.velocitypowered.proxy.network.packet;
|
||||
|
||||
import com.google.common.base.MoreObjects;
|
||||
import com.velocitypowered.api.network.ProtocolVersion;
|
||||
import com.velocitypowered.proxy.network.ProtocolUtils;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import java.util.function.LongFunction;
|
||||
|
||||
public abstract class AbstractKeepAlivePacket implements Packet {
|
||||
protected static <P extends AbstractKeepAlivePacket> Decoder<P> decoder(final LongFunction<P> factory) {
|
||||
return (buf, direction, version) -> {
|
||||
final long randomId;
|
||||
if (version.gte(ProtocolVersion.MINECRAFT_1_12_2)) {
|
||||
randomId = buf.readLong();
|
||||
} else if (version.gte(ProtocolVersion.MINECRAFT_1_8)) {
|
||||
randomId = ProtocolUtils.readVarInt(buf);
|
||||
} else {
|
||||
randomId = buf.readInt();
|
||||
}
|
||||
return factory.apply(randomId);
|
||||
};
|
||||
}
|
||||
|
||||
private final long randomId;
|
||||
|
||||
protected AbstractKeepAlivePacket(final long randomId) {
|
||||
this.randomId = randomId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void encode(ByteBuf buf, PacketDirection direction, ProtocolVersion version) {
|
||||
if (version.gte(ProtocolVersion.MINECRAFT_1_12_2)) {
|
||||
buf.writeLong(randomId);
|
||||
} else if (version.gte(ProtocolVersion.MINECRAFT_1_8)) {
|
||||
ProtocolUtils.writeVarInt(buf, (int) randomId);
|
||||
} else {
|
||||
buf.writeInt((int) randomId);
|
||||
}
|
||||
}
|
||||
|
||||
public long getRandomId() {
|
||||
return randomId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return MoreObjects.toStringHelper(this)
|
||||
.add("randomId", this.randomId)
|
||||
.toString();
|
||||
}
|
||||
}
|
@ -0,0 +1,33 @@
|
||||
package com.velocitypowered.proxy.network.packet;
|
||||
|
||||
import com.google.common.base.MoreObjects;
|
||||
import com.velocitypowered.api.network.ProtocolVersion;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import java.util.function.LongFunction;
|
||||
|
||||
public abstract class AbstractStatusPingPacket implements Packet {
|
||||
protected static <P extends AbstractStatusPingPacket> Decoder<P> decoder(final LongFunction<P> factory) {
|
||||
return (buf, direction, version) -> {
|
||||
final long randomId = buf.readLong();
|
||||
return factory.apply(randomId);
|
||||
};
|
||||
}
|
||||
|
||||
private final long randomId;
|
||||
|
||||
protected AbstractStatusPingPacket(final long randomId) {
|
||||
this.randomId = randomId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void encode(ByteBuf buf, PacketDirection direction, ProtocolVersion version) {
|
||||
buf.writeLong(this.randomId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return MoreObjects.toStringHelper(this)
|
||||
.add("randomId", this.randomId)
|
||||
.toString();
|
||||
}
|
||||
}
|
@ -1,23 +1,22 @@
|
||||
package com.velocitypowered.proxy.protocol;
|
||||
package com.velocitypowered.proxy.network.packet;
|
||||
|
||||
import com.velocitypowered.api.network.ProtocolVersion;
|
||||
import com.velocitypowered.proxy.connection.MinecraftSessionHandler;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
public interface Packet {
|
||||
|
||||
@Deprecated
|
||||
default void decode(ByteBuf buf, ProtocolDirection direction, ProtocolVersion protocolVersion) {
|
||||
default void decode(ByteBuf buf, PacketDirection direction, ProtocolVersion protocolVersion) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
void encode(ByteBuf buf, ProtocolDirection direction, ProtocolVersion protocolVersion);
|
||||
void encode(ByteBuf buf, PacketDirection direction, ProtocolVersion protocolVersion);
|
||||
|
||||
boolean handle(MinecraftSessionHandler handler);
|
||||
boolean handle(PacketHandler handler);
|
||||
|
||||
interface Decoder<P extends Packet> {
|
||||
P decode(final ByteBuf buf, final ProtocolDirection direction, final ProtocolVersion version);
|
||||
P decode(final ByteBuf buf, final PacketDirection direction, final ProtocolVersion version);
|
||||
|
||||
static <P extends Packet> Decoder<P> unsupported() {
|
||||
return (buf, direction, version) -> {
|
||||
@ -25,6 +24,10 @@ public interface Packet {
|
||||
};
|
||||
}
|
||||
|
||||
static <P extends Packet> Decoder<P> instance(final P packet) {
|
||||
return (buf, direction, version) -> packet;
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
static <P extends Packet> Decoder<P> method(final Supplier<P> factory) {
|
||||
return (buf, direction, version) -> {
|
@ -0,0 +1,6 @@
|
||||
package com.velocitypowered.proxy.network.packet;
|
||||
|
||||
public enum PacketDirection {
|
||||
SERVERBOUND,
|
||||
CLIENTBOUND;
|
||||
}
|
@ -0,0 +1,176 @@
|
||||
package com.velocitypowered.proxy.network.packet;
|
||||
|
||||
import com.velocitypowered.proxy.network.packet.clientbound.ClientboundAvailableCommandsPacket;
|
||||
import com.velocitypowered.proxy.network.packet.clientbound.ClientboundBossBarPacket;
|
||||
import com.velocitypowered.proxy.network.packet.clientbound.ClientboundChatPacket;
|
||||
import com.velocitypowered.proxy.network.packet.clientbound.ClientboundDisconnectPacket;
|
||||
import com.velocitypowered.proxy.network.packet.clientbound.ClientboundEncryptionRequestPacket;
|
||||
import com.velocitypowered.proxy.network.packet.clientbound.ClientboundHeaderAndFooterPacket;
|
||||
import com.velocitypowered.proxy.network.packet.clientbound.ClientboundJoinGamePacket;
|
||||
import com.velocitypowered.proxy.network.packet.clientbound.ClientboundKeepAlivePacket;
|
||||
import com.velocitypowered.proxy.network.packet.clientbound.ClientboundLoginPluginMessagePacket;
|
||||
import com.velocitypowered.proxy.network.packet.clientbound.ClientboundPlayerListItemPacket;
|
||||
import com.velocitypowered.proxy.network.packet.clientbound.ClientboundResourcePackRequestPacket;
|
||||
import com.velocitypowered.proxy.network.packet.clientbound.ClientboundRespawnPacket;
|
||||
import com.velocitypowered.proxy.network.packet.clientbound.ClientboundServerLoginSuccessPacket;
|
||||
import com.velocitypowered.proxy.network.packet.clientbound.ClientboundSetCompressionPacket;
|
||||
import com.velocitypowered.proxy.network.packet.clientbound.ClientboundStatusPingPacket;
|
||||
import com.velocitypowered.proxy.network.packet.clientbound.ClientboundStatusResponsePacket;
|
||||
import com.velocitypowered.proxy.network.packet.clientbound.ClientboundTabCompleteResponsePacket;
|
||||
import com.velocitypowered.proxy.network.packet.clientbound.ClientboundTitlePacket;
|
||||
import com.velocitypowered.proxy.network.packet.legacy.LegacyHandshakePacket;
|
||||
import com.velocitypowered.proxy.network.packet.legacy.LegacyPingPacket;
|
||||
import com.velocitypowered.proxy.network.packet.serverbound.ServerboundChatPacket;
|
||||
import com.velocitypowered.proxy.network.packet.serverbound.ServerboundClientSettingsPacket;
|
||||
import com.velocitypowered.proxy.network.packet.serverbound.ServerboundEncryptionResponsePacket;
|
||||
import com.velocitypowered.proxy.network.packet.serverbound.ServerboundHandshakePacket;
|
||||
import com.velocitypowered.proxy.network.packet.serverbound.ServerboundKeepAlivePacket;
|
||||
import com.velocitypowered.proxy.network.packet.serverbound.ServerboundLoginPluginResponsePacket;
|
||||
import com.velocitypowered.proxy.network.packet.serverbound.ServerboundResourcePackResponsePacket;
|
||||
import com.velocitypowered.proxy.network.packet.serverbound.ServerboundServerLoginPacket;
|
||||
import com.velocitypowered.proxy.network.packet.serverbound.ServerboundStatusPingPacket;
|
||||
import com.velocitypowered.proxy.network.packet.serverbound.ServerboundStatusRequestPacket;
|
||||
import com.velocitypowered.proxy.network.packet.serverbound.ServerboundTabCompleteRequestPacket;
|
||||
import com.velocitypowered.proxy.network.packet.shared.PluginMessagePacket;
|
||||
|
||||
public interface PacketHandler {
|
||||
default boolean handle(PluginMessagePacket packet) {
|
||||
return false;
|
||||
}
|
||||
|
||||
/*
|
||||
* Clientbound
|
||||
*/
|
||||
|
||||
default boolean handle(ClientboundAvailableCommandsPacket commands) {
|
||||
return false;
|
||||
}
|
||||
|
||||
default boolean handle(ClientboundBossBarPacket packet) {
|
||||
return false;
|
||||
}
|
||||
|
||||
default boolean handle(ClientboundChatPacket packet) {
|
||||
return false;
|
||||
}
|
||||
|
||||
default boolean handle(ClientboundDisconnectPacket packet) {
|
||||
return false;
|
||||
}
|
||||
|
||||
default boolean handle(ClientboundEncryptionRequestPacket packet) {
|
||||
return false;
|
||||
}
|
||||
|
||||
default boolean handle(ClientboundHeaderAndFooterPacket packet) {
|
||||
return false;
|
||||
}
|
||||
|
||||
default boolean handle(ClientboundJoinGamePacket packet) {
|
||||
return false;
|
||||
}
|
||||
|
||||
default boolean handle(ClientboundKeepAlivePacket packet) {
|
||||
return false;
|
||||
}
|
||||
|
||||
default boolean handle(ClientboundLoginPluginMessagePacket packet) {
|
||||
return false;
|
||||
}
|
||||
|
||||
default boolean handle(ClientboundPlayerListItemPacket packet) {
|
||||
return false;
|
||||
}
|
||||
|
||||
default boolean handle(ClientboundResourcePackRequestPacket packet) {
|
||||
return false;
|
||||
}
|
||||
|
||||
default boolean handle(ClientboundRespawnPacket packet) {
|
||||
return false;
|
||||
}
|
||||
|
||||
default boolean handle(ClientboundServerLoginSuccessPacket packet) {
|
||||
return false;
|
||||
}
|
||||
|
||||
default boolean handle(ClientboundSetCompressionPacket packet) {
|
||||
return false;
|
||||
}
|
||||
|
||||
default boolean handle(ClientboundStatusPingPacket packet) {
|
||||
return false;
|
||||
}
|
||||
|
||||
default boolean handle(ClientboundStatusResponsePacket packet) {
|
||||
return false;
|
||||
}
|
||||
|
||||
default boolean handle(ClientboundTabCompleteResponsePacket packet) {
|
||||
return false;
|
||||
}
|
||||
|
||||
default boolean handle(ClientboundTitlePacket packet) {
|
||||
return false;
|
||||
}
|
||||
|
||||
/*
|
||||
* Serverbound
|
||||
*/
|
||||
|
||||
default boolean handle(ServerboundChatPacket packet) {
|
||||
return false;
|
||||
}
|
||||
|
||||
default boolean handle(ServerboundClientSettingsPacket packet) {
|
||||
return false;
|
||||
}
|
||||
|
||||
default boolean handle(ServerboundEncryptionResponsePacket packet) {
|
||||
return false;
|
||||
}
|
||||
|
||||
default boolean handle(ServerboundHandshakePacket packet) {
|
||||
return false;
|
||||
}
|
||||
|
||||
default boolean handle(ServerboundKeepAlivePacket packet) {
|
||||
return false;
|
||||
}
|
||||
|
||||
default boolean handle(ServerboundLoginPluginResponsePacket packet) {
|
||||
return false;
|
||||
}
|
||||
|
||||
default boolean handle(ServerboundResourcePackResponsePacket packet) {
|
||||
return false;
|
||||
}
|
||||
|
||||
default boolean handle(ServerboundServerLoginPacket packet) {
|
||||
return false;
|
||||
}
|
||||
|
||||
default boolean handle(ServerboundStatusPingPacket packet) {
|
||||
return false;
|
||||
}
|
||||
|
||||
default boolean handle(ServerboundStatusRequestPacket packet) {
|
||||
return false;
|
||||
}
|
||||
|
||||
default boolean handle(ServerboundTabCompleteRequestPacket packet) {
|
||||
return false;
|
||||
}
|
||||
|
||||
/*
|
||||
* Legacy
|
||||
*/
|
||||
|
||||
default boolean handle(LegacyHandshakePacket packet) {
|
||||
return false;
|
||||
}
|
||||
|
||||
default boolean handle(LegacyPingPacket packet) {
|
||||
return false;
|
||||
}
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
package com.velocitypowered.proxy.protocol.packet;
|
||||
package com.velocitypowered.proxy.network.packet.clientbound;
|
||||
|
||||
import com.google.common.base.MoreObjects;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
@ -18,11 +18,11 @@ import com.mojang.brigadier.tree.LiteralCommandNode;
|
||||
import com.mojang.brigadier.tree.RootCommandNode;
|
||||
import com.velocitypowered.api.command.CommandSource;
|
||||
import com.velocitypowered.api.network.ProtocolVersion;
|
||||
import com.velocitypowered.proxy.connection.MinecraftSessionHandler;
|
||||
import com.velocitypowered.proxy.protocol.Packet;
|
||||
import com.velocitypowered.proxy.protocol.ProtocolUtils;
|
||||
import com.velocitypowered.proxy.protocol.ProtocolDirection;
|
||||
import com.velocitypowered.proxy.protocol.packet.brigadier.ArgumentPropertyRegistry;
|
||||
import com.velocitypowered.proxy.network.ProtocolUtils;
|
||||
import com.velocitypowered.proxy.network.packet.Packet;
|
||||
import com.velocitypowered.proxy.network.packet.PacketDirection;
|
||||
import com.velocitypowered.proxy.network.packet.PacketHandler;
|
||||
import com.velocitypowered.proxy.network.serialization.brigadier.ArgumentPropertyRegistry;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import it.unimi.dsi.fastutil.objects.Object2IntLinkedOpenHashMap;
|
||||
import it.unimi.dsi.fastutil.objects.Object2IntMap;
|
||||
@ -35,8 +35,8 @@ import java.util.concurrent.CompletableFuture;
|
||||
import org.checkerframework.checker.nullness.qual.MonotonicNonNull;
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
|
||||
public class AvailableCommandsPacket implements Packet {
|
||||
public static final Decoder<AvailableCommandsPacket> DECODER = Decoder.method(AvailableCommandsPacket::new);
|
||||
public class ClientboundAvailableCommandsPacket implements Packet {
|
||||
public static final Decoder<ClientboundAvailableCommandsPacket> DECODER = Decoder.method(ClientboundAvailableCommandsPacket::new);
|
||||
|
||||
private static final Command<CommandSource> PLACEHOLDER_COMMAND = source -> 0;
|
||||
|
||||
@ -63,7 +63,7 @@ public class AvailableCommandsPacket implements Packet {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void decode(ByteBuf buf, ProtocolDirection direction, ProtocolVersion protocolVersion) {
|
||||
public void decode(ByteBuf buf, PacketDirection direction, ProtocolVersion protocolVersion) {
|
||||
int commands = ProtocolUtils.readVarInt(buf);
|
||||
WireNode[] wireNodes = new WireNode[commands];
|
||||
for (int i = 0; i < commands; i++) {
|
||||
@ -95,7 +95,7 @@ public class AvailableCommandsPacket implements Packet {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void encode(ByteBuf buf, ProtocolDirection direction, ProtocolVersion protocolVersion) {
|
||||
public void encode(ByteBuf buf, PacketDirection direction, ProtocolVersion protocolVersion) {
|
||||
// Assign all the children an index.
|
||||
Deque<CommandNode<CommandSource>> childrenQueue = new ArrayDeque<>(ImmutableList.of(rootNode));
|
||||
Object2IntMap<CommandNode<CommandSource>> idMappings = new Object2IntLinkedOpenHashMap<>();
|
||||
@ -165,7 +165,7 @@ public class AvailableCommandsPacket implements Packet {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean handle(MinecraftSessionHandler handler) {
|
||||
public boolean handle(PacketHandler handler) {
|
||||
return handler.handle(this);
|
||||
}
|
||||
|
@ -1,17 +1,18 @@
|
||||
package com.velocitypowered.proxy.protocol.packet;
|
||||
package com.velocitypowered.proxy.network.packet.clientbound;
|
||||
|
||||
import com.google.common.base.MoreObjects;
|
||||
import com.velocitypowered.api.network.ProtocolVersion;
|
||||
import com.velocitypowered.proxy.connection.MinecraftSessionHandler;
|
||||
import com.velocitypowered.proxy.protocol.Packet;
|
||||
import com.velocitypowered.proxy.protocol.ProtocolDirection;
|
||||
import com.velocitypowered.proxy.protocol.ProtocolUtils;
|
||||
import com.velocitypowered.proxy.network.ProtocolUtils;
|
||||
import com.velocitypowered.proxy.network.packet.Packet;
|
||||
import com.velocitypowered.proxy.network.packet.PacketDirection;
|
||||
import com.velocitypowered.proxy.network.packet.PacketHandler;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import java.util.UUID;
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
|
||||
public class BossBarPacket implements Packet {
|
||||
public class ClientboundBossBarPacket implements Packet {
|
||||
|
||||
public static final Decoder<BossBarPacket> DECODER = Decoder.method(BossBarPacket::new);
|
||||
public static final Decoder<ClientboundBossBarPacket> DECODER = Decoder.method(ClientboundBossBarPacket::new);
|
||||
|
||||
public static final int ADD = 0;
|
||||
public static final int REMOVE = 1;
|
||||
@ -88,20 +89,7 @@ public class BossBarPacket implements Packet {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "BossBarPacket{"
|
||||
+ "uuid=" + uuid
|
||||
+ ", action=" + action
|
||||
+ ", name='" + name + '\''
|
||||
+ ", percent=" + percent
|
||||
+ ", color=" + color
|
||||
+ ", overlay=" + overlay
|
||||
+ ", flags=" + flags
|
||||
+ '}';
|
||||
}
|
||||
|
||||
@Override
|
||||
public void decode(ByteBuf buf, ProtocolDirection direction, ProtocolVersion version) {
|
||||
public void decode(ByteBuf buf, PacketDirection direction, ProtocolVersion version) {
|
||||
this.uuid = ProtocolUtils.readUuid(buf);
|
||||
this.action = ProtocolUtils.readVarInt(buf);
|
||||
switch (action) {
|
||||
@ -133,7 +121,7 @@ public class BossBarPacket implements Packet {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void encode(ByteBuf buf, ProtocolDirection direction, ProtocolVersion version) {
|
||||
public void encode(ByteBuf buf, PacketDirection direction, ProtocolVersion version) {
|
||||
if (uuid == null) {
|
||||
throw new IllegalStateException("No boss bar UUID specified");
|
||||
}
|
||||
@ -174,14 +162,27 @@ public class BossBarPacket implements Packet {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean handle(MinecraftSessionHandler handler) {
|
||||
public boolean handle(PacketHandler handler) {
|
||||
return handler.handle(this);
|
||||
}
|
||||
|
||||
public static BossBarPacket createRemovePacket(UUID id) {
|
||||
BossBarPacket packet = new BossBarPacket();
|
||||
public static ClientboundBossBarPacket createRemovePacket(UUID id) {
|
||||
ClientboundBossBarPacket packet = new ClientboundBossBarPacket();
|
||||
packet.setUuid(id);
|
||||
packet.setAction(REMOVE);
|
||||
return packet;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return MoreObjects.toStringHelper(this)
|
||||
.add("uuid", this.uuid)
|
||||
.add("action", this.action)
|
||||
.add("name", this.name)
|
||||
.add("percent", this.percent)
|
||||
.add("color", this.color)
|
||||
.add("overlay", this.overlay)
|
||||
.add("flags", this.flags)
|
||||
.toString();
|
||||
}
|
||||
}
|
@ -1,17 +1,16 @@
|
||||
package com.velocitypowered.proxy.protocol.packet;
|
||||
package com.velocitypowered.proxy.network.packet.clientbound;
|
||||
|
||||
import com.google.common.base.MoreObjects;
|
||||
import com.velocitypowered.api.network.ProtocolVersion;
|
||||
import com.velocitypowered.proxy.connection.MinecraftSessionHandler;
|
||||
import com.velocitypowered.proxy.protocol.Packet;
|
||||
import com.velocitypowered.proxy.protocol.ProtocolDirection;
|
||||
import com.velocitypowered.proxy.protocol.ProtocolUtils;
|
||||
import com.velocitypowered.proxy.network.ProtocolUtils;
|
||||
import com.velocitypowered.proxy.network.packet.Packet;
|
||||
import com.velocitypowered.proxy.network.packet.PacketDirection;
|
||||
import com.velocitypowered.proxy.network.packet.PacketHandler;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import java.util.UUID;
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
public class ClientboundChatPacket implements Packet {
|
||||
|
||||
public static final Decoder<ClientboundChatPacket> DECODER = Decoder.method(ClientboundChatPacket::new);
|
||||
|
||||
public static final byte CHAT_TYPE = (byte) 0;
|
||||
@ -32,7 +31,7 @@ public class ClientboundChatPacket implements Packet {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void decode(ByteBuf buf, ProtocolDirection direction, ProtocolVersion version) {
|
||||
public void decode(ByteBuf buf, PacketDirection direction, ProtocolVersion version) {
|
||||
message = ProtocolUtils.readString(buf);
|
||||
if (version.gte(ProtocolVersion.MINECRAFT_1_8)) {
|
||||
type = buf.readByte();
|
||||
@ -43,7 +42,7 @@ public class ClientboundChatPacket implements Packet {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void encode(ByteBuf buf, ProtocolDirection direction, ProtocolVersion version) {
|
||||
public void encode(ByteBuf buf, PacketDirection direction, ProtocolVersion version) {
|
||||
if (message == null) {
|
||||
throw new IllegalStateException("Message is not specified");
|
||||
}
|
||||
@ -57,7 +56,7 @@ public class ClientboundChatPacket implements Packet {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean handle(MinecraftSessionHandler handler) {
|
||||
public boolean handle(PacketHandler handler) {
|
||||
return handler.handle(this);
|
||||
}
|
||||
|
||||
@ -78,10 +77,10 @@ public class ClientboundChatPacket implements Packet {
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "ClientboundChatPacket{"
|
||||
+ "message='" + message + '\''
|
||||
+ ", type=" + type
|
||||
+ ", sender=" + sender
|
||||
+ '}';
|
||||
return MoreObjects.toStringHelper(this)
|
||||
.add("message", this.message)
|
||||
.add("type", this.type)
|
||||
.add("sender", this.sender)
|
||||
.toString();
|
||||
}
|
||||
}
|
@ -0,0 +1,66 @@
|
||||
package com.velocitypowered.proxy.network.packet.clientbound;
|
||||
|
||||
import com.google.common.base.MoreObjects;
|
||||
import com.google.common.base.Preconditions;
|
||||
import com.velocitypowered.api.network.ProtocolVersion;
|
||||
import com.velocitypowered.proxy.network.ProtocolUtils;
|
||||
import com.velocitypowered.proxy.network.packet.Packet;
|
||||
import com.velocitypowered.proxy.network.packet.PacketDirection;
|
||||
import com.velocitypowered.proxy.network.packet.PacketHandler;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
|
||||
public class ClientboundDisconnectPacket implements Packet {
|
||||
public static final Decoder<ClientboundDisconnectPacket> DECODER = Decoder.method(ClientboundDisconnectPacket::new);
|
||||
|
||||
private @Nullable String reason;
|
||||
|
||||
public ClientboundDisconnectPacket() {
|
||||
}
|
||||
|
||||
public ClientboundDisconnectPacket(String reason) {
|
||||
this.reason = Preconditions.checkNotNull(reason, "reason");
|
||||
}
|
||||
|
||||
public String getReason() {
|
||||
if (reason == null) {
|
||||
throw new IllegalStateException("No reason specified");
|
||||
}
|
||||
return reason;
|
||||
}
|
||||
|
||||
public void setReason(@Nullable String reason) {
|
||||
this.reason = reason;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void decode(ByteBuf buf, PacketDirection direction, ProtocolVersion version) {
|
||||
reason = ProtocolUtils.readString(buf);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void encode(ByteBuf buf, PacketDirection direction, ProtocolVersion version) {
|
||||
if (reason == null) {
|
||||
throw new IllegalStateException("No reason specified.");
|
||||
}
|
||||
ProtocolUtils.writeString(buf, reason);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean handle(PacketHandler handler) {
|
||||
return handler.handle(this);
|
||||
}
|
||||
|
||||
public static ClientboundDisconnectPacket create(Component component, ProtocolVersion version) {
|
||||
Preconditions.checkNotNull(component, "component");
|
||||
return new ClientboundDisconnectPacket(ProtocolUtils.getJsonChatSerializer(version).serialize(component));
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return MoreObjects.toStringHelper(this)
|
||||
.add("reason", this.reason)
|
||||
.toString();
|
||||
}
|
||||
}
|
@ -1,17 +1,17 @@
|
||||
package com.velocitypowered.proxy.protocol.packet;
|
||||
package com.velocitypowered.proxy.network.packet.clientbound;
|
||||
|
||||
import static com.velocitypowered.proxy.connection.VelocityConstants.EMPTY_BYTE_ARRAY;
|
||||
|
||||
import com.google.common.base.MoreObjects;
|
||||
import com.velocitypowered.api.network.ProtocolVersion;
|
||||
import com.velocitypowered.proxy.connection.MinecraftSessionHandler;
|
||||
import com.velocitypowered.proxy.protocol.Packet;
|
||||
import com.velocitypowered.proxy.protocol.ProtocolDirection;
|
||||
import com.velocitypowered.proxy.protocol.ProtocolUtils;
|
||||
import com.velocitypowered.proxy.network.ProtocolUtils;
|
||||
import com.velocitypowered.proxy.network.packet.Packet;
|
||||
import com.velocitypowered.proxy.network.packet.PacketDirection;
|
||||
import com.velocitypowered.proxy.network.packet.PacketHandler;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import java.util.Arrays;
|
||||
|
||||
public class EncryptionRequestPacket implements Packet {
|
||||
public static final Decoder<EncryptionRequestPacket> DECODER = Decoder.method(EncryptionRequestPacket::new);
|
||||
public class ClientboundEncryptionRequestPacket implements Packet {
|
||||
public static final Decoder<ClientboundEncryptionRequestPacket> DECODER = Decoder.method(ClientboundEncryptionRequestPacket::new);
|
||||
|
||||
private String serverId = "";
|
||||
private byte[] publicKey = EMPTY_BYTE_ARRAY;
|
||||
@ -34,15 +34,7 @@ public class EncryptionRequestPacket implements Packet {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "EncryptionRequestPacket{"
|
||||
+ "publicKey=" + Arrays.toString(publicKey)
|
||||
+ ", verifyToken=" + Arrays.toString(verifyToken)
|
||||
+ '}';
|
||||
}
|
||||
|
||||
@Override
|
||||
public void decode(ByteBuf buf, ProtocolDirection direction, ProtocolVersion version) {
|
||||
public void decode(ByteBuf buf, PacketDirection direction, ProtocolVersion version) {
|
||||
this.serverId = ProtocolUtils.readString(buf, 20);
|
||||
|
||||
if (version.gte(ProtocolVersion.MINECRAFT_1_8)) {
|
||||
@ -55,7 +47,7 @@ public class EncryptionRequestPacket implements Packet {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void encode(ByteBuf buf, ProtocolDirection direction, ProtocolVersion version) {
|
||||
public void encode(ByteBuf buf, PacketDirection direction, ProtocolVersion version) {
|
||||
ProtocolUtils.writeString(buf, this.serverId);
|
||||
|
||||
if (version.gte(ProtocolVersion.MINECRAFT_1_8)) {
|
||||
@ -68,7 +60,16 @@ public class EncryptionRequestPacket implements Packet {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean handle(MinecraftSessionHandler handler) {
|
||||
public boolean handle(PacketHandler handler) {
|
||||
return handler.handle(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return MoreObjects.toStringHelper(this)
|
||||
.add("serverId", this.serverId)
|
||||
.add("publicKey", this.publicKey)
|
||||
.add("verifyToken", this.verifyToken)
|
||||
.toString();
|
||||
}
|
||||
}
|
@ -0,0 +1,62 @@
|
||||
package com.velocitypowered.proxy.network.packet.clientbound;
|
||||
|
||||
import static com.velocitypowered.proxy.network.ProtocolUtils.writeString;
|
||||
|
||||
import com.google.common.base.MoreObjects;
|
||||
import com.google.common.base.Preconditions;
|
||||
import com.velocitypowered.api.network.ProtocolVersion;
|
||||
import com.velocitypowered.proxy.network.packet.Packet;
|
||||
import com.velocitypowered.proxy.network.packet.PacketDirection;
|
||||
import com.velocitypowered.proxy.network.packet.PacketHandler;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
|
||||
public class ClientboundHeaderAndFooterPacket implements Packet {
|
||||
public static final Decoder<ClientboundHeaderAndFooterPacket> DECODER = Decoder.method(ClientboundHeaderAndFooterPacket::new);
|
||||
|
||||
private static final String EMPTY_COMPONENT = "{\"translate\":\"\"}";
|
||||
private static final ClientboundHeaderAndFooterPacket RESET
|
||||
= new ClientboundHeaderAndFooterPacket();
|
||||
|
||||
private final String header;
|
||||
private final String footer;
|
||||
|
||||
public ClientboundHeaderAndFooterPacket() {
|
||||
this(EMPTY_COMPONENT, EMPTY_COMPONENT);
|
||||
}
|
||||
|
||||
public ClientboundHeaderAndFooterPacket(String header, String footer) {
|
||||
this.header = Preconditions.checkNotNull(header, "header");
|
||||
this.footer = Preconditions.checkNotNull(footer, "footer");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void encode(ByteBuf buf, PacketDirection direction, ProtocolVersion version) {
|
||||
writeString(buf, header);
|
||||
writeString(buf, footer);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean handle(PacketHandler handler) {
|
||||
return handler.handle(this);
|
||||
}
|
||||
|
||||
public String getHeader() {
|
||||
return header;
|
||||
}
|
||||
|
||||
public String getFooter() {
|
||||
return footer;
|
||||
}
|
||||
|
||||
public static ClientboundHeaderAndFooterPacket reset() {
|
||||
return RESET;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return MoreObjects.toStringHelper(this)
|
||||
.add("header", this.header)
|
||||
.add("footer", this.footer)
|
||||
.toString();
|
||||
}
|
||||
}
|
@ -1,22 +1,23 @@
|
||||
package com.velocitypowered.proxy.protocol.packet;
|
||||
package com.velocitypowered.proxy.network.packet.clientbound;
|
||||
|
||||
import com.google.common.base.MoreObjects;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import com.velocitypowered.api.network.ProtocolVersion;
|
||||
import com.velocitypowered.proxy.connection.MinecraftSessionHandler;
|
||||
import com.velocitypowered.proxy.connection.registry.DimensionData;
|
||||
import com.velocitypowered.proxy.connection.registry.DimensionInfo;
|
||||
import com.velocitypowered.proxy.connection.registry.DimensionRegistry;
|
||||
import com.velocitypowered.proxy.protocol.Packet;
|
||||
import com.velocitypowered.proxy.protocol.ProtocolDirection;
|
||||
import com.velocitypowered.proxy.protocol.ProtocolUtils;
|
||||
import com.velocitypowered.proxy.network.ProtocolUtils;
|
||||
import com.velocitypowered.proxy.network.packet.Packet;
|
||||
import com.velocitypowered.proxy.network.packet.PacketDirection;
|
||||
import com.velocitypowered.proxy.network.packet.PacketHandler;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import net.kyori.adventure.nbt.BinaryTagTypes;
|
||||
import net.kyori.adventure.nbt.CompoundBinaryTag;
|
||||
import net.kyori.adventure.nbt.ListBinaryTag;
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
|
||||
public class JoinGamePacket implements Packet {
|
||||
public static final Decoder<JoinGamePacket> DECODER = Decoder.method(JoinGamePacket::new);
|
||||
public class ClientboundJoinGamePacket implements Packet {
|
||||
public static final Decoder<ClientboundJoinGamePacket> DECODER = Decoder.method(ClientboundJoinGamePacket::new);
|
||||
|
||||
private int entityId;
|
||||
private short gamemode;
|
||||
@ -35,138 +36,16 @@ public class JoinGamePacket implements Packet {
|
||||
private short previousGamemode; // 1.16+
|
||||
private CompoundBinaryTag biomeRegistry; // 1.16.2+
|
||||
|
||||
public int getEntityId() {
|
||||
return entityId;
|
||||
}
|
||||
|
||||
public void setEntityId(int entityId) {
|
||||
this.entityId = entityId;
|
||||
}
|
||||
|
||||
public short getGamemode() {
|
||||
return gamemode;
|
||||
}
|
||||
|
||||
public void setGamemode(short gamemode) {
|
||||
this.gamemode = gamemode;
|
||||
}
|
||||
|
||||
public int getDimension() {
|
||||
return dimension;
|
||||
public void withDimension(int dimension) {
|
||||
this.dimension = dimension;
|
||||
}
|
||||
|
||||
public void setDimension(int dimension) {
|
||||
this.dimension = dimension;
|
||||
}
|
||||
|
||||
public long getPartialHashedSeed() {
|
||||
return partialHashedSeed;
|
||||
}
|
||||
|
||||
public short getDifficulty() {
|
||||
return difficulty;
|
||||
}
|
||||
|
||||
public void setDifficulty(short difficulty) {
|
||||
this.difficulty = difficulty;
|
||||
}
|
||||
|
||||
public int getMaxPlayers() {
|
||||
return maxPlayers;
|
||||
}
|
||||
|
||||
public void setMaxPlayers(int maxPlayers) {
|
||||
this.maxPlayers = maxPlayers;
|
||||
}
|
||||
|
||||
public @Nullable String getLevelType() {
|
||||
return levelType;
|
||||
}
|
||||
|
||||
public void setLevelType(String levelType) {
|
||||
this.levelType = levelType;
|
||||
}
|
||||
|
||||
public int getViewDistance() {
|
||||
return viewDistance;
|
||||
}
|
||||
|
||||
public void setViewDistance(int viewDistance) {
|
||||
this.viewDistance = viewDistance;
|
||||
}
|
||||
|
||||
public boolean isReducedDebugInfo() {
|
||||
return reducedDebugInfo;
|
||||
}
|
||||
|
||||
public void setReducedDebugInfo(boolean reducedDebugInfo) {
|
||||
this.reducedDebugInfo = reducedDebugInfo;
|
||||
}
|
||||
|
||||
public DimensionInfo getDimensionInfo() {
|
||||
return dimensionInfo;
|
||||
}
|
||||
|
||||
public void setDimensionInfo(DimensionInfo dimensionInfo) {
|
||||
this.dimensionInfo = dimensionInfo;
|
||||
}
|
||||
|
||||
public DimensionRegistry getDimensionRegistry() {
|
||||
return dimensionRegistry;
|
||||
}
|
||||
|
||||
public void setDimensionRegistry(DimensionRegistry dimensionRegistry) {
|
||||
this.dimensionRegistry = dimensionRegistry;
|
||||
}
|
||||
|
||||
public short getPreviousGamemode() {
|
||||
return previousGamemode;
|
||||
}
|
||||
|
||||
public void setPreviousGamemode(short previousGamemode) {
|
||||
this.previousGamemode = previousGamemode;
|
||||
}
|
||||
|
||||
public boolean getIsHardcore() {
|
||||
return isHardcore;
|
||||
}
|
||||
|
||||
public void setIsHardcore(boolean isHardcore) {
|
||||
this.isHardcore = isHardcore;
|
||||
}
|
||||
|
||||
public CompoundBinaryTag getBiomeRegistry() {
|
||||
return biomeRegistry;
|
||||
}
|
||||
|
||||
public void setBiomeRegistry(CompoundBinaryTag biomeRegistry) {
|
||||
this.biomeRegistry = biomeRegistry;
|
||||
}
|
||||
|
||||
public DimensionData getCurrentDimensionData() {
|
||||
return currentDimensionData;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "JoinGamePacket{"
|
||||
+ "entityId=" + entityId
|
||||
+ ", gamemode=" + gamemode
|
||||
+ ", dimension=" + dimension
|
||||
+ ", partialHashedSeed=" + partialHashedSeed
|
||||
+ ", difficulty=" + difficulty
|
||||
+ ", maxPlayers=" + maxPlayers
|
||||
+ ", levelType='" + levelType + '\''
|
||||
+ ", viewDistance=" + viewDistance
|
||||
+ ", reducedDebugInfo=" + reducedDebugInfo
|
||||
+ ", dimensionRegistry='" + dimensionRegistry + '\''
|
||||
+ ", dimensionInfo='" + dimensionInfo + '\''
|
||||
+ ", previousGamemode=" + previousGamemode
|
||||
+ '}';
|
||||
}
|
||||
|
||||
@Override
|
||||
public void decode(ByteBuf buf, ProtocolDirection direction, ProtocolVersion version) {
|
||||
public void decode(ByteBuf buf, PacketDirection direction, ProtocolVersion version) {
|
||||
this.entityId = buf.readInt();
|
||||
if (version.gte(ProtocolVersion.MINECRAFT_1_16_2)) {
|
||||
this.isHardcore = buf.readBoolean();
|
||||
@ -239,7 +118,7 @@ public class JoinGamePacket implements Packet {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void encode(ByteBuf buf, ProtocolDirection direction, ProtocolVersion version) {
|
||||
public void encode(ByteBuf buf, PacketDirection direction, ProtocolVersion version) {
|
||||
buf.writeInt(entityId);
|
||||
if (version.gte(ProtocolVersion.MINECRAFT_1_16_2)) {
|
||||
buf.writeBoolean(isHardcore);
|
||||
@ -306,8 +185,90 @@ public class JoinGamePacket implements Packet {
|
||||
}
|
||||
}
|
||||
|
||||
public int getEntityId() {
|
||||
return entityId;
|
||||
}
|
||||
|
||||
public short getGamemode() {
|
||||
return gamemode;
|
||||
}
|
||||
|
||||
public int getDimension() {
|
||||
return dimension;
|
||||
}
|
||||
|
||||
public long getPartialHashedSeed() {
|
||||
return partialHashedSeed;
|
||||
}
|
||||
|
||||
public short getDifficulty() {
|
||||
return difficulty;
|
||||
}
|
||||
|
||||
public int getMaxPlayers() {
|
||||
return maxPlayers;
|
||||
}
|
||||
|
||||
public @Nullable String getLevelType() {
|
||||
return levelType;
|
||||
}
|
||||
|
||||
public int getViewDistance() {
|
||||
return viewDistance;
|
||||
}
|
||||
|
||||
public boolean isReducedDebugInfo() {
|
||||
return reducedDebugInfo;
|
||||
}
|
||||
|
||||
public DimensionInfo getDimensionInfo() {
|
||||
return dimensionInfo;
|
||||
}
|
||||
|
||||
public DimensionRegistry getDimensionRegistry() {
|
||||
return dimensionRegistry;
|
||||
}
|
||||
|
||||
public short getPreviousGamemode() {
|
||||
return previousGamemode;
|
||||
}
|
||||
|
||||
public boolean getIsHardcore() {
|
||||
return isHardcore;
|
||||
}
|
||||
|
||||
public CompoundBinaryTag getBiomeRegistry() {
|
||||
return biomeRegistry;
|
||||
}
|
||||
|
||||
public DimensionData getCurrentDimensionData() {
|
||||
return currentDimensionData;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean handle(MinecraftSessionHandler handler) {
|
||||
public boolean handle(PacketHandler handler) {
|
||||
return handler.handle(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return MoreObjects.toStringHelper(this)
|
||||
.add("entityId", this.entityId)
|
||||
.add("gamemode", this.gamemode)
|
||||
.add("dimension", this.dimension)
|
||||
.add("partialHashedSeed", this.partialHashedSeed)
|
||||
.add("difficulty", this.difficulty)
|
||||
.add("isHardcore", this.isHardcore)
|
||||
.add("maxPlayers", this.maxPlayers)
|
||||
.add("levelType", this.levelType)
|
||||
.add("viewDistance", this.viewDistance)
|
||||
.add("reducedDebugInfo", this.reducedDebugInfo)
|
||||
.add("showRespawnScreen", this.showRespawnScreen)
|
||||
.add("dimensionRegistry", this.dimensionRegistry)
|
||||
.add("dimensionInfo", this.dimensionInfo)
|
||||
.add("currentDimensionData", this.currentDimensionData)
|
||||
.add("previousGamemode", this.previousGamemode)
|
||||
.add("biomeRegistry", this.biomeRegistry)
|
||||
.toString();
|
||||
}
|
||||
}
|
@ -0,0 +1,18 @@
|
||||
package com.velocitypowered.proxy.network.packet.clientbound;
|
||||
|
||||
import com.velocitypowered.proxy.network.packet.AbstractKeepAlivePacket;
|
||||
import com.velocitypowered.proxy.network.packet.Packet;
|
||||
import com.velocitypowered.proxy.network.packet.PacketHandler;
|
||||
|
||||
public class ClientboundKeepAlivePacket extends AbstractKeepAlivePacket implements Packet {
|
||||
public static final Decoder<ClientboundKeepAlivePacket> DECODER = decoder(ClientboundKeepAlivePacket::new);
|
||||
|
||||
public ClientboundKeepAlivePacket(final long randomId) {
|
||||
super(randomId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean handle(PacketHandler handler) {
|
||||
return handler.handle(this);
|
||||
}
|
||||
}
|
@ -1,19 +1,19 @@
|
||||
package com.velocitypowered.proxy.protocol.packet;
|
||||
package com.velocitypowered.proxy.network.packet.clientbound;
|
||||
|
||||
import com.google.common.base.MoreObjects;
|
||||
import com.velocitypowered.api.network.ProtocolVersion;
|
||||
import com.velocitypowered.proxy.connection.MinecraftSessionHandler;
|
||||
import com.velocitypowered.proxy.protocol.Packet;
|
||||
import com.velocitypowered.proxy.protocol.ProtocolDirection;
|
||||
import com.velocitypowered.proxy.protocol.ProtocolUtils;
|
||||
import com.velocitypowered.proxy.network.ProtocolUtils;
|
||||
import com.velocitypowered.proxy.network.packet.Packet;
|
||||
import com.velocitypowered.proxy.network.packet.PacketDirection;
|
||||
import com.velocitypowered.proxy.network.packet.PacketHandler;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty.buffer.DefaultByteBufHolder;
|
||||
import io.netty.buffer.Unpooled;
|
||||
import java.util.Objects;
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
|
||||
public class LoginPluginMessagePacket extends DefaultByteBufHolder implements Packet {
|
||||
|
||||
public static final Decoder<LoginPluginMessagePacket> DECODER = (buf, direction, version) -> {
|
||||
public class ClientboundLoginPluginMessagePacket extends DefaultByteBufHolder implements Packet {
|
||||
public static final Decoder<ClientboundLoginPluginMessagePacket> DECODER = (buf, direction, version) -> {
|
||||
final int id = ProtocolUtils.readVarInt(buf);
|
||||
final String channel = ProtocolUtils.readString(buf);
|
||||
final ByteBuf data;
|
||||
@ -22,20 +22,20 @@ public class LoginPluginMessagePacket extends DefaultByteBufHolder implements Pa
|
||||
} else {
|
||||
data = Unpooled.EMPTY_BUFFER;
|
||||
}
|
||||
return new LoginPluginMessagePacket(id, channel, data);
|
||||
return new ClientboundLoginPluginMessagePacket(id, channel, data);
|
||||
};
|
||||
|
||||
private final int id;
|
||||
private final @Nullable String channel;
|
||||
|
||||
public LoginPluginMessagePacket(int id, @Nullable String channel, ByteBuf data) {
|
||||
public ClientboundLoginPluginMessagePacket(int id, @Nullable String channel, ByteBuf data) {
|
||||
super(data);
|
||||
this.id = id;
|
||||
this.channel = channel;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void encode(ByteBuf buf, ProtocolDirection direction, ProtocolVersion version) {
|
||||
public void encode(ByteBuf buf, PacketDirection direction, ProtocolVersion version) {
|
||||
ProtocolUtils.writeVarInt(buf, id);
|
||||
if (channel == null) {
|
||||
throw new IllegalStateException("Channel is not specified!");
|
||||
@ -45,7 +45,7 @@ public class LoginPluginMessagePacket extends DefaultByteBufHolder implements Pa
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean handle(MinecraftSessionHandler handler) {
|
||||
public boolean handle(PacketHandler handler) {
|
||||
return handler.handle(this);
|
||||
}
|
||||
|
||||
@ -60,20 +60,15 @@ public class LoginPluginMessagePacket extends DefaultByteBufHolder implements Pa
|
||||
return channel;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "LoginPluginMessagePacket{"
|
||||
+ "id=" + id
|
||||
+ ", channel='" + channel + '\''
|
||||
+ ", data=" + super.toString()
|
||||
+ '}';
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(final Object other) {
|
||||
if(this == other) return true;
|
||||
if(other == null || this.getClass() != other.getClass()) return false;
|
||||
final LoginPluginMessagePacket that = (LoginPluginMessagePacket) other;
|
||||
if (this == other) {
|
||||
return true;
|
||||
}
|
||||
if (other == null || this.getClass() != other.getClass()) {
|
||||
return false;
|
||||
}
|
||||
final ClientboundLoginPluginMessagePacket that = (ClientboundLoginPluginMessagePacket) other;
|
||||
return this.id == that.id
|
||||
&& Objects.equals(this.channel, that.channel)
|
||||
&& super.equals(other);
|
||||
@ -83,4 +78,13 @@ public class LoginPluginMessagePacket extends DefaultByteBufHolder implements Pa
|
||||
public int hashCode() {
|
||||
return Objects.hash(this.id, this.channel, super.hashCode());
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return MoreObjects.toStringHelper(this)
|
||||
.add("id", this.id)
|
||||
.add("channel", this.channel)
|
||||
.add("data", this.contentToString())
|
||||
.toString();
|
||||
}
|
||||
}
|
@ -1,13 +1,14 @@
|
||||
package com.velocitypowered.proxy.protocol.packet;
|
||||
package com.velocitypowered.proxy.network.packet.clientbound;
|
||||
|
||||
import com.google.common.base.MoreObjects;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.velocitypowered.api.network.ProtocolVersion;
|
||||
import com.velocitypowered.api.proxy.player.TabListEntry;
|
||||
import com.velocitypowered.api.util.GameProfile;
|
||||
import com.velocitypowered.proxy.connection.MinecraftSessionHandler;
|
||||
import com.velocitypowered.proxy.protocol.Packet;
|
||||
import com.velocitypowered.proxy.protocol.ProtocolDirection;
|
||||
import com.velocitypowered.proxy.protocol.ProtocolUtils;
|
||||
import com.velocitypowered.proxy.network.ProtocolUtils;
|
||||
import com.velocitypowered.proxy.network.packet.Packet;
|
||||
import com.velocitypowered.proxy.network.packet.PacketDirection;
|
||||
import com.velocitypowered.proxy.network.packet.PacketHandler;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
@ -16,8 +17,8 @@ import net.kyori.adventure.text.Component;
|
||||
import net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer;
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
|
||||
public class PlayerListItemPacket implements Packet {
|
||||
public static final Decoder<PlayerListItemPacket> DECODER = Decoder.method(PlayerListItemPacket::new);
|
||||
public class ClientboundPlayerListItemPacket implements Packet {
|
||||
public static final Decoder<ClientboundPlayerListItemPacket> DECODER = Decoder.method(ClientboundPlayerListItemPacket::new);
|
||||
|
||||
public static final int ADD_PLAYER = 0;
|
||||
public static final int UPDATE_GAMEMODE = 1;
|
||||
@ -27,12 +28,12 @@ public class PlayerListItemPacket implements Packet {
|
||||
private int action;
|
||||
private final List<Item> items = new ArrayList<>();
|
||||
|
||||
public PlayerListItemPacket(int action, List<Item> items) {
|
||||
public ClientboundPlayerListItemPacket(int action, List<Item> items) {
|
||||
this.action = action;
|
||||
this.items.addAll(items);
|
||||
}
|
||||
|
||||
public PlayerListItemPacket() {
|
||||
public ClientboundPlayerListItemPacket() {
|
||||
}
|
||||
|
||||
public int getAction() {
|
||||
@ -44,7 +45,7 @@ public class PlayerListItemPacket implements Packet {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void decode(ByteBuf buf, ProtocolDirection direction, ProtocolVersion version) {
|
||||
public void decode(ByteBuf buf, PacketDirection direction, ProtocolVersion version) {
|
||||
if (version.gte(ProtocolVersion.MINECRAFT_1_8)) {
|
||||
action = ProtocolUtils.readVarInt(buf);
|
||||
int length = ProtocolUtils.readVarInt(buf);
|
||||
@ -94,7 +95,7 @@ public class PlayerListItemPacket implements Packet {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void encode(ByteBuf buf, ProtocolDirection direction, ProtocolVersion version) {
|
||||
public void encode(ByteBuf buf, PacketDirection direction, ProtocolVersion version) {
|
||||
if (version.gte(ProtocolVersion.MINECRAFT_1_8)) {
|
||||
ProtocolUtils.writeVarInt(buf, action);
|
||||
ProtocolUtils.writeVarInt(buf, items.size());
|
||||
@ -145,7 +146,7 @@ public class PlayerListItemPacket implements Packet {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean handle(MinecraftSessionHandler handler) {
|
||||
public boolean handle(PacketHandler handler) {
|
||||
return handler.handle(this);
|
||||
}
|
||||
|
||||
@ -158,6 +159,14 @@ public class PlayerListItemPacket implements Packet {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return MoreObjects.toStringHelper(this)
|
||||
.add("action", this.action)
|
||||
.add("items", this.items)
|
||||
.toString();
|
||||
}
|
||||
|
||||
public static class Item {
|
||||
|
||||
private final UUID uuid;
|
@ -0,0 +1,53 @@
|
||||
package com.velocitypowered.proxy.network.packet.clientbound;
|
||||
|
||||
import com.google.common.base.MoreObjects;
|
||||
import com.velocitypowered.api.network.ProtocolVersion;
|
||||
import com.velocitypowered.proxy.network.ProtocolUtils;
|
||||
import com.velocitypowered.proxy.network.packet.Packet;
|
||||
import com.velocitypowered.proxy.network.packet.PacketDirection;
|
||||
import com.velocitypowered.proxy.network.packet.PacketHandler;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import java.util.Objects;
|
||||
|
||||
public class ClientboundResourcePackRequestPacket implements Packet {
|
||||
public static final Decoder<ClientboundResourcePackRequestPacket> DECODER = (buf, direction, version) -> {
|
||||
final String url = ProtocolUtils.readString(buf);
|
||||
final String hash = ProtocolUtils.readString(buf);
|
||||
return new ClientboundResourcePackRequestPacket(url, hash);
|
||||
};
|
||||
|
||||
private final String url;
|
||||
private final String hash;
|
||||
|
||||
public ClientboundResourcePackRequestPacket(final String url, final String hash) {
|
||||
this.url = Objects.requireNonNull(url, "url");
|
||||
this.hash = Objects.requireNonNull(hash, "hash");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void encode(ByteBuf buf, PacketDirection direction, ProtocolVersion protocolVersion) {
|
||||
ProtocolUtils.writeString(buf, url);
|
||||
ProtocolUtils.writeString(buf, hash);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean handle(PacketHandler handler) {
|
||||
return handler.handle(this);
|
||||
}
|
||||
|
||||
public String getUrl() {
|
||||
return url;
|
||||
}
|
||||
|
||||
public String getHash() {
|
||||
return hash;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return MoreObjects.toStringHelper(this)
|
||||
.add("url", this.url)
|
||||
.add("hash", this.hash)
|
||||
.toString();
|
||||
}
|
||||
}
|
@ -1,17 +1,18 @@
|
||||
package com.velocitypowered.proxy.protocol.packet;
|
||||
package com.velocitypowered.proxy.network.packet.clientbound;
|
||||
|
||||
import com.google.common.base.MoreObjects;
|
||||
import com.velocitypowered.api.network.ProtocolVersion;
|
||||
import com.velocitypowered.proxy.connection.MinecraftSessionHandler;
|
||||
import com.velocitypowered.proxy.connection.registry.DimensionData;
|
||||
import com.velocitypowered.proxy.connection.registry.DimensionInfo;
|
||||
import com.velocitypowered.proxy.protocol.Packet;
|
||||
import com.velocitypowered.proxy.protocol.ProtocolDirection;
|
||||
import com.velocitypowered.proxy.protocol.ProtocolUtils;
|
||||
import com.velocitypowered.proxy.network.ProtocolUtils;
|
||||
import com.velocitypowered.proxy.network.packet.Packet;
|
||||
import com.velocitypowered.proxy.network.packet.PacketDirection;
|
||||
import com.velocitypowered.proxy.network.packet.PacketHandler;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import net.kyori.adventure.nbt.CompoundBinaryTag;
|
||||
|
||||
public class RespawnPacket implements Packet {
|
||||
public static final Decoder<RespawnPacket> DECODER = Decoder.method(RespawnPacket::new);
|
||||
public class ClientboundRespawnPacket implements Packet {
|
||||
public static final Decoder<ClientboundRespawnPacket> DECODER = Decoder.method(ClientboundRespawnPacket::new);
|
||||
|
||||
private int dimension;
|
||||
private long partialHashedSeed;
|
||||
@ -23,12 +24,12 @@ public class RespawnPacket implements Packet {
|
||||
private short previousGamemode; // 1.16+
|
||||
private DimensionData currentDimensionData; // 1.16.2+
|
||||
|
||||
public RespawnPacket() {
|
||||
public ClientboundRespawnPacket() {
|
||||
}
|
||||
|
||||
public RespawnPacket(int dimension, long partialHashedSeed, short difficulty, short gamemode,
|
||||
String levelType, boolean shouldKeepPlayerData, DimensionInfo dimensionInfo,
|
||||
short previousGamemode, DimensionData currentDimensionData) {
|
||||
public ClientboundRespawnPacket(int dimension, long partialHashedSeed, short difficulty, short gamemode,
|
||||
String levelType, boolean shouldKeepPlayerData, DimensionInfo dimensionInfo,
|
||||
short previousGamemode, DimensionData currentDimensionData) {
|
||||
this.dimension = dimension;
|
||||
this.partialHashedSeed = partialHashedSeed;
|
||||
this.difficulty = difficulty;
|
||||
@ -97,23 +98,7 @@ public class RespawnPacket implements Packet {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "RespawnPacket{"
|
||||
+ "dimension=" + dimension
|
||||
+ ", partialHashedSeed=" + partialHashedSeed
|
||||
+ ", difficulty=" + difficulty
|
||||
+ ", gamemode=" + gamemode
|
||||
+ ", levelType='" + levelType + '\''
|
||||
+ ", shouldKeepPlayerData=" + shouldKeepPlayerData
|
||||
+ ", dimensionRegistryName='" + dimensionInfo.toString() + '\''
|
||||
+ ", dimensionInfo=" + dimensionInfo
|
||||
+ ", previousGamemode=" + previousGamemode
|
||||
+ ", dimensionData=" + currentDimensionData
|
||||
+ '}';
|
||||
}
|
||||
|
||||
@Override
|
||||
public void decode(ByteBuf buf, ProtocolDirection direction, ProtocolVersion version) {
|
||||
public void decode(ByteBuf buf, PacketDirection direction, ProtocolVersion version) {
|
||||
String dimensionIdentifier = null;
|
||||
String levelName = null;
|
||||
if (version.gte(ProtocolVersion.MINECRAFT_1_16)) {
|
||||
@ -148,7 +133,7 @@ public class RespawnPacket implements Packet {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void encode(ByteBuf buf, ProtocolDirection direction, ProtocolVersion version) {
|
||||
public void encode(ByteBuf buf, PacketDirection direction, ProtocolVersion version) {
|
||||
if (version.gte(ProtocolVersion.MINECRAFT_1_16)) {
|
||||
if (version.gte(ProtocolVersion.MINECRAFT_1_16_2)) {
|
||||
ProtocolUtils.writeCompoundTag(buf, currentDimensionData.serializeDimensionDetails());
|
||||
@ -178,7 +163,22 @@ public class RespawnPacket implements Packet {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean handle(MinecraftSessionHandler handler) {
|
||||
public boolean handle(PacketHandler handler) {
|
||||
return handler.handle(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return MoreObjects.toStringHelper(this)
|
||||
.add("dimension", this.dimension)
|
||||
.add("partialHashedSeed", this.partialHashedSeed)
|
||||
.add("difficulty", this.difficulty)
|
||||
.add("gamemode", this.gamemode)
|
||||
.add("levelType", this.levelType)
|
||||
.add("shouldKeepPlayerData", this.shouldKeepPlayerData)
|
||||
.add("dimensionInfo", this.dimensionInfo)
|
||||
.add("previousGamemode", this.previousGamemode)
|
||||
.add("currentDimensionData", this.currentDimensionData)
|
||||
.toString();
|
||||
}
|
||||
}
|
@ -0,0 +1,68 @@
|
||||
package com.velocitypowered.proxy.network.packet.clientbound;
|
||||
|
||||
import com.google.common.base.MoreObjects;
|
||||
import com.velocitypowered.api.network.ProtocolVersion;
|
||||
import com.velocitypowered.api.util.UuidUtils;
|
||||
import com.velocitypowered.proxy.network.ProtocolUtils;
|
||||
import com.velocitypowered.proxy.network.packet.Packet;
|
||||
import com.velocitypowered.proxy.network.packet.PacketDirection;
|
||||
import com.velocitypowered.proxy.network.packet.PacketHandler;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import java.util.Objects;
|
||||
import java.util.UUID;
|
||||
|
||||
public class ClientboundServerLoginSuccessPacket implements Packet {
|
||||
public static final Decoder<ClientboundServerLoginSuccessPacket> DECODER = (buf, direction, version) -> {
|
||||
final UUID uuid;
|
||||
if (version.gte(ProtocolVersion.MINECRAFT_1_16)) {
|
||||
uuid = ProtocolUtils.readUuidIntArray(buf);
|
||||
} else if (version.gte(ProtocolVersion.MINECRAFT_1_7_6)) {
|
||||
uuid = UUID.fromString(ProtocolUtils.readString(buf, 36));
|
||||
} else {
|
||||
uuid = UuidUtils.fromUndashed(ProtocolUtils.readString(buf, 32));
|
||||
}
|
||||
final String username = ProtocolUtils.readString(buf, 16);
|
||||
return new ClientboundServerLoginSuccessPacket(uuid, username);
|
||||
};
|
||||
|
||||
private final UUID uuid;
|
||||
private final String username;
|
||||
|
||||
public ClientboundServerLoginSuccessPacket(final UUID uuid, final String username) {
|
||||
this.uuid = Objects.requireNonNull(uuid, "uuid");
|
||||
this.username = Objects.requireNonNull(username, "username");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void encode(ByteBuf buf, PacketDirection direction, ProtocolVersion version) {
|
||||
if (version.gte(ProtocolVersion.MINECRAFT_1_16)) {
|
||||
ProtocolUtils.writeUuidIntArray(buf, uuid);
|
||||
} else if (version.gte(ProtocolVersion.MINECRAFT_1_7_6)) {
|
||||
ProtocolUtils.writeString(buf, uuid.toString());
|
||||
} else {
|
||||
ProtocolUtils.writeString(buf, UuidUtils.toUndashed(uuid));
|
||||
}
|
||||
ProtocolUtils.writeString(buf, username);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean handle(PacketHandler handler) {
|
||||
return handler.handle(this);
|
||||
}
|
||||
|
||||
public UUID getUuid() {
|
||||
return uuid;
|
||||
}
|
||||
|
||||
public String getUsername() {
|
||||
return username;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return MoreObjects.toStringHelper(this)
|
||||
.add("uuid", this.uuid)
|
||||
.add("username", this.username)
|
||||
.toString();
|
||||
}
|
||||
}
|
@ -0,0 +1,43 @@
|
||||
package com.velocitypowered.proxy.network.packet.clientbound;
|
||||
|
||||
import com.google.common.base.MoreObjects;
|
||||
import com.velocitypowered.api.network.ProtocolVersion;
|
||||
import com.velocitypowered.proxy.network.ProtocolUtils;
|
||||
import com.velocitypowered.proxy.network.packet.Packet;
|
||||
import com.velocitypowered.proxy.network.packet.PacketDirection;
|
||||
import com.velocitypowered.proxy.network.packet.PacketHandler;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
|
||||
public class ClientboundSetCompressionPacket implements Packet {
|
||||
public static final Decoder<ClientboundSetCompressionPacket> DECODER = (buf, direction, version) -> {
|
||||
final int threshold = ProtocolUtils.readVarInt(buf);
|
||||
return new ClientboundSetCompressionPacket(threshold);
|
||||
};
|
||||
|
||||
private final int threshold;
|
||||
|
||||
public ClientboundSetCompressionPacket(int threshold) {
|
||||
this.threshold = threshold;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void encode(ByteBuf buf, PacketDirection direction, ProtocolVersion version) {
|
||||
ProtocolUtils.writeVarInt(buf, threshold);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean handle(PacketHandler handler) {
|
||||
return handler.handle(this);
|
||||
}
|
||||
|
||||
public int getThreshold() {
|
||||
return threshold;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return MoreObjects.toStringHelper(this)
|
||||
.add("threshold", this.threshold)
|
||||
.toString();
|
||||
}
|
||||
}
|
@ -0,0 +1,18 @@
|
||||
package com.velocitypowered.proxy.network.packet.clientbound;
|
||||
|
||||
import com.velocitypowered.proxy.network.packet.AbstractStatusPingPacket;
|
||||
import com.velocitypowered.proxy.network.packet.Packet;
|
||||
import com.velocitypowered.proxy.network.packet.PacketHandler;
|
||||
|
||||
public class ClientboundStatusPingPacket extends AbstractStatusPingPacket implements Packet {
|
||||
public static final Decoder<ClientboundStatusPingPacket> DECODER = decoder(ClientboundStatusPingPacket::new);
|
||||
|
||||
public ClientboundStatusPingPacket(final long randomId) {
|
||||
super(randomId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean handle(PacketHandler handler) {
|
||||
return handler.handle(this);
|
||||
}
|
||||
}
|
@ -0,0 +1,50 @@
|
||||
package com.velocitypowered.proxy.network.packet.clientbound;
|
||||
|
||||
import com.google.common.base.MoreObjects;
|
||||
import com.velocitypowered.api.network.ProtocolVersion;
|
||||
import com.velocitypowered.proxy.network.ProtocolUtils;
|
||||
import com.velocitypowered.proxy.network.packet.Packet;
|
||||
import com.velocitypowered.proxy.network.packet.PacketDirection;
|
||||
import com.velocitypowered.proxy.network.packet.PacketHandler;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
|
||||
public class ClientboundStatusResponsePacket implements Packet {
|
||||
public static final Decoder<ClientboundStatusResponsePacket> DECODER = (buf, direction, version) -> {
|
||||
final String status = ProtocolUtils.readString(buf, Short.MAX_VALUE);
|
||||
return new ClientboundStatusResponsePacket(status);
|
||||
};
|
||||
|
||||
private final @Nullable CharSequence status;
|
||||
|
||||
public ClientboundStatusResponsePacket(CharSequence status) {
|
||||
this.status = status;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void encode(ByteBuf buf, PacketDirection direction, ProtocolVersion version) {
|
||||
if (status == null) {
|
||||
throw new IllegalStateException("Status is not specified");
|
||||
}
|
||||
ProtocolUtils.writeString(buf, status);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean handle(PacketHandler handler) {
|
||||
return handler.handle(this);
|
||||
}
|
||||
|
||||
public String getStatus() {
|
||||
if (status == null) {
|
||||
throw new IllegalStateException("Status is not specified");
|
||||
}
|
||||
return status.toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return MoreObjects.toStringHelper(this)
|
||||
.add("status", this.status)
|
||||
.toString();
|
||||
}
|
||||
}
|
@ -1,22 +1,19 @@
|
||||
package com.velocitypowered.proxy.protocol.packet;
|
||||
|
||||
import static com.velocitypowered.api.network.ProtocolVersion.MINECRAFT_1_13;
|
||||
package com.velocitypowered.proxy.network.packet.clientbound;
|
||||
|
||||
import com.google.common.base.MoreObjects;
|
||||
import com.velocitypowered.api.network.ProtocolVersion;
|
||||
import com.velocitypowered.proxy.connection.MinecraftSessionHandler;
|
||||
import com.velocitypowered.proxy.protocol.Packet;
|
||||
import com.velocitypowered.proxy.protocol.ProtocolDirection;
|
||||
import com.velocitypowered.proxy.protocol.ProtocolUtils;
|
||||
import com.velocitypowered.proxy.network.ProtocolUtils;
|
||||
import com.velocitypowered.proxy.network.packet.Packet;
|
||||
import com.velocitypowered.proxy.network.packet.PacketDirection;
|
||||
import com.velocitypowered.proxy.network.packet.PacketHandler;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
|
||||
public class TabCompleteResponsePacket implements Packet {
|
||||
|
||||
public static final Decoder<TabCompleteResponsePacket> DECODER = Decoder.method(TabCompleteResponsePacket::new);
|
||||
public class ClientboundTabCompleteResponsePacket implements Packet {
|
||||
public static final Decoder<ClientboundTabCompleteResponsePacket> DECODER = Decoder.method(ClientboundTabCompleteResponsePacket::new);
|
||||
|
||||
private int transactionId;
|
||||
private int start;
|
||||
@ -52,18 +49,8 @@ public class TabCompleteResponsePacket implements Packet {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "TabCompleteResponsePacket{"
|
||||
+ "transactionId=" + transactionId
|
||||
+ ", start=" + start
|
||||
+ ", length=" + length
|
||||
+ ", offers=" + offers
|
||||
+ '}';
|
||||
}
|
||||
|
||||
@Override
|
||||
public void decode(ByteBuf buf, ProtocolDirection direction, ProtocolVersion version) {
|
||||
if (version.gte(MINECRAFT_1_13)) {
|
||||
public void decode(ByteBuf buf, PacketDirection direction, ProtocolVersion version) {
|
||||
if (version.gte(ProtocolVersion.MINECRAFT_1_13)) {
|
||||
this.transactionId = ProtocolUtils.readVarInt(buf);
|
||||
this.start = ProtocolUtils.readVarInt(buf);
|
||||
this.length = ProtocolUtils.readVarInt(buf);
|
||||
@ -83,8 +70,8 @@ public class TabCompleteResponsePacket implements Packet {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void encode(ByteBuf buf, ProtocolDirection direction, ProtocolVersion version) {
|
||||
if (version.gte(MINECRAFT_1_13)) {
|
||||
public void encode(ByteBuf buf, PacketDirection direction, ProtocolVersion version) {
|
||||
if (version.gte(ProtocolVersion.MINECRAFT_1_13)) {
|
||||
ProtocolUtils.writeVarInt(buf, this.transactionId);
|
||||
ProtocolUtils.writeVarInt(buf, this.start);
|
||||
ProtocolUtils.writeVarInt(buf, this.length);
|
||||
@ -106,10 +93,20 @@ public class TabCompleteResponsePacket implements Packet {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean handle(MinecraftSessionHandler handler) {
|
||||
public boolean handle(PacketHandler handler) {
|
||||
return handler.handle(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return MoreObjects.toStringHelper(this)
|
||||
.add("transactionId", this.transactionId)
|
||||
.add("start", this.start)
|
||||
.add("length", this.length)
|
||||
.add("offers", this.offers)
|
||||
.toString();
|
||||
}
|
||||
|
||||
public static class Offer implements Comparable<Offer> {
|
||||
private final String text;
|
||||
private final @Nullable Component tooltip;
|
@ -1,42 +1,42 @@
|
||||
package com.velocitypowered.proxy.protocol.packet;
|
||||
package com.velocitypowered.proxy.network.packet.clientbound;
|
||||
|
||||
import com.google.common.base.MoreObjects;
|
||||
import com.google.common.primitives.Ints;
|
||||
import com.velocitypowered.api.network.ProtocolVersion;
|
||||
import com.velocitypowered.proxy.connection.MinecraftSessionHandler;
|
||||
import com.velocitypowered.proxy.protocol.Packet;
|
||||
import com.velocitypowered.proxy.protocol.ProtocolDirection;
|
||||
import com.velocitypowered.proxy.protocol.ProtocolUtils;
|
||||
import com.velocitypowered.proxy.network.ProtocolUtils;
|
||||
import com.velocitypowered.proxy.network.packet.Packet;
|
||||
import com.velocitypowered.proxy.network.packet.PacketDirection;
|
||||
import com.velocitypowered.proxy.network.packet.PacketHandler;
|
||||
import com.velocitypowered.proxy.util.DurationUtils;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import java.util.Arrays;
|
||||
import net.kyori.adventure.title.Title;
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
|
||||
public class TitlePacket implements Packet {
|
||||
public class ClientboundTitlePacket implements Packet {
|
||||
public static final Decoder<ClientboundTitlePacket> DECODER = Decoder.unsupported();
|
||||
|
||||
public static final Decoder<TitlePacket> DECODER = Decoder.unsupported();
|
||||
|
||||
public static TitlePacket hide(final ProtocolVersion version) {
|
||||
public static ClientboundTitlePacket hide(final ProtocolVersion version) {
|
||||
return version.gte(ProtocolVersion.MINECRAFT_1_11)
|
||||
? Instances.HIDE
|
||||
: Instances.HIDE_OLD;
|
||||
}
|
||||
|
||||
public static TitlePacket reset(final ProtocolVersion version) {
|
||||
public static ClientboundTitlePacket reset(final ProtocolVersion version) {
|
||||
return version.gte(ProtocolVersion.MINECRAFT_1_11)
|
||||
? Instances.RESET
|
||||
: Instances.RESET_OLD;
|
||||
? Instances.RESET
|
||||
: Instances.RESET_OLD;
|
||||
}
|
||||
|
||||
public static TitlePacket times(final ProtocolVersion version, final Title.Times times) {
|
||||
public static ClientboundTitlePacket times(final ProtocolVersion version, final Title.Times times) {
|
||||
final int action = version.gte(ProtocolVersion.MINECRAFT_1_11)
|
||||
? SET_TIMES
|
||||
: SET_TIMES_OLD;
|
||||
return new TitlePacket(
|
||||
action,
|
||||
(int) DurationUtils.toTicks(times.fadeIn()),
|
||||
(int) DurationUtils.toTicks(times.stay()),
|
||||
(int) DurationUtils.toTicks(times.fadeOut())
|
||||
? SET_TIMES
|
||||
: SET_TIMES_OLD;
|
||||
return new ClientboundTitlePacket(
|
||||
action,
|
||||
(int) DurationUtils.toTicks(times.fadeIn()),
|
||||
(int) DurationUtils.toTicks(times.stay()),
|
||||
(int) DurationUtils.toTicks(times.fadeOut())
|
||||
);
|
||||
}
|
||||
|
||||
@ -57,7 +57,7 @@ public class TitlePacket implements Packet {
|
||||
private final int stay;
|
||||
private final int fadeOut;
|
||||
|
||||
private TitlePacket(final int action) {
|
||||
private ClientboundTitlePacket(final int action) {
|
||||
checkAction(action, HIDE, RESET, HIDE_OLD, RESET_OLD);
|
||||
this.action = action;
|
||||
this.component = null;
|
||||
@ -66,7 +66,7 @@ public class TitlePacket implements Packet {
|
||||
this.fadeOut = -1;
|
||||
}
|
||||
|
||||
public TitlePacket(final int action, final String component) {
|
||||
public ClientboundTitlePacket(final int action, final String component) {
|
||||
checkAction(action, SET_TITLE, SET_SUBTITLE, SET_ACTION_BAR);
|
||||
this.action = action;
|
||||
this.component = component;
|
||||
@ -75,7 +75,7 @@ public class TitlePacket implements Packet {
|
||||
this.fadeOut = -1;
|
||||
}
|
||||
|
||||
public TitlePacket(final int action, final int fadeIn, final int stay, final int fadeOut) {
|
||||
public ClientboundTitlePacket(final int action, final int fadeIn, final int stay, final int fadeOut) {
|
||||
checkAction(action, SET_TIMES, SET_TIMES_OLD);
|
||||
this.action = action;
|
||||
this.component = null;
|
||||
@ -91,7 +91,7 @@ public class TitlePacket implements Packet {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void encode(ByteBuf buf, ProtocolDirection direction, ProtocolVersion version) {
|
||||
public void encode(ByteBuf buf, PacketDirection direction, ProtocolVersion version) {
|
||||
ProtocolUtils.writeVarInt(buf, action);
|
||||
if (version.gte(ProtocolVersion.MINECRAFT_1_11)) {
|
||||
// 1.11+ shifted the action enum by 1 to handle the action bar
|
||||
@ -139,7 +139,7 @@ public class TitlePacket implements Packet {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean handle(MinecraftSessionHandler handler) {
|
||||
public boolean handle(PacketHandler handler) {
|
||||
return handler.handle(this);
|
||||
}
|
||||
|
||||
@ -165,21 +165,23 @@ public class TitlePacket implements Packet {
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "TitlePacket{"
|
||||
+ "action=" + action
|
||||
+ ", component='" + component + '\''
|
||||
+ ", fadeIn=" + fadeIn
|
||||
+ ", stay=" + stay
|
||||
+ ", fadeOut=" + fadeOut
|
||||
+ '}';
|
||||
return MoreObjects.toStringHelper(this)
|
||||
.add("action", this.action)
|
||||
.add("component", this.component)
|
||||
.add("fadeIn", this.fadeIn)
|
||||
.add("stay", this.stay)
|
||||
.add("fadeOut", this.fadeOut)
|
||||
.toString();
|
||||
}
|
||||
|
||||
public static final class Instances {
|
||||
public static final TitlePacket HIDE = new TitlePacket(TitlePacket.HIDE);
|
||||
public static final TitlePacket RESET = new TitlePacket(TitlePacket.RESET);
|
||||
public static final ClientboundTitlePacket HIDE
|
||||
= new ClientboundTitlePacket(ClientboundTitlePacket.HIDE);
|
||||
public static final ClientboundTitlePacket RESET
|
||||
= new ClientboundTitlePacket(ClientboundTitlePacket.RESET);
|
||||
|
||||
public static final TitlePacket HIDE_OLD = new TitlePacket(TitlePacket.HIDE_OLD);
|
||||
public static final TitlePacket RESET_OLD = new TitlePacket(TitlePacket.RESET_OLD);
|
||||
public static final ClientboundTitlePacket HIDE_OLD = new ClientboundTitlePacket(ClientboundTitlePacket.HIDE_OLD);
|
||||
public static final ClientboundTitlePacket RESET_OLD = new ClientboundTitlePacket(ClientboundTitlePacket.RESET_OLD);
|
||||
|
||||
private Instances() {
|
||||
}
|
@ -1,9 +1,8 @@
|
||||
package com.velocitypowered.proxy.protocol.packet.legacy;
|
||||
package com.velocitypowered.proxy.network.packet.legacy;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.velocitypowered.api.proxy.server.ServerPing;
|
||||
import com.velocitypowered.api.proxy.server.ServerPing.Players;
|
||||
import com.velocitypowered.proxy.protocol.packet.legacyping.LegacyMinecraftPingVersion;
|
||||
import net.kyori.adventure.text.TextComponent;
|
||||
import net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer;
|
||||
import net.kyori.adventure.text.serializer.plain.PlainComponentSerializer;
|
@ -0,0 +1,20 @@
|
||||
package com.velocitypowered.proxy.network.packet.legacy;
|
||||
|
||||
import com.velocitypowered.api.network.ProtocolVersion;
|
||||
import com.velocitypowered.proxy.network.packet.Packet;
|
||||
import com.velocitypowered.proxy.network.packet.PacketDirection;
|
||||
import com.velocitypowered.proxy.network.packet.PacketHandler;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
|
||||
public class LegacyHandshakePacket implements LegacyPacket, Packet {
|
||||
|
||||
@Override
|
||||
public void encode(ByteBuf buf, PacketDirection direction, ProtocolVersion version) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean handle(PacketHandler handler) {
|
||||
return handler.handle(this);
|
||||
}
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
package com.velocitypowered.proxy.protocol.packet.legacyping;
|
||||
package com.velocitypowered.proxy.network.packet.legacy;
|
||||
|
||||
public enum LegacyMinecraftPingVersion {
|
||||
MINECRAFT_1_3,
|
@ -0,0 +1,4 @@
|
||||
package com.velocitypowered.proxy.network.packet.legacy;
|
||||
|
||||
public interface LegacyPacket {
|
||||
}
|
@ -1,10 +1,9 @@
|
||||
package com.velocitypowered.proxy.protocol.packet.legacy;
|
||||
package com.velocitypowered.proxy.network.packet.legacy;
|
||||
|
||||
import com.velocitypowered.api.network.ProtocolVersion;
|
||||
import com.velocitypowered.proxy.connection.MinecraftSessionHandler;
|
||||
import com.velocitypowered.proxy.protocol.Packet;
|
||||
import com.velocitypowered.proxy.protocol.ProtocolDirection;
|
||||
import com.velocitypowered.proxy.protocol.packet.legacyping.LegacyMinecraftPingVersion;
|
||||
import com.velocitypowered.proxy.network.packet.Packet;
|
||||
import com.velocitypowered.proxy.network.packet.PacketDirection;
|
||||
import com.velocitypowered.proxy.network.packet.PacketHandler;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import java.net.InetSocketAddress;
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
@ -25,12 +24,12 @@ public class LegacyPingPacket implements LegacyPacket, Packet {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void encode(ByteBuf buf, ProtocolDirection direction, ProtocolVersion version) {
|
||||
public void encode(ByteBuf buf, PacketDirection direction, ProtocolVersion version) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean handle(MinecraftSessionHandler handler) {
|
||||
public boolean handle(PacketHandler handler) {
|
||||
return handler.handle(this);
|
||||
}
|
||||
|
@ -1,14 +1,14 @@
|
||||
package com.velocitypowered.proxy.protocol.packet;
|
||||
package com.velocitypowered.proxy.network.packet.serverbound;
|
||||
|
||||
import com.google.common.base.MoreObjects;
|
||||
import com.velocitypowered.api.network.ProtocolVersion;
|
||||
import com.velocitypowered.proxy.connection.MinecraftSessionHandler;
|
||||
import com.velocitypowered.proxy.protocol.Packet;
|
||||
import com.velocitypowered.proxy.protocol.ProtocolDirection;
|
||||
import com.velocitypowered.proxy.protocol.ProtocolUtils;
|
||||
import com.velocitypowered.proxy.network.ProtocolUtils;
|
||||
import com.velocitypowered.proxy.network.packet.Packet;
|
||||
import com.velocitypowered.proxy.network.packet.PacketDirection;
|
||||
import com.velocitypowered.proxy.network.packet.PacketHandler;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
|
||||
public class ServerboundChatPacket implements Packet {
|
||||
|
||||
public static final Decoder<ServerboundChatPacket> DECODER = (buf, direction, version) -> {
|
||||
final String message = ProtocolUtils.readString(buf);
|
||||
return new ServerboundChatPacket(message);
|
||||
@ -23,12 +23,12 @@ public class ServerboundChatPacket implements Packet {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void encode(ByteBuf buf, ProtocolDirection direction, ProtocolVersion version) {
|
||||
public void encode(ByteBuf buf, PacketDirection direction, ProtocolVersion version) {
|
||||
ProtocolUtils.writeString(buf, message);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean handle(MinecraftSessionHandler handler) {
|
||||
public boolean handle(PacketHandler handler) {
|
||||
return handler.handle(this);
|
||||
}
|
||||
|
||||
@ -38,8 +38,8 @@ public class ServerboundChatPacket implements Packet {
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "ServerboundChatPacket{"
|
||||
+ "message='" + message + '\''
|
||||
+ '}';
|
||||
return MoreObjects.toStringHelper(this)
|
||||
.add("message", this.message)
|
||||
.toString();
|
||||
}
|
||||
}
|
@ -1,16 +1,16 @@
|
||||
package com.velocitypowered.proxy.protocol.packet;
|
||||
package com.velocitypowered.proxy.network.packet.serverbound;
|
||||
|
||||
import com.google.common.base.MoreObjects;
|
||||
import com.velocitypowered.api.network.ProtocolVersion;
|
||||
import com.velocitypowered.proxy.connection.MinecraftSessionHandler;
|
||||
import com.velocitypowered.proxy.protocol.Packet;
|
||||
import com.velocitypowered.proxy.protocol.ProtocolDirection;
|
||||
import com.velocitypowered.proxy.protocol.ProtocolUtils;
|
||||
import com.velocitypowered.proxy.network.ProtocolUtils;
|
||||
import com.velocitypowered.proxy.network.packet.Packet;
|
||||
import com.velocitypowered.proxy.network.packet.PacketDirection;
|
||||
import com.velocitypowered.proxy.network.packet.PacketHandler;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
|
||||
public class ClientSettingsPacket implements Packet {
|
||||
|
||||
public static final Decoder<ClientSettingsPacket> DECODER = Decoder.method(ClientSettingsPacket::new);
|
||||
public class ServerboundClientSettingsPacket implements Packet {
|
||||
public static final Decoder<ServerboundClientSettingsPacket> DECODER = Decoder.method(ServerboundClientSettingsPacket::new);
|
||||
|
||||
private @Nullable String locale;
|
||||
private byte viewDistance;
|
||||
@ -20,11 +20,11 @@ public class ClientSettingsPacket implements Packet {
|
||||
private short skinParts;
|
||||
private int mainHand;
|
||||
|
||||
public ClientSettingsPacket() {
|
||||
public ServerboundClientSettingsPacket() {
|
||||
}
|
||||
|
||||
public ClientSettingsPacket(String locale, byte viewDistance, int chatVisibility, boolean chatColors,
|
||||
short skinParts, int mainHand) {
|
||||
public ServerboundClientSettingsPacket(String locale, byte viewDistance, int chatVisibility, boolean chatColors,
|
||||
short skinParts, int mainHand) {
|
||||
this.locale = locale;
|
||||
this.viewDistance = viewDistance;
|
||||
this.chatVisibility = chatVisibility;
|
||||
@ -33,71 +33,8 @@ public class ClientSettingsPacket implements Packet {
|
||||
this.mainHand = mainHand;
|
||||
}
|
||||
|
||||
public String getLocale() {
|
||||
if (locale == null) {
|
||||
throw new IllegalStateException("No locale specified");
|
||||
}
|
||||
return locale;
|
||||
}
|
||||
|
||||
public void setLocale(String locale) {
|
||||
this.locale = locale;
|
||||
}
|
||||
|
||||
public byte getViewDistance() {
|
||||
return viewDistance;
|
||||
}
|
||||
|
||||
public void setViewDistance(byte viewDistance) {
|
||||
this.viewDistance = viewDistance;
|
||||
}
|
||||
|
||||
public int getChatVisibility() {
|
||||
return chatVisibility;
|
||||
}
|
||||
|
||||
public void setChatVisibility(int chatVisibility) {
|
||||
this.chatVisibility = chatVisibility;
|
||||
}
|
||||
|
||||
public boolean isChatColors() {
|
||||
return chatColors;
|
||||
}
|
||||
|
||||
public void setChatColors(boolean chatColors) {
|
||||
this.chatColors = chatColors;
|
||||
}
|
||||
|
||||
public short getSkinParts() {
|
||||
return skinParts;
|
||||
}
|
||||
|
||||
public void setSkinParts(short skinParts) {
|
||||
this.skinParts = skinParts;
|
||||
}
|
||||
|
||||
public int getMainHand() {
|
||||
return mainHand;
|
||||
}
|
||||
|
||||
public void setMainHand(int mainHand) {
|
||||
this.mainHand = mainHand;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "ClientSettingsPacket{"
|
||||
+ "locale='" + locale + '\''
|
||||
+ ", viewDistance=" + viewDistance
|
||||
+ ", chatVisibility=" + chatVisibility
|
||||
+ ", chatColors=" + chatColors
|
||||
+ ", skinParts=" + skinParts
|
||||
+ ", mainHand=" + mainHand
|
||||
+ '}';
|
||||
}
|
||||
|
||||
@Override
|
||||
public void decode(ByteBuf buf, ProtocolDirection direction, ProtocolVersion version) {
|
||||
public void decode(ByteBuf buf, PacketDirection direction, ProtocolVersion version) {
|
||||
this.locale = ProtocolUtils.readString(buf, 16);
|
||||
this.viewDistance = buf.readByte();
|
||||
this.chatVisibility = ProtocolUtils.readVarInt(buf);
|
||||
@ -115,7 +52,7 @@ public class ClientSettingsPacket implements Packet {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void encode(ByteBuf buf, ProtocolDirection direction, ProtocolVersion version) {
|
||||
public void encode(ByteBuf buf, PacketDirection direction, ProtocolVersion version) {
|
||||
if (locale == null) {
|
||||
throw new IllegalStateException("No locale specified");
|
||||
}
|
||||
@ -136,7 +73,47 @@ public class ClientSettingsPacket implements Packet {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean handle(MinecraftSessionHandler handler) {
|
||||
public boolean handle(PacketHandler handler) {
|
||||
return handler.handle(this);
|
||||
}
|
||||
|
||||
public String getLocale() {
|
||||
if (locale == null) {
|
||||
throw new IllegalStateException("No locale specified");
|
||||
}
|
||||
return locale;
|
||||
}
|
||||
|
||||
public byte getViewDistance() {
|
||||
return viewDistance;
|
||||
}
|
||||
|
||||
public int getChatVisibility() {
|
||||
return chatVisibility;
|
||||
}
|
||||
|
||||
public boolean isChatColors() {
|
||||
return chatColors;
|
||||
}
|
||||
|
||||
public short getSkinParts() {
|
||||
return skinParts;
|
||||
}
|
||||
|
||||
public int getMainHand() {
|
||||
return mainHand;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return MoreObjects.toStringHelper(this)
|
||||
.add("locale", this.locale)
|
||||
.add("viewDistance", this.viewDistance)
|
||||
.add("chatVisibility", this.chatVisibility)
|
||||
.add("chatColors", this.chatColors)
|
||||
.add("difficulty", this.difficulty)
|
||||
.add("skinParts", this.skinParts)
|
||||
.add("mainHand", this.mainHand)
|
||||
.toString();
|
||||
}
|
||||
}
|
@ -0,0 +1,64 @@
|
||||
package com.velocitypowered.proxy.network.packet.serverbound;
|
||||
|
||||
import com.google.common.base.MoreObjects;
|
||||
import com.velocitypowered.api.network.ProtocolVersion;
|
||||
import com.velocitypowered.proxy.network.ProtocolUtils;
|
||||
import com.velocitypowered.proxy.network.packet.Packet;
|
||||
import com.velocitypowered.proxy.network.packet.PacketDirection;
|
||||
import com.velocitypowered.proxy.network.packet.PacketHandler;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
|
||||
public class ServerboundEncryptionResponsePacket implements Packet {
|
||||
public static final Decoder<ServerboundEncryptionResponsePacket> DECODER = (buf, direction, version) -> {
|
||||
final byte[] sharedSecret;
|
||||
final byte[] verifyToken;
|
||||
if (version.gte(ProtocolVersion.MINECRAFT_1_8)) {
|
||||
sharedSecret = ProtocolUtils.readByteArray(buf, 256);
|
||||
verifyToken = ProtocolUtils.readByteArray(buf, 128);
|
||||
} else {
|
||||
sharedSecret = ProtocolUtils.readByteArray17(buf);
|
||||
verifyToken = ProtocolUtils.readByteArray17(buf);
|
||||
}
|
||||
return new ServerboundEncryptionResponsePacket(sharedSecret, verifyToken);
|
||||
};
|
||||
|
||||
private final byte[] sharedSecret;
|
||||
private final byte[] verifyToken;
|
||||
|
||||
public ServerboundEncryptionResponsePacket(final byte[] sharedSecret, final byte[] verifyToken) {
|
||||
this.sharedSecret = sharedSecret;
|
||||
this.verifyToken = verifyToken;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void encode(ByteBuf buf, PacketDirection direction, ProtocolVersion version) {
|
||||
if (version.gte(ProtocolVersion.MINECRAFT_1_8)) {
|
||||
ProtocolUtils.writeByteArray(buf, sharedSecret);
|
||||
ProtocolUtils.writeByteArray(buf, verifyToken);
|
||||
} else {
|
||||
ProtocolUtils.writeByteArray17(sharedSecret, buf, false);
|
||||
ProtocolUtils.writeByteArray17(verifyToken, buf, false);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean handle(PacketHandler handler) {
|
||||
return handler.handle(this);
|
||||
}
|
||||
|
||||
public byte[] getSharedSecret() {
|
||||
return sharedSecret.clone();
|
||||
}
|
||||
|
||||
public byte[] getVerifyToken() {
|
||||
return verifyToken.clone();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return MoreObjects.toStringHelper(this)
|
||||
.add("sharedSecret", this.sharedSecret)
|
||||
.add("verifyToken", this.verifyToken)
|
||||
.toString();
|
||||
}
|
||||
}
|
@ -0,0 +1,94 @@
|
||||
package com.velocitypowered.proxy.network.packet.serverbound;
|
||||
|
||||
import com.google.common.base.MoreObjects;
|
||||
import com.velocitypowered.api.network.ProtocolVersion;
|
||||
import com.velocitypowered.proxy.network.ProtocolUtils;
|
||||
import com.velocitypowered.proxy.network.packet.Packet;
|
||||
import com.velocitypowered.proxy.network.packet.PacketDirection;
|
||||
import com.velocitypowered.proxy.network.packet.PacketHandler;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
|
||||
public class ServerboundHandshakePacket implements Packet {
|
||||
public static final Decoder<ServerboundHandshakePacket> DECODER = (buf, direction, version) -> {
|
||||
int realProtocolVersion = ProtocolUtils.readVarInt(buf);
|
||||
final ProtocolVersion protocolVersion = ProtocolVersion.getProtocolVersion(realProtocolVersion);
|
||||
final String hostname = ProtocolUtils.readString(buf);
|
||||
final int port = buf.readUnsignedShort();
|
||||
final int nextStatus = ProtocolUtils.readVarInt(buf);
|
||||
return new ServerboundHandshakePacket(protocolVersion, hostname, port, nextStatus);
|
||||
};
|
||||
|
||||
private ProtocolVersion protocolVersion;
|
||||
private String serverAddress = "";
|
||||
private int port;
|
||||
private int nextStatus;
|
||||
|
||||
public ServerboundHandshakePacket() {
|
||||
}
|
||||
|
||||
public ServerboundHandshakePacket(final ProtocolVersion protocolVersion, final String hostname, final int port, final int nextStatus) {
|
||||
this.protocolVersion = protocolVersion;
|
||||
this.serverAddress = hostname;
|
||||
this.port = port;
|
||||
this.nextStatus = nextStatus;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void encode(ByteBuf buf, PacketDirection direction, ProtocolVersion ignored) {
|
||||
ProtocolUtils.writeVarInt(buf, this.protocolVersion.getProtocol());
|
||||
ProtocolUtils.writeString(buf, this.serverAddress);
|
||||
buf.writeShort(this.port);
|
||||
ProtocolUtils.writeVarInt(buf, this.nextStatus);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean handle(PacketHandler handler) {
|
||||
return handler.handle(this);
|
||||
}
|
||||
|
||||
public ProtocolVersion getProtocolVersion() {
|
||||
return protocolVersion;
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public void setProtocolVersion(ProtocolVersion protocolVersion) {
|
||||
this.protocolVersion = protocolVersion;
|
||||
}
|
||||
|
||||
public String getServerAddress() {
|
||||
return serverAddress;
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public void setServerAddress(String serverAddress) {
|
||||
this.serverAddress = serverAddress;
|
||||
}
|
||||
|
||||
public int getPort() {
|
||||
return port;
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public void setPort(int port) {
|
||||
this.port = port;
|
||||
}
|
||||
|
||||
public int getNextStatus() {
|
||||
return nextStatus;
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public void setNextStatus(int nextStatus) {
|
||||
this.nextStatus = nextStatus;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return MoreObjects.toStringHelper(this)
|
||||
.add("protocolVersion", this.protocolVersion)
|
||||
.add("serverAddress", this.serverAddress)
|
||||
.add("port", this.port)
|
||||
.add("nextStatus", this.nextStatus)
|
||||
.toString();
|
||||
}
|
||||
}
|
@ -0,0 +1,18 @@
|
||||
package com.velocitypowered.proxy.network.packet.serverbound;
|
||||
|
||||
import com.velocitypowered.proxy.network.packet.AbstractKeepAlivePacket;
|
||||
import com.velocitypowered.proxy.network.packet.Packet;
|
||||
import com.velocitypowered.proxy.network.packet.PacketHandler;
|
||||
|
||||
public class ServerboundKeepAlivePacket extends AbstractKeepAlivePacket implements Packet {
|
||||
public static final Decoder<ServerboundKeepAlivePacket> DECODER = decoder(ServerboundKeepAlivePacket::new);
|
||||
|
||||
public ServerboundKeepAlivePacket(final long randomId) {
|
||||
super(randomId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean handle(PacketHandler handler) {
|
||||
return handler.handle(this);
|
||||
}
|
||||
}
|
@ -0,0 +1,84 @@
|
||||
package com.velocitypowered.proxy.network.packet.serverbound;
|
||||
|
||||
import com.google.common.base.MoreObjects;
|
||||
import com.velocitypowered.api.network.ProtocolVersion;
|
||||
import com.velocitypowered.proxy.network.ProtocolUtils;
|
||||
import com.velocitypowered.proxy.network.packet.Packet;
|
||||
import com.velocitypowered.proxy.network.packet.PacketDirection;
|
||||
import com.velocitypowered.proxy.network.packet.PacketHandler;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty.buffer.DefaultByteBufHolder;
|
||||
import io.netty.buffer.Unpooled;
|
||||
import java.util.Objects;
|
||||
import org.checkerframework.checker.nullness.qual.MonotonicNonNull;
|
||||
|
||||
public class ServerboundLoginPluginResponsePacket extends DefaultByteBufHolder implements Packet {
|
||||
public static final Decoder<ServerboundLoginPluginResponsePacket> DECODER = (buf, direction, version) -> {
|
||||
final int id = ProtocolUtils.readVarInt(buf);
|
||||
final boolean success = buf.readBoolean();
|
||||
final ByteBuf data;
|
||||
if (buf.isReadable()) {
|
||||
data = buf.readSlice(buf.readableBytes());
|
||||
} else {
|
||||
data = Unpooled.EMPTY_BUFFER;
|
||||
}
|
||||
return new ServerboundLoginPluginResponsePacket(id, success, data);
|
||||
};
|
||||
|
||||
private final int id;
|
||||
private final boolean success;
|
||||
|
||||
public ServerboundLoginPluginResponsePacket(int id, boolean success, @MonotonicNonNull ByteBuf buf) {
|
||||
super(buf);
|
||||
this.id = id;
|
||||
this.success = success;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void encode(ByteBuf buf, PacketDirection direction, ProtocolVersion version) {
|
||||
ProtocolUtils.writeVarInt(buf, id);
|
||||
buf.writeBoolean(success);
|
||||
buf.writeBytes(content());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean handle(PacketHandler handler) {
|
||||
return handler.handle(this);
|
||||
}
|
||||
|
||||
public int getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public boolean isSuccess() {
|
||||
return success;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return MoreObjects.toStringHelper(this)
|
||||
.add("id", this.id)
|
||||
.add("success", this.success)
|
||||
.add("data", this.contentToString())
|
||||
.toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(final Object other) {
|
||||
if (this == other) {
|
||||
return true;
|
||||
}
|
||||
if (other == null || this.getClass() != other.getClass()) {
|
||||
return false;
|
||||
}
|
||||
final ServerboundLoginPluginResponsePacket that = (ServerboundLoginPluginResponsePacket) other;
|
||||
return this.id == that.id
|
||||
&& Objects.equals(this.success, that.success)
|
||||
&& super.equals(other);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(this.id, this.success, super.hashCode());
|
||||
}
|
||||
}
|
@ -0,0 +1,57 @@
|
||||
package com.velocitypowered.proxy.network.packet.serverbound;
|
||||
|
||||
import com.google.common.base.MoreObjects;
|
||||
import com.velocitypowered.api.event.player.PlayerResourcePackStatusEvent.Status;
|
||||
import com.velocitypowered.api.network.ProtocolVersion;
|
||||
import com.velocitypowered.proxy.network.ProtocolUtils;
|
||||
import com.velocitypowered.proxy.network.packet.Packet;
|
||||
import com.velocitypowered.proxy.network.packet.PacketDirection;
|
||||
import com.velocitypowered.proxy.network.packet.PacketHandler;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
|
||||
public class ServerboundResourcePackResponsePacket implements Packet {
|
||||
public static final Decoder<ServerboundResourcePackResponsePacket> DECODER = (buf, direction, version) -> {
|
||||
final String hash;
|
||||
if (version.lte(ProtocolVersion.MINECRAFT_1_9_4)) {
|
||||
hash = ProtocolUtils.readString(buf);
|
||||
} else {
|
||||
hash = null;
|
||||
}
|
||||
final Status status = Status.values()[ProtocolUtils.readVarInt(buf)];
|
||||
return new ServerboundResourcePackResponsePacket(hash, status);
|
||||
};
|
||||
|
||||
private final @Nullable String hash;
|
||||
private final Status status;
|
||||
|
||||
public ServerboundResourcePackResponsePacket(final @Nullable String hash, final Status status) {
|
||||
this.hash = hash;
|
||||
this.status = status;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void encode(ByteBuf buf, PacketDirection direction, ProtocolVersion protocolVersion) {
|
||||
if (protocolVersion.lte(ProtocolVersion.MINECRAFT_1_9_4)) {
|
||||
ProtocolUtils.writeString(buf, hash);
|
||||
}
|
||||
ProtocolUtils.writeVarInt(buf, status.ordinal());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean handle(PacketHandler handler) {
|
||||
return handler.handle(this);
|
||||
}
|
||||
|
||||
public Status getStatus() {
|
||||
return status;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return MoreObjects.toStringHelper(this)
|
||||
.add("hash", this.hash)
|
||||
.add("status", this.status)
|
||||
.toString();
|
||||
}
|
||||
}
|
@ -0,0 +1,50 @@
|
||||
package com.velocitypowered.proxy.network.packet.serverbound;
|
||||
|
||||
import com.google.common.base.MoreObjects;
|
||||
import com.velocitypowered.api.network.ProtocolVersion;
|
||||
import com.velocitypowered.proxy.network.ProtocolUtils;
|
||||
import com.velocitypowered.proxy.network.packet.Packet;
|
||||
import com.velocitypowered.proxy.network.packet.PacketDirection;
|
||||
import com.velocitypowered.proxy.network.packet.PacketHandler;
|
||||
import com.velocitypowered.proxy.util.except.QuietDecoderException;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import java.util.Objects;
|
||||
|
||||
public class ServerboundServerLoginPacket implements Packet {
|
||||
private static final QuietDecoderException EMPTY_USERNAME = new QuietDecoderException("Empty username!");
|
||||
|
||||
public static final Decoder<ServerboundServerLoginPacket> DECODER = (buf, direction, version) -> {
|
||||
final String username = ProtocolUtils.readString(buf, 16);
|
||||
if (username.isEmpty()) {
|
||||
throw EMPTY_USERNAME;
|
||||
}
|
||||
return new ServerboundServerLoginPacket(username);
|
||||
};
|
||||
|
||||
private final String username;
|
||||
|
||||
public ServerboundServerLoginPacket(String username) {
|
||||
this.username = Objects.requireNonNull(username, "username");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void encode(ByteBuf buf, PacketDirection direction, ProtocolVersion version) {
|
||||
ProtocolUtils.writeString(buf, username);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean handle(PacketHandler handler) {
|
||||
return handler.handle(this);
|
||||
}
|
||||
|
||||
public String getUsername() {
|
||||
return username;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return MoreObjects.toStringHelper(this)
|
||||
.add("username", this.username)
|
||||
.toString();
|
||||
}
|
||||
}
|
@ -0,0 +1,18 @@
|
||||
package com.velocitypowered.proxy.network.packet.serverbound;
|
||||
|
||||
import com.velocitypowered.proxy.network.packet.AbstractStatusPingPacket;
|
||||
import com.velocitypowered.proxy.network.packet.Packet;
|
||||
import com.velocitypowered.proxy.network.packet.PacketHandler;
|
||||
|
||||
public class ServerboundStatusPingPacket extends AbstractStatusPingPacket implements Packet {
|
||||
public static final Decoder<ServerboundStatusPingPacket> DECODER = decoder(ServerboundStatusPingPacket::new);
|
||||
|
||||
public ServerboundStatusPingPacket(final long randomId) {
|
||||
super(randomId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean handle(PacketHandler handler) {
|
||||
return handler.handle(this);
|
||||
}
|
||||
}
|
@ -0,0 +1,30 @@
|
||||
package com.velocitypowered.proxy.network.packet.serverbound;
|
||||
|
||||
import com.velocitypowered.api.network.ProtocolVersion;
|
||||
import com.velocitypowered.proxy.network.packet.Packet;
|
||||
import com.velocitypowered.proxy.network.packet.PacketDirection;
|
||||
import com.velocitypowered.proxy.network.packet.PacketHandler;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
|
||||
public class ServerboundStatusRequestPacket implements Packet {
|
||||
public static final ServerboundStatusRequestPacket INSTANCE = new ServerboundStatusRequestPacket();
|
||||
public static final Decoder<ServerboundStatusRequestPacket> DECODER = Decoder.instance(INSTANCE);
|
||||
|
||||
private ServerboundStatusRequestPacket() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void encode(ByteBuf buf, PacketDirection direction, ProtocolVersion version) {
|
||||
// There is no data to decode.
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean handle(PacketHandler handler) {
|
||||
return handler.handle(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "StatusRequestPacket";
|
||||
}
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
package com.velocitypowered.proxy.protocol.packet;
|
||||
package com.velocitypowered.proxy.network.packet.serverbound;
|
||||
|
||||
import static com.velocitypowered.api.network.ProtocolVersion.MINECRAFT_1_13;
|
||||
import static com.velocitypowered.api.network.ProtocolVersion.MINECRAFT_1_8;
|
||||
@ -6,16 +6,15 @@ import static com.velocitypowered.api.network.ProtocolVersion.MINECRAFT_1_9;
|
||||
|
||||
import com.google.common.base.MoreObjects;
|
||||
import com.velocitypowered.api.network.ProtocolVersion;
|
||||
import com.velocitypowered.proxy.connection.MinecraftSessionHandler;
|
||||
import com.velocitypowered.proxy.protocol.Packet;
|
||||
import com.velocitypowered.proxy.protocol.ProtocolDirection;
|
||||
import com.velocitypowered.proxy.protocol.ProtocolUtils;
|
||||
import com.velocitypowered.proxy.network.ProtocolUtils;
|
||||
import com.velocitypowered.proxy.network.packet.Packet;
|
||||
import com.velocitypowered.proxy.network.packet.PacketDirection;
|
||||
import com.velocitypowered.proxy.network.packet.PacketHandler;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
|
||||
public class TabCompleteRequestPacket implements Packet {
|
||||
|
||||
public static final Decoder<TabCompleteRequestPacket> DECODER = Decoder.method(TabCompleteRequestPacket::new);
|
||||
public class ServerboundTabCompleteRequestPacket implements Packet {
|
||||
public static final Decoder<ServerboundTabCompleteRequestPacket> DECODER = Decoder.method(ServerboundTabCompleteRequestPacket::new);
|
||||
|
||||
private static final int VANILLA_MAX_TAB_COMPLETE_LEN = 2048;
|
||||
|
||||
@ -69,18 +68,7 @@ public class TabCompleteRequestPacket implements Packet {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return MoreObjects.toStringHelper(this)
|
||||
.add("command", command)
|
||||
.add("transactionId", transactionId)
|
||||
.add("assumeCommand", assumeCommand)
|
||||
.add("hasPosition", hasPosition)
|
||||
.add("position", position)
|
||||
.toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void decode(ByteBuf buf, ProtocolDirection direction, ProtocolVersion version) {
|
||||
public void decode(ByteBuf buf, PacketDirection direction, ProtocolVersion version) {
|
||||
if (version.gte(MINECRAFT_1_13)) {
|
||||
this.transactionId = ProtocolUtils.readVarInt(buf);
|
||||
this.command = ProtocolUtils.readString(buf, VANILLA_MAX_TAB_COMPLETE_LEN);
|
||||
@ -99,7 +87,7 @@ public class TabCompleteRequestPacket implements Packet {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void encode(ByteBuf buf, ProtocolDirection direction, ProtocolVersion version) {
|
||||
public void encode(ByteBuf buf, PacketDirection direction, ProtocolVersion version) {
|
||||
if (command == null) {
|
||||
throw new IllegalStateException("Command is not specified");
|
||||
}
|
||||
@ -122,7 +110,18 @@ public class TabCompleteRequestPacket implements Packet {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean handle(MinecraftSessionHandler handler) {
|
||||
public boolean handle(PacketHandler handler) {
|
||||
return handler.handle(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return MoreObjects.toStringHelper(this)
|
||||
.add("command", command)
|
||||
.add("transactionId", transactionId)
|
||||
.add("assumeCommand", assumeCommand)
|
||||
.add("hasPosition", hasPosition)
|
||||
.add("position", position)
|
||||
.toString();
|
||||
}
|
||||
}
|
@ -1,12 +1,13 @@
|
||||
package com.velocitypowered.proxy.protocol.packet;
|
||||
package com.velocitypowered.proxy.network.packet.shared;
|
||||
|
||||
import static com.velocitypowered.proxy.protocol.util.PluginMessageUtil.transformLegacyToModernChannel;
|
||||
import static com.velocitypowered.proxy.network.PluginMessageUtil.transformLegacyToModernChannel;
|
||||
|
||||
import com.google.common.base.MoreObjects;
|
||||
import com.velocitypowered.api.network.ProtocolVersion;
|
||||
import com.velocitypowered.proxy.connection.MinecraftSessionHandler;
|
||||
import com.velocitypowered.proxy.protocol.Packet;
|
||||
import com.velocitypowered.proxy.protocol.ProtocolDirection;
|
||||
import com.velocitypowered.proxy.protocol.ProtocolUtils;
|
||||
import com.velocitypowered.proxy.network.ProtocolUtils;
|
||||
import com.velocitypowered.proxy.network.packet.Packet;
|
||||
import com.velocitypowered.proxy.network.packet.PacketDirection;
|
||||
import com.velocitypowered.proxy.network.packet.PacketHandler;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty.buffer.DefaultByteBufHolder;
|
||||
import java.util.Objects;
|
||||
@ -14,7 +15,6 @@ import org.checkerframework.checker.nullness.qual.MonotonicNonNull;
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
|
||||
public class PluginMessagePacket extends DefaultByteBufHolder implements Packet {
|
||||
|
||||
public static final Decoder<PluginMessagePacket> DECODER = (buf, direction, version) -> {
|
||||
String channel = ProtocolUtils.readString(buf);
|
||||
if (version.gte(ProtocolVersion.MINECRAFT_1_13)) {
|
||||
@ -38,7 +38,7 @@ public class PluginMessagePacket extends DefaultByteBufHolder implements Packet
|
||||
}
|
||||
|
||||
@Override
|
||||
public void encode(ByteBuf buf, ProtocolDirection direction, ProtocolVersion version) {
|
||||
public void encode(ByteBuf buf, PacketDirection direction, ProtocolVersion version) {
|
||||
if (channel == null) {
|
||||
throw new IllegalStateException("Channel is not specified.");
|
||||
}
|
||||
@ -55,7 +55,7 @@ public class PluginMessagePacket extends DefaultByteBufHolder implements Packet
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean handle(MinecraftSessionHandler handler) {
|
||||
public boolean handle(PacketHandler handler) {
|
||||
return handler.handle(this);
|
||||
}
|
||||
|
||||
@ -91,18 +91,14 @@ public class PluginMessagePacket extends DefaultByteBufHolder implements Packet
|
||||
return (PluginMessagePacket) super.touch(hint);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "PluginMessagePacket{"
|
||||
+ "channel='" + channel + '\''
|
||||
+ ", data=" + super.toString()
|
||||
+ '}';
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(final Object other) {
|
||||
if(this == other) return true;
|
||||
if(other == null || this.getClass() != other.getClass()) return false;
|
||||
if (this == other) {
|
||||
return true;
|
||||
}
|
||||
if (other == null || this.getClass() != other.getClass()) {
|
||||
return false;
|
||||
}
|
||||
final PluginMessagePacket that = (PluginMessagePacket) other;
|
||||
return Objects.equals(this.channel, that.channel)
|
||||
&& super.equals(other);
|
||||
@ -112,4 +108,12 @@ public class PluginMessagePacket extends DefaultByteBufHolder implements Packet
|
||||
public int hashCode() {
|
||||
return Objects.hash(this.channel, super.hashCode());
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return MoreObjects.toStringHelper(this)
|
||||
.add("channel", this.channel)
|
||||
.add("data", this.contentToString())
|
||||
.toString();
|
||||
}
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
package com.velocitypowered.proxy.protocol.netty;
|
||||
package com.velocitypowered.proxy.network.pipeline;
|
||||
|
||||
import io.netty.channel.ChannelDuplexHandler;
|
||||
import io.netty.channel.ChannelHandlerContext;
|
@ -1,4 +1,4 @@
|
||||
package com.velocitypowered.proxy.protocol.netty;
|
||||
package com.velocitypowered.proxy.network.pipeline;
|
||||
|
||||
import static com.velocitypowered.api.event.connection.ProxyQueryEvent.QueryType.BASIC;
|
||||
import static com.velocitypowered.api.event.connection.ProxyQueryEvent.QueryType.FULL;
|
@ -1,10 +1,10 @@
|
||||
package com.velocitypowered.proxy.protocol.netty;
|
||||
package com.velocitypowered.proxy.network.pipeline;
|
||||
|
||||
import static com.velocitypowered.proxy.protocol.util.NettyPreconditions.checkFrame;
|
||||
import static com.velocitypowered.proxy.network.NettyPreconditions.checkFrame;
|
||||
|
||||
import com.velocitypowered.proxy.protocol.packet.legacy.LegacyHandshakePacket;
|
||||
import com.velocitypowered.proxy.protocol.packet.legacy.LegacyPingPacket;
|
||||
import com.velocitypowered.proxy.protocol.packet.legacyping.LegacyMinecraftPingVersion;
|
||||
import com.velocitypowered.proxy.network.packet.legacy.LegacyHandshakePacket;
|
||||
import com.velocitypowered.proxy.network.packet.legacy.LegacyMinecraftPingVersion;
|
||||
import com.velocitypowered.proxy.network.packet.legacy.LegacyPingPacket;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty.channel.ChannelHandlerContext;
|
||||
import io.netty.handler.codec.ByteToMessageDecoder;
|
@ -1,6 +1,6 @@
|
||||
package com.velocitypowered.proxy.protocol.netty;
|
||||
package com.velocitypowered.proxy.network.pipeline;
|
||||
|
||||
import com.velocitypowered.proxy.protocol.packet.legacy.LegacyDisconnectPacket;
|
||||
import com.velocitypowered.proxy.network.packet.legacy.LegacyDisconnectPacket;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty.channel.ChannelHandler;
|
||||
import io.netty.channel.ChannelHandlerContext;
|
@ -1,4 +1,4 @@
|
||||
package com.velocitypowered.proxy.protocol.netty;
|
||||
package com.velocitypowered.proxy.network.pipeline;
|
||||
|
||||
import com.google.common.base.Preconditions;
|
||||
import com.velocitypowered.natives.encryption.VelocityCipher;
|
@ -1,4 +1,4 @@
|
||||
package com.velocitypowered.proxy.protocol.netty;
|
||||
package com.velocitypowered.proxy.network.pipeline;
|
||||
|
||||
import com.google.common.base.Preconditions;
|
||||
import com.velocitypowered.natives.encryption.VelocityCipher;
|
@ -1,11 +1,11 @@
|
||||
package com.velocitypowered.proxy.protocol.netty;
|
||||
package com.velocitypowered.proxy.network.pipeline;
|
||||
|
||||
import static com.velocitypowered.natives.util.MoreByteBufUtils.ensureCompatible;
|
||||
import static com.velocitypowered.natives.util.MoreByteBufUtils.preferredBuffer;
|
||||
import static com.velocitypowered.proxy.protocol.util.NettyPreconditions.checkFrame;
|
||||
import static com.velocitypowered.proxy.network.NettyPreconditions.checkFrame;
|
||||
|
||||
import com.velocitypowered.natives.compression.VelocityCompressor;
|
||||
import com.velocitypowered.proxy.protocol.ProtocolUtils;
|
||||
import com.velocitypowered.proxy.network.ProtocolUtils;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty.channel.ChannelHandlerContext;
|
||||
import io.netty.handler.codec.MessageToMessageDecoder;
|
@ -1,8 +1,8 @@
|
||||
package com.velocitypowered.proxy.protocol.netty;
|
||||
package com.velocitypowered.proxy.network.pipeline;
|
||||
|
||||
import com.velocitypowered.natives.compression.VelocityCompressor;
|
||||
import com.velocitypowered.natives.util.MoreByteBufUtils;
|
||||
import com.velocitypowered.proxy.protocol.ProtocolUtils;
|
||||
import com.velocitypowered.proxy.network.ProtocolUtils;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty.channel.ChannelHandlerContext;
|
||||
import io.netty.handler.codec.MessageToByteEncoder;
|
@ -1,11 +1,11 @@
|
||||
package com.velocitypowered.proxy.protocol.netty;
|
||||
package com.velocitypowered.proxy.network.pipeline;
|
||||
|
||||
import com.google.common.base.Preconditions;
|
||||
import com.velocitypowered.api.network.ProtocolVersion;
|
||||
import com.velocitypowered.proxy.protocol.Packet;
|
||||
import com.velocitypowered.proxy.protocol.ProtocolDirection;
|
||||
import com.velocitypowered.proxy.protocol.ProtocolUtils;
|
||||
import com.velocitypowered.proxy.protocol.StateRegistry;
|
||||
import com.velocitypowered.proxy.network.ProtocolUtils;
|
||||
import com.velocitypowered.proxy.network.StateRegistry;
|
||||
import com.velocitypowered.proxy.network.packet.Packet;
|
||||
import com.velocitypowered.proxy.network.packet.PacketDirection;
|
||||
import com.velocitypowered.proxy.util.except.QuietDecoderException;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty.channel.ChannelHandlerContext;
|
||||
@ -19,7 +19,7 @@ public class MinecraftDecoder extends ChannelInboundHandlerAdapter {
|
||||
new QuietDecoderException("A packet did not decode successfully (invalid data). If you are a "
|
||||
+ "developer, launch Velocity with -Dvelocity.packet-decode-logging=true to see more.");
|
||||
|
||||
private final ProtocolDirection direction;
|
||||
private final PacketDirection direction;
|
||||
private StateRegistry state;
|
||||
private StateRegistry.PacketRegistry.ProtocolRegistry registry;
|
||||
|
||||
@ -28,7 +28,7 @@ public class MinecraftDecoder extends ChannelInboundHandlerAdapter {
|
||||
*
|
||||
* @param direction the direction from which we decode from
|
||||
*/
|
||||
public MinecraftDecoder(ProtocolDirection direction) {
|
||||
public MinecraftDecoder(PacketDirection direction) {
|
||||
this.direction = Preconditions.checkNotNull(direction, "direction");
|
||||
this.registry = StateRegistry.HANDSHAKE.getProtocolRegistry(direction,
|
||||
ProtocolVersion.MINIMUM_VERSION);
|
@ -1,18 +1,18 @@
|
||||
package com.velocitypowered.proxy.protocol.netty;
|
||||
package com.velocitypowered.proxy.network.pipeline;
|
||||
|
||||
import com.google.common.base.Preconditions;
|
||||
import com.velocitypowered.api.network.ProtocolVersion;
|
||||
import com.velocitypowered.proxy.protocol.Packet;
|
||||
import com.velocitypowered.proxy.protocol.ProtocolDirection;
|
||||
import com.velocitypowered.proxy.protocol.ProtocolUtils;
|
||||
import com.velocitypowered.proxy.protocol.StateRegistry;
|
||||
import com.velocitypowered.proxy.network.ProtocolUtils;
|
||||
import com.velocitypowered.proxy.network.StateRegistry;
|
||||
import com.velocitypowered.proxy.network.packet.Packet;
|
||||
import com.velocitypowered.proxy.network.packet.PacketDirection;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty.channel.ChannelHandlerContext;
|
||||
import io.netty.handler.codec.MessageToByteEncoder;
|
||||
|
||||
public class MinecraftEncoder extends MessageToByteEncoder<Packet> {
|
||||
|
||||
private final ProtocolDirection direction;
|
||||
private final PacketDirection direction;
|
||||
private StateRegistry state;
|
||||
private StateRegistry.PacketRegistry.ProtocolRegistry registry;
|
||||
|
||||
@ -21,7 +21,7 @@ public class MinecraftEncoder extends MessageToByteEncoder<Packet> {
|
||||
*
|
||||
* @param direction the direction to encode to
|
||||
*/
|
||||
public MinecraftEncoder(ProtocolDirection direction) {
|
||||
public MinecraftEncoder(PacketDirection direction) {
|
||||
this.direction = Preconditions.checkNotNull(direction, "direction");
|
||||
this.registry = StateRegistry.HANDSHAKE
|
||||
.getProtocolRegistry(direction, ProtocolVersion.MINIMUM_VERSION);
|
@ -1,6 +1,6 @@
|
||||
package com.velocitypowered.proxy.protocol.netty;
|
||||
package com.velocitypowered.proxy.network.pipeline;
|
||||
|
||||
import com.velocitypowered.proxy.protocol.netty.VarintByteDecoder.DecodeResult;
|
||||
import com.velocitypowered.proxy.network.pipeline.VarintByteDecoder.DecodeResult;
|
||||
import com.velocitypowered.proxy.util.except.QuietDecoderException;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty.channel.ChannelHandlerContext;
|
@ -1,8 +1,8 @@
|
||||
package com.velocitypowered.proxy.protocol.netty;
|
||||
package com.velocitypowered.proxy.network.pipeline;
|
||||
|
||||
import com.velocitypowered.natives.encryption.JavaVelocityCipher;
|
||||
import com.velocitypowered.natives.util.Natives;
|
||||
import com.velocitypowered.proxy.protocol.ProtocolUtils;
|
||||
import com.velocitypowered.proxy.network.ProtocolUtils;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty.channel.ChannelHandler;
|
||||
import io.netty.channel.ChannelHandlerContext;
|
@ -1,4 +1,4 @@
|
||||
package com.velocitypowered.proxy.protocol.netty;
|
||||
package com.velocitypowered.proxy.network.pipeline;
|
||||
|
||||
import io.netty.util.ByteProcessor;
|
||||
|
@ -1,4 +1,4 @@
|
||||
package com.velocitypowered.proxy.network.netty;
|
||||
package com.velocitypowered.proxy.network.resolver;
|
||||
|
||||
import com.google.common.cache.Cache;
|
||||
import com.google.common.cache.CacheBuilder;
|
@ -1,4 +1,4 @@
|
||||
package com.velocitypowered.proxy.protocol.util;
|
||||
package com.velocitypowered.proxy.network.serialization;
|
||||
|
||||
import com.google.gson.JsonDeserializationContext;
|
||||
import com.google.gson.JsonDeserializer;
|
@ -1,4 +1,4 @@
|
||||
package com.velocitypowered.proxy.protocol.util;
|
||||
package com.velocitypowered.proxy.network.serialization;
|
||||
|
||||
import com.google.gson.JsonDeserializationContext;
|
||||
import com.google.gson.JsonDeserializer;
|
@ -1,4 +1,4 @@
|
||||
package com.velocitypowered.proxy.protocol.util;
|
||||
package com.velocitypowered.proxy.network.serialization;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.UUID;
|
||||
@ -7,7 +7,6 @@ import net.kyori.adventure.nbt.CompoundBinaryTag;
|
||||
import net.kyori.adventure.nbt.TagStringIO;
|
||||
import net.kyori.adventure.nbt.api.BinaryTagHolder;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.kyori.adventure.text.TextComponent;
|
||||
import net.kyori.adventure.text.event.HoverEvent;
|
||||
import net.kyori.adventure.text.event.HoverEvent.ShowEntity;
|
||||
import net.kyori.adventure.text.event.HoverEvent.ShowItem;
|
@ -1,11 +1,11 @@
|
||||
package com.velocitypowered.proxy.protocol.packet.brigadier;
|
||||
package com.velocitypowered.proxy.network.serialization.brigadier;
|
||||
|
||||
import static com.velocitypowered.proxy.protocol.packet.brigadier.DoubleArgumentPropertySerializer.DOUBLE;
|
||||
import static com.velocitypowered.proxy.protocol.packet.brigadier.EmptyArgumentPropertySerializer.EMPTY;
|
||||
import static com.velocitypowered.proxy.protocol.packet.brigadier.FloatArgumentPropertySerializer.FLOAT;
|
||||
import static com.velocitypowered.proxy.protocol.packet.brigadier.IntegerArgumentPropertySerializer.INTEGER;
|
||||
import static com.velocitypowered.proxy.protocol.packet.brigadier.LongArgumentPropertySerializer.LONG;
|
||||
import static com.velocitypowered.proxy.protocol.packet.brigadier.StringArgumentPropertySerializer.STRING;
|
||||
import static com.velocitypowered.proxy.network.serialization.brigadier.DoubleArgumentPropertySerializer.DOUBLE;
|
||||
import static com.velocitypowered.proxy.network.serialization.brigadier.EmptyArgumentPropertySerializer.EMPTY;
|
||||
import static com.velocitypowered.proxy.network.serialization.brigadier.FloatArgumentPropertySerializer.FLOAT;
|
||||
import static com.velocitypowered.proxy.network.serialization.brigadier.IntegerArgumentPropertySerializer.INTEGER;
|
||||
import static com.velocitypowered.proxy.network.serialization.brigadier.LongArgumentPropertySerializer.LONG;
|
||||
import static com.velocitypowered.proxy.network.serialization.brigadier.StringArgumentPropertySerializer.STRING;
|
||||
|
||||
import com.mojang.brigadier.arguments.ArgumentType;
|
||||
import com.mojang.brigadier.arguments.BoolArgumentType;
|
||||
@ -14,7 +14,7 @@ import com.mojang.brigadier.arguments.FloatArgumentType;
|
||||
import com.mojang.brigadier.arguments.IntegerArgumentType;
|
||||
import com.mojang.brigadier.arguments.LongArgumentType;
|
||||
import com.mojang.brigadier.arguments.StringArgumentType;
|
||||
import com.velocitypowered.proxy.protocol.ProtocolUtils;
|
||||
import com.velocitypowered.proxy.network.ProtocolUtils;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
@ -1,4 +1,4 @@
|
||||
package com.velocitypowered.proxy.protocol.packet.brigadier;
|
||||
package com.velocitypowered.proxy.network.serialization.brigadier;
|
||||
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
@ -1,4 +1,4 @@
|
||||
package com.velocitypowered.proxy.protocol.packet.brigadier;
|
||||
package com.velocitypowered.proxy.network.serialization.brigadier;
|
||||
|
||||
import io.netty.buffer.ByteBuf;
|
||||
|
@ -1,8 +1,8 @@
|
||||
package com.velocitypowered.proxy.protocol.packet.brigadier;
|
||||
package com.velocitypowered.proxy.network.serialization.brigadier;
|
||||
|
||||
import static com.velocitypowered.proxy.protocol.packet.brigadier.IntegerArgumentPropertySerializer.HAS_MAXIMUM;
|
||||
import static com.velocitypowered.proxy.protocol.packet.brigadier.IntegerArgumentPropertySerializer.HAS_MINIMUM;
|
||||
import static com.velocitypowered.proxy.protocol.packet.brigadier.IntegerArgumentPropertySerializer.getFlags;
|
||||
import static com.velocitypowered.proxy.network.serialization.brigadier.IntegerArgumentPropertySerializer.HAS_MAXIMUM;
|
||||
import static com.velocitypowered.proxy.network.serialization.brigadier.IntegerArgumentPropertySerializer.HAS_MINIMUM;
|
||||
import static com.velocitypowered.proxy.network.serialization.brigadier.IntegerArgumentPropertySerializer.getFlags;
|
||||
|
||||
import com.mojang.brigadier.arguments.DoubleArgumentType;
|
||||
import io.netty.buffer.ByteBuf;
|
Einige Dateien werden nicht angezeigt, da zu viele Dateien in diesem Diff geändert wurden Mehr anzeigen
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren