From 115ac92d5c2097f2d4376ccb2d99820d630969e1 Mon Sep 17 00:00:00 2001 From: Andrew Steinborn Date: Fri, 27 Oct 2023 18:38:26 -0400 Subject: [PATCH] A full reorganization of the networking logic While we're at it, make the packet files mostly Checkstyle clean, except for Javadocs (not very useful) --- .../kotlin/velocity-checkstyle.gradle.kts | 2 + config/checkstyle/checkstyle-suppressions.xml | 12 ++ config/checkstyle/checkstyle.xml | 2 +- .../velocitypowered/proxy/VelocityServer.java | 6 +- .../proxy/connection/MinecraftConnection.java | 25 ++-- .../connection/MinecraftSessionHandler.java | 106 ++++++------- .../backend/BackendConnectionPhase.java | 2 +- .../backend/BackendConnectionPhases.java | 2 +- .../backend/BackendPlaySessionHandler.java | 42 +++--- .../backend/BungeeCordMessageResponder.java | 6 +- .../backend/ConfigSessionHandler.java | 26 ++-- .../backend/LoginSessionHandler.java | 18 +-- .../backend/TransitionSessionHandler.java | 10 +- .../backend/VelocityServerConnection.java | 11 +- .../connection/client/AuthSessionHandler.java | 8 +- .../client/ClientConfigSessionHandler.java | 18 +-- .../client/ClientConnectionPhase.java | 2 +- .../client/ClientPlaySessionHandler.java | 64 ++++---- .../client/ClientSettingsWrapper.java | 2 +- .../connection/client/ConnectedPlayer.java | 30 ++-- .../client/HandshakeSessionHandler.java | 12 +- .../client/InitialConnectSessionHandler.java | 2 +- .../client/InitialInboundConnection.java | 4 +- .../client/InitialLoginSessionHandler.java | 12 +- .../client/LoginInboundConnection.java | 4 +- .../client/StatusSessionHandler.java | 8 +- .../LegacyForgeHandshakeBackendPhase.java | 2 +- .../LegacyForgeHandshakeClientPhase.java | 2 +- .../forge/legacy/LegacyForgeUtil.java | 4 +- .../connection/registry/ClientConfigData.java | 2 +- .../util/ConnectionRequestResults.java | 2 +- .../util/ServerListPingHandler.java | 2 +- .../proxy/network/ConnectionManager.java | 13 +- .../MinecraftCompressDecoder.java | 6 +- .../MinecraftCompressorAndLengthEncoder.java | 6 +- .../pipeline/deser}/LegacyPingDecoder.java | 10 +- .../pipeline/deser}/LegacyPingEncoder.java | 4 +- .../pipeline/deser}/MinecraftDecoder.java | 8 +- .../pipeline/deser}/MinecraftEncoder.java | 8 +- .../encryption}/MinecraftCipherDecoder.java | 2 +- .../encryption}/MinecraftCipherEncoder.java | 2 +- .../framing}/MinecraftVarintFrameDecoder.java | 4 +- .../MinecraftVarintLengthEncoder.java | 4 +- .../pipeline/framing}/VarintByteDecoder.java | 2 +- .../BackendChannelInitializer.java | 35 +++-- .../BackendChannelInitializerHolder.java | 5 +- .../ServerChannelInitializer.java | 19 +-- .../ServerChannelInitializerHolder.java | 5 +- .../pipeline/query}/GameSpyQueryHandler.java | 2 +- .../pipeline/util}/AutoReadHolderHandler.java | 2 +- .../util}/PlayPacketQueueHandler.java | 8 +- .../util}/VelocityConnectionEvent.java | 2 +- .../protocol/MinecraftPacket.java | 2 +- .../{ => network}/protocol/ProtocolUtils.java | 8 +- .../{ => network}/protocol/StateRegistry.java | 139 +++++++++--------- .../protocol/packet/AvailableCommands.java | 10 +- .../protocol/packet/BossBarPacket.java} | 15 +- .../protocol/packet/ClientSettings.java | 19 +-- .../protocol/packet/Disconnect.java | 9 +- .../protocol/packet/EncryptionRequest.java | 9 +- .../protocol/packet/EncryptionResponse.java | 15 +- .../protocol/packet/Handshake.java | 9 +- .../protocol/packet/HeaderAndFooter.java | 17 +-- .../protocol/packet/JoinGame.java | 30 ++-- .../protocol/packet/KeepAlive.java | 9 +- .../protocol/packet/LegacyDisconnect.java | 4 +- .../protocol/packet/LegacyHandshake.java | 10 +- .../protocol/packet/LegacyPing.java | 12 +- .../protocol/packet/LegacyPlayerListItem.java | 9 +- .../protocol/packet/LoginAcknowledged.java | 18 +-- .../protocol/packet/LoginPluginMessage.java | 11 +- .../protocol/packet/LoginPluginResponse.java | 11 +- .../protocol/packet/PingIdentify.java | 10 +- .../protocol/packet/PluginMessage.java | 13 +- .../protocol/packet/RemovePlayerInfo.java | 9 +- .../protocol/packet/ResourcePackRequest.java | 15 +- .../protocol/packet/ResourcePackResponse.java | 8 +- .../protocol/packet/Respawn.java | 12 +- .../protocol/packet/ServerData.java | 19 ++- .../protocol/packet/ServerLogin.java | 11 +- .../protocol/packet/ServerLoginSuccess.java | 10 +- .../protocol/packet/SetCompression.java | 9 +- .../protocol/packet/StatusPing.java | 11 +- .../protocol/packet/StatusRequest.java | 11 +- .../protocol/packet/StatusResponse.java | 9 +- .../protocol/packet/TabCompleteRequest.java | 9 +- .../protocol/packet/TabCompleteResponse.java | 9 +- .../protocol/packet/UpsertPlayerInfo.java | 29 ++-- .../packet/brigadier/ArgumentIdentifier.java | 2 +- .../brigadier/ArgumentPropertyRegistry.java | 29 ++-- .../brigadier/ArgumentPropertySerializer.java | 2 +- .../ByteArgumentPropertySerializer.java | 2 +- .../DoubleArgumentPropertySerializer.java | 14 +- .../EmptyArgumentPropertySerializer.java | 2 +- .../FloatArgumentPropertySerializer.java | 8 +- .../IntegerArgumentPropertySerializer.java | 2 +- .../LongArgumentPropertySerializer.java | 8 +- .../packet/brigadier/ModArgumentProperty.java | 2 +- .../ModArgumentPropertySerializer.java | 4 +- .../packet/brigadier/PassthroughProperty.java | 2 +- .../packet/brigadier/RegistryKeyArgument.java | 4 +- .../brigadier/RegistryKeyArgumentList.java | 4 +- .../RegistryKeyArgumentSerializer.java | 4 +- .../StringArgumentPropertySerializer.java | 4 +- .../brigadier/TimeArgumentSerializer.java | 2 +- .../packet/chat/ChatAcknowledgement.java | 58 ++++++++ .../protocol/packet/chat/ChatHandler.java | 4 +- .../protocol/packet/chat/ChatQueue.java | 9 +- .../protocol/packet/chat/ChatTimeKeeper.java | 2 +- .../protocol/packet/chat/ChatType.java | 2 +- .../protocol/packet/chat/CommandHandler.java | 7 +- .../packet/chat/LastSeenMessages.java | 16 +- .../packet/chat/PlayerChatCompletion.java | 9 +- .../packet/chat/RemoteChatSession.java | 4 +- .../protocol/packet/chat/SystemChat.java | 9 +- .../chat/builder/ChatBuilderFactory.java | 8 +- .../packet/chat/builder/ChatBuilderV2.java | 6 +- .../packet/chat/keyed/KeyedChatBuilder.java | 10 +- .../packet/chat/keyed/KeyedChatHandler.java | 9 +- .../chat/keyed/KeyedCommandHandler.java | 6 +- .../packet/chat/keyed/KeyedPlayerChat.java | 9 +- .../packet/chat/keyed/KeyedPlayerCommand.java | 18 +-- .../packet/chat/legacy/LegacyChat.java | 9 +- .../packet/chat/legacy/LegacyChatBuilder.java | 8 +- .../packet/chat/legacy/LegacyChatHandler.java | 4 +- .../chat/legacy/LegacyCommandHandler.java | 4 +- .../chat/session/SessionChatBuilder.java | 12 +- .../chat/session/SessionChatHandler.java | 10 +- .../chat/session/SessionCommandHandler.java | 12 +- .../chat/session/SessionPlayerChat.java | 11 +- .../chat/session/SessionPlayerCommand.java | 38 ++--- .../packet/config/ActiveFeatures.java | 13 +- .../packet/config/FinishedUpdate.java | 18 +-- .../protocol/packet/config/RegistrySync.java | 16 +- .../protocol/packet/config/StartUpdate.java | 18 +-- .../protocol/packet/config/TagsUpdate.java | 14 +- .../LegacyMinecraftPingVersion.java | 2 +- .../packet/title/GenericTitlePacket.java | 8 +- .../packet/title/LegacyTitlePacket.java | 7 +- .../packet/title/TitleActionbarPacket.java | 7 +- .../packet/title/TitleClearPacket.java | 6 +- .../packet/title/TitleSubtitlePacket.java | 7 +- .../packet/title/TitleTextPacket.java | 7 +- .../packet/title/TitleTimesPacket.java | 6 +- .../protocol/util/ByteBufDataInput.java | 2 +- .../protocol/util/ByteBufDataOutput.java | 2 +- .../protocol/util/DeferredByteBufHolder.java | 2 +- .../protocol/util/FaviconSerializer.java | 2 +- .../protocol/util/GameProfileSerializer.java | 2 +- .../protocol/util/NettyPreconditions.java | 4 +- .../protocol/util/PluginMessageUtil.java | 6 +- .../VelocityLegacyHoverEventSerializer.java | 2 +- .../SeparatePoolInetNameResolver.java | 8 +- .../network/{ => util}/TransportType.java | 6 +- .../packet/chat/ChatAcknowledgement.java | 57 ------- .../proxy/server/PingSessionHandler.java | 8 +- .../server/VelocityRegisteredServer.java | 57 +++---- .../proxy/tablist/InternalTabList.java | 6 +- .../proxy/tablist/KeyedVelocityTabList.java | 4 +- .../tablist/KeyedVelocityTabListEntry.java | 4 +- .../proxy/tablist/VelocityTabList.java | 6 +- .../proxy/tablist/VelocityTabListEntry.java | 2 +- .../proxy/tablist/VelocityTabListLegacy.java | 4 +- .../proxy/util/InformationUtils.java | 2 +- .../proxy/util/VelocityChannelRegistrar.java | 2 +- .../util/bossbar/AdventureBossBarManager.java | 62 ++++---- .../protocol/PacketRegistryTest.java | 6 +- .../protocol/ProtocolUtilsTest.java | 2 +- .../protocol/util/PluginMessageUtilTest.java | 2 +- 169 files changed, 991 insertions(+), 944 deletions(-) create mode 100644 config/checkstyle/checkstyle-suppressions.xml rename proxy/src/main/java/com/velocitypowered/proxy/{protocol/netty => network/pipeline/compression}/MinecraftCompressDecoder.java (93%) rename proxy/src/main/java/com/velocitypowered/proxy/{protocol/netty => network/pipeline/compression}/MinecraftCompressorAndLengthEncoder.java (93%) rename proxy/src/main/java/com/velocitypowered/proxy/{protocol/netty => network/pipeline/deser}/LegacyPingDecoder.java (88%) rename proxy/src/main/java/com/velocitypowered/proxy/{protocol/netty => network/pipeline/deser}/LegacyPingEncoder.java (92%) rename proxy/src/main/java/com/velocitypowered/proxy/{protocol/netty => network/pipeline/deser}/MinecraftDecoder.java (95%) rename proxy/src/main/java/com/velocitypowered/proxy/{protocol/netty => network/pipeline/deser}/MinecraftEncoder.java (89%) rename proxy/src/main/java/com/velocitypowered/proxy/{protocol/netty => network/pipeline/encryption}/MinecraftCipherDecoder.java (96%) rename proxy/src/main/java/com/velocitypowered/proxy/{protocol/netty => network/pipeline/encryption}/MinecraftCipherEncoder.java (96%) rename proxy/src/main/java/com/velocitypowered/proxy/{protocol/netty => network/pipeline/framing}/MinecraftVarintFrameDecoder.java (95%) rename proxy/src/main/java/com/velocitypowered/proxy/{protocol/netty => network/pipeline/framing}/MinecraftVarintLengthEncoder.java (94%) rename proxy/src/main/java/com/velocitypowered/proxy/{protocol/netty => network/pipeline/framing}/VarintByteDecoder.java (96%) rename proxy/src/main/java/com/velocitypowered/proxy/network/{ => pipeline/initializers}/BackendChannelInitializer.java (65%) rename proxy/src/main/java/com/velocitypowered/proxy/network/{ => pipeline/initializers}/BackendChannelInitializerHolder.java (88%) rename proxy/src/main/java/com/velocitypowered/proxy/network/{ => pipeline/initializers}/ServerChannelInitializer.java (80%) rename proxy/src/main/java/com/velocitypowered/proxy/network/{ => pipeline/initializers}/ServerChannelInitializerHolder.java (88%) rename proxy/src/main/java/com/velocitypowered/proxy/{protocol/netty => network/pipeline/query}/GameSpyQueryHandler.java (99%) rename proxy/src/main/java/com/velocitypowered/proxy/{protocol/netty => network/pipeline/util}/AutoReadHolderHandler.java (97%) rename proxy/src/main/java/com/velocitypowered/proxy/{protocol/netty => network/pipeline/util}/PlayPacketQueueHandler.java (93%) rename proxy/src/main/java/com/velocitypowered/proxy/{protocol => network/pipeline/util}/VelocityConnectionEvent.java (94%) rename proxy/src/main/java/com/velocitypowered/proxy/{ => network}/protocol/MinecraftPacket.java (96%) rename proxy/src/main/java/com/velocitypowered/proxy/{ => network}/protocol/ProtocolUtils.java (98%) rename proxy/src/main/java/com/velocitypowered/proxy/{ => network}/protocol/StateRegistry.java (87%) rename proxy/src/main/java/com/velocitypowered/proxy/{ => network}/protocol/packet/AvailableCommands.java (97%) rename proxy/src/main/java/com/velocitypowered/proxy/{protocol/packet/BossBar.java => network/protocol/packet/BossBarPacket.java} (90%) rename proxy/src/main/java/com/velocitypowered/proxy/{ => network}/protocol/packet/ClientSettings.java (90%) rename proxy/src/main/java/com/velocitypowered/proxy/{ => network}/protocol/packet/Disconnect.java (86%) rename proxy/src/main/java/com/velocitypowered/proxy/{ => network}/protocol/packet/EncryptionRequest.java (88%) rename proxy/src/main/java/com/velocitypowered/proxy/{ => network}/protocol/packet/EncryptionResponse.java (91%) rename proxy/src/main/java/com/velocitypowered/proxy/{ => network}/protocol/packet/Handshake.java (89%) rename proxy/src/main/java/com/velocitypowered/proxy/{ => network}/protocol/packet/HeaderAndFooter.java (81%) rename proxy/src/main/java/com/velocitypowered/proxy/{ => network}/protocol/packet/JoinGame.java (91%) rename proxy/src/main/java/com/velocitypowered/proxy/{ => network}/protocol/packet/KeepAlive.java (85%) rename proxy/src/main/java/com/velocitypowered/proxy/{ => network}/protocol/packet/LegacyDisconnect.java (96%) rename proxy/src/main/java/com/velocitypowered/proxy/{ => network}/protocol/packet/LegacyHandshake.java (76%) rename proxy/src/main/java/com/velocitypowered/proxy/{ => network}/protocol/packet/LegacyPing.java (79%) rename proxy/src/main/java/com/velocitypowered/proxy/{ => network}/protocol/packet/LegacyPlayerListItem.java (96%) rename proxy/src/main/java/com/velocitypowered/proxy/{ => network}/protocol/packet/LoginAcknowledged.java (66%) rename proxy/src/main/java/com/velocitypowered/proxy/{ => network}/protocol/packet/LoginPluginMessage.java (84%) rename proxy/src/main/java/com/velocitypowered/proxy/{ => network}/protocol/packet/LoginPluginResponse.java (84%) rename proxy/src/main/java/com/velocitypowered/proxy/{ => network}/protocol/packet/PingIdentify.java (76%) rename proxy/src/main/java/com/velocitypowered/proxy/{ => network}/protocol/packet/PluginMessage.java (87%) rename proxy/src/main/java/com/velocitypowered/proxy/{ => network}/protocol/packet/RemovePlayerInfo.java (87%) rename proxy/src/main/java/com/velocitypowered/proxy/{ => network}/protocol/packet/ResourcePackRequest.java (91%) rename proxy/src/main/java/com/velocitypowered/proxy/{ => network}/protocol/packet/ResourcePackResponse.java (89%) rename proxy/src/main/java/com/velocitypowered/proxy/{ => network}/protocol/packet/Respawn.java (95%) rename proxy/src/main/java/com/velocitypowered/proxy/{ => network}/protocol/packet/ServerData.java (88%) rename proxy/src/main/java/com/velocitypowered/proxy/{ => network}/protocol/packet/ServerLogin.java (95%) rename proxy/src/main/java/com/velocitypowered/proxy/{ => network}/protocol/packet/ServerLoginSuccess.java (91%) rename proxy/src/main/java/com/velocitypowered/proxy/{ => network}/protocol/packet/SetCompression.java (82%) rename proxy/src/main/java/com/velocitypowered/proxy/{ => network}/protocol/packet/StatusPing.java (76%) rename proxy/src/main/java/com/velocitypowered/proxy/{ => network}/protocol/packet/StatusRequest.java (77%) rename proxy/src/main/java/com/velocitypowered/proxy/{ => network}/protocol/packet/StatusResponse.java (84%) rename proxy/src/main/java/com/velocitypowered/proxy/{ => network}/protocol/packet/TabCompleteRequest.java (92%) rename proxy/src/main/java/com/velocitypowered/proxy/{ => network}/protocol/packet/TabCompleteResponse.java (93%) rename proxy/src/main/java/com/velocitypowered/proxy/{ => network}/protocol/packet/UpsertPlayerInfo.java (91%) rename proxy/src/main/java/com/velocitypowered/proxy/{ => network}/protocol/packet/brigadier/ArgumentIdentifier.java (97%) rename proxy/src/main/java/com/velocitypowered/proxy/{ => network}/protocol/packet/brigadier/ArgumentPropertyRegistry.java (90%) rename proxy/src/main/java/com/velocitypowered/proxy/{ => network}/protocol/packet/brigadier/ArgumentPropertySerializer.java (93%) rename proxy/src/main/java/com/velocitypowered/proxy/{ => network}/protocol/packet/brigadier/ByteArgumentPropertySerializer.java (94%) rename proxy/src/main/java/com/velocitypowered/proxy/{ => network}/protocol/packet/brigadier/DoubleArgumentPropertySerializer.java (73%) rename proxy/src/main/java/com/velocitypowered/proxy/{ => network}/protocol/packet/brigadier/EmptyArgumentPropertySerializer.java (95%) rename proxy/src/main/java/com/velocitypowered/proxy/{ => network}/protocol/packet/brigadier/FloatArgumentPropertySerializer.java (82%) rename proxy/src/main/java/com/velocitypowered/proxy/{ => network}/protocol/packet/brigadier/IntegerArgumentPropertySerializer.java (97%) rename proxy/src/main/java/com/velocitypowered/proxy/{ => network}/protocol/packet/brigadier/LongArgumentPropertySerializer.java (81%) rename proxy/src/main/java/com/velocitypowered/proxy/{ => network}/protocol/packet/brigadier/ModArgumentProperty.java (96%) rename proxy/src/main/java/com/velocitypowered/proxy/{ => network}/protocol/packet/brigadier/ModArgumentPropertySerializer.java (93%) rename proxy/src/main/java/com/velocitypowered/proxy/{ => network}/protocol/packet/brigadier/PassthroughProperty.java (95%) rename proxy/src/main/java/com/velocitypowered/proxy/{ => network}/protocol/packet/brigadier/RegistryKeyArgument.java (94%) rename proxy/src/main/java/com/velocitypowered/proxy/{ => network}/protocol/packet/brigadier/RegistryKeyArgumentList.java (96%) rename proxy/src/main/java/com/velocitypowered/proxy/{ => network}/protocol/packet/brigadier/RegistryKeyArgumentSerializer.java (90%) rename proxy/src/main/java/com/velocitypowered/proxy/{ => network}/protocol/packet/brigadier/StringArgumentPropertySerializer.java (94%) rename proxy/src/main/java/com/velocitypowered/proxy/{ => network}/protocol/packet/brigadier/TimeArgumentSerializer.java (95%) create mode 100644 proxy/src/main/java/com/velocitypowered/proxy/network/protocol/packet/chat/ChatAcknowledgement.java rename proxy/src/main/java/com/velocitypowered/proxy/{ => network}/protocol/packet/chat/ChatHandler.java (88%) rename proxy/src/main/java/com/velocitypowered/proxy/{ => network}/protocol/packet/chat/ChatQueue.java (95%) rename proxy/src/main/java/com/velocitypowered/proxy/{ => network}/protocol/packet/chat/ChatTimeKeeper.java (94%) rename proxy/src/main/java/com/velocitypowered/proxy/{ => network}/protocol/packet/chat/ChatType.java (93%) rename proxy/src/main/java/com/velocitypowered/proxy/{ => network}/protocol/packet/chat/CommandHandler.java (91%) rename proxy/src/main/java/com/velocitypowered/proxy/{ => network}/protocol/packet/chat/LastSeenMessages.java (82%) rename proxy/src/main/java/com/velocitypowered/proxy/{ => network}/protocol/packet/chat/PlayerChatCompletion.java (84%) rename proxy/src/main/java/com/velocitypowered/proxy/{ => network}/protocol/packet/chat/RemoteChatSession.java (93%) rename proxy/src/main/java/com/velocitypowered/proxy/{ => network}/protocol/packet/chat/SystemChat.java (87%) rename proxy/src/main/java/com/velocitypowered/proxy/{ => network}/protocol/packet/chat/builder/ChatBuilderFactory.java (81%) rename proxy/src/main/java/com/velocitypowered/proxy/{ => network}/protocol/packet/chat/builder/ChatBuilderV2.java (91%) rename proxy/src/main/java/com/velocitypowered/proxy/{ => network}/protocol/packet/chat/keyed/KeyedChatBuilder.java (81%) rename proxy/src/main/java/com/velocitypowered/proxy/{ => network}/protocol/packet/chat/keyed/KeyedChatHandler.java (93%) rename proxy/src/main/java/com/velocitypowered/proxy/{ => network}/protocol/packet/chat/keyed/KeyedCommandHandler.java (95%) rename proxy/src/main/java/com/velocitypowered/proxy/{ => network}/protocol/packet/chat/keyed/KeyedPlayerChat.java (93%) rename proxy/src/main/java/com/velocitypowered/proxy/{ => network}/protocol/packet/chat/keyed/KeyedPlayerCommand.java (90%) rename proxy/src/main/java/com/velocitypowered/proxy/{ => network}/protocol/packet/chat/legacy/LegacyChat.java (90%) rename proxy/src/main/java/com/velocitypowered/proxy/{ => network}/protocol/packet/chat/legacy/LegacyChatBuilder.java (84%) rename proxy/src/main/java/com/velocitypowered/proxy/{ => network}/protocol/packet/chat/legacy/LegacyChatHandler.java (93%) rename proxy/src/main/java/com/velocitypowered/proxy/{ => network}/protocol/packet/chat/legacy/LegacyCommandHandler.java (94%) rename proxy/src/main/java/com/velocitypowered/proxy/{ => network}/protocol/packet/chat/session/SessionChatBuilder.java (80%) rename proxy/src/main/java/com/velocitypowered/proxy/{ => network}/protocol/packet/chat/session/SessionChatHandler.java (86%) rename proxy/src/main/java/com/velocitypowered/proxy/{ => network}/protocol/packet/chat/session/SessionCommandHandler.java (91%) rename proxy/src/main/java/com/velocitypowered/proxy/{ => network}/protocol/packet/chat/session/SessionPlayerChat.java (86%) rename proxy/src/main/java/com/velocitypowered/proxy/{ => network}/protocol/packet/chat/session/SessionPlayerCommand.java (81%) rename proxy/src/main/java/com/velocitypowered/proxy/{ => network}/protocol/packet/config/ActiveFeatures.java (80%) rename proxy/src/main/java/com/velocitypowered/proxy/{ => network}/protocol/packet/config/FinishedUpdate.java (66%) rename proxy/src/main/java/com/velocitypowered/proxy/{ => network}/protocol/packet/config/RegistrySync.java (72%) rename proxy/src/main/java/com/velocitypowered/proxy/{ => network}/protocol/packet/config/StartUpdate.java (66%) rename proxy/src/main/java/com/velocitypowered/proxy/{ => network}/protocol/packet/config/TagsUpdate.java (86%) rename proxy/src/main/java/com/velocitypowered/proxy/{ => network}/protocol/packet/legacyping/LegacyMinecraftPingVersion.java (91%) rename proxy/src/main/java/com/velocitypowered/proxy/{ => network}/protocol/packet/title/GenericTitlePacket.java (93%) rename proxy/src/main/java/com/velocitypowered/proxy/{ => network}/protocol/packet/title/LegacyTitlePacket.java (91%) rename proxy/src/main/java/com/velocitypowered/proxy/{ => network}/protocol/packet/title/TitleActionbarPacket.java (84%) rename proxy/src/main/java/com/velocitypowered/proxy/{ => network}/protocol/packet/title/TitleClearPacket.java (87%) rename proxy/src/main/java/com/velocitypowered/proxy/{ => network}/protocol/packet/title/TitleSubtitlePacket.java (84%) rename proxy/src/main/java/com/velocitypowered/proxy/{ => network}/protocol/packet/title/TitleTextPacket.java (83%) rename proxy/src/main/java/com/velocitypowered/proxy/{ => network}/protocol/packet/title/TitleTimesPacket.java (89%) rename proxy/src/main/java/com/velocitypowered/proxy/{ => network}/protocol/util/ByteBufDataInput.java (97%) rename proxy/src/main/java/com/velocitypowered/proxy/{ => network}/protocol/util/ByteBufDataOutput.java (97%) rename proxy/src/main/java/com/velocitypowered/proxy/{ => network}/protocol/util/DeferredByteBufHolder.java (98%) rename proxy/src/main/java/com/velocitypowered/proxy/{ => network}/protocol/util/FaviconSerializer.java (96%) rename proxy/src/main/java/com/velocitypowered/proxy/{ => network}/protocol/util/GameProfileSerializer.java (97%) rename proxy/src/main/java/com/velocitypowered/proxy/{ => network}/protocol/util/NettyPreconditions.java (96%) rename proxy/src/main/java/com/velocitypowered/proxy/{ => network}/protocol/util/PluginMessageUtil.java (97%) rename proxy/src/main/java/com/velocitypowered/proxy/{ => network}/protocol/util/VelocityLegacyHoverEventSerializer.java (98%) rename proxy/src/main/java/com/velocitypowered/proxy/network/{netty => util}/SeparatePoolInetNameResolver.java (95%) rename proxy/src/main/java/com/velocitypowered/proxy/network/{ => util}/TransportType.java (97%) delete mode 100644 proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/chat/ChatAcknowledgement.java rename proxy/src/test/java/com/velocitypowered/proxy/{ => network}/protocol/PacketRegistryTest.java (97%) rename proxy/src/test/java/com/velocitypowered/proxy/{ => network}/protocol/ProtocolUtilsTest.java (98%) rename proxy/src/test/java/com/velocitypowered/proxy/{ => network}/protocol/util/PluginMessageUtilTest.java (97%) diff --git a/build-logic/src/main/kotlin/velocity-checkstyle.gradle.kts b/build-logic/src/main/kotlin/velocity-checkstyle.gradle.kts index 4ac506002..987d51aa9 100644 --- a/build-logic/src/main/kotlin/velocity-checkstyle.gradle.kts +++ b/build-logic/src/main/kotlin/velocity-checkstyle.gradle.kts @@ -7,4 +7,6 @@ extensions.configure { maxErrors = 0 maxWarnings = 0 toolVersion = libs.checkstyle.get().version.toString() + configProperties["org.checkstyle.google.suppressionfilter.config"] = + rootProject.file("config/checkstyle/checkstyle-suppressions.xml") } diff --git a/config/checkstyle/checkstyle-suppressions.xml b/config/checkstyle/checkstyle-suppressions.xml new file mode 100644 index 000000000..f5da6ed23 --- /dev/null +++ b/config/checkstyle/checkstyle-suppressions.xml @@ -0,0 +1,12 @@ + + + + + + + + \ No newline at end of file diff --git a/config/checkstyle/checkstyle.xml b/config/checkstyle/checkstyle.xml index cfae88ed6..204cc842f 100644 --- a/config/checkstyle/checkstyle.xml +++ b/config/checkstyle/checkstyle.xml @@ -33,7 +33,7 @@ - + diff --git a/proxy/src/main/java/com/velocitypowered/proxy/VelocityServer.java b/proxy/src/main/java/com/velocitypowered/proxy/VelocityServer.java index 912e5ecb2..f4ccf65b5 100644 --- a/proxy/src/main/java/com/velocitypowered/proxy/VelocityServer.java +++ b/proxy/src/main/java/com/velocitypowered/proxy/VelocityServer.java @@ -49,10 +49,10 @@ import com.velocitypowered.proxy.console.VelocityConsole; import com.velocitypowered.proxy.crypto.EncryptionUtils; import com.velocitypowered.proxy.event.VelocityEventManager; import com.velocitypowered.proxy.network.ConnectionManager; +import com.velocitypowered.proxy.network.protocol.ProtocolUtils; +import com.velocitypowered.proxy.network.protocol.util.FaviconSerializer; +import com.velocitypowered.proxy.network.protocol.util.GameProfileSerializer; 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; diff --git a/proxy/src/main/java/com/velocitypowered/proxy/connection/MinecraftConnection.java b/proxy/src/main/java/com/velocitypowered/proxy/connection/MinecraftConnection.java index bb0c4db72..875d2adef 100644 --- a/proxy/src/main/java/com/velocitypowered/proxy/connection/MinecraftConnection.java +++ b/proxy/src/main/java/com/velocitypowered/proxy/connection/MinecraftConnection.java @@ -37,17 +37,18 @@ import com.velocitypowered.proxy.connection.client.HandshakeSessionHandler; import com.velocitypowered.proxy.connection.client.InitialLoginSessionHandler; import com.velocitypowered.proxy.connection.client.StatusSessionHandler; import com.velocitypowered.proxy.network.Connections; -import com.velocitypowered.proxy.protocol.MinecraftPacket; -import com.velocitypowered.proxy.protocol.StateRegistry; -import com.velocitypowered.proxy.protocol.VelocityConnectionEvent; -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.MinecraftCompressorAndLengthEncoder; -import com.velocitypowered.proxy.protocol.netty.MinecraftDecoder; -import com.velocitypowered.proxy.protocol.netty.MinecraftEncoder; -import com.velocitypowered.proxy.protocol.netty.MinecraftVarintLengthEncoder; -import com.velocitypowered.proxy.protocol.netty.PlayPacketQueueHandler; +import com.velocitypowered.proxy.network.pipeline.compression.MinecraftCompressDecoder; +import com.velocitypowered.proxy.network.pipeline.compression.MinecraftCompressorAndLengthEncoder; +import com.velocitypowered.proxy.network.pipeline.deser.MinecraftDecoder; +import com.velocitypowered.proxy.network.pipeline.deser.MinecraftEncoder; +import com.velocitypowered.proxy.network.pipeline.encryption.MinecraftCipherDecoder; +import com.velocitypowered.proxy.network.pipeline.encryption.MinecraftCipherEncoder; +import com.velocitypowered.proxy.network.pipeline.framing.MinecraftVarintLengthEncoder; +import com.velocitypowered.proxy.network.pipeline.util.PlayPacketQueueHandler; +import com.velocitypowered.proxy.network.pipeline.util.VelocityConnectionEvent; +import com.velocitypowered.proxy.network.protocol.MinecraftPacket; +import com.velocitypowered.proxy.network.protocol.StateRegistry; +import com.velocitypowered.proxy.network.protocol.packet.SetCompression; import com.velocitypowered.proxy.util.except.QuietDecoderException; import io.netty.buffer.ByteBuf; import io.netty.channel.Channel; @@ -487,7 +488,7 @@ public class MinecraftConnection extends ChannelInboundHandlerAdapter { /** * Sets the compression threshold on the connection. You are responsible for sending {@link - * com.velocitypowered.proxy.protocol.packet.SetCompression} beforehand. + * SetCompression} beforehand. * * @param threshold the compression threshold to use */ diff --git a/proxy/src/main/java/com/velocitypowered/proxy/connection/MinecraftSessionHandler.java b/proxy/src/main/java/com/velocitypowered/proxy/connection/MinecraftSessionHandler.java index 189820e04..4c9d11536 100644 --- a/proxy/src/main/java/com/velocitypowered/proxy/connection/MinecraftSessionHandler.java +++ b/proxy/src/main/java/com/velocitypowered/proxy/connection/MinecraftSessionHandler.java @@ -17,58 +17,58 @@ package com.velocitypowered.proxy.connection; -import com.velocitypowered.proxy.protocol.MinecraftPacket; -import com.velocitypowered.proxy.protocol.packet.AvailableCommands; -import com.velocitypowered.proxy.protocol.packet.BossBar; -import com.velocitypowered.proxy.protocol.packet.ClientSettings; -import com.velocitypowered.proxy.protocol.packet.Disconnect; -import com.velocitypowered.proxy.protocol.packet.EncryptionRequest; -import com.velocitypowered.proxy.protocol.packet.EncryptionResponse; -import com.velocitypowered.proxy.protocol.packet.Handshake; -import com.velocitypowered.proxy.protocol.packet.HeaderAndFooter; -import com.velocitypowered.proxy.protocol.packet.JoinGame; -import com.velocitypowered.proxy.protocol.packet.KeepAlive; -import com.velocitypowered.proxy.protocol.packet.LegacyHandshake; -import com.velocitypowered.proxy.protocol.packet.LegacyPing; -import com.velocitypowered.proxy.protocol.packet.LegacyPlayerListItem; -import com.velocitypowered.proxy.protocol.packet.LoginAcknowledged; -import com.velocitypowered.proxy.protocol.packet.LoginPluginMessage; -import com.velocitypowered.proxy.protocol.packet.LoginPluginResponse; -import com.velocitypowered.proxy.protocol.packet.PingIdentify; -import com.velocitypowered.proxy.protocol.packet.PluginMessage; -import com.velocitypowered.proxy.protocol.packet.RemovePlayerInfo; -import com.velocitypowered.proxy.protocol.packet.ResourcePackRequest; -import com.velocitypowered.proxy.protocol.packet.ResourcePackResponse; -import com.velocitypowered.proxy.protocol.packet.Respawn; -import com.velocitypowered.proxy.protocol.packet.ServerData; -import com.velocitypowered.proxy.protocol.packet.ServerLogin; -import com.velocitypowered.proxy.protocol.packet.ServerLoginSuccess; -import com.velocitypowered.proxy.protocol.packet.SetCompression; -import com.velocitypowered.proxy.protocol.packet.StatusPing; -import com.velocitypowered.proxy.protocol.packet.StatusRequest; -import com.velocitypowered.proxy.protocol.packet.StatusResponse; -import com.velocitypowered.proxy.protocol.packet.TabCompleteRequest; -import com.velocitypowered.proxy.protocol.packet.TabCompleteResponse; -import com.velocitypowered.proxy.protocol.packet.UpsertPlayerInfo; -import com.velocitypowered.proxy.protocol.packet.chat.ChatAcknowledgement; -import com.velocitypowered.proxy.protocol.packet.chat.PlayerChatCompletion; -import com.velocitypowered.proxy.protocol.packet.chat.SystemChat; -import com.velocitypowered.proxy.protocol.packet.chat.keyed.KeyedPlayerChat; -import com.velocitypowered.proxy.protocol.packet.chat.keyed.KeyedPlayerCommand; -import com.velocitypowered.proxy.protocol.packet.chat.legacy.LegacyChat; -import com.velocitypowered.proxy.protocol.packet.chat.session.SessionPlayerChat; -import com.velocitypowered.proxy.protocol.packet.chat.session.SessionPlayerCommand; -import com.velocitypowered.proxy.protocol.packet.config.ActiveFeatures; -import com.velocitypowered.proxy.protocol.packet.config.FinishedUpdate; -import com.velocitypowered.proxy.protocol.packet.config.RegistrySync; -import com.velocitypowered.proxy.protocol.packet.config.StartUpdate; -import com.velocitypowered.proxy.protocol.packet.config.TagsUpdate; -import com.velocitypowered.proxy.protocol.packet.title.LegacyTitlePacket; -import com.velocitypowered.proxy.protocol.packet.title.TitleActionbarPacket; -import com.velocitypowered.proxy.protocol.packet.title.TitleClearPacket; -import com.velocitypowered.proxy.protocol.packet.title.TitleSubtitlePacket; -import com.velocitypowered.proxy.protocol.packet.title.TitleTextPacket; -import com.velocitypowered.proxy.protocol.packet.title.TitleTimesPacket; +import com.velocitypowered.proxy.network.protocol.MinecraftPacket; +import com.velocitypowered.proxy.network.protocol.packet.AvailableCommands; +import com.velocitypowered.proxy.network.protocol.packet.BossBarPacket; +import com.velocitypowered.proxy.network.protocol.packet.ClientSettings; +import com.velocitypowered.proxy.network.protocol.packet.Disconnect; +import com.velocitypowered.proxy.network.protocol.packet.EncryptionRequest; +import com.velocitypowered.proxy.network.protocol.packet.EncryptionResponse; +import com.velocitypowered.proxy.network.protocol.packet.Handshake; +import com.velocitypowered.proxy.network.protocol.packet.HeaderAndFooter; +import com.velocitypowered.proxy.network.protocol.packet.JoinGame; +import com.velocitypowered.proxy.network.protocol.packet.KeepAlive; +import com.velocitypowered.proxy.network.protocol.packet.LegacyHandshake; +import com.velocitypowered.proxy.network.protocol.packet.LegacyPing; +import com.velocitypowered.proxy.network.protocol.packet.LegacyPlayerListItem; +import com.velocitypowered.proxy.network.protocol.packet.LoginAcknowledged; +import com.velocitypowered.proxy.network.protocol.packet.LoginPluginMessage; +import com.velocitypowered.proxy.network.protocol.packet.LoginPluginResponse; +import com.velocitypowered.proxy.network.protocol.packet.PingIdentify; +import com.velocitypowered.proxy.network.protocol.packet.PluginMessage; +import com.velocitypowered.proxy.network.protocol.packet.RemovePlayerInfo; +import com.velocitypowered.proxy.network.protocol.packet.ResourcePackRequest; +import com.velocitypowered.proxy.network.protocol.packet.ResourcePackResponse; +import com.velocitypowered.proxy.network.protocol.packet.Respawn; +import com.velocitypowered.proxy.network.protocol.packet.ServerData; +import com.velocitypowered.proxy.network.protocol.packet.ServerLogin; +import com.velocitypowered.proxy.network.protocol.packet.ServerLoginSuccess; +import com.velocitypowered.proxy.network.protocol.packet.SetCompression; +import com.velocitypowered.proxy.network.protocol.packet.StatusPing; +import com.velocitypowered.proxy.network.protocol.packet.StatusRequest; +import com.velocitypowered.proxy.network.protocol.packet.StatusResponse; +import com.velocitypowered.proxy.network.protocol.packet.TabCompleteRequest; +import com.velocitypowered.proxy.network.protocol.packet.TabCompleteResponse; +import com.velocitypowered.proxy.network.protocol.packet.UpsertPlayerInfo; +import com.velocitypowered.proxy.network.protocol.packet.chat.ChatAcknowledgement; +import com.velocitypowered.proxy.network.protocol.packet.chat.PlayerChatCompletion; +import com.velocitypowered.proxy.network.protocol.packet.chat.SystemChat; +import com.velocitypowered.proxy.network.protocol.packet.chat.keyed.KeyedPlayerChat; +import com.velocitypowered.proxy.network.protocol.packet.chat.keyed.KeyedPlayerCommand; +import com.velocitypowered.proxy.network.protocol.packet.chat.legacy.LegacyChat; +import com.velocitypowered.proxy.network.protocol.packet.chat.session.SessionPlayerChat; +import com.velocitypowered.proxy.network.protocol.packet.chat.session.SessionPlayerCommand; +import com.velocitypowered.proxy.network.protocol.packet.config.ActiveFeatures; +import com.velocitypowered.proxy.network.protocol.packet.config.FinishedUpdate; +import com.velocitypowered.proxy.network.protocol.packet.config.RegistrySync; +import com.velocitypowered.proxy.network.protocol.packet.config.StartUpdate; +import com.velocitypowered.proxy.network.protocol.packet.config.TagsUpdate; +import com.velocitypowered.proxy.network.protocol.packet.title.LegacyTitlePacket; +import com.velocitypowered.proxy.network.protocol.packet.title.TitleActionbarPacket; +import com.velocitypowered.proxy.network.protocol.packet.title.TitleClearPacket; +import com.velocitypowered.proxy.network.protocol.packet.title.TitleSubtitlePacket; +import com.velocitypowered.proxy.network.protocol.packet.title.TitleTextPacket; +import com.velocitypowered.proxy.network.protocol.packet.title.TitleTimesPacket; import io.netty.buffer.ByteBuf; /** @@ -120,7 +120,7 @@ public interface MinecraftSessionHandler { return false; } - default boolean handle(BossBar packet) { + default boolean handle(BossBarPacket packet) { return false; } diff --git a/proxy/src/main/java/com/velocitypowered/proxy/connection/backend/BackendConnectionPhase.java b/proxy/src/main/java/com/velocitypowered/proxy/connection/backend/BackendConnectionPhase.java index b7bbed430..7b89882ae 100644 --- a/proxy/src/main/java/com/velocitypowered/proxy/connection/backend/BackendConnectionPhase.java +++ b/proxy/src/main/java/com/velocitypowered/proxy/connection/backend/BackendConnectionPhase.java @@ -19,7 +19,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.PluginMessage; +import com.velocitypowered.proxy.network.protocol.packet.PluginMessage; /** * Provides connection phase specific actions. diff --git a/proxy/src/main/java/com/velocitypowered/proxy/connection/backend/BackendConnectionPhases.java b/proxy/src/main/java/com/velocitypowered/proxy/connection/backend/BackendConnectionPhases.java index 4e39a155e..724baeb7f 100644 --- a/proxy/src/main/java/com/velocitypowered/proxy/connection/backend/BackendConnectionPhases.java +++ b/proxy/src/main/java/com/velocitypowered/proxy/connection/backend/BackendConnectionPhases.java @@ -19,7 +19,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.PluginMessage; +import com.velocitypowered.proxy.network.protocol.packet.PluginMessage; /** * Contains Vanilla {@link BackendConnectionPhase}s. diff --git a/proxy/src/main/java/com/velocitypowered/proxy/connection/backend/BackendPlaySessionHandler.java b/proxy/src/main/java/com/velocitypowered/proxy/connection/backend/BackendPlaySessionHandler.java index c21ae6ecd..6c050755a 100644 --- a/proxy/src/main/java/com/velocitypowered/proxy/connection/backend/BackendPlaySessionHandler.java +++ b/proxy/src/main/java/com/velocitypowered/proxy/connection/backend/BackendPlaySessionHandler.java @@ -38,24 +38,24 @@ import com.velocitypowered.proxy.connection.MinecraftSessionHandler; import com.velocitypowered.proxy.connection.client.ClientPlaySessionHandler; import com.velocitypowered.proxy.connection.player.VelocityResourcePackInfo; import com.velocitypowered.proxy.connection.util.ConnectionMessages; -import com.velocitypowered.proxy.protocol.MinecraftPacket; -import com.velocitypowered.proxy.protocol.StateRegistry; -import com.velocitypowered.proxy.protocol.netty.MinecraftDecoder; -import com.velocitypowered.proxy.protocol.packet.AvailableCommands; -import com.velocitypowered.proxy.protocol.packet.BossBar; -import com.velocitypowered.proxy.protocol.packet.ClientSettings; -import com.velocitypowered.proxy.protocol.packet.Disconnect; -import com.velocitypowered.proxy.protocol.packet.KeepAlive; -import com.velocitypowered.proxy.protocol.packet.LegacyPlayerListItem; -import com.velocitypowered.proxy.protocol.packet.PluginMessage; -import com.velocitypowered.proxy.protocol.packet.RemovePlayerInfo; -import com.velocitypowered.proxy.protocol.packet.ResourcePackRequest; -import com.velocitypowered.proxy.protocol.packet.ResourcePackResponse; -import com.velocitypowered.proxy.protocol.packet.ServerData; -import com.velocitypowered.proxy.protocol.packet.TabCompleteResponse; -import com.velocitypowered.proxy.protocol.packet.UpsertPlayerInfo; -import com.velocitypowered.proxy.protocol.packet.config.StartUpdate; -import com.velocitypowered.proxy.protocol.util.PluginMessageUtil; +import com.velocitypowered.proxy.network.pipeline.deser.MinecraftDecoder; +import com.velocitypowered.proxy.network.protocol.MinecraftPacket; +import com.velocitypowered.proxy.network.protocol.StateRegistry; +import com.velocitypowered.proxy.network.protocol.packet.AvailableCommands; +import com.velocitypowered.proxy.network.protocol.packet.BossBarPacket; +import com.velocitypowered.proxy.network.protocol.packet.ClientSettings; +import com.velocitypowered.proxy.network.protocol.packet.Disconnect; +import com.velocitypowered.proxy.network.protocol.packet.KeepAlive; +import com.velocitypowered.proxy.network.protocol.packet.LegacyPlayerListItem; +import com.velocitypowered.proxy.network.protocol.packet.PluginMessage; +import com.velocitypowered.proxy.network.protocol.packet.RemovePlayerInfo; +import com.velocitypowered.proxy.network.protocol.packet.ResourcePackRequest; +import com.velocitypowered.proxy.network.protocol.packet.ResourcePackResponse; +import com.velocitypowered.proxy.network.protocol.packet.ServerData; +import com.velocitypowered.proxy.network.protocol.packet.TabCompleteResponse; +import com.velocitypowered.proxy.network.protocol.packet.UpsertPlayerInfo; +import com.velocitypowered.proxy.network.protocol.packet.config.StartUpdate; +import com.velocitypowered.proxy.network.protocol.util.PluginMessageUtil; import io.netty.buffer.ByteBuf; import io.netty.buffer.ByteBufUtil; import io.netty.buffer.Unpooled; @@ -154,10 +154,10 @@ public class BackendPlaySessionHandler implements MinecraftSessionHandler { } @Override - public boolean handle(BossBar packet) { - if (packet.getAction() == BossBar.ADD) { + public boolean handle(BossBarPacket packet) { + if (packet.getAction() == BossBarPacket.ADD) { playerSessionHandler.getServerBossBars().add(packet.getUuid()); - } else if (packet.getAction() == BossBar.REMOVE) { + } else if (packet.getAction() == BossBarPacket.REMOVE) { playerSessionHandler.getServerBossBars().remove(packet.getUuid()); } return false; // forward diff --git a/proxy/src/main/java/com/velocitypowered/proxy/connection/backend/BungeeCordMessageResponder.java b/proxy/src/main/java/com/velocitypowered/proxy/connection/backend/BungeeCordMessageResponder.java index fa593f144..831fe0581 100644 --- a/proxy/src/main/java/com/velocitypowered/proxy/connection/backend/BungeeCordMessageResponder.java +++ b/proxy/src/main/java/com/velocitypowered/proxy/connection/backend/BungeeCordMessageResponder.java @@ -28,9 +28,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.PluginMessage; -import com.velocitypowered.proxy.protocol.util.ByteBufDataInput; -import com.velocitypowered.proxy.protocol.util.ByteBufDataOutput; +import com.velocitypowered.proxy.network.protocol.packet.PluginMessage; +import com.velocitypowered.proxy.network.protocol.util.ByteBufDataInput; +import com.velocitypowered.proxy.network.protocol.util.ByteBufDataOutput; import com.velocitypowered.proxy.server.VelocityRegisteredServer; import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; import io.netty.buffer.ByteBuf; diff --git a/proxy/src/main/java/com/velocitypowered/proxy/connection/backend/ConfigSessionHandler.java b/proxy/src/main/java/com/velocitypowered/proxy/connection/backend/ConfigSessionHandler.java index 82342ffe0..e2baa63ff 100644 --- a/proxy/src/main/java/com/velocitypowered/proxy/connection/backend/ConfigSessionHandler.java +++ b/proxy/src/main/java/com/velocitypowered/proxy/connection/backend/ConfigSessionHandler.java @@ -29,19 +29,19 @@ import com.velocitypowered.proxy.connection.player.VelocityResourcePackInfo; 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.MinecraftPacket; -import com.velocitypowered.proxy.protocol.StateRegistry; -import com.velocitypowered.proxy.protocol.netty.MinecraftDecoder; -import com.velocitypowered.proxy.protocol.packet.Disconnect; -import com.velocitypowered.proxy.protocol.packet.KeepAlive; -import com.velocitypowered.proxy.protocol.packet.PluginMessage; -import com.velocitypowered.proxy.protocol.packet.ResourcePackRequest; -import com.velocitypowered.proxy.protocol.packet.ResourcePackResponse; -import com.velocitypowered.proxy.protocol.packet.config.FinishedUpdate; -import com.velocitypowered.proxy.protocol.packet.config.RegistrySync; -import com.velocitypowered.proxy.protocol.packet.config.StartUpdate; -import com.velocitypowered.proxy.protocol.packet.config.TagsUpdate; -import com.velocitypowered.proxy.protocol.util.PluginMessageUtil; +import com.velocitypowered.proxy.network.pipeline.deser.MinecraftDecoder; +import com.velocitypowered.proxy.network.protocol.MinecraftPacket; +import com.velocitypowered.proxy.network.protocol.StateRegistry; +import com.velocitypowered.proxy.network.protocol.packet.Disconnect; +import com.velocitypowered.proxy.network.protocol.packet.KeepAlive; +import com.velocitypowered.proxy.network.protocol.packet.PluginMessage; +import com.velocitypowered.proxy.network.protocol.packet.ResourcePackRequest; +import com.velocitypowered.proxy.network.protocol.packet.ResourcePackResponse; +import com.velocitypowered.proxy.network.protocol.packet.config.FinishedUpdate; +import com.velocitypowered.proxy.network.protocol.packet.config.RegistrySync; +import com.velocitypowered.proxy.network.protocol.packet.config.StartUpdate; +import com.velocitypowered.proxy.network.protocol.packet.config.TagsUpdate; +import com.velocitypowered.proxy.network.protocol.util.PluginMessageUtil; import java.io.IOException; import java.util.concurrent.CompletableFuture; import java.util.regex.Pattern; diff --git a/proxy/src/main/java/com/velocitypowered/proxy/connection/backend/LoginSessionHandler.java b/proxy/src/main/java/com/velocitypowered/proxy/connection/backend/LoginSessionHandler.java index 10079db72..c3418baf9 100644 --- a/proxy/src/main/java/com/velocitypowered/proxy/connection/backend/LoginSessionHandler.java +++ b/proxy/src/main/java/com/velocitypowered/proxy/connection/backend/LoginSessionHandler.java @@ -31,15 +31,15 @@ import com.velocitypowered.proxy.connection.client.ClientPlaySessionHandler; import com.velocitypowered.proxy.connection.client.ConnectedPlayer; 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.Disconnect; -import com.velocitypowered.proxy.protocol.packet.EncryptionRequest; -import com.velocitypowered.proxy.protocol.packet.LoginAcknowledged; -import com.velocitypowered.proxy.protocol.packet.LoginPluginMessage; -import com.velocitypowered.proxy.protocol.packet.LoginPluginResponse; -import com.velocitypowered.proxy.protocol.packet.ServerLoginSuccess; -import com.velocitypowered.proxy.protocol.packet.SetCompression; +import com.velocitypowered.proxy.network.protocol.ProtocolUtils; +import com.velocitypowered.proxy.network.protocol.StateRegistry; +import com.velocitypowered.proxy.network.protocol.packet.Disconnect; +import com.velocitypowered.proxy.network.protocol.packet.EncryptionRequest; +import com.velocitypowered.proxy.network.protocol.packet.LoginAcknowledged; +import com.velocitypowered.proxy.network.protocol.packet.LoginPluginMessage; +import com.velocitypowered.proxy.network.protocol.packet.LoginPluginResponse; +import com.velocitypowered.proxy.network.protocol.packet.ServerLoginSuccess; +import com.velocitypowered.proxy.network.protocol.packet.SetCompression; import com.velocitypowered.proxy.util.except.QuietRuntimeException; import io.netty.buffer.ByteBuf; import io.netty.buffer.ByteBufUtil; diff --git a/proxy/src/main/java/com/velocitypowered/proxy/connection/backend/TransitionSessionHandler.java b/proxy/src/main/java/com/velocitypowered/proxy/connection/backend/TransitionSessionHandler.java index 0f32fbefb..9b2d79cb7 100644 --- a/proxy/src/main/java/com/velocitypowered/proxy/connection/backend/TransitionSessionHandler.java +++ b/proxy/src/main/java/com/velocitypowered/proxy/connection/backend/TransitionSessionHandler.java @@ -33,11 +33,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.StateRegistry; -import com.velocitypowered.proxy.protocol.packet.Disconnect; -import com.velocitypowered.proxy.protocol.packet.JoinGame; -import com.velocitypowered.proxy.protocol.packet.KeepAlive; -import com.velocitypowered.proxy.protocol.packet.PluginMessage; +import com.velocitypowered.proxy.network.protocol.StateRegistry; +import com.velocitypowered.proxy.network.protocol.packet.Disconnect; +import com.velocitypowered.proxy.network.protocol.packet.JoinGame; +import com.velocitypowered.proxy.network.protocol.packet.KeepAlive; +import com.velocitypowered.proxy.network.protocol.packet.PluginMessage; import java.io.IOException; import java.util.concurrent.CompletableFuture; import org.apache.logging.log4j.LogManager; diff --git a/proxy/src/main/java/com/velocitypowered/proxy/connection/backend/VelocityServerConnection.java b/proxy/src/main/java/com/velocitypowered/proxy/connection/backend/VelocityServerConnection.java index a0cecd1b9..2dec36127 100644 --- a/proxy/src/main/java/com/velocitypowered/proxy/connection/backend/VelocityServerConnection.java +++ b/proxy/src/main/java/com/velocitypowered/proxy/connection/backend/VelocityServerConnection.java @@ -37,10 +37,11 @@ import com.velocitypowered.proxy.connection.MinecraftConnectionAssociation; import com.velocitypowered.proxy.connection.MinecraftSessionHandler; import com.velocitypowered.proxy.connection.client.ConnectedPlayer; import com.velocitypowered.proxy.connection.util.ConnectionRequestResults.Impl; -import com.velocitypowered.proxy.protocol.StateRegistry; -import com.velocitypowered.proxy.protocol.packet.Handshake; -import com.velocitypowered.proxy.protocol.packet.PluginMessage; -import com.velocitypowered.proxy.protocol.packet.ServerLogin; +import com.velocitypowered.proxy.network.protocol.StateRegistry; +import com.velocitypowered.proxy.network.protocol.packet.Handshake; +import com.velocitypowered.proxy.network.protocol.packet.JoinGame; +import com.velocitypowered.proxy.network.protocol.packet.PluginMessage; +import com.velocitypowered.proxy.network.protocol.packet.ServerLogin; import com.velocitypowered.proxy.server.VelocityRegisteredServer; import io.netty.buffer.ByteBuf; import io.netty.buffer.Unpooled; @@ -356,7 +357,7 @@ public class VelocityServerConnection implements MinecraftConnectionAssociation, } /** - * Gets whether the {@link com.velocitypowered.proxy.protocol.packet.JoinGame} packet has been + * Gets whether the {@link JoinGame} packet has been * sent by this server. * * @return Whether the join has been completed. diff --git a/proxy/src/main/java/com/velocitypowered/proxy/connection/client/AuthSessionHandler.java b/proxy/src/main/java/com/velocitypowered/proxy/connection/client/AuthSessionHandler.java index 15caa5567..5351a67cb 100644 --- a/proxy/src/main/java/com/velocitypowered/proxy/connection/client/AuthSessionHandler.java +++ b/proxy/src/main/java/com/velocitypowered/proxy/connection/client/AuthSessionHandler.java @@ -37,10 +37,10 @@ import com.velocitypowered.proxy.config.VelocityConfiguration; import com.velocitypowered.proxy.connection.MinecraftConnection; import com.velocitypowered.proxy.connection.MinecraftSessionHandler; import com.velocitypowered.proxy.crypto.IdentifiedKeyImpl; -import com.velocitypowered.proxy.protocol.StateRegistry; -import com.velocitypowered.proxy.protocol.packet.LoginAcknowledged; -import com.velocitypowered.proxy.protocol.packet.ServerLoginSuccess; -import com.velocitypowered.proxy.protocol.packet.SetCompression; +import com.velocitypowered.proxy.network.protocol.StateRegistry; +import com.velocitypowered.proxy.network.protocol.packet.LoginAcknowledged; +import com.velocitypowered.proxy.network.protocol.packet.ServerLoginSuccess; +import com.velocitypowered.proxy.network.protocol.packet.SetCompression; import io.netty.buffer.ByteBuf; import java.util.Objects; import java.util.Optional; diff --git a/proxy/src/main/java/com/velocitypowered/proxy/connection/client/ClientConfigSessionHandler.java b/proxy/src/main/java/com/velocitypowered/proxy/connection/client/ClientConfigSessionHandler.java index 61f733f0f..aee90cf80 100644 --- a/proxy/src/main/java/com/velocitypowered/proxy/connection/client/ClientConfigSessionHandler.java +++ b/proxy/src/main/java/com/velocitypowered/proxy/connection/client/ClientConfigSessionHandler.java @@ -22,15 +22,15 @@ import com.velocitypowered.proxy.VelocityServer; import com.velocitypowered.proxy.connection.MinecraftConnection; import com.velocitypowered.proxy.connection.MinecraftSessionHandler; import com.velocitypowered.proxy.connection.backend.VelocityServerConnection; -import com.velocitypowered.proxy.protocol.MinecraftPacket; -import com.velocitypowered.proxy.protocol.StateRegistry; -import com.velocitypowered.proxy.protocol.packet.ClientSettings; -import com.velocitypowered.proxy.protocol.packet.KeepAlive; -import com.velocitypowered.proxy.protocol.packet.PingIdentify; -import com.velocitypowered.proxy.protocol.packet.PluginMessage; -import com.velocitypowered.proxy.protocol.packet.ResourcePackResponse; -import com.velocitypowered.proxy.protocol.packet.config.FinishedUpdate; -import com.velocitypowered.proxy.protocol.util.PluginMessageUtil; +import com.velocitypowered.proxy.network.protocol.MinecraftPacket; +import com.velocitypowered.proxy.network.protocol.StateRegistry; +import com.velocitypowered.proxy.network.protocol.packet.ClientSettings; +import com.velocitypowered.proxy.network.protocol.packet.KeepAlive; +import com.velocitypowered.proxy.network.protocol.packet.PingIdentify; +import com.velocitypowered.proxy.network.protocol.packet.PluginMessage; +import com.velocitypowered.proxy.network.protocol.packet.ResourcePackResponse; +import com.velocitypowered.proxy.network.protocol.packet.config.FinishedUpdate; +import com.velocitypowered.proxy.network.protocol.util.PluginMessageUtil; import io.netty.buffer.ByteBuf; import java.util.concurrent.CompletableFuture; import net.kyori.adventure.text.Component; diff --git a/proxy/src/main/java/com/velocitypowered/proxy/connection/client/ClientConnectionPhase.java b/proxy/src/main/java/com/velocitypowered/proxy/connection/client/ClientConnectionPhase.java index 0a7fc086c..28b7223df 100644 --- a/proxy/src/main/java/com/velocitypowered/proxy/connection/client/ClientConnectionPhase.java +++ b/proxy/src/main/java/com/velocitypowered/proxy/connection/client/ClientConnectionPhase.java @@ -19,7 +19,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.PluginMessage; +import com.velocitypowered.proxy.network.protocol.packet.PluginMessage; /** * Provides connection phase specific actions. diff --git a/proxy/src/main/java/com/velocitypowered/proxy/connection/client/ClientPlaySessionHandler.java b/proxy/src/main/java/com/velocitypowered/proxy/connection/client/ClientPlaySessionHandler.java index 6004cf834..1e2c9d3ed 100644 --- a/proxy/src/main/java/com/velocitypowered/proxy/connection/client/ClientPlaySessionHandler.java +++ b/proxy/src/main/java/com/velocitypowered/proxy/connection/client/ClientPlaySessionHandler.java @@ -17,7 +17,7 @@ package com.velocitypowered.proxy.connection.client; -import static com.velocitypowered.proxy.protocol.util.PluginMessageUtil.constructChannelsPacket; +import static com.velocitypowered.proxy.network.protocol.util.PluginMessageUtil.constructChannelsPacket; import com.google.common.collect.ImmutableList; import com.mojang.brigadier.suggestion.Suggestion; @@ -38,35 +38,35 @@ 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.connection.forge.legacy.LegacyForgeConstants; -import com.velocitypowered.proxy.protocol.MinecraftPacket; -import com.velocitypowered.proxy.protocol.StateRegistry; -import com.velocitypowered.proxy.protocol.packet.BossBar; -import com.velocitypowered.proxy.protocol.packet.ClientSettings; -import com.velocitypowered.proxy.protocol.packet.JoinGame; -import com.velocitypowered.proxy.protocol.packet.KeepAlive; -import com.velocitypowered.proxy.protocol.packet.PluginMessage; -import com.velocitypowered.proxy.protocol.packet.ResourcePackResponse; -import com.velocitypowered.proxy.protocol.packet.Respawn; -import com.velocitypowered.proxy.protocol.packet.TabCompleteRequest; -import com.velocitypowered.proxy.protocol.packet.TabCompleteResponse; -import com.velocitypowered.proxy.protocol.packet.TabCompleteResponse.Offer; -import com.velocitypowered.proxy.protocol.packet.chat.ChatHandler; -import com.velocitypowered.proxy.protocol.packet.chat.ChatTimeKeeper; -import com.velocitypowered.proxy.protocol.packet.chat.CommandHandler; -import com.velocitypowered.proxy.protocol.packet.chat.keyed.KeyedChatHandler; -import com.velocitypowered.proxy.protocol.packet.chat.keyed.KeyedCommandHandler; -import com.velocitypowered.proxy.protocol.packet.chat.keyed.KeyedPlayerChat; -import com.velocitypowered.proxy.protocol.packet.chat.keyed.KeyedPlayerCommand; -import com.velocitypowered.proxy.protocol.packet.chat.legacy.LegacyChat; -import com.velocitypowered.proxy.protocol.packet.chat.legacy.LegacyChatHandler; -import com.velocitypowered.proxy.protocol.packet.chat.legacy.LegacyCommandHandler; -import com.velocitypowered.proxy.protocol.packet.chat.session.SessionChatHandler; -import com.velocitypowered.proxy.protocol.packet.chat.session.SessionCommandHandler; -import com.velocitypowered.proxy.protocol.packet.chat.session.SessionPlayerChat; -import com.velocitypowered.proxy.protocol.packet.chat.session.SessionPlayerCommand; -import com.velocitypowered.proxy.protocol.packet.config.FinishedUpdate; -import com.velocitypowered.proxy.protocol.packet.title.GenericTitlePacket; -import com.velocitypowered.proxy.protocol.util.PluginMessageUtil; +import com.velocitypowered.proxy.network.protocol.MinecraftPacket; +import com.velocitypowered.proxy.network.protocol.StateRegistry; +import com.velocitypowered.proxy.network.protocol.packet.BossBarPacket; +import com.velocitypowered.proxy.network.protocol.packet.ClientSettings; +import com.velocitypowered.proxy.network.protocol.packet.JoinGame; +import com.velocitypowered.proxy.network.protocol.packet.KeepAlive; +import com.velocitypowered.proxy.network.protocol.packet.PluginMessage; +import com.velocitypowered.proxy.network.protocol.packet.ResourcePackResponse; +import com.velocitypowered.proxy.network.protocol.packet.Respawn; +import com.velocitypowered.proxy.network.protocol.packet.TabCompleteRequest; +import com.velocitypowered.proxy.network.protocol.packet.TabCompleteResponse; +import com.velocitypowered.proxy.network.protocol.packet.TabCompleteResponse.Offer; +import com.velocitypowered.proxy.network.protocol.packet.chat.ChatHandler; +import com.velocitypowered.proxy.network.protocol.packet.chat.ChatTimeKeeper; +import com.velocitypowered.proxy.network.protocol.packet.chat.CommandHandler; +import com.velocitypowered.proxy.network.protocol.packet.chat.keyed.KeyedChatHandler; +import com.velocitypowered.proxy.network.protocol.packet.chat.keyed.KeyedCommandHandler; +import com.velocitypowered.proxy.network.protocol.packet.chat.keyed.KeyedPlayerChat; +import com.velocitypowered.proxy.network.protocol.packet.chat.keyed.KeyedPlayerCommand; +import com.velocitypowered.proxy.network.protocol.packet.chat.legacy.LegacyChat; +import com.velocitypowered.proxy.network.protocol.packet.chat.legacy.LegacyChatHandler; +import com.velocitypowered.proxy.network.protocol.packet.chat.legacy.LegacyCommandHandler; +import com.velocitypowered.proxy.network.protocol.packet.chat.session.SessionChatHandler; +import com.velocitypowered.proxy.network.protocol.packet.chat.session.SessionCommandHandler; +import com.velocitypowered.proxy.network.protocol.packet.chat.session.SessionPlayerChat; +import com.velocitypowered.proxy.network.protocol.packet.chat.session.SessionPlayerCommand; +import com.velocitypowered.proxy.network.protocol.packet.config.FinishedUpdate; +import com.velocitypowered.proxy.network.protocol.packet.title.GenericTitlePacket; +import com.velocitypowered.proxy.network.protocol.util.PluginMessageUtil; import com.velocitypowered.proxy.util.CharacterUtil; import io.netty.buffer.ByteBuf; import io.netty.buffer.ByteBufUtil; @@ -529,9 +529,9 @@ public class ClientPlaySessionHandler implements MinecraftSessionHandler { // Remove previous boss bars. These don't get cleared when sending JoinGame, thus the need to // track them. for (UUID serverBossBar : serverBossBars) { - BossBar deletePacket = new BossBar(); + BossBarPacket deletePacket = new BossBarPacket(); deletePacket.setUuid(serverBossBar); - deletePacket.setAction(BossBar.REMOVE); + deletePacket.setAction(BossBarPacket.REMOVE); player.getConnection().delayedWrite(deletePacket); } serverBossBars.clear(); diff --git a/proxy/src/main/java/com/velocitypowered/proxy/connection/client/ClientSettingsWrapper.java b/proxy/src/main/java/com/velocitypowered/proxy/connection/client/ClientSettingsWrapper.java index 61bed2730..ddcef5fff 100644 --- a/proxy/src/main/java/com/velocitypowered/proxy/connection/client/ClientSettingsWrapper.java +++ b/proxy/src/main/java/com/velocitypowered/proxy/connection/client/ClientSettingsWrapper.java @@ -19,7 +19,7 @@ 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.ClientSettings; +import com.velocitypowered.proxy.network.protocol.packet.ClientSettings; import java.util.Locale; import java.util.Objects; import org.checkerframework.checker.nullness.qual.Nullable; diff --git a/proxy/src/main/java/com/velocitypowered/proxy/connection/client/ConnectedPlayer.java b/proxy/src/main/java/com/velocitypowered/proxy/connection/client/ConnectedPlayer.java index 309c9cb2e..14888e54b 100644 --- a/proxy/src/main/java/com/velocitypowered/proxy/connection/client/ConnectedPlayer.java +++ b/proxy/src/main/java/com/velocitypowered/proxy/connection/client/ConnectedPlayer.java @@ -55,21 +55,21 @@ import com.velocitypowered.proxy.connection.player.VelocityResourcePackInfo; import com.velocitypowered.proxy.connection.util.ConnectionMessages; import com.velocitypowered.proxy.connection.util.ConnectionRequestResults.Impl; import com.velocitypowered.proxy.connection.util.VelocityInboundConnection; -import com.velocitypowered.proxy.protocol.ProtocolUtils; -import com.velocitypowered.proxy.protocol.StateRegistry; -import com.velocitypowered.proxy.protocol.netty.MinecraftEncoder; -import com.velocitypowered.proxy.protocol.packet.ClientSettings; -import com.velocitypowered.proxy.protocol.packet.Disconnect; -import com.velocitypowered.proxy.protocol.packet.HeaderAndFooter; -import com.velocitypowered.proxy.protocol.packet.KeepAlive; -import com.velocitypowered.proxy.protocol.packet.PluginMessage; -import com.velocitypowered.proxy.protocol.packet.ResourcePackRequest; -import com.velocitypowered.proxy.protocol.packet.chat.ChatQueue; -import com.velocitypowered.proxy.protocol.packet.chat.ChatType; -import com.velocitypowered.proxy.protocol.packet.chat.builder.ChatBuilderFactory; -import com.velocitypowered.proxy.protocol.packet.chat.legacy.LegacyChat; -import com.velocitypowered.proxy.protocol.packet.config.StartUpdate; -import com.velocitypowered.proxy.protocol.packet.title.GenericTitlePacket; +import com.velocitypowered.proxy.network.pipeline.deser.MinecraftEncoder; +import com.velocitypowered.proxy.network.protocol.ProtocolUtils; +import com.velocitypowered.proxy.network.protocol.StateRegistry; +import com.velocitypowered.proxy.network.protocol.packet.ClientSettings; +import com.velocitypowered.proxy.network.protocol.packet.Disconnect; +import com.velocitypowered.proxy.network.protocol.packet.HeaderAndFooter; +import com.velocitypowered.proxy.network.protocol.packet.KeepAlive; +import com.velocitypowered.proxy.network.protocol.packet.PluginMessage; +import com.velocitypowered.proxy.network.protocol.packet.ResourcePackRequest; +import com.velocitypowered.proxy.network.protocol.packet.chat.ChatQueue; +import com.velocitypowered.proxy.network.protocol.packet.chat.ChatType; +import com.velocitypowered.proxy.network.protocol.packet.chat.builder.ChatBuilderFactory; +import com.velocitypowered.proxy.network.protocol.packet.chat.legacy.LegacyChat; +import com.velocitypowered.proxy.network.protocol.packet.config.StartUpdate; +import com.velocitypowered.proxy.network.protocol.packet.title.GenericTitlePacket; import com.velocitypowered.proxy.server.VelocityRegisteredServer; import com.velocitypowered.proxy.tablist.InternalTabList; import com.velocitypowered.proxy.tablist.KeyedVelocityTabList; diff --git a/proxy/src/main/java/com/velocitypowered/proxy/connection/client/HandshakeSessionHandler.java b/proxy/src/main/java/com/velocitypowered/proxy/connection/client/HandshakeSessionHandler.java index 079ce035f..eb345f67f 100644 --- a/proxy/src/main/java/com/velocitypowered/proxy/connection/client/HandshakeSessionHandler.java +++ b/proxy/src/main/java/com/velocitypowered/proxy/connection/client/HandshakeSessionHandler.java @@ -29,12 +29,12 @@ import com.velocitypowered.proxy.connection.MinecraftConnection; import com.velocitypowered.proxy.connection.MinecraftSessionHandler; import com.velocitypowered.proxy.connection.forge.legacy.LegacyForgeConstants; import com.velocitypowered.proxy.connection.util.VelocityInboundConnection; -import com.velocitypowered.proxy.protocol.MinecraftPacket; -import com.velocitypowered.proxy.protocol.StateRegistry; -import com.velocitypowered.proxy.protocol.packet.Handshake; -import com.velocitypowered.proxy.protocol.packet.LegacyDisconnect; -import com.velocitypowered.proxy.protocol.packet.LegacyHandshake; -import com.velocitypowered.proxy.protocol.packet.LegacyPing; +import com.velocitypowered.proxy.network.protocol.MinecraftPacket; +import com.velocitypowered.proxy.network.protocol.StateRegistry; +import com.velocitypowered.proxy.network.protocol.packet.Handshake; +import com.velocitypowered.proxy.network.protocol.packet.LegacyDisconnect; +import com.velocitypowered.proxy.network.protocol.packet.LegacyHandshake; +import com.velocitypowered.proxy.network.protocol.packet.LegacyPing; import io.netty.buffer.ByteBuf; import java.net.InetAddress; import java.net.InetSocketAddress; diff --git a/proxy/src/main/java/com/velocitypowered/proxy/connection/client/InitialConnectSessionHandler.java b/proxy/src/main/java/com/velocitypowered/proxy/connection/client/InitialConnectSessionHandler.java index f264d262e..22dd2e56c 100644 --- a/proxy/src/main/java/com/velocitypowered/proxy/connection/client/InitialConnectSessionHandler.java +++ b/proxy/src/main/java/com/velocitypowered/proxy/connection/client/InitialConnectSessionHandler.java @@ -23,7 +23,7 @@ import com.velocitypowered.proxy.VelocityServer; 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.PluginMessage; +import com.velocitypowered.proxy.network.protocol.packet.PluginMessage; import io.netty.buffer.ByteBufUtil; import io.netty.buffer.Unpooled; import org.apache.logging.log4j.LogManager; diff --git a/proxy/src/main/java/com/velocitypowered/proxy/connection/client/InitialInboundConnection.java b/proxy/src/main/java/com/velocitypowered/proxy/connection/client/InitialInboundConnection.java index ecb1cc428..7b79a731a 100644 --- a/proxy/src/main/java/com/velocitypowered/proxy/connection/client/InitialInboundConnection.java +++ b/proxy/src/main/java/com/velocitypowered/proxy/connection/client/InitialInboundConnection.java @@ -22,8 +22,8 @@ import com.velocitypowered.api.proxy.InboundConnection; import com.velocitypowered.proxy.connection.MinecraftConnection; import com.velocitypowered.proxy.connection.MinecraftConnectionAssociation; import com.velocitypowered.proxy.connection.util.VelocityInboundConnection; -import com.velocitypowered.proxy.protocol.packet.Disconnect; -import com.velocitypowered.proxy.protocol.packet.Handshake; +import com.velocitypowered.proxy.network.protocol.packet.Disconnect; +import com.velocitypowered.proxy.network.protocol.packet.Handshake; import com.velocitypowered.proxy.util.ClosestLocaleMatcher; import java.net.InetSocketAddress; import java.util.Locale; diff --git a/proxy/src/main/java/com/velocitypowered/proxy/connection/client/InitialLoginSessionHandler.java b/proxy/src/main/java/com/velocitypowered/proxy/connection/client/InitialLoginSessionHandler.java index 1409dc4ba..032f01ffb 100644 --- a/proxy/src/main/java/com/velocitypowered/proxy/connection/client/InitialLoginSessionHandler.java +++ b/proxy/src/main/java/com/velocitypowered/proxy/connection/client/InitialLoginSessionHandler.java @@ -34,12 +34,12 @@ import com.velocitypowered.proxy.VelocityServer; import com.velocitypowered.proxy.connection.MinecraftConnection; import com.velocitypowered.proxy.connection.MinecraftSessionHandler; import com.velocitypowered.proxy.crypto.IdentifiedKeyImpl; -import com.velocitypowered.proxy.protocol.StateRegistry; -import com.velocitypowered.proxy.protocol.netty.MinecraftDecoder; -import com.velocitypowered.proxy.protocol.packet.EncryptionRequest; -import com.velocitypowered.proxy.protocol.packet.EncryptionResponse; -import com.velocitypowered.proxy.protocol.packet.LoginPluginResponse; -import com.velocitypowered.proxy.protocol.packet.ServerLogin; +import com.velocitypowered.proxy.network.pipeline.deser.MinecraftDecoder; +import com.velocitypowered.proxy.network.protocol.StateRegistry; +import com.velocitypowered.proxy.network.protocol.packet.EncryptionRequest; +import com.velocitypowered.proxy.network.protocol.packet.EncryptionResponse; +import com.velocitypowered.proxy.network.protocol.packet.LoginPluginResponse; +import com.velocitypowered.proxy.network.protocol.packet.ServerLogin; import io.netty.buffer.ByteBuf; import java.net.InetSocketAddress; import java.security.GeneralSecurityException; diff --git a/proxy/src/main/java/com/velocitypowered/proxy/connection/client/LoginInboundConnection.java b/proxy/src/main/java/com/velocitypowered/proxy/connection/client/LoginInboundConnection.java index 7a90268fa..92a3a4c3f 100644 --- a/proxy/src/main/java/com/velocitypowered/proxy/connection/client/LoginInboundConnection.java +++ b/proxy/src/main/java/com/velocitypowered/proxy/connection/client/LoginInboundConnection.java @@ -23,8 +23,8 @@ import com.velocitypowered.api.proxy.crypto.IdentifiedKey; import com.velocitypowered.api.proxy.crypto.KeyIdentifiable; import com.velocitypowered.api.proxy.messages.ChannelIdentifier; import com.velocitypowered.proxy.connection.MinecraftConnection; -import com.velocitypowered.proxy.protocol.packet.LoginPluginMessage; -import com.velocitypowered.proxy.protocol.packet.LoginPluginResponse; +import com.velocitypowered.proxy.network.protocol.packet.LoginPluginMessage; +import com.velocitypowered.proxy.network.protocol.packet.LoginPluginResponse; import io.netty.buffer.ByteBufUtil; import io.netty.buffer.Unpooled; import it.unimi.dsi.fastutil.ints.Int2ObjectMap; diff --git a/proxy/src/main/java/com/velocitypowered/proxy/connection/client/StatusSessionHandler.java b/proxy/src/main/java/com/velocitypowered/proxy/connection/client/StatusSessionHandler.java index f1e96df7b..654eb15d6 100644 --- a/proxy/src/main/java/com/velocitypowered/proxy/connection/client/StatusSessionHandler.java +++ b/proxy/src/main/java/com/velocitypowered/proxy/connection/client/StatusSessionHandler.java @@ -21,10 +21,10 @@ import com.velocitypowered.proxy.VelocityServer; import com.velocitypowered.proxy.connection.MinecraftConnection; import com.velocitypowered.proxy.connection.MinecraftSessionHandler; import com.velocitypowered.proxy.connection.util.VelocityInboundConnection; -import com.velocitypowered.proxy.protocol.packet.LegacyDisconnect; -import com.velocitypowered.proxy.protocol.packet.LegacyPing; -import com.velocitypowered.proxy.protocol.packet.StatusPing; -import com.velocitypowered.proxy.protocol.packet.StatusRequest; +import com.velocitypowered.proxy.network.protocol.packet.LegacyDisconnect; +import com.velocitypowered.proxy.network.protocol.packet.LegacyPing; +import com.velocitypowered.proxy.network.protocol.packet.StatusPing; +import com.velocitypowered.proxy.network.protocol.packet.StatusRequest; import com.velocitypowered.proxy.util.except.QuietRuntimeException; import io.netty.buffer.ByteBuf; import org.apache.logging.log4j.LogManager; diff --git a/proxy/src/main/java/com/velocitypowered/proxy/connection/forge/legacy/LegacyForgeHandshakeBackendPhase.java b/proxy/src/main/java/com/velocitypowered/proxy/connection/forge/legacy/LegacyForgeHandshakeBackendPhase.java index e4f1b3c24..07a977df5 100644 --- a/proxy/src/main/java/com/velocitypowered/proxy/connection/forge/legacy/LegacyForgeHandshakeBackendPhase.java +++ b/proxy/src/main/java/com/velocitypowered/proxy/connection/forge/legacy/LegacyForgeHandshakeBackendPhase.java @@ -23,7 +23,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.PluginMessage; +import com.velocitypowered.proxy.network.protocol.packet.PluginMessage; import javax.annotation.Nullable; /** diff --git a/proxy/src/main/java/com/velocitypowered/proxy/connection/forge/legacy/LegacyForgeHandshakeClientPhase.java b/proxy/src/main/java/com/velocitypowered/proxy/connection/forge/legacy/LegacyForgeHandshakeClientPhase.java index 19b09c122..3d8eb2420 100644 --- a/proxy/src/main/java/com/velocitypowered/proxy/connection/forge/legacy/LegacyForgeHandshakeClientPhase.java +++ b/proxy/src/main/java/com/velocitypowered/proxy/connection/forge/legacy/LegacyForgeHandshakeClientPhase.java @@ -24,7 +24,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.PluginMessage; +import com.velocitypowered.proxy.network.protocol.packet.PluginMessage; import java.util.List; import javax.annotation.Nullable; diff --git a/proxy/src/main/java/com/velocitypowered/proxy/connection/forge/legacy/LegacyForgeUtil.java b/proxy/src/main/java/com/velocitypowered/proxy/connection/forge/legacy/LegacyForgeUtil.java index 502c829db..7dcc06e6a 100644 --- a/proxy/src/main/java/com/velocitypowered/proxy/connection/forge/legacy/LegacyForgeUtil.java +++ b/proxy/src/main/java/com/velocitypowered/proxy/connection/forge/legacy/LegacyForgeUtil.java @@ -24,8 +24,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.PluginMessage; +import com.velocitypowered.proxy.network.protocol.ProtocolUtils; +import com.velocitypowered.proxy.network.protocol.packet.PluginMessage; import io.netty.buffer.ByteBuf; import io.netty.buffer.Unpooled; import java.util.List; diff --git a/proxy/src/main/java/com/velocitypowered/proxy/connection/registry/ClientConfigData.java b/proxy/src/main/java/com/velocitypowered/proxy/connection/registry/ClientConfigData.java index 1bca74515..84ed2a5bb 100644 --- a/proxy/src/main/java/com/velocitypowered/proxy/connection/registry/ClientConfigData.java +++ b/proxy/src/main/java/com/velocitypowered/proxy/connection/registry/ClientConfigData.java @@ -18,7 +18,7 @@ package com.velocitypowered.proxy.connection.registry; import com.velocitypowered.proxy.connection.player.VelocityResourcePackInfo; -import com.velocitypowered.proxy.protocol.packet.config.RegistrySync; +import com.velocitypowered.proxy.network.protocol.packet.config.RegistrySync; import net.kyori.adventure.key.Key; import org.jetbrains.annotations.Nullable; diff --git a/proxy/src/main/java/com/velocitypowered/proxy/connection/util/ConnectionRequestResults.java b/proxy/src/main/java/com/velocitypowered/proxy/connection/util/ConnectionRequestResults.java index 7ef1601e1..5d668f294 100644 --- a/proxy/src/main/java/com/velocitypowered/proxy/connection/util/ConnectionRequestResults.java +++ b/proxy/src/main/java/com/velocitypowered/proxy/connection/util/ConnectionRequestResults.java @@ -20,7 +20,7 @@ package com.velocitypowered.proxy.connection.util; import com.velocitypowered.api.proxy.ConnectionRequestBuilder; import com.velocitypowered.api.proxy.ConnectionRequestBuilder.Status; import com.velocitypowered.api.proxy.server.RegisteredServer; -import com.velocitypowered.proxy.protocol.packet.Disconnect; +import com.velocitypowered.proxy.network.protocol.packet.Disconnect; import java.util.Optional; import javax.annotation.Nullable; import net.kyori.adventure.text.Component; diff --git a/proxy/src/main/java/com/velocitypowered/proxy/connection/util/ServerListPingHandler.java b/proxy/src/main/java/com/velocitypowered/proxy/connection/util/ServerListPingHandler.java index d168d2ee2..81d9edcfd 100644 --- a/proxy/src/main/java/com/velocitypowered/proxy/connection/util/ServerListPingHandler.java +++ b/proxy/src/main/java/com/velocitypowered/proxy/connection/util/ServerListPingHandler.java @@ -28,7 +28,7 @@ import com.velocitypowered.api.util.ModInfo; import com.velocitypowered.proxy.VelocityServer; import com.velocitypowered.proxy.config.PingPassthroughMode; import com.velocitypowered.proxy.config.VelocityConfiguration; -import com.velocitypowered.proxy.protocol.packet.StatusResponse; +import com.velocitypowered.proxy.network.protocol.packet.StatusResponse; import com.velocitypowered.proxy.server.VelocityRegisteredServer; import java.net.InetSocketAddress; import java.util.ArrayList; diff --git a/proxy/src/main/java/com/velocitypowered/proxy/network/ConnectionManager.java b/proxy/src/main/java/com/velocitypowered/proxy/network/ConnectionManager.java index f7c8cea59..b770ea5de 100644 --- a/proxy/src/main/java/com/velocitypowered/proxy/network/ConnectionManager.java +++ b/proxy/src/main/java/com/velocitypowered/proxy/network/ConnectionManager.java @@ -26,8 +26,13 @@ import com.velocitypowered.api.event.proxy.ListenerCloseEvent; import com.velocitypowered.api.network.ListenerType; import com.velocitypowered.natives.util.Natives; import com.velocitypowered.proxy.VelocityServer; -import com.velocitypowered.proxy.network.netty.SeparatePoolInetNameResolver; -import com.velocitypowered.proxy.protocol.netty.GameSpyQueryHandler; +import com.velocitypowered.proxy.network.pipeline.initializers.BackendChannelInitializer; +import com.velocitypowered.proxy.network.pipeline.initializers.BackendChannelInitializerHolder; +import com.velocitypowered.proxy.network.pipeline.initializers.ServerChannelInitializer; +import com.velocitypowered.proxy.network.pipeline.initializers.ServerChannelInitializerHolder; +import com.velocitypowered.proxy.network.pipeline.query.GameSpyQueryHandler; +import com.velocitypowered.proxy.network.util.SeparatePoolInetNameResolver; +import com.velocitypowered.proxy.network.util.TransportType; import io.netty.bootstrap.Bootstrap; import io.netty.bootstrap.ServerBootstrap; import io.netty.channel.Channel; @@ -154,7 +159,7 @@ public final class ConnectionManager { public void queryBind(final String hostname, final int port) { InetSocketAddress address = new InetSocketAddress(hostname, port); final Bootstrap bootstrap = new Bootstrap() - .channelFactory(this.transportType.datagramChannelFactory) + .channelFactory(this.transportType.getDatagramChannelFactory()) .group(this.workerGroup) .handler(new GameSpyQueryHandler(this.server)) .localAddress(address); @@ -177,7 +182,7 @@ public final class ConnectionManager { /** * Creates a {@link Bootstrap} using Velocity's event loops. * - * @param group the event loop group to use. Use {@code null} for the default worker group. + * @param group the event loop group to use. Use {@code null} for the default worker group. * @param target the address the client will connect to * @return a new {@link Bootstrap} */ diff --git a/proxy/src/main/java/com/velocitypowered/proxy/protocol/netty/MinecraftCompressDecoder.java b/proxy/src/main/java/com/velocitypowered/proxy/network/pipeline/compression/MinecraftCompressDecoder.java similarity index 93% rename from proxy/src/main/java/com/velocitypowered/proxy/protocol/netty/MinecraftCompressDecoder.java rename to proxy/src/main/java/com/velocitypowered/proxy/network/pipeline/compression/MinecraftCompressDecoder.java index 6e7fb4d4e..d62dc9486 100644 --- a/proxy/src/main/java/com/velocitypowered/proxy/protocol/netty/MinecraftCompressDecoder.java +++ b/proxy/src/main/java/com/velocitypowered/proxy/network/pipeline/compression/MinecraftCompressDecoder.java @@ -15,14 +15,14 @@ * along with this program. If not, see . */ -package com.velocitypowered.proxy.protocol.netty; +package com.velocitypowered.proxy.network.pipeline.compression; 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.protocol.util.NettyPreconditions.checkFrame; import com.velocitypowered.natives.compression.VelocityCompressor; -import com.velocitypowered.proxy.protocol.ProtocolUtils; +import com.velocitypowered.proxy.network.protocol.ProtocolUtils; import io.netty.buffer.ByteBuf; import io.netty.channel.ChannelHandlerContext; import io.netty.handler.codec.MessageToMessageDecoder; diff --git a/proxy/src/main/java/com/velocitypowered/proxy/protocol/netty/MinecraftCompressorAndLengthEncoder.java b/proxy/src/main/java/com/velocitypowered/proxy/network/pipeline/compression/MinecraftCompressorAndLengthEncoder.java similarity index 93% rename from proxy/src/main/java/com/velocitypowered/proxy/protocol/netty/MinecraftCompressorAndLengthEncoder.java rename to proxy/src/main/java/com/velocitypowered/proxy/network/pipeline/compression/MinecraftCompressorAndLengthEncoder.java index 90952a729..432fdab57 100644 --- a/proxy/src/main/java/com/velocitypowered/proxy/protocol/netty/MinecraftCompressorAndLengthEncoder.java +++ b/proxy/src/main/java/com/velocitypowered/proxy/network/pipeline/compression/MinecraftCompressorAndLengthEncoder.java @@ -15,13 +15,13 @@ * along with this program. If not, see . */ -package com.velocitypowered.proxy.protocol.netty; +package com.velocitypowered.proxy.network.pipeline.compression; -import static com.velocitypowered.proxy.protocol.netty.MinecraftVarintLengthEncoder.IS_JAVA_CIPHER; +import static com.velocitypowered.proxy.network.pipeline.framing.MinecraftVarintLengthEncoder.IS_JAVA_CIPHER; import com.velocitypowered.natives.compression.VelocityCompressor; import com.velocitypowered.natives.util.MoreByteBufUtils; -import com.velocitypowered.proxy.protocol.ProtocolUtils; +import com.velocitypowered.proxy.network.protocol.ProtocolUtils; import io.netty.buffer.ByteBuf; import io.netty.channel.ChannelHandlerContext; import io.netty.handler.codec.MessageToByteEncoder; diff --git a/proxy/src/main/java/com/velocitypowered/proxy/protocol/netty/LegacyPingDecoder.java b/proxy/src/main/java/com/velocitypowered/proxy/network/pipeline/deser/LegacyPingDecoder.java similarity index 88% rename from proxy/src/main/java/com/velocitypowered/proxy/protocol/netty/LegacyPingDecoder.java rename to proxy/src/main/java/com/velocitypowered/proxy/network/pipeline/deser/LegacyPingDecoder.java index ada637368..982f915cf 100644 --- a/proxy/src/main/java/com/velocitypowered/proxy/protocol/netty/LegacyPingDecoder.java +++ b/proxy/src/main/java/com/velocitypowered/proxy/network/pipeline/deser/LegacyPingDecoder.java @@ -15,13 +15,13 @@ * along with this program. If not, see . */ -package com.velocitypowered.proxy.protocol.netty; +package com.velocitypowered.proxy.network.pipeline.deser; -import static com.velocitypowered.proxy.protocol.util.NettyPreconditions.checkFrame; +import static com.velocitypowered.proxy.network.protocol.util.NettyPreconditions.checkFrame; -import com.velocitypowered.proxy.protocol.packet.LegacyHandshake; -import com.velocitypowered.proxy.protocol.packet.LegacyPing; -import com.velocitypowered.proxy.protocol.packet.legacyping.LegacyMinecraftPingVersion; +import com.velocitypowered.proxy.network.protocol.packet.LegacyHandshake; +import com.velocitypowered.proxy.network.protocol.packet.LegacyPing; +import com.velocitypowered.proxy.network.protocol.packet.legacyping.LegacyMinecraftPingVersion; import io.netty.buffer.ByteBuf; import io.netty.channel.ChannelHandlerContext; import io.netty.handler.codec.ByteToMessageDecoder; diff --git a/proxy/src/main/java/com/velocitypowered/proxy/protocol/netty/LegacyPingEncoder.java b/proxy/src/main/java/com/velocitypowered/proxy/network/pipeline/deser/LegacyPingEncoder.java similarity index 92% rename from proxy/src/main/java/com/velocitypowered/proxy/protocol/netty/LegacyPingEncoder.java rename to proxy/src/main/java/com/velocitypowered/proxy/network/pipeline/deser/LegacyPingEncoder.java index ad06fa5a2..9adfbcd99 100644 --- a/proxy/src/main/java/com/velocitypowered/proxy/protocol/netty/LegacyPingEncoder.java +++ b/proxy/src/main/java/com/velocitypowered/proxy/network/pipeline/deser/LegacyPingEncoder.java @@ -15,9 +15,9 @@ * along with this program. If not, see . */ -package com.velocitypowered.proxy.protocol.netty; +package com.velocitypowered.proxy.network.pipeline.deser; -import com.velocitypowered.proxy.protocol.packet.LegacyDisconnect; +import com.velocitypowered.proxy.network.protocol.packet.LegacyDisconnect; import io.netty.buffer.ByteBuf; import io.netty.channel.ChannelHandler; import io.netty.channel.ChannelHandlerContext; diff --git a/proxy/src/main/java/com/velocitypowered/proxy/protocol/netty/MinecraftDecoder.java b/proxy/src/main/java/com/velocitypowered/proxy/network/pipeline/deser/MinecraftDecoder.java similarity index 95% rename from proxy/src/main/java/com/velocitypowered/proxy/protocol/netty/MinecraftDecoder.java rename to proxy/src/main/java/com/velocitypowered/proxy/network/pipeline/deser/MinecraftDecoder.java index f8362cc09..d2233eedf 100644 --- a/proxy/src/main/java/com/velocitypowered/proxy/protocol/netty/MinecraftDecoder.java +++ b/proxy/src/main/java/com/velocitypowered/proxy/network/pipeline/deser/MinecraftDecoder.java @@ -15,13 +15,13 @@ * along with this program. If not, see . */ -package com.velocitypowered.proxy.protocol.netty; +package com.velocitypowered.proxy.network.pipeline.deser; import com.google.common.base.Preconditions; import com.velocitypowered.api.network.ProtocolVersion; -import com.velocitypowered.proxy.protocol.MinecraftPacket; -import com.velocitypowered.proxy.protocol.ProtocolUtils; -import com.velocitypowered.proxy.protocol.StateRegistry; +import com.velocitypowered.proxy.network.protocol.MinecraftPacket; +import com.velocitypowered.proxy.network.protocol.ProtocolUtils; +import com.velocitypowered.proxy.network.protocol.StateRegistry; import com.velocitypowered.proxy.util.except.QuietRuntimeException; import io.netty.buffer.ByteBuf; import io.netty.channel.ChannelHandlerContext; diff --git a/proxy/src/main/java/com/velocitypowered/proxy/protocol/netty/MinecraftEncoder.java b/proxy/src/main/java/com/velocitypowered/proxy/network/pipeline/deser/MinecraftEncoder.java similarity index 89% rename from proxy/src/main/java/com/velocitypowered/proxy/protocol/netty/MinecraftEncoder.java rename to proxy/src/main/java/com/velocitypowered/proxy/network/pipeline/deser/MinecraftEncoder.java index 7133f1d26..ecbdb9df6 100644 --- a/proxy/src/main/java/com/velocitypowered/proxy/protocol/netty/MinecraftEncoder.java +++ b/proxy/src/main/java/com/velocitypowered/proxy/network/pipeline/deser/MinecraftEncoder.java @@ -15,13 +15,13 @@ * along with this program. If not, see . */ -package com.velocitypowered.proxy.protocol.netty; +package com.velocitypowered.proxy.network.pipeline.deser; import com.google.common.base.Preconditions; import com.velocitypowered.api.network.ProtocolVersion; -import com.velocitypowered.proxy.protocol.MinecraftPacket; -import com.velocitypowered.proxy.protocol.ProtocolUtils; -import com.velocitypowered.proxy.protocol.StateRegistry; +import com.velocitypowered.proxy.network.protocol.MinecraftPacket; +import com.velocitypowered.proxy.network.protocol.ProtocolUtils; +import com.velocitypowered.proxy.network.protocol.StateRegistry; import io.netty.buffer.ByteBuf; import io.netty.channel.ChannelHandlerContext; import io.netty.handler.codec.MessageToByteEncoder; diff --git a/proxy/src/main/java/com/velocitypowered/proxy/protocol/netty/MinecraftCipherDecoder.java b/proxy/src/main/java/com/velocitypowered/proxy/network/pipeline/encryption/MinecraftCipherDecoder.java similarity index 96% rename from proxy/src/main/java/com/velocitypowered/proxy/protocol/netty/MinecraftCipherDecoder.java rename to proxy/src/main/java/com/velocitypowered/proxy/network/pipeline/encryption/MinecraftCipherDecoder.java index 229b8a8de..aaa1fc4e6 100644 --- a/proxy/src/main/java/com/velocitypowered/proxy/protocol/netty/MinecraftCipherDecoder.java +++ b/proxy/src/main/java/com/velocitypowered/proxy/network/pipeline/encryption/MinecraftCipherDecoder.java @@ -15,7 +15,7 @@ * along with this program. If not, see . */ -package com.velocitypowered.proxy.protocol.netty; +package com.velocitypowered.proxy.network.pipeline.encryption; import com.google.common.base.Preconditions; import com.velocitypowered.natives.encryption.VelocityCipher; diff --git a/proxy/src/main/java/com/velocitypowered/proxy/protocol/netty/MinecraftCipherEncoder.java b/proxy/src/main/java/com/velocitypowered/proxy/network/pipeline/encryption/MinecraftCipherEncoder.java similarity index 96% rename from proxy/src/main/java/com/velocitypowered/proxy/protocol/netty/MinecraftCipherEncoder.java rename to proxy/src/main/java/com/velocitypowered/proxy/network/pipeline/encryption/MinecraftCipherEncoder.java index b7adc12d9..e9270a5e7 100644 --- a/proxy/src/main/java/com/velocitypowered/proxy/protocol/netty/MinecraftCipherEncoder.java +++ b/proxy/src/main/java/com/velocitypowered/proxy/network/pipeline/encryption/MinecraftCipherEncoder.java @@ -15,7 +15,7 @@ * along with this program. If not, see . */ -package com.velocitypowered.proxy.protocol.netty; +package com.velocitypowered.proxy.network.pipeline.encryption; import com.google.common.base.Preconditions; import com.velocitypowered.natives.encryption.VelocityCipher; diff --git a/proxy/src/main/java/com/velocitypowered/proxy/protocol/netty/MinecraftVarintFrameDecoder.java b/proxy/src/main/java/com/velocitypowered/proxy/network/pipeline/framing/MinecraftVarintFrameDecoder.java similarity index 95% rename from proxy/src/main/java/com/velocitypowered/proxy/protocol/netty/MinecraftVarintFrameDecoder.java rename to proxy/src/main/java/com/velocitypowered/proxy/network/pipeline/framing/MinecraftVarintFrameDecoder.java index 94baa2ffe..f70874111 100644 --- a/proxy/src/main/java/com/velocitypowered/proxy/protocol/netty/MinecraftVarintFrameDecoder.java +++ b/proxy/src/main/java/com/velocitypowered/proxy/network/pipeline/framing/MinecraftVarintFrameDecoder.java @@ -15,9 +15,9 @@ * along with this program. If not, see . */ -package com.velocitypowered.proxy.protocol.netty; +package com.velocitypowered.proxy.network.pipeline.framing; -import com.velocitypowered.proxy.protocol.netty.VarintByteDecoder.DecodeResult; +import com.velocitypowered.proxy.network.pipeline.framing.VarintByteDecoder.DecodeResult; import com.velocitypowered.proxy.util.except.QuietDecoderException; import io.netty.buffer.ByteBuf; import io.netty.channel.ChannelHandlerContext; diff --git a/proxy/src/main/java/com/velocitypowered/proxy/protocol/netty/MinecraftVarintLengthEncoder.java b/proxy/src/main/java/com/velocitypowered/proxy/network/pipeline/framing/MinecraftVarintLengthEncoder.java similarity index 94% rename from proxy/src/main/java/com/velocitypowered/proxy/protocol/netty/MinecraftVarintLengthEncoder.java rename to proxy/src/main/java/com/velocitypowered/proxy/network/pipeline/framing/MinecraftVarintLengthEncoder.java index ecbcc8b84..9c2ec357b 100644 --- a/proxy/src/main/java/com/velocitypowered/proxy/protocol/netty/MinecraftVarintLengthEncoder.java +++ b/proxy/src/main/java/com/velocitypowered/proxy/network/pipeline/framing/MinecraftVarintLengthEncoder.java @@ -15,11 +15,11 @@ * along with this program. If not, see . */ -package com.velocitypowered.proxy.protocol.netty; +package com.velocitypowered.proxy.network.pipeline.framing; import com.velocitypowered.natives.encryption.JavaVelocityCipher; import com.velocitypowered.natives.util.Natives; -import com.velocitypowered.proxy.protocol.ProtocolUtils; +import com.velocitypowered.proxy.network.protocol.ProtocolUtils; import io.netty.buffer.ByteBuf; import io.netty.channel.ChannelHandler; import io.netty.channel.ChannelHandlerContext; diff --git a/proxy/src/main/java/com/velocitypowered/proxy/protocol/netty/VarintByteDecoder.java b/proxy/src/main/java/com/velocitypowered/proxy/network/pipeline/framing/VarintByteDecoder.java similarity index 96% rename from proxy/src/main/java/com/velocitypowered/proxy/protocol/netty/VarintByteDecoder.java rename to proxy/src/main/java/com/velocitypowered/proxy/network/pipeline/framing/VarintByteDecoder.java index 06cec7350..2dc0db767 100644 --- a/proxy/src/main/java/com/velocitypowered/proxy/protocol/netty/VarintByteDecoder.java +++ b/proxy/src/main/java/com/velocitypowered/proxy/network/pipeline/framing/VarintByteDecoder.java @@ -15,7 +15,7 @@ * along with this program. If not, see . */ -package com.velocitypowered.proxy.protocol.netty; +package com.velocitypowered.proxy.network.pipeline.framing; import io.netty.util.ByteProcessor; diff --git a/proxy/src/main/java/com/velocitypowered/proxy/network/BackendChannelInitializer.java b/proxy/src/main/java/com/velocitypowered/proxy/network/pipeline/initializers/BackendChannelInitializer.java similarity index 65% rename from proxy/src/main/java/com/velocitypowered/proxy/network/BackendChannelInitializer.java rename to proxy/src/main/java/com/velocitypowered/proxy/network/pipeline/initializers/BackendChannelInitializer.java index 1e6f387b3..508c9d6b2 100644 --- a/proxy/src/main/java/com/velocitypowered/proxy/network/BackendChannelInitializer.java +++ b/proxy/src/main/java/com/velocitypowered/proxy/network/pipeline/initializers/BackendChannelInitializer.java @@ -15,7 +15,7 @@ * along with this program. If not, see . */ -package com.velocitypowered.proxy.network; +package com.velocitypowered.proxy.network.pipeline.initializers; import static com.velocitypowered.proxy.network.Connections.FLOW_HANDLER; import static com.velocitypowered.proxy.network.Connections.FRAME_DECODER; @@ -25,12 +25,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.ProtocolUtils; -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.pipeline.deser.MinecraftDecoder; +import com.velocitypowered.proxy.network.pipeline.deser.MinecraftEncoder; +import com.velocitypowered.proxy.network.pipeline.framing.MinecraftVarintFrameDecoder; +import com.velocitypowered.proxy.network.pipeline.framing.MinecraftVarintLengthEncoder; +import com.velocitypowered.proxy.network.pipeline.util.AutoReadHolderHandler; +import com.velocitypowered.proxy.network.protocol.ProtocolUtils; import io.netty.channel.Channel; import io.netty.channel.ChannelInitializer; import io.netty.handler.timeout.ReadTimeoutHandler; @@ -42,20 +42,25 @@ import java.util.concurrent.TimeUnit; @SuppressWarnings("WeakerAccess") public class BackendChannelInitializer extends ChannelInitializer { - private final VelocityServer server; + private final long readTimeoutMs; public BackendChannelInitializer(VelocityServer server) { - this.server = server; + this(server.getConfiguration().getReadTimeout()); + } + + public BackendChannelInitializer(long readTimeoutMs) { + this.readTimeoutMs = readTimeoutMs; } @Override protected void initChannel(Channel ch) throws Exception { - ch.pipeline() - .addLast(FRAME_DECODER, new MinecraftVarintFrameDecoder()) - .addLast(READ_TIMEOUT, - new ReadTimeoutHandler(server.getConfiguration().getReadTimeout(), - TimeUnit.MILLISECONDS)) - .addLast(FRAME_ENCODER, MinecraftVarintLengthEncoder.INSTANCE) + ch.pipeline().addLast(FRAME_DECODER, new MinecraftVarintFrameDecoder()); + if (this.readTimeoutMs > 0) { + ch.pipeline().addLast(READ_TIMEOUT, new ReadTimeoutHandler( + this.readTimeoutMs, TimeUnit.MILLISECONDS)); + } + + ch.pipeline().addLast(FRAME_ENCODER, MinecraftVarintLengthEncoder.INSTANCE) .addLast(MINECRAFT_DECODER, new MinecraftDecoder(ProtocolUtils.Direction.CLIENTBOUND)) .addLast(FLOW_HANDLER, new AutoReadHolderHandler()) diff --git a/proxy/src/main/java/com/velocitypowered/proxy/network/BackendChannelInitializerHolder.java b/proxy/src/main/java/com/velocitypowered/proxy/network/pipeline/initializers/BackendChannelInitializerHolder.java similarity index 88% rename from proxy/src/main/java/com/velocitypowered/proxy/network/BackendChannelInitializerHolder.java rename to proxy/src/main/java/com/velocitypowered/proxy/network/pipeline/initializers/BackendChannelInitializerHolder.java index fbe9123f3..d69d638ad 100644 --- a/proxy/src/main/java/com/velocitypowered/proxy/network/BackendChannelInitializerHolder.java +++ b/proxy/src/main/java/com/velocitypowered/proxy/network/pipeline/initializers/BackendChannelInitializerHolder.java @@ -15,8 +15,9 @@ * along with this program. If not, see . */ -package com.velocitypowered.proxy.network; +package com.velocitypowered.proxy.network.pipeline.initializers; +import com.velocitypowered.proxy.network.ConnectionManager; import io.netty.channel.Channel; import io.netty.channel.ChannelInitializer; import java.util.function.Supplier; @@ -31,7 +32,7 @@ public class BackendChannelInitializerHolder implements Supplier initializer; - BackendChannelInitializerHolder(final ChannelInitializer initializer) { + public BackendChannelInitializerHolder(final ChannelInitializer initializer) { this.initializer = initializer; } diff --git a/proxy/src/main/java/com/velocitypowered/proxy/network/ServerChannelInitializer.java b/proxy/src/main/java/com/velocitypowered/proxy/network/pipeline/initializers/ServerChannelInitializer.java similarity index 80% rename from proxy/src/main/java/com/velocitypowered/proxy/network/ServerChannelInitializer.java rename to proxy/src/main/java/com/velocitypowered/proxy/network/pipeline/initializers/ServerChannelInitializer.java index ef8e6b1cb..2132f5967 100644 --- a/proxy/src/main/java/com/velocitypowered/proxy/network/ServerChannelInitializer.java +++ b/proxy/src/main/java/com/velocitypowered/proxy/network/pipeline/initializers/ServerChannelInitializer.java @@ -15,7 +15,7 @@ * along with this program. If not, see . */ -package com.velocitypowered.proxy.network; +package com.velocitypowered.proxy.network.pipeline.initializers; import static com.velocitypowered.proxy.network.Connections.FRAME_DECODER; import static com.velocitypowered.proxy.network.Connections.FRAME_ENCODER; @@ -28,14 +28,15 @@ 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.ProtocolUtils; -import com.velocitypowered.proxy.protocol.StateRegistry; -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.Connections; +import com.velocitypowered.proxy.network.pipeline.deser.LegacyPingDecoder; +import com.velocitypowered.proxy.network.pipeline.deser.LegacyPingEncoder; +import com.velocitypowered.proxy.network.pipeline.deser.MinecraftDecoder; +import com.velocitypowered.proxy.network.pipeline.deser.MinecraftEncoder; +import com.velocitypowered.proxy.network.pipeline.framing.MinecraftVarintFrameDecoder; +import com.velocitypowered.proxy.network.pipeline.framing.MinecraftVarintLengthEncoder; +import com.velocitypowered.proxy.network.protocol.ProtocolUtils; +import com.velocitypowered.proxy.network.protocol.StateRegistry; import io.netty.channel.Channel; import io.netty.channel.ChannelInitializer; import io.netty.handler.codec.haproxy.HAProxyMessageDecoder; diff --git a/proxy/src/main/java/com/velocitypowered/proxy/network/ServerChannelInitializerHolder.java b/proxy/src/main/java/com/velocitypowered/proxy/network/pipeline/initializers/ServerChannelInitializerHolder.java similarity index 88% rename from proxy/src/main/java/com/velocitypowered/proxy/network/ServerChannelInitializerHolder.java rename to proxy/src/main/java/com/velocitypowered/proxy/network/pipeline/initializers/ServerChannelInitializerHolder.java index 6ea2439ea..c48f2e459 100644 --- a/proxy/src/main/java/com/velocitypowered/proxy/network/ServerChannelInitializerHolder.java +++ b/proxy/src/main/java/com/velocitypowered/proxy/network/pipeline/initializers/ServerChannelInitializerHolder.java @@ -15,8 +15,9 @@ * along with this program. If not, see . */ -package com.velocitypowered.proxy.network; +package com.velocitypowered.proxy.network.pipeline.initializers; +import com.velocitypowered.proxy.network.ConnectionManager; import io.netty.channel.Channel; import io.netty.channel.ChannelInitializer; import java.util.function.Supplier; @@ -31,7 +32,7 @@ public class ServerChannelInitializerHolder implements Supplier initializer; - ServerChannelInitializerHolder(final ChannelInitializer initializer) { + public ServerChannelInitializerHolder(final ChannelInitializer initializer) { this.initializer = initializer; } diff --git a/proxy/src/main/java/com/velocitypowered/proxy/protocol/netty/GameSpyQueryHandler.java b/proxy/src/main/java/com/velocitypowered/proxy/network/pipeline/query/GameSpyQueryHandler.java similarity index 99% rename from proxy/src/main/java/com/velocitypowered/proxy/protocol/netty/GameSpyQueryHandler.java rename to proxy/src/main/java/com/velocitypowered/proxy/network/pipeline/query/GameSpyQueryHandler.java index 721c3b062..13ae699ad 100644 --- a/proxy/src/main/java/com/velocitypowered/proxy/protocol/netty/GameSpyQueryHandler.java +++ b/proxy/src/main/java/com/velocitypowered/proxy/network/pipeline/query/GameSpyQueryHandler.java @@ -15,7 +15,7 @@ * along with this program. If not, see . */ -package com.velocitypowered.proxy.protocol.netty; +package com.velocitypowered.proxy.network.pipeline.query; import static com.velocitypowered.api.event.query.ProxyQueryEvent.QueryType.BASIC; import static com.velocitypowered.api.event.query.ProxyQueryEvent.QueryType.FULL; diff --git a/proxy/src/main/java/com/velocitypowered/proxy/protocol/netty/AutoReadHolderHandler.java b/proxy/src/main/java/com/velocitypowered/proxy/network/pipeline/util/AutoReadHolderHandler.java similarity index 97% rename from proxy/src/main/java/com/velocitypowered/proxy/protocol/netty/AutoReadHolderHandler.java rename to proxy/src/main/java/com/velocitypowered/proxy/network/pipeline/util/AutoReadHolderHandler.java index 2e5ea323d..4f95a0a2a 100644 --- a/proxy/src/main/java/com/velocitypowered/proxy/protocol/netty/AutoReadHolderHandler.java +++ b/proxy/src/main/java/com/velocitypowered/proxy/network/pipeline/util/AutoReadHolderHandler.java @@ -15,7 +15,7 @@ * along with this program. If not, see . */ -package com.velocitypowered.proxy.protocol.netty; +package com.velocitypowered.proxy.network.pipeline.util; import io.netty.channel.ChannelDuplexHandler; import io.netty.channel.ChannelHandlerContext; diff --git a/proxy/src/main/java/com/velocitypowered/proxy/protocol/netty/PlayPacketQueueHandler.java b/proxy/src/main/java/com/velocitypowered/proxy/network/pipeline/util/PlayPacketQueueHandler.java similarity index 93% rename from proxy/src/main/java/com/velocitypowered/proxy/protocol/netty/PlayPacketQueueHandler.java rename to proxy/src/main/java/com/velocitypowered/proxy/network/pipeline/util/PlayPacketQueueHandler.java index 612de451e..7eee59573 100644 --- a/proxy/src/main/java/com/velocitypowered/proxy/protocol/netty/PlayPacketQueueHandler.java +++ b/proxy/src/main/java/com/velocitypowered/proxy/network/pipeline/util/PlayPacketQueueHandler.java @@ -15,12 +15,12 @@ * along with this program. If not, see . */ -package com.velocitypowered.proxy.protocol.netty; +package com.velocitypowered.proxy.network.pipeline.util; import com.velocitypowered.api.network.ProtocolVersion; -import com.velocitypowered.proxy.protocol.MinecraftPacket; -import com.velocitypowered.proxy.protocol.ProtocolUtils; -import com.velocitypowered.proxy.protocol.StateRegistry; +import com.velocitypowered.proxy.network.protocol.MinecraftPacket; +import com.velocitypowered.proxy.network.protocol.ProtocolUtils; +import com.velocitypowered.proxy.network.protocol.StateRegistry; import io.netty.channel.ChannelDuplexHandler; import io.netty.channel.ChannelHandlerContext; import io.netty.channel.ChannelPromise; diff --git a/proxy/src/main/java/com/velocitypowered/proxy/protocol/VelocityConnectionEvent.java b/proxy/src/main/java/com/velocitypowered/proxy/network/pipeline/util/VelocityConnectionEvent.java similarity index 94% rename from proxy/src/main/java/com/velocitypowered/proxy/protocol/VelocityConnectionEvent.java rename to proxy/src/main/java/com/velocitypowered/proxy/network/pipeline/util/VelocityConnectionEvent.java index 423f41dc4..92e1cb6e8 100644 --- a/proxy/src/main/java/com/velocitypowered/proxy/protocol/VelocityConnectionEvent.java +++ b/proxy/src/main/java/com/velocitypowered/proxy/network/pipeline/util/VelocityConnectionEvent.java @@ -15,7 +15,7 @@ * along with this program. If not, see . */ -package com.velocitypowered.proxy.protocol; +package com.velocitypowered.proxy.network.pipeline.util; /** * Describes various events fired during the course of a connection. diff --git a/proxy/src/main/java/com/velocitypowered/proxy/protocol/MinecraftPacket.java b/proxy/src/main/java/com/velocitypowered/proxy/network/protocol/MinecraftPacket.java similarity index 96% rename from proxy/src/main/java/com/velocitypowered/proxy/protocol/MinecraftPacket.java rename to proxy/src/main/java/com/velocitypowered/proxy/network/protocol/MinecraftPacket.java index e54ee7707..8098c570d 100644 --- a/proxy/src/main/java/com/velocitypowered/proxy/protocol/MinecraftPacket.java +++ b/proxy/src/main/java/com/velocitypowered/proxy/network/protocol/MinecraftPacket.java @@ -15,7 +15,7 @@ * along with this program. If not, see . */ -package com.velocitypowered.proxy.protocol; +package com.velocitypowered.proxy.network.protocol; import com.velocitypowered.api.network.ProtocolVersion; import com.velocitypowered.proxy.connection.MinecraftSessionHandler; diff --git a/proxy/src/main/java/com/velocitypowered/proxy/protocol/ProtocolUtils.java b/proxy/src/main/java/com/velocitypowered/proxy/network/protocol/ProtocolUtils.java similarity index 98% rename from proxy/src/main/java/com/velocitypowered/proxy/protocol/ProtocolUtils.java rename to proxy/src/main/java/com/velocitypowered/proxy/network/protocol/ProtocolUtils.java index e65ee056b..878d811d0 100644 --- a/proxy/src/main/java/com/velocitypowered/proxy/protocol/ProtocolUtils.java +++ b/proxy/src/main/java/com/velocitypowered/proxy/network/protocol/ProtocolUtils.java @@ -15,17 +15,17 @@ * along with this program. If not, see . */ -package com.velocitypowered.proxy.protocol; +package com.velocitypowered.proxy.network.protocol; import static com.google.common.base.Preconditions.checkArgument; -import static com.velocitypowered.proxy.protocol.util.NettyPreconditions.checkFrame; +import static com.velocitypowered.proxy.network.protocol.util.NettyPreconditions.checkFrame; import com.velocitypowered.api.network.ProtocolVersion; import com.velocitypowered.api.proxy.crypto.IdentifiedKey; import com.velocitypowered.api.util.GameProfile; import com.velocitypowered.proxy.crypto.IdentifiedKeyImpl; -import com.velocitypowered.proxy.protocol.netty.MinecraftDecoder; -import com.velocitypowered.proxy.protocol.util.VelocityLegacyHoverEventSerializer; +import com.velocitypowered.proxy.network.pipeline.deser.MinecraftDecoder; +import com.velocitypowered.proxy.network.protocol.util.VelocityLegacyHoverEventSerializer; import com.velocitypowered.proxy.util.except.QuietDecoderException; import io.netty.buffer.ByteBuf; import io.netty.buffer.ByteBufInputStream; diff --git a/proxy/src/main/java/com/velocitypowered/proxy/protocol/StateRegistry.java b/proxy/src/main/java/com/velocitypowered/proxy/network/protocol/StateRegistry.java similarity index 87% rename from proxy/src/main/java/com/velocitypowered/proxy/protocol/StateRegistry.java rename to proxy/src/main/java/com/velocitypowered/proxy/network/protocol/StateRegistry.java index 8ebb7eadc..915466950 100644 --- a/proxy/src/main/java/com/velocitypowered/proxy/protocol/StateRegistry.java +++ b/proxy/src/main/java/com/velocitypowered/proxy/network/protocol/StateRegistry.java @@ -15,7 +15,7 @@ * along with this program. If not, see . */ -package com.velocitypowered.proxy.protocol; +package com.velocitypowered.proxy.network.protocol; import static com.google.common.collect.Iterables.getLast; import static com.velocitypowered.api.network.ProtocolVersion.MINECRAFT_1_12; @@ -40,60 +40,58 @@ import static com.velocitypowered.api.network.ProtocolVersion.MINECRAFT_1_9; import static com.velocitypowered.api.network.ProtocolVersion.MINECRAFT_1_9_4; import static com.velocitypowered.api.network.ProtocolVersion.MINIMUM_VERSION; import static com.velocitypowered.api.network.ProtocolVersion.SUPPORTED_VERSIONS; -import static com.velocitypowered.proxy.protocol.ProtocolUtils.Direction; -import static com.velocitypowered.proxy.protocol.ProtocolUtils.Direction.CLIENTBOUND; -import static com.velocitypowered.proxy.protocol.ProtocolUtils.Direction.SERVERBOUND; import com.velocitypowered.api.network.ProtocolVersion; -import com.velocitypowered.proxy.protocol.packet.AvailableCommands; -import com.velocitypowered.proxy.protocol.packet.BossBar; -import com.velocitypowered.proxy.protocol.packet.ClientSettings; -import com.velocitypowered.proxy.protocol.packet.Disconnect; -import com.velocitypowered.proxy.protocol.packet.EncryptionRequest; -import com.velocitypowered.proxy.protocol.packet.EncryptionResponse; -import com.velocitypowered.proxy.protocol.packet.Handshake; -import com.velocitypowered.proxy.protocol.packet.HeaderAndFooter; -import com.velocitypowered.proxy.protocol.packet.JoinGame; -import com.velocitypowered.proxy.protocol.packet.KeepAlive; -import com.velocitypowered.proxy.protocol.packet.LegacyPlayerListItem; -import com.velocitypowered.proxy.protocol.packet.LoginAcknowledged; -import com.velocitypowered.proxy.protocol.packet.LoginPluginMessage; -import com.velocitypowered.proxy.protocol.packet.LoginPluginResponse; -import com.velocitypowered.proxy.protocol.packet.PingIdentify; -import com.velocitypowered.proxy.protocol.packet.PluginMessage; -import com.velocitypowered.proxy.protocol.packet.RemovePlayerInfo; -import com.velocitypowered.proxy.protocol.packet.ResourcePackRequest; -import com.velocitypowered.proxy.protocol.packet.ResourcePackResponse; -import com.velocitypowered.proxy.protocol.packet.Respawn; -import com.velocitypowered.proxy.protocol.packet.ServerData; -import com.velocitypowered.proxy.protocol.packet.ServerLogin; -import com.velocitypowered.proxy.protocol.packet.ServerLoginSuccess; -import com.velocitypowered.proxy.protocol.packet.SetCompression; -import com.velocitypowered.proxy.protocol.packet.StatusPing; -import com.velocitypowered.proxy.protocol.packet.StatusRequest; -import com.velocitypowered.proxy.protocol.packet.StatusResponse; -import com.velocitypowered.proxy.protocol.packet.TabCompleteRequest; -import com.velocitypowered.proxy.protocol.packet.TabCompleteResponse; -import com.velocitypowered.proxy.protocol.packet.UpsertPlayerInfo; -import com.velocitypowered.proxy.protocol.packet.chat.ChatAcknowledgement; -import com.velocitypowered.proxy.protocol.packet.chat.PlayerChatCompletion; -import com.velocitypowered.proxy.protocol.packet.chat.SystemChat; -import com.velocitypowered.proxy.protocol.packet.chat.keyed.KeyedPlayerChat; -import com.velocitypowered.proxy.protocol.packet.chat.keyed.KeyedPlayerCommand; -import com.velocitypowered.proxy.protocol.packet.chat.legacy.LegacyChat; -import com.velocitypowered.proxy.protocol.packet.chat.session.SessionPlayerChat; -import com.velocitypowered.proxy.protocol.packet.chat.session.SessionPlayerCommand; -import com.velocitypowered.proxy.protocol.packet.config.ActiveFeatures; -import com.velocitypowered.proxy.protocol.packet.config.FinishedUpdate; -import com.velocitypowered.proxy.protocol.packet.config.RegistrySync; -import com.velocitypowered.proxy.protocol.packet.config.StartUpdate; -import com.velocitypowered.proxy.protocol.packet.config.TagsUpdate; -import com.velocitypowered.proxy.protocol.packet.title.LegacyTitlePacket; -import com.velocitypowered.proxy.protocol.packet.title.TitleActionbarPacket; -import com.velocitypowered.proxy.protocol.packet.title.TitleClearPacket; -import com.velocitypowered.proxy.protocol.packet.title.TitleSubtitlePacket; -import com.velocitypowered.proxy.protocol.packet.title.TitleTextPacket; -import com.velocitypowered.proxy.protocol.packet.title.TitleTimesPacket; +import com.velocitypowered.proxy.network.protocol.ProtocolUtils.Direction; +import com.velocitypowered.proxy.network.protocol.packet.AvailableCommands; +import com.velocitypowered.proxy.network.protocol.packet.BossBarPacket; +import com.velocitypowered.proxy.network.protocol.packet.ClientSettings; +import com.velocitypowered.proxy.network.protocol.packet.Disconnect; +import com.velocitypowered.proxy.network.protocol.packet.EncryptionRequest; +import com.velocitypowered.proxy.network.protocol.packet.EncryptionResponse; +import com.velocitypowered.proxy.network.protocol.packet.Handshake; +import com.velocitypowered.proxy.network.protocol.packet.HeaderAndFooter; +import com.velocitypowered.proxy.network.protocol.packet.JoinGame; +import com.velocitypowered.proxy.network.protocol.packet.KeepAlive; +import com.velocitypowered.proxy.network.protocol.packet.LegacyPlayerListItem; +import com.velocitypowered.proxy.network.protocol.packet.LoginAcknowledged; +import com.velocitypowered.proxy.network.protocol.packet.LoginPluginMessage; +import com.velocitypowered.proxy.network.protocol.packet.LoginPluginResponse; +import com.velocitypowered.proxy.network.protocol.packet.PingIdentify; +import com.velocitypowered.proxy.network.protocol.packet.PluginMessage; +import com.velocitypowered.proxy.network.protocol.packet.RemovePlayerInfo; +import com.velocitypowered.proxy.network.protocol.packet.ResourcePackRequest; +import com.velocitypowered.proxy.network.protocol.packet.ResourcePackResponse; +import com.velocitypowered.proxy.network.protocol.packet.Respawn; +import com.velocitypowered.proxy.network.protocol.packet.ServerData; +import com.velocitypowered.proxy.network.protocol.packet.ServerLogin; +import com.velocitypowered.proxy.network.protocol.packet.ServerLoginSuccess; +import com.velocitypowered.proxy.network.protocol.packet.SetCompression; +import com.velocitypowered.proxy.network.protocol.packet.StatusPing; +import com.velocitypowered.proxy.network.protocol.packet.StatusRequest; +import com.velocitypowered.proxy.network.protocol.packet.StatusResponse; +import com.velocitypowered.proxy.network.protocol.packet.TabCompleteRequest; +import com.velocitypowered.proxy.network.protocol.packet.TabCompleteResponse; +import com.velocitypowered.proxy.network.protocol.packet.UpsertPlayerInfo; +import com.velocitypowered.proxy.network.protocol.packet.chat.ChatAcknowledgement; +import com.velocitypowered.proxy.network.protocol.packet.chat.PlayerChatCompletion; +import com.velocitypowered.proxy.network.protocol.packet.chat.SystemChat; +import com.velocitypowered.proxy.network.protocol.packet.chat.keyed.KeyedPlayerChat; +import com.velocitypowered.proxy.network.protocol.packet.chat.keyed.KeyedPlayerCommand; +import com.velocitypowered.proxy.network.protocol.packet.chat.legacy.LegacyChat; +import com.velocitypowered.proxy.network.protocol.packet.chat.session.SessionPlayerChat; +import com.velocitypowered.proxy.network.protocol.packet.chat.session.SessionPlayerCommand; +import com.velocitypowered.proxy.network.protocol.packet.config.ActiveFeatures; +import com.velocitypowered.proxy.network.protocol.packet.config.FinishedUpdate; +import com.velocitypowered.proxy.network.protocol.packet.config.RegistrySync; +import com.velocitypowered.proxy.network.protocol.packet.config.StartUpdate; +import com.velocitypowered.proxy.network.protocol.packet.config.TagsUpdate; +import com.velocitypowered.proxy.network.protocol.packet.title.LegacyTitlePacket; +import com.velocitypowered.proxy.network.protocol.packet.title.TitleActionbarPacket; +import com.velocitypowered.proxy.network.protocol.packet.title.TitleClearPacket; +import com.velocitypowered.proxy.network.protocol.packet.title.TitleSubtitlePacket; +import com.velocitypowered.proxy.network.protocol.packet.title.TitleTextPacket; +import com.velocitypowered.proxy.network.protocol.packet.title.TitleTimesPacket; import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; import io.netty.util.collection.IntObjectHashMap; import io.netty.util.collection.IntObjectMap; @@ -107,7 +105,9 @@ import java.util.Objects; import java.util.function.Supplier; import org.checkerframework.checker.nullness.qual.Nullable; -/** Registry of all Minecraft protocol states and the packets for each state. */ +/** + * Registry of all Minecraft protocol states and the packets for each state. + */ public enum StateRegistry { HANDSHAKE { @@ -186,9 +186,9 @@ public enum StateRegistry { map(0x02, MINECRAFT_1_12_1, false), map(0x03, MINECRAFT_1_14, MINECRAFT_1_18_2, false)); serverbound.register( - ChatAcknowledgement.class, - ChatAcknowledgement::new, - map(0x03, MINECRAFT_1_19_3, false)); + ChatAcknowledgement.class, + ChatAcknowledgement::new, + map(0x03, MINECRAFT_1_19_3, false)); serverbound.register(KeyedPlayerCommand.class, KeyedPlayerCommand::new, map(0x03, MINECRAFT_1_19, false), map(0x04, MINECRAFT_1_19_1, MINECRAFT_1_19_1, false)); @@ -262,8 +262,8 @@ public enum StateRegistry { FinishedUpdate.class, FinishedUpdate::new, map(0x0B, MINECRAFT_1_20_2, false)); clientbound.register( - BossBar.class, - BossBar::new, + BossBarPacket.class, + BossBarPacket::new, map(0x0C, MINECRAFT_1_9, false), map(0x0D, MINECRAFT_1_15, false), map(0x0C, MINECRAFT_1_16, false), @@ -550,15 +550,18 @@ public enum StateRegistry { public static final int STATUS_ID = 1; public static final int LOGIN_ID = 2; - protected final PacketRegistry clientbound = new PacketRegistry(CLIENTBOUND, this); - protected final PacketRegistry serverbound = new PacketRegistry(SERVERBOUND, this); + protected final PacketRegistry clientbound = new PacketRegistry(Direction.CLIENTBOUND, this); + protected final PacketRegistry serverbound = new PacketRegistry(Direction.SERVERBOUND, this); public StateRegistry.PacketRegistry.ProtocolRegistry getProtocolRegistry(Direction direction, ProtocolVersion version) { - return (direction == SERVERBOUND ? serverbound : clientbound).getProtocolRegistry(version); + return (direction == Direction.SERVERBOUND ? serverbound : clientbound).getProtocolRegistry( + version); } - /** Packet registry. */ + /** + * Packet registry. + */ public static class PacketRegistry { private final Direction direction; @@ -656,7 +659,9 @@ public enum StateRegistry { } } - /** Protocol registry. */ + /** + * Protocol registry. + */ public class ProtocolRegistry { public final ProtocolVersion version; @@ -697,7 +702,7 @@ public enum StateRegistry { throw new IllegalArgumentException(String.format( "Unable to find id for packet of type %s in %s protocol %s phase %s", packet.getClass().getName(), PacketRegistry.this.direction, - this.version, PacketRegistry.this.registry + this.version, PacketRegistry.this.registry )); } return id; @@ -715,7 +720,9 @@ public enum StateRegistry { } } - /** Packet mapping. */ + /** + * Packet mapping. + */ public static final class PacketMapping { private final int id; diff --git a/proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/AvailableCommands.java b/proxy/src/main/java/com/velocitypowered/proxy/network/protocol/packet/AvailableCommands.java similarity index 97% rename from proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/AvailableCommands.java rename to proxy/src/main/java/com/velocitypowered/proxy/network/protocol/packet/AvailableCommands.java index 6c842c3a5..75f1bb918 100644 --- a/proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/AvailableCommands.java +++ b/proxy/src/main/java/com/velocitypowered/proxy/network/protocol/packet/AvailableCommands.java @@ -15,7 +15,7 @@ * along with this program. If not, see . */ -package com.velocitypowered.proxy.protocol.packet; +package com.velocitypowered.proxy.network.protocol.packet; import com.google.common.base.MoreObjects; import com.google.common.collect.ImmutableList; @@ -36,10 +36,10 @@ 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.MinecraftPacket; -import com.velocitypowered.proxy.protocol.ProtocolUtils; -import com.velocitypowered.proxy.protocol.ProtocolUtils.Direction; -import com.velocitypowered.proxy.protocol.packet.brigadier.ArgumentPropertyRegistry; +import com.velocitypowered.proxy.network.protocol.MinecraftPacket; +import com.velocitypowered.proxy.network.protocol.ProtocolUtils; +import com.velocitypowered.proxy.network.protocol.ProtocolUtils.Direction; +import com.velocitypowered.proxy.network.protocol.packet.brigadier.ArgumentPropertyRegistry; import com.velocitypowered.proxy.util.collect.IdentityHashStrategy; import io.netty.buffer.ByteBuf; import it.unimi.dsi.fastutil.objects.Object2IntLinkedOpenCustomHashMap; diff --git a/proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/BossBar.java b/proxy/src/main/java/com/velocitypowered/proxy/network/protocol/packet/BossBarPacket.java similarity index 90% rename from proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/BossBar.java rename to proxy/src/main/java/com/velocitypowered/proxy/network/protocol/packet/BossBarPacket.java index 91f4bacff..f0dc6c456 100644 --- a/proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/BossBar.java +++ b/proxy/src/main/java/com/velocitypowered/proxy/network/protocol/packet/BossBarPacket.java @@ -15,17 +15,18 @@ * along with this program. If not, see . */ -package com.velocitypowered.proxy.protocol.packet; +package com.velocitypowered.proxy.network.protocol.packet; import com.velocitypowered.api.network.ProtocolVersion; import com.velocitypowered.proxy.connection.MinecraftSessionHandler; -import com.velocitypowered.proxy.protocol.MinecraftPacket; -import com.velocitypowered.proxy.protocol.ProtocolUtils; +import com.velocitypowered.proxy.network.protocol.MinecraftPacket; +import com.velocitypowered.proxy.network.protocol.ProtocolUtils; +import com.velocitypowered.proxy.network.protocol.ProtocolUtils.Direction; import io.netty.buffer.ByteBuf; import java.util.UUID; import org.checkerframework.checker.nullness.qual.Nullable; -public class BossBar implements MinecraftPacket { +public class BossBarPacket implements MinecraftPacket { public static final int ADD = 0; public static final int REMOVE = 1; @@ -114,7 +115,7 @@ public class BossBar implements MinecraftPacket { } @Override - public void decode(ByteBuf buf, ProtocolUtils.Direction direction, ProtocolVersion version) { + public void decode(ByteBuf buf, Direction direction, ProtocolVersion version) { this.uuid = ProtocolUtils.readUuid(buf); this.action = ProtocolUtils.readVarInt(buf); switch (action) { @@ -191,8 +192,8 @@ public class BossBar implements MinecraftPacket { return handler.handle(this); } - public static BossBar createRemovePacket(UUID id) { - BossBar packet = new BossBar(); + public static BossBarPacket createRemovePacket(UUID id) { + BossBarPacket packet = new BossBarPacket(); packet.setUuid(id); packet.setAction(REMOVE); return packet; diff --git a/proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/ClientSettings.java b/proxy/src/main/java/com/velocitypowered/proxy/network/protocol/packet/ClientSettings.java similarity index 90% rename from proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/ClientSettings.java rename to proxy/src/main/java/com/velocitypowered/proxy/network/protocol/packet/ClientSettings.java index a42d1ee90..307b7ab88 100644 --- a/proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/ClientSettings.java +++ b/proxy/src/main/java/com/velocitypowered/proxy/network/protocol/packet/ClientSettings.java @@ -15,18 +15,19 @@ * along with this program. If not, see . */ -package com.velocitypowered.proxy.protocol.packet; +package com.velocitypowered.proxy.network.protocol.packet; import com.velocitypowered.api.network.ProtocolVersion; import com.velocitypowered.proxy.connection.MinecraftSessionHandler; -import com.velocitypowered.proxy.protocol.MinecraftPacket; -import com.velocitypowered.proxy.protocol.ProtocolUtils; +import com.velocitypowered.proxy.network.protocol.MinecraftPacket; +import com.velocitypowered.proxy.network.protocol.ProtocolUtils; +import com.velocitypowered.proxy.network.protocol.ProtocolUtils.Direction; import io.netty.buffer.ByteBuf; import java.util.Objects; - import org.checkerframework.checker.nullness.qual.Nullable; public class ClientSettings implements MinecraftPacket { + private @Nullable String locale; private byte viewDistance; private int chatVisibility; @@ -120,14 +121,14 @@ public class ClientSettings implements MinecraftPacket { @Override public String toString() { - return "ClientSettings{" + "locale='" + locale + '\'' + ", viewDistance=" + viewDistance + - ", chatVisibility=" + chatVisibility + ", chatColors=" + chatColors + ", skinParts=" + - skinParts + ", mainHand=" + mainHand + ", chatFilteringEnabled=" + chatFilteringEnabled + - ", clientListingAllowed=" + clientListingAllowed + '}'; + return "ClientSettings{" + "locale='" + locale + '\'' + ", viewDistance=" + viewDistance + + ", chatVisibility=" + chatVisibility + ", chatColors=" + chatColors + ", skinParts=" + + skinParts + ", mainHand=" + mainHand + ", chatFilteringEnabled=" + chatFilteringEnabled + + ", clientListingAllowed=" + clientListingAllowed + '}'; } @Override - public void decode(ByteBuf buf, ProtocolUtils.Direction direction, ProtocolVersion version) { + public void decode(ByteBuf buf, Direction direction, ProtocolVersion version) { this.locale = ProtocolUtils.readString(buf, 16); this.viewDistance = buf.readByte(); this.chatVisibility = ProtocolUtils.readVarInt(buf); diff --git a/proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/Disconnect.java b/proxy/src/main/java/com/velocitypowered/proxy/network/protocol/packet/Disconnect.java similarity index 86% rename from proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/Disconnect.java rename to proxy/src/main/java/com/velocitypowered/proxy/network/protocol/packet/Disconnect.java index cdc9d0d75..895d8fffd 100644 --- a/proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/Disconnect.java +++ b/proxy/src/main/java/com/velocitypowered/proxy/network/protocol/packet/Disconnect.java @@ -15,13 +15,14 @@ * along with this program. If not, see . */ -package com.velocitypowered.proxy.protocol.packet; +package com.velocitypowered.proxy.network.protocol.packet; import com.google.common.base.Preconditions; import com.velocitypowered.api.network.ProtocolVersion; import com.velocitypowered.proxy.connection.MinecraftSessionHandler; -import com.velocitypowered.proxy.protocol.MinecraftPacket; -import com.velocitypowered.proxy.protocol.ProtocolUtils; +import com.velocitypowered.proxy.network.protocol.MinecraftPacket; +import com.velocitypowered.proxy.network.protocol.ProtocolUtils; +import com.velocitypowered.proxy.network.protocol.ProtocolUtils.Direction; import io.netty.buffer.ByteBuf; import org.checkerframework.checker.nullness.qual.Nullable; @@ -55,7 +56,7 @@ public class Disconnect implements MinecraftPacket { } @Override - public void decode(ByteBuf buf, ProtocolUtils.Direction direction, ProtocolVersion version) { + public void decode(ByteBuf buf, Direction direction, ProtocolVersion version) { reason = ProtocolUtils.readString(buf); } diff --git a/proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/EncryptionRequest.java b/proxy/src/main/java/com/velocitypowered/proxy/network/protocol/packet/EncryptionRequest.java similarity index 88% rename from proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/EncryptionRequest.java rename to proxy/src/main/java/com/velocitypowered/proxy/network/protocol/packet/EncryptionRequest.java index f54769f1e..886b97bd6 100644 --- a/proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/EncryptionRequest.java +++ b/proxy/src/main/java/com/velocitypowered/proxy/network/protocol/packet/EncryptionRequest.java @@ -15,14 +15,15 @@ * along with this program. If not, see . */ -package com.velocitypowered.proxy.protocol.packet; +package com.velocitypowered.proxy.network.protocol.packet; import static com.velocitypowered.proxy.connection.VelocityConstants.EMPTY_BYTE_ARRAY; import com.velocitypowered.api.network.ProtocolVersion; import com.velocitypowered.proxy.connection.MinecraftSessionHandler; -import com.velocitypowered.proxy.protocol.MinecraftPacket; -import com.velocitypowered.proxy.protocol.ProtocolUtils; +import com.velocitypowered.proxy.network.protocol.MinecraftPacket; +import com.velocitypowered.proxy.network.protocol.ProtocolUtils; +import com.velocitypowered.proxy.network.protocol.ProtocolUtils.Direction; import io.netty.buffer.ByteBuf; import java.util.Arrays; @@ -57,7 +58,7 @@ public class EncryptionRequest implements MinecraftPacket { } @Override - public void decode(ByteBuf buf, ProtocolUtils.Direction direction, ProtocolVersion version) { + public void decode(ByteBuf buf, Direction direction, ProtocolVersion version) { this.serverId = ProtocolUtils.readString(buf, 20); if (version.compareTo(ProtocolVersion.MINECRAFT_1_8) >= 0) { diff --git a/proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/EncryptionResponse.java b/proxy/src/main/java/com/velocitypowered/proxy/network/protocol/packet/EncryptionResponse.java similarity index 91% rename from proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/EncryptionResponse.java rename to proxy/src/main/java/com/velocitypowered/proxy/network/protocol/packet/EncryptionResponse.java index 2fc9523c8..e2c9bd562 100644 --- a/proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/EncryptionResponse.java +++ b/proxy/src/main/java/com/velocitypowered/proxy/network/protocol/packet/EncryptionResponse.java @@ -15,24 +15,23 @@ * along with this program. If not, see . */ -package com.velocitypowered.proxy.protocol.packet; +package com.velocitypowered.proxy.network.protocol.packet; import static com.velocitypowered.proxy.connection.VelocityConstants.EMPTY_BYTE_ARRAY; import com.velocitypowered.api.network.ProtocolVersion; import com.velocitypowered.proxy.connection.MinecraftSessionHandler; -import com.velocitypowered.proxy.protocol.MinecraftPacket; -import com.velocitypowered.proxy.protocol.ProtocolUtils; -import com.velocitypowered.proxy.protocol.ProtocolUtils.Direction; +import com.velocitypowered.proxy.network.protocol.MinecraftPacket; +import com.velocitypowered.proxy.network.protocol.ProtocolUtils; +import com.velocitypowered.proxy.network.protocol.ProtocolUtils.Direction; import com.velocitypowered.proxy.util.except.QuietDecoderException; import io.netty.buffer.ByteBuf; -import org.checkerframework.checker.nullness.qual.Nullable; - import java.util.Arrays; +import org.checkerframework.checker.nullness.qual.Nullable; public class EncryptionResponse implements MinecraftPacket { - private final static QuietDecoderException NO_SALT = new QuietDecoderException( + private static final QuietDecoderException NO_SALT = new QuietDecoderException( "Encryption response didn't contain salt"); private byte[] sharedSecret = EMPTY_BYTE_ARRAY; @@ -63,7 +62,7 @@ public class EncryptionResponse implements MinecraftPacket { } @Override - public void decode(ByteBuf buf, ProtocolUtils.Direction direction, ProtocolVersion version) { + public void decode(ByteBuf buf, Direction direction, ProtocolVersion version) { if (version.compareTo(ProtocolVersion.MINECRAFT_1_8) >= 0) { this.sharedSecret = ProtocolUtils.readByteArray(buf, 128); diff --git a/proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/Handshake.java b/proxy/src/main/java/com/velocitypowered/proxy/network/protocol/packet/Handshake.java similarity index 89% rename from proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/Handshake.java rename to proxy/src/main/java/com/velocitypowered/proxy/network/protocol/packet/Handshake.java index 7b1a397cd..30df73d69 100644 --- a/proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/Handshake.java +++ b/proxy/src/main/java/com/velocitypowered/proxy/network/protocol/packet/Handshake.java @@ -15,14 +15,15 @@ * along with this program. If not, see . */ -package com.velocitypowered.proxy.protocol.packet; +package com.velocitypowered.proxy.network.protocol.packet; import static com.velocitypowered.proxy.connection.forge.legacy.LegacyForgeConstants.HANDSHAKE_HOSTNAME_TOKEN; import com.velocitypowered.api.network.ProtocolVersion; import com.velocitypowered.proxy.connection.MinecraftSessionHandler; -import com.velocitypowered.proxy.protocol.MinecraftPacket; -import com.velocitypowered.proxy.protocol.ProtocolUtils; +import com.velocitypowered.proxy.network.protocol.MinecraftPacket; +import com.velocitypowered.proxy.network.protocol.ProtocolUtils; +import com.velocitypowered.proxy.network.protocol.ProtocolUtils.Direction; import io.netty.buffer.ByteBuf; public class Handshake implements MinecraftPacket { @@ -78,7 +79,7 @@ public class Handshake implements MinecraftPacket { } @Override - public void decode(ByteBuf buf, ProtocolUtils.Direction direction, ProtocolVersion ignored) { + public void decode(ByteBuf buf, Direction direction, ProtocolVersion ignored) { int realProtocolVersion = ProtocolUtils.readVarInt(buf); this.protocolVersion = ProtocolVersion.getProtocolVersion(realProtocolVersion); this.serverAddress = ProtocolUtils.readString(buf, MAXIMUM_HOSTNAME_LENGTH); diff --git a/proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/HeaderAndFooter.java b/proxy/src/main/java/com/velocitypowered/proxy/network/protocol/packet/HeaderAndFooter.java similarity index 81% rename from proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/HeaderAndFooter.java rename to proxy/src/main/java/com/velocitypowered/proxy/network/protocol/packet/HeaderAndFooter.java index 43e1ac7e8..6734b4dbb 100644 --- a/proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/HeaderAndFooter.java +++ b/proxy/src/main/java/com/velocitypowered/proxy/network/protocol/packet/HeaderAndFooter.java @@ -15,15 +15,14 @@ * along with this program. If not, see . */ -package com.velocitypowered.proxy.protocol.packet; - -import static com.velocitypowered.proxy.protocol.ProtocolUtils.writeString; +package com.velocitypowered.proxy.network.protocol.packet; import com.google.common.base.Preconditions; import com.velocitypowered.api.network.ProtocolVersion; import com.velocitypowered.proxy.connection.MinecraftSessionHandler; -import com.velocitypowered.proxy.protocol.MinecraftPacket; -import com.velocitypowered.proxy.protocol.ProtocolUtils; +import com.velocitypowered.proxy.network.protocol.MinecraftPacket; +import com.velocitypowered.proxy.network.protocol.ProtocolUtils; +import com.velocitypowered.proxy.network.protocol.ProtocolUtils.Direction; import io.netty.buffer.ByteBuf; import net.kyori.adventure.text.Component; import net.kyori.adventure.text.serializer.gson.GsonComponentSerializer; @@ -54,14 +53,14 @@ public class HeaderAndFooter implements MinecraftPacket { } @Override - public void decode(ByteBuf buf, ProtocolUtils.Direction direction, ProtocolVersion version) { + public void decode(ByteBuf buf, Direction direction, ProtocolVersion version) { throw new UnsupportedOperationException("Decode is not implemented"); } @Override - public void encode(ByteBuf buf, ProtocolUtils.Direction direction, ProtocolVersion version) { - writeString(buf, header); - writeString(buf, footer); + public void encode(ByteBuf buf, Direction direction, ProtocolVersion version) { + ProtocolUtils.writeString(buf, header); + ProtocolUtils.writeString(buf, footer); } @Override diff --git a/proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/JoinGame.java b/proxy/src/main/java/com/velocitypowered/proxy/network/protocol/packet/JoinGame.java similarity index 91% rename from proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/JoinGame.java rename to proxy/src/main/java/com/velocitypowered/proxy/network/protocol/packet/JoinGame.java index 938d1190a..184e94e5e 100644 --- a/proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/JoinGame.java +++ b/proxy/src/main/java/com/velocitypowered/proxy/network/protocol/packet/JoinGame.java @@ -15,13 +15,15 @@ * along with this program. If not, see . */ -package com.velocitypowered.proxy.protocol.packet; +package com.velocitypowered.proxy.network.protocol.packet; import com.google.common.collect.ImmutableSet; import com.velocitypowered.api.network.ProtocolVersion; import com.velocitypowered.proxy.connection.MinecraftSessionHandler; import com.velocitypowered.proxy.connection.registry.DimensionInfo; -import com.velocitypowered.proxy.protocol.*; +import com.velocitypowered.proxy.network.protocol.MinecraftPacket; +import com.velocitypowered.proxy.network.protocol.ProtocolUtils; +import com.velocitypowered.proxy.network.protocol.ProtocolUtils.Direction; import io.netty.buffer.ByteBuf; import it.unimi.dsi.fastutil.Pair; import net.kyori.adventure.nbt.BinaryTagIO; @@ -186,20 +188,20 @@ public class JoinGame implements MinecraftPacket { @Override public String toString() { - return "JoinGame{" + "entityId=" + entityId + ", gamemode=" + gamemode + ", dimension=" + - dimension + ", partialHashedSeed=" + partialHashedSeed + ", difficulty=" + difficulty + - ", isHardcore=" + isHardcore + ", maxPlayers=" + maxPlayers + ", levelType='" + levelType + - '\'' + ", viewDistance=" + viewDistance + ", reducedDebugInfo=" + reducedDebugInfo + - ", showRespawnScreen=" + showRespawnScreen + ", doLimitedCrafting=" + doLimitedCrafting + - ", levelNames=" + levelNames + ", registry='" + registry + '\'' + ", dimensionInfo='" + - dimensionInfo + '\'' + ", currentDimensionData='" + currentDimensionData + '\'' + - ", previousGamemode=" + previousGamemode + ", simulationDistance=" + simulationDistance + - ", lastDeathPosition='" + lastDeathPosition + '\'' + ", portalCooldown=" + portalCooldown + - '}'; + return "JoinGame{" + "entityId=" + entityId + ", gamemode=" + gamemode + ", dimension=" + + dimension + ", partialHashedSeed=" + partialHashedSeed + ", difficulty=" + difficulty + + ", isHardcore=" + isHardcore + ", maxPlayers=" + maxPlayers + ", levelType='" + levelType + + '\'' + ", viewDistance=" + viewDistance + ", reducedDebugInfo=" + reducedDebugInfo + + ", showRespawnScreen=" + showRespawnScreen + ", doLimitedCrafting=" + doLimitedCrafting + + ", levelNames=" + levelNames + ", registry='" + registry + '\'' + ", dimensionInfo='" + + dimensionInfo + '\'' + ", currentDimensionData='" + currentDimensionData + '\'' + + ", previousGamemode=" + previousGamemode + ", simulationDistance=" + simulationDistance + + ", lastDeathPosition='" + lastDeathPosition + '\'' + ", portalCooldown=" + portalCooldown + + '}'; } @Override - public void decode(ByteBuf buf, ProtocolUtils.Direction direction, ProtocolVersion version) { + public void decode(ByteBuf buf, Direction direction, ProtocolVersion version) { if (version.compareTo(ProtocolVersion.MINECRAFT_1_20_2) >= 0) { // haha funny, they made 1.20.2 more complicated this.decode1202Up(buf, version); @@ -311,8 +313,10 @@ public class JoinGame implements MinecraftPacket { this.showRespawnScreen = buf.readBoolean(); this.doLimitedCrafting = buf.readBoolean(); + // CHECKSTYLE.OFF: VariableDeclarationUsageDistance - we can't pull this down, side effects String dimensionIdentifier = ProtocolUtils.readString(buf); String levelName = ProtocolUtils.readString(buf); + // CHECKSTYLE.ON: VariableDeclarationUsageDistance - we can't pull this down, side effects this.partialHashedSeed = buf.readLong(); this.gamemode = buf.readByte(); diff --git a/proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/KeepAlive.java b/proxy/src/main/java/com/velocitypowered/proxy/network/protocol/packet/KeepAlive.java similarity index 85% rename from proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/KeepAlive.java rename to proxy/src/main/java/com/velocitypowered/proxy/network/protocol/packet/KeepAlive.java index 3f4d47dce..7f4a5cd3d 100644 --- a/proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/KeepAlive.java +++ b/proxy/src/main/java/com/velocitypowered/proxy/network/protocol/packet/KeepAlive.java @@ -15,12 +15,13 @@ * along with this program. If not, see . */ -package com.velocitypowered.proxy.protocol.packet; +package com.velocitypowered.proxy.network.protocol.packet; import com.velocitypowered.api.network.ProtocolVersion; import com.velocitypowered.proxy.connection.MinecraftSessionHandler; -import com.velocitypowered.proxy.protocol.MinecraftPacket; -import com.velocitypowered.proxy.protocol.ProtocolUtils; +import com.velocitypowered.proxy.network.protocol.MinecraftPacket; +import com.velocitypowered.proxy.network.protocol.ProtocolUtils; +import com.velocitypowered.proxy.network.protocol.ProtocolUtils.Direction; import io.netty.buffer.ByteBuf; public class KeepAlive implements MinecraftPacket { @@ -43,7 +44,7 @@ public class KeepAlive implements MinecraftPacket { } @Override - public void decode(ByteBuf buf, ProtocolUtils.Direction direction, ProtocolVersion version) { + public void decode(ByteBuf buf, Direction direction, ProtocolVersion version) { if (version.compareTo(ProtocolVersion.MINECRAFT_1_12_2) >= 0) { randomId = buf.readLong(); } else if (version.compareTo(ProtocolVersion.MINECRAFT_1_8) >= 0) { diff --git a/proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/LegacyDisconnect.java b/proxy/src/main/java/com/velocitypowered/proxy/network/protocol/packet/LegacyDisconnect.java similarity index 96% rename from proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/LegacyDisconnect.java rename to proxy/src/main/java/com/velocitypowered/proxy/network/protocol/packet/LegacyDisconnect.java index f3033b021..8265ea6d9 100644 --- a/proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/LegacyDisconnect.java +++ b/proxy/src/main/java/com/velocitypowered/proxy/network/protocol/packet/LegacyDisconnect.java @@ -15,12 +15,12 @@ * along with this program. If not, see . */ -package com.velocitypowered.proxy.protocol.packet; +package com.velocitypowered.proxy.network.protocol.packet; 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 com.velocitypowered.proxy.network.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.PlainTextComponentSerializer; diff --git a/proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/LegacyHandshake.java b/proxy/src/main/java/com/velocitypowered/proxy/network/protocol/packet/LegacyHandshake.java similarity index 76% rename from proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/LegacyHandshake.java rename to proxy/src/main/java/com/velocitypowered/proxy/network/protocol/packet/LegacyHandshake.java index ee66f8d3e..226981d29 100644 --- a/proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/LegacyHandshake.java +++ b/proxy/src/main/java/com/velocitypowered/proxy/network/protocol/packet/LegacyHandshake.java @@ -15,23 +15,23 @@ * along with this program. If not, see . */ -package com.velocitypowered.proxy.protocol.packet; +package com.velocitypowered.proxy.network.protocol.packet; import com.velocitypowered.api.network.ProtocolVersion; import com.velocitypowered.proxy.connection.MinecraftSessionHandler; -import com.velocitypowered.proxy.protocol.MinecraftPacket; -import com.velocitypowered.proxy.protocol.ProtocolUtils; +import com.velocitypowered.proxy.network.protocol.MinecraftPacket; +import com.velocitypowered.proxy.network.protocol.ProtocolUtils.Direction; import io.netty.buffer.ByteBuf; public class LegacyHandshake implements MinecraftPacket { @Override - public void decode(ByteBuf buf, ProtocolUtils.Direction direction, ProtocolVersion version) { + public void decode(ByteBuf buf, Direction direction, ProtocolVersion version) { throw new UnsupportedOperationException(); } @Override - public void encode(ByteBuf buf, ProtocolUtils.Direction direction, ProtocolVersion version) { + public void encode(ByteBuf buf, Direction direction, ProtocolVersion version) { throw new UnsupportedOperationException(); } diff --git a/proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/LegacyPing.java b/proxy/src/main/java/com/velocitypowered/proxy/network/protocol/packet/LegacyPing.java similarity index 79% rename from proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/LegacyPing.java rename to proxy/src/main/java/com/velocitypowered/proxy/network/protocol/packet/LegacyPing.java index 8439bbb1e..99f8604b7 100644 --- a/proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/LegacyPing.java +++ b/proxy/src/main/java/com/velocitypowered/proxy/network/protocol/packet/LegacyPing.java @@ -15,13 +15,13 @@ * along with this program. If not, see . */ -package com.velocitypowered.proxy.protocol.packet; +package com.velocitypowered.proxy.network.protocol.packet; import com.velocitypowered.api.network.ProtocolVersion; import com.velocitypowered.proxy.connection.MinecraftSessionHandler; -import com.velocitypowered.proxy.protocol.MinecraftPacket; -import com.velocitypowered.proxy.protocol.ProtocolUtils; -import com.velocitypowered.proxy.protocol.packet.legacyping.LegacyMinecraftPingVersion; +import com.velocitypowered.proxy.network.protocol.MinecraftPacket; +import com.velocitypowered.proxy.network.protocol.ProtocolUtils.Direction; +import com.velocitypowered.proxy.network.protocol.packet.legacyping.LegacyMinecraftPingVersion; import io.netty.buffer.ByteBuf; import java.net.InetSocketAddress; import org.checkerframework.checker.nullness.qual.Nullable; @@ -50,12 +50,12 @@ public class LegacyPing implements MinecraftPacket { } @Override - public void decode(ByteBuf buf, ProtocolUtils.Direction direction, ProtocolVersion version) { + public void decode(ByteBuf buf, Direction direction, ProtocolVersion version) { throw new UnsupportedOperationException(); } @Override - public void encode(ByteBuf buf, ProtocolUtils.Direction direction, ProtocolVersion version) { + public void encode(ByteBuf buf, Direction direction, ProtocolVersion version) { throw new UnsupportedOperationException(); } diff --git a/proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/LegacyPlayerListItem.java b/proxy/src/main/java/com/velocitypowered/proxy/network/protocol/packet/LegacyPlayerListItem.java similarity index 96% rename from proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/LegacyPlayerListItem.java rename to proxy/src/main/java/com/velocitypowered/proxy/network/protocol/packet/LegacyPlayerListItem.java index 721d54b66..9934d2662 100644 --- a/proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/LegacyPlayerListItem.java +++ b/proxy/src/main/java/com/velocitypowered/proxy/network/protocol/packet/LegacyPlayerListItem.java @@ -15,7 +15,7 @@ * along with this program. If not, see . */ -package com.velocitypowered.proxy.protocol.packet; +package com.velocitypowered.proxy.network.protocol.packet; import com.google.common.collect.ImmutableList; import com.velocitypowered.api.network.ProtocolVersion; @@ -23,8 +23,9 @@ import com.velocitypowered.api.proxy.crypto.IdentifiedKey; import com.velocitypowered.api.proxy.player.TabListEntry; import com.velocitypowered.api.util.GameProfile; import com.velocitypowered.proxy.connection.MinecraftSessionHandler; -import com.velocitypowered.proxy.protocol.MinecraftPacket; -import com.velocitypowered.proxy.protocol.ProtocolUtils; +import com.velocitypowered.proxy.network.protocol.MinecraftPacket; +import com.velocitypowered.proxy.network.protocol.ProtocolUtils; +import com.velocitypowered.proxy.network.protocol.ProtocolUtils.Direction; import io.netty.buffer.ByteBuf; import java.util.ArrayList; import java.util.List; @@ -60,7 +61,7 @@ public class LegacyPlayerListItem implements MinecraftPacket { } @Override - public void decode(ByteBuf buf, ProtocolUtils.Direction direction, ProtocolVersion version) { + public void decode(ByteBuf buf, Direction direction, ProtocolVersion version) { if (version.compareTo(ProtocolVersion.MINECRAFT_1_8) >= 0) { action = ProtocolUtils.readVarInt(buf); int length = ProtocolUtils.readVarInt(buf); diff --git a/proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/LoginAcknowledged.java b/proxy/src/main/java/com/velocitypowered/proxy/network/protocol/packet/LoginAcknowledged.java similarity index 66% rename from proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/LoginAcknowledged.java rename to proxy/src/main/java/com/velocitypowered/proxy/network/protocol/packet/LoginAcknowledged.java index 1f7941004..08a90bbbf 100644 --- a/proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/LoginAcknowledged.java +++ b/proxy/src/main/java/com/velocitypowered/proxy/network/protocol/packet/LoginAcknowledged.java @@ -15,29 +15,29 @@ * along with this program. If not, see . */ -package com.velocitypowered.proxy.protocol.packet; +package com.velocitypowered.proxy.network.protocol.packet; import com.velocitypowered.api.network.ProtocolVersion; import com.velocitypowered.proxy.connection.MinecraftSessionHandler; -import com.velocitypowered.proxy.protocol.MinecraftPacket; -import com.velocitypowered.proxy.protocol.ProtocolUtils; +import com.velocitypowered.proxy.network.protocol.MinecraftPacket; +import com.velocitypowered.proxy.network.protocol.ProtocolUtils.Direction; import io.netty.buffer.ByteBuf; public class LoginAcknowledged implements MinecraftPacket { @Override - public void decode(ByteBuf buf, ProtocolUtils.Direction direction, - ProtocolVersion protocolVersion) { + public void decode(ByteBuf buf, Direction direction, + ProtocolVersion protocolVersion) { } @Override - public void encode(ByteBuf buf, ProtocolUtils.Direction direction, - ProtocolVersion protocolVersion) { + public void encode(ByteBuf buf, Direction direction, + ProtocolVersion protocolVersion) { } @Override - public int expectedMaxLength(ByteBuf buf, ProtocolUtils.Direction direction, - ProtocolVersion version) { + public int expectedMaxLength(ByteBuf buf, Direction direction, + ProtocolVersion version) { return 0; } diff --git a/proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/LoginPluginMessage.java b/proxy/src/main/java/com/velocitypowered/proxy/network/protocol/packet/LoginPluginMessage.java similarity index 84% rename from proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/LoginPluginMessage.java rename to proxy/src/main/java/com/velocitypowered/proxy/network/protocol/packet/LoginPluginMessage.java index b5a2ac0a3..8a0db9f10 100644 --- a/proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/LoginPluginMessage.java +++ b/proxy/src/main/java/com/velocitypowered/proxy/network/protocol/packet/LoginPluginMessage.java @@ -15,13 +15,14 @@ * along with this program. If not, see . */ -package com.velocitypowered.proxy.protocol.packet; +package com.velocitypowered.proxy.network.protocol.packet; import com.velocitypowered.api.network.ProtocolVersion; import com.velocitypowered.proxy.connection.MinecraftSessionHandler; -import com.velocitypowered.proxy.protocol.MinecraftPacket; -import com.velocitypowered.proxy.protocol.ProtocolUtils; -import com.velocitypowered.proxy.protocol.util.DeferredByteBufHolder; +import com.velocitypowered.proxy.network.protocol.MinecraftPacket; +import com.velocitypowered.proxy.network.protocol.ProtocolUtils; +import com.velocitypowered.proxy.network.protocol.ProtocolUtils.Direction; +import com.velocitypowered.proxy.network.protocol.util.DeferredByteBufHolder; import io.netty.buffer.ByteBuf; import io.netty.buffer.Unpooled; import org.checkerframework.checker.nullness.qual.Nullable; @@ -62,7 +63,7 @@ public class LoginPluginMessage extends DeferredByteBufHolder implements Minecra } @Override - public void decode(ByteBuf buf, ProtocolUtils.Direction direction, ProtocolVersion version) { + public void decode(ByteBuf buf, Direction direction, ProtocolVersion version) { this.id = ProtocolUtils.readVarInt(buf); this.channel = ProtocolUtils.readString(buf); if (buf.isReadable()) { diff --git a/proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/LoginPluginResponse.java b/proxy/src/main/java/com/velocitypowered/proxy/network/protocol/packet/LoginPluginResponse.java similarity index 84% rename from proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/LoginPluginResponse.java rename to proxy/src/main/java/com/velocitypowered/proxy/network/protocol/packet/LoginPluginResponse.java index c4ecc8b6b..87ea0b504 100644 --- a/proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/LoginPluginResponse.java +++ b/proxy/src/main/java/com/velocitypowered/proxy/network/protocol/packet/LoginPluginResponse.java @@ -15,13 +15,14 @@ * along with this program. If not, see . */ -package com.velocitypowered.proxy.protocol.packet; +package com.velocitypowered.proxy.network.protocol.packet; import com.velocitypowered.api.network.ProtocolVersion; import com.velocitypowered.proxy.connection.MinecraftSessionHandler; -import com.velocitypowered.proxy.protocol.MinecraftPacket; -import com.velocitypowered.proxy.protocol.ProtocolUtils; -import com.velocitypowered.proxy.protocol.util.DeferredByteBufHolder; +import com.velocitypowered.proxy.network.protocol.MinecraftPacket; +import com.velocitypowered.proxy.network.protocol.ProtocolUtils; +import com.velocitypowered.proxy.network.protocol.ProtocolUtils.Direction; +import com.velocitypowered.proxy.network.protocol.util.DeferredByteBufHolder; import io.netty.buffer.ByteBuf; import io.netty.buffer.Unpooled; import org.checkerframework.checker.nullness.qual.MonotonicNonNull; @@ -67,7 +68,7 @@ public class LoginPluginResponse extends DeferredByteBufHolder implements Minecr } @Override - public void decode(ByteBuf buf, ProtocolUtils.Direction direction, ProtocolVersion version) { + public void decode(ByteBuf buf, Direction direction, ProtocolVersion version) { this.id = ProtocolUtils.readVarInt(buf); this.success = buf.readBoolean(); if (buf.isReadable()) { diff --git a/proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/PingIdentify.java b/proxy/src/main/java/com/velocitypowered/proxy/network/protocol/packet/PingIdentify.java similarity index 76% rename from proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/PingIdentify.java rename to proxy/src/main/java/com/velocitypowered/proxy/network/protocol/packet/PingIdentify.java index 2d3d9b5da..fe0000f1b 100644 --- a/proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/PingIdentify.java +++ b/proxy/src/main/java/com/velocitypowered/proxy/network/protocol/packet/PingIdentify.java @@ -15,12 +15,12 @@ * along with this program. If not, see . */ -package com.velocitypowered.proxy.protocol.packet; +package com.velocitypowered.proxy.network.protocol.packet; import com.velocitypowered.api.network.ProtocolVersion; import com.velocitypowered.proxy.connection.MinecraftSessionHandler; -import com.velocitypowered.proxy.protocol.MinecraftPacket; -import com.velocitypowered.proxy.protocol.ProtocolUtils; +import com.velocitypowered.proxy.network.protocol.MinecraftPacket; +import com.velocitypowered.proxy.network.protocol.ProtocolUtils.Direction; import io.netty.buffer.ByteBuf; public class PingIdentify implements MinecraftPacket { @@ -33,12 +33,12 @@ public class PingIdentify implements MinecraftPacket { } @Override - public void decode(ByteBuf buf, ProtocolUtils.Direction direction, ProtocolVersion version) { + public void decode(ByteBuf buf, Direction direction, ProtocolVersion version) { id = buf.readInt(); } @Override - public void encode(ByteBuf buf, ProtocolUtils.Direction direction, ProtocolVersion version) { + public void encode(ByteBuf buf, Direction direction, ProtocolVersion version) { buf.writeInt(id); } diff --git a/proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/PluginMessage.java b/proxy/src/main/java/com/velocitypowered/proxy/network/protocol/packet/PluginMessage.java similarity index 87% rename from proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/PluginMessage.java rename to proxy/src/main/java/com/velocitypowered/proxy/network/protocol/packet/PluginMessage.java index 431585712..1680d5a41 100644 --- a/proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/PluginMessage.java +++ b/proxy/src/main/java/com/velocitypowered/proxy/network/protocol/packet/PluginMessage.java @@ -15,15 +15,16 @@ * along with this program. If not, see . */ -package com.velocitypowered.proxy.protocol.packet; +package com.velocitypowered.proxy.network.protocol.packet; -import static com.velocitypowered.proxy.protocol.util.PluginMessageUtil.transformLegacyToModernChannel; +import static com.velocitypowered.proxy.network.protocol.util.PluginMessageUtil.transformLegacyToModernChannel; import com.velocitypowered.api.network.ProtocolVersion; import com.velocitypowered.proxy.connection.MinecraftSessionHandler; -import com.velocitypowered.proxy.protocol.MinecraftPacket; -import com.velocitypowered.proxy.protocol.ProtocolUtils; -import com.velocitypowered.proxy.protocol.util.DeferredByteBufHolder; +import com.velocitypowered.proxy.network.protocol.MinecraftPacket; +import com.velocitypowered.proxy.network.protocol.ProtocolUtils; +import com.velocitypowered.proxy.network.protocol.ProtocolUtils.Direction; +import com.velocitypowered.proxy.network.protocol.util.DeferredByteBufHolder; import io.netty.buffer.ByteBuf; import org.checkerframework.checker.nullness.qual.MonotonicNonNull; import org.checkerframework.checker.nullness.qual.Nullable; @@ -62,7 +63,7 @@ public class PluginMessage extends DeferredByteBufHolder implements MinecraftPac } @Override - public void decode(ByteBuf buf, ProtocolUtils.Direction direction, ProtocolVersion version) { + public void decode(ByteBuf buf, Direction direction, ProtocolVersion version) { this.channel = ProtocolUtils.readString(buf); if (version.compareTo(ProtocolVersion.MINECRAFT_1_13) >= 0) { this.channel = transformLegacyToModernChannel(this.channel); diff --git a/proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/RemovePlayerInfo.java b/proxy/src/main/java/com/velocitypowered/proxy/network/protocol/packet/RemovePlayerInfo.java similarity index 87% rename from proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/RemovePlayerInfo.java rename to proxy/src/main/java/com/velocitypowered/proxy/network/protocol/packet/RemovePlayerInfo.java index a9859fcc5..c352e3639 100644 --- a/proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/RemovePlayerInfo.java +++ b/proxy/src/main/java/com/velocitypowered/proxy/network/protocol/packet/RemovePlayerInfo.java @@ -15,13 +15,14 @@ * along with this program. If not, see . */ -package com.velocitypowered.proxy.protocol.packet; +package com.velocitypowered.proxy.network.protocol.packet; import com.google.common.collect.Lists; import com.velocitypowered.api.network.ProtocolVersion; import com.velocitypowered.proxy.connection.MinecraftSessionHandler; -import com.velocitypowered.proxy.protocol.MinecraftPacket; -import com.velocitypowered.proxy.protocol.ProtocolUtils; +import com.velocitypowered.proxy.network.protocol.MinecraftPacket; +import com.velocitypowered.proxy.network.protocol.ProtocolUtils; +import com.velocitypowered.proxy.network.protocol.ProtocolUtils.Direction; import io.netty.buffer.ByteBuf; import java.util.ArrayList; import java.util.Collection; @@ -48,7 +49,7 @@ public class RemovePlayerInfo implements MinecraftPacket { } @Override - public void decode(ByteBuf buf, ProtocolUtils.Direction direction, + public void decode(ByteBuf buf, Direction direction, ProtocolVersion protocolVersion) { int length = ProtocolUtils.readVarInt(buf); Collection profilesToRemove = Lists.newArrayListWithCapacity(length); diff --git a/proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/ResourcePackRequest.java b/proxy/src/main/java/com/velocitypowered/proxy/network/protocol/packet/ResourcePackRequest.java similarity index 91% rename from proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/ResourcePackRequest.java rename to proxy/src/main/java/com/velocitypowered/proxy/network/protocol/packet/ResourcePackRequest.java index c80b97c16..765961589 100644 --- a/proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/ResourcePackRequest.java +++ b/proxy/src/main/java/com/velocitypowered/proxy/network/protocol/packet/ResourcePackRequest.java @@ -15,25 +15,24 @@ * along with this program. If not, see . */ -package com.velocitypowered.proxy.protocol.packet; +package com.velocitypowered.proxy.network.protocol.packet; import com.google.common.base.Preconditions; import com.velocitypowered.api.network.ProtocolVersion; import com.velocitypowered.api.proxy.player.ResourcePackInfo; import com.velocitypowered.proxy.connection.MinecraftSessionHandler; import com.velocitypowered.proxy.connection.player.VelocityResourcePackInfo; -import com.velocitypowered.proxy.protocol.MinecraftPacket; -import com.velocitypowered.proxy.protocol.ProtocolUtils; -import com.velocitypowered.proxy.protocol.ProtocolUtils.Direction; +import com.velocitypowered.proxy.network.protocol.MinecraftPacket; +import com.velocitypowered.proxy.network.protocol.ProtocolUtils; +import com.velocitypowered.proxy.network.protocol.ProtocolUtils.Direction; import io.netty.buffer.ByteBuf; import io.netty.buffer.ByteBufUtil; +import java.util.regex.Pattern; import net.kyori.adventure.text.Component; import net.kyori.adventure.text.serializer.gson.GsonComponentSerializer; import org.checkerframework.checker.nullness.qual.MonotonicNonNull; import org.checkerframework.checker.nullness.qual.Nullable; -import java.util.regex.Pattern; - public class ResourcePackRequest implements MinecraftPacket { private @MonotonicNonNull String url; @@ -127,7 +126,7 @@ public class ResourcePackRequest implements MinecraftPacket { @Override public String toString() { - return "ResourcePackRequest{" + "url='" + url + '\'' + ", hash='" + hash + '\'' + - ", isRequired=" + isRequired + ", prompt='" + prompt + '\'' + '}'; + return "ResourcePackRequest{" + "url='" + url + '\'' + ", hash='" + hash + '\'' + + ", isRequired=" + isRequired + ", prompt='" + prompt + '\'' + '}'; } } diff --git a/proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/ResourcePackResponse.java b/proxy/src/main/java/com/velocitypowered/proxy/network/protocol/packet/ResourcePackResponse.java similarity index 89% rename from proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/ResourcePackResponse.java rename to proxy/src/main/java/com/velocitypowered/proxy/network/protocol/packet/ResourcePackResponse.java index 4b67cf695..072cea538 100644 --- a/proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/ResourcePackResponse.java +++ b/proxy/src/main/java/com/velocitypowered/proxy/network/protocol/packet/ResourcePackResponse.java @@ -15,14 +15,14 @@ * along with this program. If not, see . */ -package com.velocitypowered.proxy.protocol.packet; +package com.velocitypowered.proxy.network.protocol.packet; import com.velocitypowered.api.event.player.PlayerResourcePackStatusEvent.Status; import com.velocitypowered.api.network.ProtocolVersion; import com.velocitypowered.proxy.connection.MinecraftSessionHandler; -import com.velocitypowered.proxy.protocol.MinecraftPacket; -import com.velocitypowered.proxy.protocol.ProtocolUtils; -import com.velocitypowered.proxy.protocol.ProtocolUtils.Direction; +import com.velocitypowered.proxy.network.protocol.MinecraftPacket; +import com.velocitypowered.proxy.network.protocol.ProtocolUtils; +import com.velocitypowered.proxy.network.protocol.ProtocolUtils.Direction; import io.netty.buffer.ByteBuf; import org.checkerframework.checker.nullness.qual.MonotonicNonNull; diff --git a/proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/Respawn.java b/proxy/src/main/java/com/velocitypowered/proxy/network/protocol/packet/Respawn.java similarity index 95% rename from proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/Respawn.java rename to proxy/src/main/java/com/velocitypowered/proxy/network/protocol/packet/Respawn.java index 712024f63..f3081c116 100644 --- a/proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/Respawn.java +++ b/proxy/src/main/java/com/velocitypowered/proxy/network/protocol/packet/Respawn.java @@ -15,13 +15,14 @@ * along with this program. If not, see . */ -package com.velocitypowered.proxy.protocol.packet; +package com.velocitypowered.proxy.network.protocol.packet; import com.velocitypowered.api.network.ProtocolVersion; import com.velocitypowered.proxy.connection.MinecraftSessionHandler; import com.velocitypowered.proxy.connection.registry.DimensionInfo; -import com.velocitypowered.proxy.protocol.MinecraftPacket; -import com.velocitypowered.proxy.protocol.ProtocolUtils; +import com.velocitypowered.proxy.network.protocol.MinecraftPacket; +import com.velocitypowered.proxy.network.protocol.ProtocolUtils; +import com.velocitypowered.proxy.network.protocol.ProtocolUtils.Direction; import io.netty.buffer.ByteBuf; import it.unimi.dsi.fastutil.Pair; import net.kyori.adventure.nbt.BinaryTagIO; @@ -66,7 +67,8 @@ public class Respawn implements MinecraftPacket { return new Respawn(joinGame.getDimension(), joinGame.getPartialHashedSeed(), joinGame.getDifficulty(), joinGame.getGamemode(), joinGame.getLevelType(), (byte) 0, joinGame.getDimensionInfo(), joinGame.getPreviousGamemode(), - joinGame.getCurrentDimensionData(), joinGame.getLastDeathPosition(), joinGame.getPortalCooldown()); + joinGame.getCurrentDimensionData(), joinGame.getLastDeathPosition(), + joinGame.getPortalCooldown()); } public int getDimension() { @@ -159,7 +161,7 @@ public class Respawn implements MinecraftPacket { } @Override - public void decode(ByteBuf buf, ProtocolUtils.Direction direction, ProtocolVersion version) { + public void decode(ByteBuf buf, Direction direction, ProtocolVersion version) { String dimensionIdentifier = null; String levelName = null; if (version.compareTo(ProtocolVersion.MINECRAFT_1_16) >= 0) { diff --git a/proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/ServerData.java b/proxy/src/main/java/com/velocitypowered/proxy/network/protocol/packet/ServerData.java similarity index 88% rename from proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/ServerData.java rename to proxy/src/main/java/com/velocitypowered/proxy/network/protocol/packet/ServerData.java index 4223c488f..6758e37e3 100644 --- a/proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/ServerData.java +++ b/proxy/src/main/java/com/velocitypowered/proxy/network/protocol/packet/ServerData.java @@ -15,18 +15,19 @@ * along with this program. If not, see . */ -package com.velocitypowered.proxy.protocol.packet; +package com.velocitypowered.proxy.network.protocol.packet; import com.velocitypowered.api.network.ProtocolVersion; import com.velocitypowered.api.util.Favicon; import com.velocitypowered.proxy.connection.MinecraftSessionHandler; -import com.velocitypowered.proxy.protocol.MinecraftPacket; -import com.velocitypowered.proxy.protocol.ProtocolUtils; +import com.velocitypowered.proxy.network.protocol.MinecraftPacket; +import com.velocitypowered.proxy.network.protocol.ProtocolUtils; +import com.velocitypowered.proxy.network.protocol.ProtocolUtils.Direction; import io.netty.buffer.ByteBuf; -import net.kyori.adventure.text.Component; -import org.jetbrains.annotations.Nullable; import java.nio.charset.StandardCharsets; import java.util.Base64; +import net.kyori.adventure.text.Component; +import org.jetbrains.annotations.Nullable; public class ServerData implements MinecraftPacket { @@ -45,7 +46,7 @@ public class ServerData implements MinecraftPacket { } @Override - public void decode(ByteBuf buf, ProtocolUtils.Direction direction, + public void decode(ByteBuf buf, Direction direction, ProtocolVersion protocolVersion) { if (protocolVersion.compareTo(ProtocolVersion.MINECRAFT_1_19_4) >= 0 || buf.readBoolean()) { this.description = ProtocolUtils.getJsonChatSerializer(protocolVersion) @@ -55,7 +56,8 @@ public class ServerData implements MinecraftPacket { String iconBase64; if (protocolVersion.compareTo(ProtocolVersion.MINECRAFT_1_19_4) >= 0) { byte[] iconBytes = ProtocolUtils.readByteArray(buf); - iconBase64 = "data:image/png;base64," + new String(Base64.getEncoder().encode(iconBytes), StandardCharsets.UTF_8); + iconBase64 = "data:image/png;base64," + new String(Base64.getEncoder().encode(iconBytes), + StandardCharsets.UTF_8); } else { iconBase64 = ProtocolUtils.readString(buf); } @@ -88,7 +90,8 @@ public class ServerData implements MinecraftPacket { if (hasFavicon) { if (protocolVersion.compareTo(ProtocolVersion.MINECRAFT_1_19_4) >= 0) { String cutIconBase64 = favicon.getBase64Url().substring("data:image/png;base64,".length()); - byte[] iconBytes = Base64.getDecoder().decode(cutIconBase64.getBytes(StandardCharsets.UTF_8)); + byte[] iconBytes = Base64.getDecoder() + .decode(cutIconBase64.getBytes(StandardCharsets.UTF_8)); ProtocolUtils.writeByteArray(buf, iconBytes); } else { ProtocolUtils.writeString(buf, favicon.getBase64Url()); diff --git a/proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/ServerLogin.java b/proxy/src/main/java/com/velocitypowered/proxy/network/protocol/packet/ServerLogin.java similarity index 95% rename from proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/ServerLogin.java rename to proxy/src/main/java/com/velocitypowered/proxy/network/protocol/packet/ServerLogin.java index 57c8c61c2..b43ebb22c 100644 --- a/proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/ServerLogin.java +++ b/proxy/src/main/java/com/velocitypowered/proxy/network/protocol/packet/ServerLogin.java @@ -15,20 +15,19 @@ * along with this program. If not, see . */ -package com.velocitypowered.proxy.protocol.packet; +package com.velocitypowered.proxy.network.protocol.packet; import com.google.common.base.Preconditions; import com.velocitypowered.api.network.ProtocolVersion; import com.velocitypowered.api.proxy.crypto.IdentifiedKey; import com.velocitypowered.proxy.connection.MinecraftSessionHandler; -import com.velocitypowered.proxy.protocol.MinecraftPacket; -import com.velocitypowered.proxy.protocol.ProtocolUtils; -import com.velocitypowered.proxy.protocol.ProtocolUtils.Direction; +import com.velocitypowered.proxy.network.protocol.MinecraftPacket; +import com.velocitypowered.proxy.network.protocol.ProtocolUtils; +import com.velocitypowered.proxy.network.protocol.ProtocolUtils.Direction; import com.velocitypowered.proxy.util.except.QuietDecoderException; import io.netty.buffer.ByteBuf; -import org.checkerframework.checker.nullness.qual.Nullable; - import java.util.UUID; +import org.checkerframework.checker.nullness.qual.Nullable; public class ServerLogin implements MinecraftPacket { diff --git a/proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/ServerLoginSuccess.java b/proxy/src/main/java/com/velocitypowered/proxy/network/protocol/packet/ServerLoginSuccess.java similarity index 91% rename from proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/ServerLoginSuccess.java rename to proxy/src/main/java/com/velocitypowered/proxy/network/protocol/packet/ServerLoginSuccess.java index 35142b944..37e63b100 100644 --- a/proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/ServerLoginSuccess.java +++ b/proxy/src/main/java/com/velocitypowered/proxy/network/protocol/packet/ServerLoginSuccess.java @@ -15,16 +15,16 @@ * along with this program. If not, see . */ -package com.velocitypowered.proxy.protocol.packet; +package com.velocitypowered.proxy.network.protocol.packet; import com.velocitypowered.api.network.ProtocolVersion; import com.velocitypowered.api.util.GameProfile; import com.velocitypowered.api.util.UuidUtils; import com.velocitypowered.proxy.connection.MinecraftSessionHandler; -import com.velocitypowered.proxy.protocol.MinecraftPacket; -import com.velocitypowered.proxy.protocol.ProtocolUtils; +import com.velocitypowered.proxy.network.protocol.MinecraftPacket; +import com.velocitypowered.proxy.network.protocol.ProtocolUtils; +import com.velocitypowered.proxy.network.protocol.ProtocolUtils.Direction; import io.netty.buffer.ByteBuf; - import java.util.List; import java.util.UUID; import org.checkerframework.checker.nullness.qual.Nullable; @@ -75,7 +75,7 @@ public class ServerLoginSuccess implements MinecraftPacket { } @Override - public void decode(ByteBuf buf, ProtocolUtils.Direction direction, ProtocolVersion version) { + public void decode(ByteBuf buf, Direction direction, ProtocolVersion version) { if (version.compareTo(ProtocolVersion.MINECRAFT_1_19) >= 0) { uuid = ProtocolUtils.readUuid(buf); } else if (version.compareTo(ProtocolVersion.MINECRAFT_1_16) >= 0) { diff --git a/proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/SetCompression.java b/proxy/src/main/java/com/velocitypowered/proxy/network/protocol/packet/SetCompression.java similarity index 82% rename from proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/SetCompression.java rename to proxy/src/main/java/com/velocitypowered/proxy/network/protocol/packet/SetCompression.java index 41a23a2bd..72492307c 100644 --- a/proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/SetCompression.java +++ b/proxy/src/main/java/com/velocitypowered/proxy/network/protocol/packet/SetCompression.java @@ -15,12 +15,13 @@ * along with this program. If not, see . */ -package com.velocitypowered.proxy.protocol.packet; +package com.velocitypowered.proxy.network.protocol.packet; import com.velocitypowered.api.network.ProtocolVersion; import com.velocitypowered.proxy.connection.MinecraftSessionHandler; -import com.velocitypowered.proxy.protocol.MinecraftPacket; -import com.velocitypowered.proxy.protocol.ProtocolUtils; +import com.velocitypowered.proxy.network.protocol.MinecraftPacket; +import com.velocitypowered.proxy.network.protocol.ProtocolUtils; +import com.velocitypowered.proxy.network.protocol.ProtocolUtils.Direction; import io.netty.buffer.ByteBuf; public class SetCompression implements MinecraftPacket { @@ -50,7 +51,7 @@ public class SetCompression implements MinecraftPacket { } @Override - public void decode(ByteBuf buf, ProtocolUtils.Direction direction, ProtocolVersion version) { + public void decode(ByteBuf buf, Direction direction, ProtocolVersion version) { this.threshold = ProtocolUtils.readVarInt(buf); } diff --git a/proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/StatusPing.java b/proxy/src/main/java/com/velocitypowered/proxy/network/protocol/packet/StatusPing.java similarity index 76% rename from proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/StatusPing.java rename to proxy/src/main/java/com/velocitypowered/proxy/network/protocol/packet/StatusPing.java index a86db61d8..ae12080ad 100644 --- a/proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/StatusPing.java +++ b/proxy/src/main/java/com/velocitypowered/proxy/network/protocol/packet/StatusPing.java @@ -15,13 +15,12 @@ * along with this program. If not, see . */ -package com.velocitypowered.proxy.protocol.packet; +package com.velocitypowered.proxy.network.protocol.packet; import com.velocitypowered.api.network.ProtocolVersion; import com.velocitypowered.proxy.connection.MinecraftSessionHandler; -import com.velocitypowered.proxy.protocol.MinecraftPacket; -import com.velocitypowered.proxy.protocol.ProtocolUtils; -import com.velocitypowered.proxy.protocol.ProtocolUtils.Direction; +import com.velocitypowered.proxy.network.protocol.MinecraftPacket; +import com.velocitypowered.proxy.network.protocol.ProtocolUtils.Direction; import io.netty.buffer.ByteBuf; public class StatusPing implements MinecraftPacket { @@ -29,12 +28,12 @@ public class StatusPing implements MinecraftPacket { private long randomId; @Override - public void decode(ByteBuf buf, ProtocolUtils.Direction direction, ProtocolVersion version) { + public void decode(ByteBuf buf, Direction direction, ProtocolVersion version) { randomId = buf.readLong(); } @Override - public void encode(ByteBuf buf, ProtocolUtils.Direction direction, ProtocolVersion version) { + public void encode(ByteBuf buf, Direction direction, ProtocolVersion version) { buf.writeLong(randomId); } diff --git a/proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/StatusRequest.java b/proxy/src/main/java/com/velocitypowered/proxy/network/protocol/packet/StatusRequest.java similarity index 77% rename from proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/StatusRequest.java rename to proxy/src/main/java/com/velocitypowered/proxy/network/protocol/packet/StatusRequest.java index 448246623..488f1a956 100644 --- a/proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/StatusRequest.java +++ b/proxy/src/main/java/com/velocitypowered/proxy/network/protocol/packet/StatusRequest.java @@ -15,13 +15,12 @@ * along with this program. If not, see . */ -package com.velocitypowered.proxy.protocol.packet; +package com.velocitypowered.proxy.network.protocol.packet; import com.velocitypowered.api.network.ProtocolVersion; import com.velocitypowered.proxy.connection.MinecraftSessionHandler; -import com.velocitypowered.proxy.protocol.MinecraftPacket; -import com.velocitypowered.proxy.protocol.ProtocolUtils; -import com.velocitypowered.proxy.protocol.ProtocolUtils.Direction; +import com.velocitypowered.proxy.network.protocol.MinecraftPacket; +import com.velocitypowered.proxy.network.protocol.ProtocolUtils.Direction; import io.netty.buffer.ByteBuf; public class StatusRequest implements MinecraftPacket { @@ -33,12 +32,12 @@ public class StatusRequest implements MinecraftPacket { } @Override - public void decode(ByteBuf buf, ProtocolUtils.Direction direction, ProtocolVersion version) { + public void decode(ByteBuf buf, Direction direction, ProtocolVersion version) { // There is no additional data to decode. } @Override - public void encode(ByteBuf buf, ProtocolUtils.Direction direction, ProtocolVersion version) { + public void encode(ByteBuf buf, Direction direction, ProtocolVersion version) { // There is no data to decode. } diff --git a/proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/StatusResponse.java b/proxy/src/main/java/com/velocitypowered/proxy/network/protocol/packet/StatusResponse.java similarity index 84% rename from proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/StatusResponse.java rename to proxy/src/main/java/com/velocitypowered/proxy/network/protocol/packet/StatusResponse.java index 0df0df4a5..b09a77c13 100644 --- a/proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/StatusResponse.java +++ b/proxy/src/main/java/com/velocitypowered/proxy/network/protocol/packet/StatusResponse.java @@ -15,12 +15,13 @@ * along with this program. If not, see . */ -package com.velocitypowered.proxy.protocol.packet; +package com.velocitypowered.proxy.network.protocol.packet; import com.velocitypowered.api.network.ProtocolVersion; import com.velocitypowered.proxy.connection.MinecraftSessionHandler; -import com.velocitypowered.proxy.protocol.MinecraftPacket; -import com.velocitypowered.proxy.protocol.ProtocolUtils; +import com.velocitypowered.proxy.network.protocol.MinecraftPacket; +import com.velocitypowered.proxy.network.protocol.ProtocolUtils; +import com.velocitypowered.proxy.network.protocol.ProtocolUtils.Direction; import io.netty.buffer.ByteBuf; import org.checkerframework.checker.nullness.qual.Nullable; @@ -50,7 +51,7 @@ public class StatusResponse implements MinecraftPacket { } @Override - public void decode(ByteBuf buf, ProtocolUtils.Direction direction, ProtocolVersion version) { + public void decode(ByteBuf buf, Direction direction, ProtocolVersion version) { status = ProtocolUtils.readString(buf, Short.MAX_VALUE); } diff --git a/proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/TabCompleteRequest.java b/proxy/src/main/java/com/velocitypowered/proxy/network/protocol/packet/TabCompleteRequest.java similarity index 92% rename from proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/TabCompleteRequest.java rename to proxy/src/main/java/com/velocitypowered/proxy/network/protocol/packet/TabCompleteRequest.java index 1a1a71355..0c9870e83 100644 --- a/proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/TabCompleteRequest.java +++ b/proxy/src/main/java/com/velocitypowered/proxy/network/protocol/packet/TabCompleteRequest.java @@ -15,7 +15,7 @@ * along with this program. If not, see . */ -package com.velocitypowered.proxy.protocol.packet; +package com.velocitypowered.proxy.network.protocol.packet; import static com.velocitypowered.api.network.ProtocolVersion.MINECRAFT_1_13; import static com.velocitypowered.api.network.ProtocolVersion.MINECRAFT_1_8; @@ -24,8 +24,9 @@ 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.MinecraftPacket; -import com.velocitypowered.proxy.protocol.ProtocolUtils; +import com.velocitypowered.proxy.network.protocol.MinecraftPacket; +import com.velocitypowered.proxy.network.protocol.ProtocolUtils; +import com.velocitypowered.proxy.network.protocol.ProtocolUtils.Direction; import io.netty.buffer.ByteBuf; import org.checkerframework.checker.nullness.qual.Nullable; @@ -94,7 +95,7 @@ public class TabCompleteRequest implements MinecraftPacket { } @Override - public void decode(ByteBuf buf, ProtocolUtils.Direction direction, ProtocolVersion version) { + public void decode(ByteBuf buf, Direction direction, ProtocolVersion version) { if (version.compareTo(MINECRAFT_1_13) >= 0) { this.transactionId = ProtocolUtils.readVarInt(buf); this.command = ProtocolUtils.readString(buf, VANILLA_MAX_TAB_COMPLETE_LEN); diff --git a/proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/TabCompleteResponse.java b/proxy/src/main/java/com/velocitypowered/proxy/network/protocol/packet/TabCompleteResponse.java similarity index 93% rename from proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/TabCompleteResponse.java rename to proxy/src/main/java/com/velocitypowered/proxy/network/protocol/packet/TabCompleteResponse.java index 835c39a00..76701c6f8 100644 --- a/proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/TabCompleteResponse.java +++ b/proxy/src/main/java/com/velocitypowered/proxy/network/protocol/packet/TabCompleteResponse.java @@ -15,15 +15,16 @@ * along with this program. If not, see . */ -package com.velocitypowered.proxy.protocol.packet; +package com.velocitypowered.proxy.network.protocol.packet; import static com.velocitypowered.api.network.ProtocolVersion.MINECRAFT_1_13; import com.google.common.base.MoreObjects; import com.velocitypowered.api.network.ProtocolVersion; import com.velocitypowered.proxy.connection.MinecraftSessionHandler; -import com.velocitypowered.proxy.protocol.MinecraftPacket; -import com.velocitypowered.proxy.protocol.ProtocolUtils; +import com.velocitypowered.proxy.network.protocol.MinecraftPacket; +import com.velocitypowered.proxy.network.protocol.ProtocolUtils; +import com.velocitypowered.proxy.network.protocol.ProtocolUtils.Direction; import io.netty.buffer.ByteBuf; import java.util.ArrayList; import java.util.List; @@ -76,7 +77,7 @@ public class TabCompleteResponse implements MinecraftPacket { } @Override - public void decode(ByteBuf buf, ProtocolUtils.Direction direction, ProtocolVersion version) { + public void decode(ByteBuf buf, Direction direction, ProtocolVersion version) { if (version.compareTo(MINECRAFT_1_13) >= 0) { this.transactionId = ProtocolUtils.readVarInt(buf); this.start = ProtocolUtils.readVarInt(buf); diff --git a/proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/UpsertPlayerInfo.java b/proxy/src/main/java/com/velocitypowered/proxy/network/protocol/packet/UpsertPlayerInfo.java similarity index 91% rename from proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/UpsertPlayerInfo.java rename to proxy/src/main/java/com/velocitypowered/proxy/network/protocol/packet/UpsertPlayerInfo.java index a63eb6941..27fe3051c 100644 --- a/proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/UpsertPlayerInfo.java +++ b/proxy/src/main/java/com/velocitypowered/proxy/network/protocol/packet/UpsertPlayerInfo.java @@ -15,14 +15,15 @@ * along with this program. If not, see . */ -package com.velocitypowered.proxy.protocol.packet; +package com.velocitypowered.proxy.network.protocol.packet; import com.velocitypowered.api.network.ProtocolVersion; import com.velocitypowered.api.util.GameProfile; import com.velocitypowered.proxy.connection.MinecraftSessionHandler; -import com.velocitypowered.proxy.protocol.MinecraftPacket; -import com.velocitypowered.proxy.protocol.ProtocolUtils; -import com.velocitypowered.proxy.protocol.packet.chat.RemoteChatSession; +import com.velocitypowered.proxy.network.protocol.MinecraftPacket; +import com.velocitypowered.proxy.network.protocol.ProtocolUtils; +import com.velocitypowered.proxy.network.protocol.ProtocolUtils.Direction; +import com.velocitypowered.proxy.network.protocol.packet.chat.RemoteChatSession; import io.netty.buffer.ByteBuf; import java.util.ArrayList; import java.util.Arrays; @@ -83,7 +84,7 @@ public class UpsertPlayerInfo implements MinecraftPacket { } @Override - public void decode(ByteBuf buf, ProtocolUtils.Direction direction, + public void decode(ByteBuf buf, Direction direction, ProtocolVersion protocolVersion) { Action[] actions = Action.class.getEnumConstants(); byte[] bytes = new byte[-Math.floorDiv(-actions.length, 8)]; @@ -283,15 +284,15 @@ public class UpsertPlayerInfo implements MinecraftPacket { @Override public String toString() { - return "Entry{" + - "profileId=" + profileId + - ", profile=" + profile + - ", listed=" + listed + - ", latency=" + latency + - ", gameMode=" + gameMode + - ", displayName=" + displayName + - ", chatSession=" + chatSession + - '}'; + return "Entry{" + + "profileId=" + profileId + + ", profile=" + profile + + ", listed=" + listed + + ", latency=" + latency + + ", gameMode=" + gameMode + + ", displayName=" + displayName + + ", chatSession=" + chatSession + + '}'; } } } diff --git a/proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/brigadier/ArgumentIdentifier.java b/proxy/src/main/java/com/velocitypowered/proxy/network/protocol/packet/brigadier/ArgumentIdentifier.java similarity index 97% rename from proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/brigadier/ArgumentIdentifier.java rename to proxy/src/main/java/com/velocitypowered/proxy/network/protocol/packet/brigadier/ArgumentIdentifier.java index b26401b7f..98c74b666 100644 --- a/proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/brigadier/ArgumentIdentifier.java +++ b/proxy/src/main/java/com/velocitypowered/proxy/network/protocol/packet/brigadier/ArgumentIdentifier.java @@ -15,7 +15,7 @@ * along with this program. If not, see . */ -package com.velocitypowered.proxy.protocol.packet.brigadier; +package com.velocitypowered.proxy.network.protocol.packet.brigadier; import com.google.common.base.Preconditions; import com.google.common.collect.ImmutableMap; diff --git a/proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/brigadier/ArgumentPropertyRegistry.java b/proxy/src/main/java/com/velocitypowered/proxy/network/protocol/packet/brigadier/ArgumentPropertyRegistry.java similarity index 90% rename from proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/brigadier/ArgumentPropertyRegistry.java rename to proxy/src/main/java/com/velocitypowered/proxy/network/protocol/packet/brigadier/ArgumentPropertyRegistry.java index df877b0b5..0362f9a5a 100644 --- a/proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/brigadier/ArgumentPropertyRegistry.java +++ b/proxy/src/main/java/com/velocitypowered/proxy/network/protocol/packet/brigadier/ArgumentPropertyRegistry.java @@ -15,20 +15,18 @@ * along with this program. If not, see . */ -package com.velocitypowered.proxy.protocol.packet.brigadier; +package com.velocitypowered.proxy.network.protocol.packet.brigadier; import static com.velocitypowered.api.network.ProtocolVersion.MINECRAFT_1_19; import static com.velocitypowered.api.network.ProtocolVersion.MINECRAFT_1_19_3; import static com.velocitypowered.api.network.ProtocolVersion.MINECRAFT_1_19_4; -import static com.velocitypowered.proxy.protocol.packet.brigadier.ArgumentIdentifier.id; -import static com.velocitypowered.proxy.protocol.packet.brigadier.ArgumentIdentifier.mapSet; -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.ModArgumentPropertySerializer.MOD; -import static com.velocitypowered.proxy.protocol.packet.brigadier.StringArgumentPropertySerializer.STRING; +import static com.velocitypowered.proxy.network.protocol.packet.brigadier.ArgumentIdentifier.id; +import static com.velocitypowered.proxy.network.protocol.packet.brigadier.ArgumentIdentifier.mapSet; +import static com.velocitypowered.proxy.network.protocol.packet.brigadier.DoubleArgumentPropertySerializer.DOUBLE; +import static com.velocitypowered.proxy.network.protocol.packet.brigadier.EmptyArgumentPropertySerializer.EMPTY; +import static com.velocitypowered.proxy.network.protocol.packet.brigadier.FloatArgumentPropertySerializer.FLOAT; +import static com.velocitypowered.proxy.network.protocol.packet.brigadier.IntegerArgumentPropertySerializer.INTEGER; +import static com.velocitypowered.proxy.network.protocol.packet.brigadier.ModArgumentPropertySerializer.MOD; import com.google.common.base.Preconditions; import com.mojang.brigadier.arguments.ArgumentType; @@ -39,7 +37,7 @@ import com.mojang.brigadier.arguments.IntegerArgumentType; import com.mojang.brigadier.arguments.LongArgumentType; import com.mojang.brigadier.arguments.StringArgumentType; import com.velocitypowered.api.network.ProtocolVersion; -import com.velocitypowered.proxy.protocol.ProtocolUtils; +import com.velocitypowered.proxy.network.protocol.ProtocolUtils; import io.netty.buffer.ByteBuf; import java.util.HashMap; import java.util.Map; @@ -191,8 +189,10 @@ public class ArgumentPropertyRegistry { register(id("brigadier:double", mapSet(MINECRAFT_1_19, 2)), DoubleArgumentType.class, DOUBLE); register(id("brigadier:integer", mapSet(MINECRAFT_1_19, 3)), IntegerArgumentType.class, INTEGER); - register(id("brigadier:long", mapSet(MINECRAFT_1_19, 4)), LongArgumentType.class, LONG); - register(id("brigadier:string", mapSet(MINECRAFT_1_19, 5)), StringArgumentType.class, STRING); + register(id("brigadier:long", mapSet(MINECRAFT_1_19, 4)), LongArgumentType.class, + LongArgumentPropertySerializer.LONG); + register(id("brigadier:string", mapSet(MINECRAFT_1_19, 5)), StringArgumentType.class, + StringArgumentPropertySerializer.STRING); empty(id("minecraft:entity", mapSet(MINECRAFT_1_19, 6)), ByteArgumentPropertySerializer.BYTE); empty(id("minecraft:game_profile", mapSet(MINECRAFT_1_19, 7))); @@ -253,7 +253,8 @@ public class ArgumentPropertyRegistry { empty(id("minecraft:template_rotation", mapSet(MINECRAFT_1_19, 46))); // 1.19 empty(id("minecraft:heightmap", mapSet(MINECRAFT_1_19_4, 47))); // 1.19.4 - empty(id("minecraft:uuid", mapSet(MINECRAFT_1_19_4, 48), mapSet(MINECRAFT_1_19, 47))); // added in 1.16 + empty(id("minecraft:uuid", mapSet(MINECRAFT_1_19_4, 48), + mapSet(MINECRAFT_1_19, 47))); // added in 1.16 // Crossstitch support register(id("crossstitch:mod_argument", mapSet(MINECRAFT_1_19, -256)), diff --git a/proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/brigadier/ArgumentPropertySerializer.java b/proxy/src/main/java/com/velocitypowered/proxy/network/protocol/packet/brigadier/ArgumentPropertySerializer.java similarity index 93% rename from proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/brigadier/ArgumentPropertySerializer.java rename to proxy/src/main/java/com/velocitypowered/proxy/network/protocol/packet/brigadier/ArgumentPropertySerializer.java index 25dcfd76c..33ee1d7a5 100644 --- a/proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/brigadier/ArgumentPropertySerializer.java +++ b/proxy/src/main/java/com/velocitypowered/proxy/network/protocol/packet/brigadier/ArgumentPropertySerializer.java @@ -15,7 +15,7 @@ * along with this program. If not, see . */ -package com.velocitypowered.proxy.protocol.packet.brigadier; +package com.velocitypowered.proxy.network.protocol.packet.brigadier; import com.velocitypowered.api.network.ProtocolVersion; import io.netty.buffer.ByteBuf; diff --git a/proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/brigadier/ByteArgumentPropertySerializer.java b/proxy/src/main/java/com/velocitypowered/proxy/network/protocol/packet/brigadier/ByteArgumentPropertySerializer.java similarity index 94% rename from proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/brigadier/ByteArgumentPropertySerializer.java rename to proxy/src/main/java/com/velocitypowered/proxy/network/protocol/packet/brigadier/ByteArgumentPropertySerializer.java index e70bfe33a..eb5e305f7 100644 --- a/proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/brigadier/ByteArgumentPropertySerializer.java +++ b/proxy/src/main/java/com/velocitypowered/proxy/network/protocol/packet/brigadier/ByteArgumentPropertySerializer.java @@ -15,7 +15,7 @@ * along with this program. If not, see . */ -package com.velocitypowered.proxy.protocol.packet.brigadier; +package com.velocitypowered.proxy.network.protocol.packet.brigadier; import com.velocitypowered.api.network.ProtocolVersion; import io.netty.buffer.ByteBuf; diff --git a/proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/brigadier/DoubleArgumentPropertySerializer.java b/proxy/src/main/java/com/velocitypowered/proxy/network/protocol/packet/brigadier/DoubleArgumentPropertySerializer.java similarity index 73% rename from proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/brigadier/DoubleArgumentPropertySerializer.java rename to proxy/src/main/java/com/velocitypowered/proxy/network/protocol/packet/brigadier/DoubleArgumentPropertySerializer.java index 0cebad719..2fd1c799b 100644 --- a/proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/brigadier/DoubleArgumentPropertySerializer.java +++ b/proxy/src/main/java/com/velocitypowered/proxy/network/protocol/packet/brigadier/DoubleArgumentPropertySerializer.java @@ -15,11 +15,7 @@ * along with this program. If not, see . */ -package com.velocitypowered.proxy.protocol.packet.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; +package com.velocitypowered.proxy.network.protocol.packet.brigadier; import com.mojang.brigadier.arguments.DoubleArgumentType; import com.velocitypowered.api.network.ProtocolVersion; @@ -35,8 +31,10 @@ class DoubleArgumentPropertySerializer implements ArgumentPropertySerializer. */ -package com.velocitypowered.proxy.protocol.packet.brigadier; +package com.velocitypowered.proxy.network.protocol.packet.brigadier; import com.velocitypowered.api.network.ProtocolVersion; import io.netty.buffer.ByteBuf; diff --git a/proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/brigadier/FloatArgumentPropertySerializer.java b/proxy/src/main/java/com/velocitypowered/proxy/network/protocol/packet/brigadier/FloatArgumentPropertySerializer.java similarity index 82% rename from proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/brigadier/FloatArgumentPropertySerializer.java rename to proxy/src/main/java/com/velocitypowered/proxy/network/protocol/packet/brigadier/FloatArgumentPropertySerializer.java index af8996d54..6b824015c 100644 --- a/proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/brigadier/FloatArgumentPropertySerializer.java +++ b/proxy/src/main/java/com/velocitypowered/proxy/network/protocol/packet/brigadier/FloatArgumentPropertySerializer.java @@ -15,11 +15,11 @@ * along with this program. If not, see . */ -package com.velocitypowered.proxy.protocol.packet.brigadier; +package com.velocitypowered.proxy.network.protocol.packet.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.protocol.packet.brigadier.IntegerArgumentPropertySerializer.HAS_MAXIMUM; +import static com.velocitypowered.proxy.network.protocol.packet.brigadier.IntegerArgumentPropertySerializer.HAS_MINIMUM; +import static com.velocitypowered.proxy.network.protocol.packet.brigadier.IntegerArgumentPropertySerializer.getFlags; import com.mojang.brigadier.arguments.FloatArgumentType; import com.velocitypowered.api.network.ProtocolVersion; diff --git a/proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/brigadier/IntegerArgumentPropertySerializer.java b/proxy/src/main/java/com/velocitypowered/proxy/network/protocol/packet/brigadier/IntegerArgumentPropertySerializer.java similarity index 97% rename from proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/brigadier/IntegerArgumentPropertySerializer.java rename to proxy/src/main/java/com/velocitypowered/proxy/network/protocol/packet/brigadier/IntegerArgumentPropertySerializer.java index 32e87188b..82e336327 100644 --- a/proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/brigadier/IntegerArgumentPropertySerializer.java +++ b/proxy/src/main/java/com/velocitypowered/proxy/network/protocol/packet/brigadier/IntegerArgumentPropertySerializer.java @@ -15,7 +15,7 @@ * along with this program. If not, see . */ -package com.velocitypowered.proxy.protocol.packet.brigadier; +package com.velocitypowered.proxy.network.protocol.packet.brigadier; import com.mojang.brigadier.arguments.IntegerArgumentType; import com.velocitypowered.api.network.ProtocolVersion; diff --git a/proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/brigadier/LongArgumentPropertySerializer.java b/proxy/src/main/java/com/velocitypowered/proxy/network/protocol/packet/brigadier/LongArgumentPropertySerializer.java similarity index 81% rename from proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/brigadier/LongArgumentPropertySerializer.java rename to proxy/src/main/java/com/velocitypowered/proxy/network/protocol/packet/brigadier/LongArgumentPropertySerializer.java index 2f42731e8..49aa8bb8c 100644 --- a/proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/brigadier/LongArgumentPropertySerializer.java +++ b/proxy/src/main/java/com/velocitypowered/proxy/network/protocol/packet/brigadier/LongArgumentPropertySerializer.java @@ -15,11 +15,11 @@ * along with this program. If not, see . */ -package com.velocitypowered.proxy.protocol.packet.brigadier; +package com.velocitypowered.proxy.network.protocol.packet.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.protocol.packet.brigadier.IntegerArgumentPropertySerializer.HAS_MAXIMUM; +import static com.velocitypowered.proxy.network.protocol.packet.brigadier.IntegerArgumentPropertySerializer.HAS_MINIMUM; +import static com.velocitypowered.proxy.network.protocol.packet.brigadier.IntegerArgumentPropertySerializer.getFlags; import com.mojang.brigadier.arguments.LongArgumentType; import com.velocitypowered.api.network.ProtocolVersion; diff --git a/proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/brigadier/ModArgumentProperty.java b/proxy/src/main/java/com/velocitypowered/proxy/network/protocol/packet/brigadier/ModArgumentProperty.java similarity index 96% rename from proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/brigadier/ModArgumentProperty.java rename to proxy/src/main/java/com/velocitypowered/proxy/network/protocol/packet/brigadier/ModArgumentProperty.java index 15416f861..d7fc482e4 100644 --- a/proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/brigadier/ModArgumentProperty.java +++ b/proxy/src/main/java/com/velocitypowered/proxy/network/protocol/packet/brigadier/ModArgumentProperty.java @@ -15,7 +15,7 @@ * along with this program. If not, see . */ -package com.velocitypowered.proxy.protocol.packet.brigadier; +package com.velocitypowered.proxy.network.protocol.packet.brigadier; import com.mojang.brigadier.StringReader; import com.mojang.brigadier.arguments.ArgumentType; diff --git a/proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/brigadier/ModArgumentPropertySerializer.java b/proxy/src/main/java/com/velocitypowered/proxy/network/protocol/packet/brigadier/ModArgumentPropertySerializer.java similarity index 93% rename from proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/brigadier/ModArgumentPropertySerializer.java rename to proxy/src/main/java/com/velocitypowered/proxy/network/protocol/packet/brigadier/ModArgumentPropertySerializer.java index 385172022..e102b5b80 100644 --- a/proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/brigadier/ModArgumentPropertySerializer.java +++ b/proxy/src/main/java/com/velocitypowered/proxy/network/protocol/packet/brigadier/ModArgumentPropertySerializer.java @@ -15,10 +15,10 @@ * along with this program. If not, see . */ -package com.velocitypowered.proxy.protocol.packet.brigadier; +package com.velocitypowered.proxy.network.protocol.packet.brigadier; import com.velocitypowered.api.network.ProtocolVersion; -import com.velocitypowered.proxy.protocol.ProtocolUtils; +import com.velocitypowered.proxy.network.protocol.ProtocolUtils; import io.netty.buffer.ByteBuf; import io.netty.buffer.Unpooled; import org.checkerframework.checker.nullness.qual.Nullable; diff --git a/proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/brigadier/PassthroughProperty.java b/proxy/src/main/java/com/velocitypowered/proxy/network/protocol/packet/brigadier/PassthroughProperty.java similarity index 95% rename from proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/brigadier/PassthroughProperty.java rename to proxy/src/main/java/com/velocitypowered/proxy/network/protocol/packet/brigadier/PassthroughProperty.java index 74f34ec6e..847336dc7 100644 --- a/proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/brigadier/PassthroughProperty.java +++ b/proxy/src/main/java/com/velocitypowered/proxy/network/protocol/packet/brigadier/PassthroughProperty.java @@ -15,7 +15,7 @@ * along with this program. If not, see . */ -package com.velocitypowered.proxy.protocol.packet.brigadier; +package com.velocitypowered.proxy.network.protocol.packet.brigadier; import com.mojang.brigadier.StringReader; import com.mojang.brigadier.arguments.ArgumentType; diff --git a/proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/brigadier/RegistryKeyArgument.java b/proxy/src/main/java/com/velocitypowered/proxy/network/protocol/packet/brigadier/RegistryKeyArgument.java similarity index 94% rename from proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/brigadier/RegistryKeyArgument.java rename to proxy/src/main/java/com/velocitypowered/proxy/network/protocol/packet/brigadier/RegistryKeyArgument.java index 6d55b246f..e0e34fa7b 100644 --- a/proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/brigadier/RegistryKeyArgument.java +++ b/proxy/src/main/java/com/velocitypowered/proxy/network/protocol/packet/brigadier/RegistryKeyArgument.java @@ -15,7 +15,7 @@ * along with this program. If not, see . */ -package com.velocitypowered.proxy.protocol.packet.brigadier; +package com.velocitypowered.proxy.network.protocol.packet.brigadier; import com.mojang.brigadier.StringReader; import com.mojang.brigadier.arguments.ArgumentType; @@ -31,7 +31,7 @@ import java.util.concurrent.CompletableFuture; public class RegistryKeyArgument implements ArgumentType { private static final List EXAMPLES = Arrays.asList("foo", "foo:bar", "012"); - private String identifier; + private final String identifier; public RegistryKeyArgument(String identifier) { this.identifier = identifier; diff --git a/proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/brigadier/RegistryKeyArgumentList.java b/proxy/src/main/java/com/velocitypowered/proxy/network/protocol/packet/brigadier/RegistryKeyArgumentList.java similarity index 96% rename from proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/brigadier/RegistryKeyArgumentList.java rename to proxy/src/main/java/com/velocitypowered/proxy/network/protocol/packet/brigadier/RegistryKeyArgumentList.java index fbd0b623b..23d1dde0b 100644 --- a/proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/brigadier/RegistryKeyArgumentList.java +++ b/proxy/src/main/java/com/velocitypowered/proxy/network/protocol/packet/brigadier/RegistryKeyArgumentList.java @@ -15,10 +15,10 @@ * along with this program. If not, see . */ -package com.velocitypowered.proxy.protocol.packet.brigadier; +package com.velocitypowered.proxy.network.protocol.packet.brigadier; import com.velocitypowered.api.network.ProtocolVersion; -import com.velocitypowered.proxy.protocol.ProtocolUtils; +import com.velocitypowered.proxy.network.protocol.ProtocolUtils; import io.netty.buffer.ByteBuf; public final class RegistryKeyArgumentList { diff --git a/proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/brigadier/RegistryKeyArgumentSerializer.java b/proxy/src/main/java/com/velocitypowered/proxy/network/protocol/packet/brigadier/RegistryKeyArgumentSerializer.java similarity index 90% rename from proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/brigadier/RegistryKeyArgumentSerializer.java rename to proxy/src/main/java/com/velocitypowered/proxy/network/protocol/packet/brigadier/RegistryKeyArgumentSerializer.java index 6ada6157b..62e6e9319 100644 --- a/proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/brigadier/RegistryKeyArgumentSerializer.java +++ b/proxy/src/main/java/com/velocitypowered/proxy/network/protocol/packet/brigadier/RegistryKeyArgumentSerializer.java @@ -15,10 +15,10 @@ * along with this program. If not, see . */ -package com.velocitypowered.proxy.protocol.packet.brigadier; +package com.velocitypowered.proxy.network.protocol.packet.brigadier; import com.velocitypowered.api.network.ProtocolVersion; -import com.velocitypowered.proxy.protocol.ProtocolUtils; +import com.velocitypowered.proxy.network.protocol.ProtocolUtils; import io.netty.buffer.ByteBuf; public class RegistryKeyArgumentSerializer implements diff --git a/proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/brigadier/StringArgumentPropertySerializer.java b/proxy/src/main/java/com/velocitypowered/proxy/network/protocol/packet/brigadier/StringArgumentPropertySerializer.java similarity index 94% rename from proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/brigadier/StringArgumentPropertySerializer.java rename to proxy/src/main/java/com/velocitypowered/proxy/network/protocol/packet/brigadier/StringArgumentPropertySerializer.java index 75f5ecc86..6c9d0fa7e 100644 --- a/proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/brigadier/StringArgumentPropertySerializer.java +++ b/proxy/src/main/java/com/velocitypowered/proxy/network/protocol/packet/brigadier/StringArgumentPropertySerializer.java @@ -15,11 +15,11 @@ * along with this program. If not, see . */ -package com.velocitypowered.proxy.protocol.packet.brigadier; +package com.velocitypowered.proxy.network.protocol.packet.brigadier; import com.mojang.brigadier.arguments.StringArgumentType; import com.velocitypowered.api.network.ProtocolVersion; -import com.velocitypowered.proxy.protocol.ProtocolUtils; +import com.velocitypowered.proxy.network.protocol.ProtocolUtils; import io.netty.buffer.ByteBuf; /** diff --git a/proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/brigadier/TimeArgumentSerializer.java b/proxy/src/main/java/com/velocitypowered/proxy/network/protocol/packet/brigadier/TimeArgumentSerializer.java similarity index 95% rename from proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/brigadier/TimeArgumentSerializer.java rename to proxy/src/main/java/com/velocitypowered/proxy/network/protocol/packet/brigadier/TimeArgumentSerializer.java index 1ddbcd68e..62f6ff4af 100644 --- a/proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/brigadier/TimeArgumentSerializer.java +++ b/proxy/src/main/java/com/velocitypowered/proxy/network/protocol/packet/brigadier/TimeArgumentSerializer.java @@ -15,7 +15,7 @@ * along with this program. If not, see . */ -package com.velocitypowered.proxy.protocol.packet.brigadier; +package com.velocitypowered.proxy.network.protocol.packet.brigadier; import com.velocitypowered.api.network.ProtocolVersion; import io.netty.buffer.ByteBuf; diff --git a/proxy/src/main/java/com/velocitypowered/proxy/network/protocol/packet/chat/ChatAcknowledgement.java b/proxy/src/main/java/com/velocitypowered/proxy/network/protocol/packet/chat/ChatAcknowledgement.java new file mode 100644 index 000000000..764bb0a9c --- /dev/null +++ b/proxy/src/main/java/com/velocitypowered/proxy/network/protocol/packet/chat/ChatAcknowledgement.java @@ -0,0 +1,58 @@ +/* + * Copyright (C) 2023 Velocity Contributors + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.velocitypowered.proxy.network.protocol.packet.chat; + +import com.velocitypowered.api.network.ProtocolVersion; +import com.velocitypowered.proxy.connection.MinecraftSessionHandler; +import com.velocitypowered.proxy.network.protocol.MinecraftPacket; +import com.velocitypowered.proxy.network.protocol.ProtocolUtils; +import com.velocitypowered.proxy.network.protocol.ProtocolUtils.Direction; +import io.netty.buffer.ByteBuf; + +public class ChatAcknowledgement implements MinecraftPacket { + + int offset; + + public ChatAcknowledgement(int offset) { + this.offset = offset; + } + + public ChatAcknowledgement() { + } + + @Override + public void decode(ByteBuf buf, Direction direction, ProtocolVersion protocolVersion) { + offset = ProtocolUtils.readVarInt(buf); + } + + @Override + public void encode(ByteBuf buf, ProtocolUtils.Direction direction, + ProtocolVersion protocolVersion) { + ProtocolUtils.writeVarInt(buf, offset); + } + + @Override + public boolean handle(MinecraftSessionHandler handler) { + return handler.handle(this); + } + + @Override + public String toString() { + return "ChatAcknowledgement{offset=" + offset + '}'; + } +} diff --git a/proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/chat/ChatHandler.java b/proxy/src/main/java/com/velocitypowered/proxy/network/protocol/packet/chat/ChatHandler.java similarity index 88% rename from proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/chat/ChatHandler.java rename to proxy/src/main/java/com/velocitypowered/proxy/network/protocol/packet/chat/ChatHandler.java index 0cd2f44af..c66dfa157 100644 --- a/proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/chat/ChatHandler.java +++ b/proxy/src/main/java/com/velocitypowered/proxy/network/protocol/packet/chat/ChatHandler.java @@ -15,9 +15,9 @@ * along with this program. If not, see . */ -package com.velocitypowered.proxy.protocol.packet.chat; +package com.velocitypowered.proxy.network.protocol.packet.chat; -import com.velocitypowered.proxy.protocol.MinecraftPacket; +import com.velocitypowered.proxy.network.protocol.MinecraftPacket; public interface ChatHandler { diff --git a/proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/chat/ChatQueue.java b/proxy/src/main/java/com/velocitypowered/proxy/network/protocol/packet/chat/ChatQueue.java similarity index 95% rename from proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/chat/ChatQueue.java rename to proxy/src/main/java/com/velocitypowered/proxy/network/protocol/packet/chat/ChatQueue.java index 67242d9a5..501e0f6d2 100644 --- a/proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/chat/ChatQueue.java +++ b/proxy/src/main/java/com/velocitypowered/proxy/network/protocol/packet/chat/ChatQueue.java @@ -15,11 +15,11 @@ * along with this program. If not, see . */ -package com.velocitypowered.proxy.protocol.packet.chat; +package com.velocitypowered.proxy.network.protocol.packet.chat; import com.velocitypowered.proxy.connection.MinecraftConnection; import com.velocitypowered.proxy.connection.client.ConnectedPlayer; -import com.velocitypowered.proxy.protocol.MinecraftPacket; +import com.velocitypowered.proxy.network.protocol.MinecraftPacket; import java.time.Instant; import java.util.concurrent.CompletableFuture; import java.util.function.BiConsumer; @@ -47,8 +47,8 @@ public class ChatQueue { /** * Queues a packet sent from the player - all packets must wait until this processes to send their - * packets. This maintains order on the server-level for the client insertions of commands - * and messages. All entries are locked through an internal object lock. + * packets. This maintains order on the server-level for the client insertions of commands and + * messages. All entries are locked through an internal object lock. * * @param nextPacket the {@link CompletableFuture} which will provide the next-processed packet. * @param timestamp the {@link Instant} timestamp of this packet so we can allow piggybacking. @@ -101,6 +101,7 @@ public class ChatQueue { binder.whenComplete((ignored1, ignored2) -> future.whenComplete(writePacket(connection))); } + @SuppressWarnings("checkstyle:LineLength") private static CompletableFuture hijackCurrentPacket( MinecraftConnection connection, CompletableFuture binder, diff --git a/proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/chat/ChatTimeKeeper.java b/proxy/src/main/java/com/velocitypowered/proxy/network/protocol/packet/chat/ChatTimeKeeper.java similarity index 94% rename from proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/chat/ChatTimeKeeper.java rename to proxy/src/main/java/com/velocitypowered/proxy/network/protocol/packet/chat/ChatTimeKeeper.java index 94fc53567..c0599281b 100644 --- a/proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/chat/ChatTimeKeeper.java +++ b/proxy/src/main/java/com/velocitypowered/proxy/network/protocol/packet/chat/ChatTimeKeeper.java @@ -15,7 +15,7 @@ * along with this program. If not, see . */ -package com.velocitypowered.proxy.protocol.packet.chat; +package com.velocitypowered.proxy.network.protocol.packet.chat; import java.time.Instant; diff --git a/proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/chat/ChatType.java b/proxy/src/main/java/com/velocitypowered/proxy/network/protocol/packet/chat/ChatType.java similarity index 93% rename from proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/chat/ChatType.java rename to proxy/src/main/java/com/velocitypowered/proxy/network/protocol/packet/chat/ChatType.java index 66e4e9884..978978e33 100644 --- a/proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/chat/ChatType.java +++ b/proxy/src/main/java/com/velocitypowered/proxy/network/protocol/packet/chat/ChatType.java @@ -15,7 +15,7 @@ * along with this program. If not, see . */ -package com.velocitypowered.proxy.protocol.packet.chat; +package com.velocitypowered.proxy.network.protocol.packet.chat; public enum ChatType { CHAT((byte) 0), diff --git a/proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/chat/CommandHandler.java b/proxy/src/main/java/com/velocitypowered/proxy/network/protocol/packet/chat/CommandHandler.java similarity index 91% rename from proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/chat/CommandHandler.java rename to proxy/src/main/java/com/velocitypowered/proxy/network/protocol/packet/chat/CommandHandler.java index c778eecd0..045b2ee57 100644 --- a/proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/chat/CommandHandler.java +++ b/proxy/src/main/java/com/velocitypowered/proxy/network/protocol/packet/chat/CommandHandler.java @@ -15,12 +15,12 @@ * along with this program. If not, see . */ -package com.velocitypowered.proxy.protocol.packet.chat; +package com.velocitypowered.proxy.network.protocol.packet.chat; import com.velocitypowered.api.event.command.CommandExecuteEvent; import com.velocitypowered.proxy.VelocityServer; import com.velocitypowered.proxy.connection.client.ConnectedPlayer; -import com.velocitypowered.proxy.protocol.MinecraftPacket; +import com.velocitypowered.proxy.network.protocol.MinecraftPacket; import java.time.Instant; import java.util.concurrent.CompletableFuture; import java.util.function.Function; @@ -64,7 +64,8 @@ public interface CommandHandler { } return pkt; }).exceptionally(e -> { - logger.info("Exception occurred while running command for {}", player.getUsername(), e); + logger.info( + "Exception occurred while running command for {}", player.getUsername(), e); player.sendMessage( Component.translatable("velocity.command.generic-error", NamedTextColor.RED)); return null; diff --git a/proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/chat/LastSeenMessages.java b/proxy/src/main/java/com/velocitypowered/proxy/network/protocol/packet/chat/LastSeenMessages.java similarity index 82% rename from proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/chat/LastSeenMessages.java rename to proxy/src/main/java/com/velocitypowered/proxy/network/protocol/packet/chat/LastSeenMessages.java index a1ed539d6..fc9e30ab3 100644 --- a/proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/chat/LastSeenMessages.java +++ b/proxy/src/main/java/com/velocitypowered/proxy/network/protocol/packet/chat/LastSeenMessages.java @@ -15,9 +15,9 @@ * along with this program. If not, see . */ -package com.velocitypowered.proxy.protocol.packet.chat; +package com.velocitypowered.proxy.network.protocol.packet.chat; -import com.velocitypowered.proxy.protocol.ProtocolUtils; +import com.velocitypowered.proxy.network.protocol.ProtocolUtils; import io.netty.buffer.ByteBuf; import java.util.Arrays; import java.util.BitSet; @@ -25,8 +25,8 @@ import java.util.BitSet; public class LastSeenMessages { private static final int DIV_FLOOR = -Math.floorDiv(-20, 8); - private int offset; - private BitSet acknowledged; + private final int offset; + private final BitSet acknowledged; public LastSeenMessages() { this.offset = 0; @@ -56,9 +56,9 @@ public class LastSeenMessages { @Override public String toString() { - return "LastSeenMessages{" + - "offset=" + offset + - ", acknowledged=" + acknowledged + - '}'; + return "LastSeenMessages{" + + "offset=" + offset + + ", acknowledged=" + acknowledged + + '}'; } } diff --git a/proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/chat/PlayerChatCompletion.java b/proxy/src/main/java/com/velocitypowered/proxy/network/protocol/packet/chat/PlayerChatCompletion.java similarity index 84% rename from proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/chat/PlayerChatCompletion.java rename to proxy/src/main/java/com/velocitypowered/proxy/network/protocol/packet/chat/PlayerChatCompletion.java index 3779f468f..9ff4ae89b 100644 --- a/proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/chat/PlayerChatCompletion.java +++ b/proxy/src/main/java/com/velocitypowered/proxy/network/protocol/packet/chat/PlayerChatCompletion.java @@ -15,12 +15,13 @@ * along with this program. If not, see . */ -package com.velocitypowered.proxy.protocol.packet.chat; +package com.velocitypowered.proxy.network.protocol.packet.chat; import com.velocitypowered.api.network.ProtocolVersion; import com.velocitypowered.proxy.connection.MinecraftSessionHandler; -import com.velocitypowered.proxy.protocol.MinecraftPacket; -import com.velocitypowered.proxy.protocol.ProtocolUtils; +import com.velocitypowered.proxy.network.protocol.MinecraftPacket; +import com.velocitypowered.proxy.network.protocol.ProtocolUtils; +import com.velocitypowered.proxy.network.protocol.ProtocolUtils.Direction; import io.netty.buffer.ByteBuf; public class PlayerChatCompletion implements MinecraftPacket { @@ -46,7 +47,7 @@ public class PlayerChatCompletion implements MinecraftPacket { } @Override - public void decode(ByteBuf buf, ProtocolUtils.Direction direction, + public void decode(ByteBuf buf, Direction direction, ProtocolVersion protocolVersion) { action = Action.values()[ProtocolUtils.readVarInt(buf)]; completions = ProtocolUtils.readStringArray(buf); diff --git a/proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/chat/RemoteChatSession.java b/proxy/src/main/java/com/velocitypowered/proxy/network/protocol/packet/chat/RemoteChatSession.java similarity index 93% rename from proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/chat/RemoteChatSession.java rename to proxy/src/main/java/com/velocitypowered/proxy/network/protocol/packet/chat/RemoteChatSession.java index 9dd5950a9..ba55d80df 100644 --- a/proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/chat/RemoteChatSession.java +++ b/proxy/src/main/java/com/velocitypowered/proxy/network/protocol/packet/chat/RemoteChatSession.java @@ -15,12 +15,12 @@ * along with this program. If not, see . */ -package com.velocitypowered.proxy.protocol.packet.chat; +package com.velocitypowered.proxy.network.protocol.packet.chat; import com.velocitypowered.api.network.ProtocolVersion; import com.velocitypowered.api.proxy.crypto.IdentifiedKey; import com.velocitypowered.api.proxy.player.ChatSession; -import com.velocitypowered.proxy.protocol.ProtocolUtils; +import com.velocitypowered.proxy.network.protocol.ProtocolUtils; import io.netty.buffer.ByteBuf; import java.util.Objects; import java.util.UUID; diff --git a/proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/chat/SystemChat.java b/proxy/src/main/java/com/velocitypowered/proxy/network/protocol/packet/chat/SystemChat.java similarity index 87% rename from proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/chat/SystemChat.java rename to proxy/src/main/java/com/velocitypowered/proxy/network/protocol/packet/chat/SystemChat.java index 48b19450f..9ad012917 100644 --- a/proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/chat/SystemChat.java +++ b/proxy/src/main/java/com/velocitypowered/proxy/network/protocol/packet/chat/SystemChat.java @@ -15,12 +15,13 @@ * along with this program. If not, see . */ -package com.velocitypowered.proxy.protocol.packet.chat; +package com.velocitypowered.proxy.network.protocol.packet.chat; import com.velocitypowered.api.network.ProtocolVersion; import com.velocitypowered.proxy.connection.MinecraftSessionHandler; -import com.velocitypowered.proxy.protocol.MinecraftPacket; -import com.velocitypowered.proxy.protocol.ProtocolUtils; +import com.velocitypowered.proxy.network.protocol.MinecraftPacket; +import com.velocitypowered.proxy.network.protocol.ProtocolUtils; +import com.velocitypowered.proxy.network.protocol.ProtocolUtils.Direction; import io.netty.buffer.ByteBuf; import net.kyori.adventure.text.Component; @@ -46,7 +47,7 @@ public class SystemChat implements MinecraftPacket { } @Override - public void decode(ByteBuf buf, ProtocolUtils.Direction direction, + public void decode(ByteBuf buf, Direction direction, ProtocolVersion protocolVersion) { component = ProtocolUtils.getJsonChatSerializer(protocolVersion) .deserialize(ProtocolUtils.readString(buf)); diff --git a/proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/chat/builder/ChatBuilderFactory.java b/proxy/src/main/java/com/velocitypowered/proxy/network/protocol/packet/chat/builder/ChatBuilderFactory.java similarity index 81% rename from proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/chat/builder/ChatBuilderFactory.java rename to proxy/src/main/java/com/velocitypowered/proxy/network/protocol/packet/chat/builder/ChatBuilderFactory.java index 2d1d78981..8f146d99c 100644 --- a/proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/chat/builder/ChatBuilderFactory.java +++ b/proxy/src/main/java/com/velocitypowered/proxy/network/protocol/packet/chat/builder/ChatBuilderFactory.java @@ -15,12 +15,12 @@ * along with this program. If not, see . */ -package com.velocitypowered.proxy.protocol.packet.chat.builder; +package com.velocitypowered.proxy.network.protocol.packet.chat.builder; import com.velocitypowered.api.network.ProtocolVersion; -import com.velocitypowered.proxy.protocol.packet.chat.keyed.KeyedChatBuilder; -import com.velocitypowered.proxy.protocol.packet.chat.legacy.LegacyChatBuilder; -import com.velocitypowered.proxy.protocol.packet.chat.session.SessionChatBuilder; +import com.velocitypowered.proxy.network.protocol.packet.chat.keyed.KeyedChatBuilder; +import com.velocitypowered.proxy.network.protocol.packet.chat.legacy.LegacyChatBuilder; +import com.velocitypowered.proxy.network.protocol.packet.chat.session.SessionChatBuilder; import java.util.function.Function; public class ChatBuilderFactory { diff --git a/proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/chat/builder/ChatBuilderV2.java b/proxy/src/main/java/com/velocitypowered/proxy/network/protocol/packet/chat/builder/ChatBuilderV2.java similarity index 91% rename from proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/chat/builder/ChatBuilderV2.java rename to proxy/src/main/java/com/velocitypowered/proxy/network/protocol/packet/chat/builder/ChatBuilderV2.java index e9e24c2a0..22c529ca0 100644 --- a/proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/chat/builder/ChatBuilderV2.java +++ b/proxy/src/main/java/com/velocitypowered/proxy/network/protocol/packet/chat/builder/ChatBuilderV2.java @@ -15,12 +15,12 @@ * along with this program. If not, see . */ -package com.velocitypowered.proxy.protocol.packet.chat.builder; +package com.velocitypowered.proxy.network.protocol.packet.chat.builder; import com.velocitypowered.api.network.ProtocolVersion; import com.velocitypowered.api.proxy.Player; -import com.velocitypowered.proxy.protocol.MinecraftPacket; -import com.velocitypowered.proxy.protocol.packet.chat.ChatType; +import com.velocitypowered.proxy.network.protocol.MinecraftPacket; +import com.velocitypowered.proxy.network.protocol.packet.chat.ChatType; import java.time.Instant; import net.kyori.adventure.identity.Identity; import net.kyori.adventure.text.Component; diff --git a/proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/chat/keyed/KeyedChatBuilder.java b/proxy/src/main/java/com/velocitypowered/proxy/network/protocol/packet/chat/keyed/KeyedChatBuilder.java similarity index 81% rename from proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/chat/keyed/KeyedChatBuilder.java rename to proxy/src/main/java/com/velocitypowered/proxy/network/protocol/packet/chat/keyed/KeyedChatBuilder.java index 830862cab..6232aa104 100644 --- a/proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/chat/keyed/KeyedChatBuilder.java +++ b/proxy/src/main/java/com/velocitypowered/proxy/network/protocol/packet/chat/keyed/KeyedChatBuilder.java @@ -15,14 +15,14 @@ * along with this program. If not, see . */ -package com.velocitypowered.proxy.protocol.packet.chat.keyed; +package com.velocitypowered.proxy.network.protocol.packet.chat.keyed; import com.google.common.collect.ImmutableList; import com.velocitypowered.api.network.ProtocolVersion; -import com.velocitypowered.proxy.protocol.MinecraftPacket; -import com.velocitypowered.proxy.protocol.packet.chat.ChatType; -import com.velocitypowered.proxy.protocol.packet.chat.SystemChat; -import com.velocitypowered.proxy.protocol.packet.chat.builder.ChatBuilderV2; +import com.velocitypowered.proxy.network.protocol.MinecraftPacket; +import com.velocitypowered.proxy.network.protocol.packet.chat.ChatType; +import com.velocitypowered.proxy.network.protocol.packet.chat.SystemChat; +import com.velocitypowered.proxy.network.protocol.packet.chat.builder.ChatBuilderV2; import net.kyori.adventure.text.Component; public class KeyedChatBuilder extends ChatBuilderV2 { diff --git a/proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/chat/keyed/KeyedChatHandler.java b/proxy/src/main/java/com/velocitypowered/proxy/network/protocol/packet/chat/keyed/KeyedChatHandler.java similarity index 93% rename from proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/chat/keyed/KeyedChatHandler.java rename to proxy/src/main/java/com/velocitypowered/proxy/network/protocol/packet/chat/keyed/KeyedChatHandler.java index af4d25e0d..1d706c8b8 100644 --- a/proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/chat/keyed/KeyedChatHandler.java +++ b/proxy/src/main/java/com/velocitypowered/proxy/network/protocol/packet/chat/keyed/KeyedChatHandler.java @@ -15,15 +15,16 @@ * along with this program. If not, see . */ -package com.velocitypowered.proxy.protocol.packet.chat.keyed; +package com.velocitypowered.proxy.network.protocol.packet.chat.keyed; import com.velocitypowered.api.event.EventManager; import com.velocitypowered.api.event.player.PlayerChatEvent; import com.velocitypowered.api.proxy.crypto.IdentifiedKey; import com.velocitypowered.proxy.VelocityServer; import com.velocitypowered.proxy.connection.client.ConnectedPlayer; -import com.velocitypowered.proxy.protocol.MinecraftPacket; -import com.velocitypowered.proxy.protocol.packet.chat.ChatQueue; +import com.velocitypowered.proxy.network.protocol.MinecraftPacket; +import com.velocitypowered.proxy.network.protocol.packet.chat.ChatHandler; +import com.velocitypowered.proxy.network.protocol.packet.chat.ChatQueue; import java.util.concurrent.CompletableFuture; import java.util.function.Function; import net.kyori.adventure.text.Component; @@ -31,7 +32,7 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; public class KeyedChatHandler implements - com.velocitypowered.proxy.protocol.packet.chat.ChatHandler { + ChatHandler { private static final Logger logger = LogManager.getLogger(KeyedChatHandler.class); diff --git a/proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/chat/keyed/KeyedCommandHandler.java b/proxy/src/main/java/com/velocitypowered/proxy/network/protocol/packet/chat/keyed/KeyedCommandHandler.java similarity index 95% rename from proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/chat/keyed/KeyedCommandHandler.java rename to proxy/src/main/java/com/velocitypowered/proxy/network/protocol/packet/chat/keyed/KeyedCommandHandler.java index 193371aad..92aab1add 100644 --- a/proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/chat/keyed/KeyedCommandHandler.java +++ b/proxy/src/main/java/com/velocitypowered/proxy/network/protocol/packet/chat/keyed/KeyedCommandHandler.java @@ -15,14 +15,14 @@ * along with this program. If not, see . */ -package com.velocitypowered.proxy.protocol.packet.chat.keyed; +package com.velocitypowered.proxy.network.protocol.packet.chat.keyed; import com.velocitypowered.api.event.command.CommandExecuteEvent; import com.velocitypowered.api.proxy.crypto.IdentifiedKey; import com.velocitypowered.proxy.VelocityServer; import com.velocitypowered.proxy.connection.client.ConnectedPlayer; -import com.velocitypowered.proxy.protocol.packet.chat.CommandHandler; -import com.velocitypowered.proxy.protocol.packet.chat.builder.ChatBuilderV2; +import com.velocitypowered.proxy.network.protocol.packet.chat.CommandHandler; +import com.velocitypowered.proxy.network.protocol.packet.chat.builder.ChatBuilderV2; import java.util.concurrent.CompletableFuture; import net.kyori.adventure.text.Component; diff --git a/proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/chat/keyed/KeyedPlayerChat.java b/proxy/src/main/java/com/velocitypowered/proxy/network/protocol/packet/chat/keyed/KeyedPlayerChat.java similarity index 93% rename from proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/chat/keyed/KeyedPlayerChat.java rename to proxy/src/main/java/com/velocitypowered/proxy/network/protocol/packet/chat/keyed/KeyedPlayerChat.java index d57627056..52276c1fb 100644 --- a/proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/chat/keyed/KeyedPlayerChat.java +++ b/proxy/src/main/java/com/velocitypowered/proxy/network/protocol/packet/chat/keyed/KeyedPlayerChat.java @@ -15,15 +15,16 @@ * along with this program. If not, see . */ -package com.velocitypowered.proxy.protocol.packet.chat.keyed; +package com.velocitypowered.proxy.network.protocol.packet.chat.keyed; import com.google.common.primitives.Longs; import com.velocitypowered.api.network.ProtocolVersion; import com.velocitypowered.proxy.connection.MinecraftSessionHandler; import com.velocitypowered.proxy.crypto.EncryptionUtils; import com.velocitypowered.proxy.crypto.SignaturePair; -import com.velocitypowered.proxy.protocol.MinecraftPacket; -import com.velocitypowered.proxy.protocol.ProtocolUtils; +import com.velocitypowered.proxy.network.protocol.MinecraftPacket; +import com.velocitypowered.proxy.network.protocol.ProtocolUtils; +import com.velocitypowered.proxy.network.protocol.ProtocolUtils.Direction; import com.velocitypowered.proxy.util.except.QuietDecoderException; import io.netty.buffer.ByteBuf; import java.time.Instant; @@ -74,7 +75,7 @@ public class KeyedPlayerChat implements MinecraftPacket { } @Override - public void decode(ByteBuf buf, ProtocolUtils.Direction direction, + public void decode(ByteBuf buf, Direction direction, ProtocolVersion protocolVersion) { message = ProtocolUtils.readString(buf, 256); diff --git a/proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/chat/keyed/KeyedPlayerCommand.java b/proxy/src/main/java/com/velocitypowered/proxy/network/protocol/packet/chat/keyed/KeyedPlayerCommand.java similarity index 90% rename from proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/chat/keyed/KeyedPlayerCommand.java rename to proxy/src/main/java/com/velocitypowered/proxy/network/protocol/packet/chat/keyed/KeyedPlayerCommand.java index d45f93daf..0a4e7a589 100644 --- a/proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/chat/keyed/KeyedPlayerCommand.java +++ b/proxy/src/main/java/com/velocitypowered/proxy/network/protocol/packet/chat/keyed/KeyedPlayerCommand.java @@ -15,18 +15,16 @@ * along with this program. If not, see . */ -package com.velocitypowered.proxy.protocol.packet.chat.keyed; - -import static com.velocitypowered.proxy.protocol.packet.chat.keyed.KeyedPlayerChat.INVALID_PREVIOUS_MESSAGES; -import static com.velocitypowered.proxy.protocol.packet.chat.keyed.KeyedPlayerChat.MAXIMUM_PREVIOUS_MESSAGE_COUNT; +package com.velocitypowered.proxy.network.protocol.packet.chat.keyed; import com.google.common.collect.ImmutableMap; import com.velocitypowered.api.network.ProtocolVersion; import com.velocitypowered.proxy.connection.MinecraftSessionHandler; import com.velocitypowered.proxy.crypto.EncryptionUtils; import com.velocitypowered.proxy.crypto.SignaturePair; -import com.velocitypowered.proxy.protocol.MinecraftPacket; -import com.velocitypowered.proxy.protocol.ProtocolUtils; +import com.velocitypowered.proxy.network.protocol.MinecraftPacket; +import com.velocitypowered.proxy.network.protocol.ProtocolUtils; +import com.velocitypowered.proxy.network.protocol.ProtocolUtils.Direction; import com.velocitypowered.proxy.util.except.QuietDecoderException; import io.netty.buffer.ByteBuf; import java.time.Instant; @@ -46,7 +44,7 @@ public class KeyedPlayerCommand implements MinecraftPacket { private String command; private Instant timestamp; private long salt; - private boolean signedPreview; // purely for pass through for 1.19 -> 1.19.2 - this will never be implemented + private boolean signedPreview; // purely for pass through for 1.19 -> 1.19.2 private SignaturePair[] previousMessages = new SignaturePair[0]; private @Nullable SignaturePair lastMessage; private Map arguments = ImmutableMap.of(); @@ -85,7 +83,7 @@ public class KeyedPlayerCommand implements MinecraftPacket { } @Override - public void decode(ByteBuf buf, ProtocolUtils.Direction direction, + public void decode(ByteBuf buf, Direction direction, ProtocolVersion protocolVersion) { command = ProtocolUtils.readString(buf, 256); timestamp = Instant.ofEpochMilli(buf.readLong()); @@ -111,8 +109,8 @@ public class KeyedPlayerCommand implements MinecraftPacket { if (protocolVersion.compareTo(ProtocolVersion.MINECRAFT_1_19_1) >= 0) { int size = ProtocolUtils.readVarInt(buf); - if (size < 0 || size > MAXIMUM_PREVIOUS_MESSAGE_COUNT) { - throw INVALID_PREVIOUS_MESSAGES; + if (size < 0 || size > KeyedPlayerChat.MAXIMUM_PREVIOUS_MESSAGE_COUNT) { + throw KeyedPlayerChat.INVALID_PREVIOUS_MESSAGES; } SignaturePair[] lastSignatures = new SignaturePair[size]; diff --git a/proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/chat/legacy/LegacyChat.java b/proxy/src/main/java/com/velocitypowered/proxy/network/protocol/packet/chat/legacy/LegacyChat.java similarity index 90% rename from proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/chat/legacy/LegacyChat.java rename to proxy/src/main/java/com/velocitypowered/proxy/network/protocol/packet/chat/legacy/LegacyChat.java index dfb659669..0e018e893 100644 --- a/proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/chat/legacy/LegacyChat.java +++ b/proxy/src/main/java/com/velocitypowered/proxy/network/protocol/packet/chat/legacy/LegacyChat.java @@ -15,12 +15,13 @@ * along with this program. If not, see . */ -package com.velocitypowered.proxy.protocol.packet.chat.legacy; +package com.velocitypowered.proxy.network.protocol.packet.chat.legacy; import com.velocitypowered.api.network.ProtocolVersion; import com.velocitypowered.proxy.connection.MinecraftSessionHandler; -import com.velocitypowered.proxy.protocol.MinecraftPacket; -import com.velocitypowered.proxy.protocol.ProtocolUtils; +import com.velocitypowered.proxy.network.protocol.MinecraftPacket; +import com.velocitypowered.proxy.network.protocol.ProtocolUtils; +import com.velocitypowered.proxy.network.protocol.ProtocolUtils.Direction; import io.netty.buffer.ByteBuf; import java.util.UUID; import org.checkerframework.checker.nullness.qual.Nullable; @@ -90,7 +91,7 @@ public class LegacyChat implements MinecraftPacket { } @Override - public void decode(ByteBuf buf, ProtocolUtils.Direction direction, ProtocolVersion version) { + public void decode(ByteBuf buf, Direction direction, ProtocolVersion version) { message = ProtocolUtils.readString(buf); if (direction == ProtocolUtils.Direction.CLIENTBOUND && version.compareTo(ProtocolVersion.MINECRAFT_1_8) >= 0) { diff --git a/proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/chat/legacy/LegacyChatBuilder.java b/proxy/src/main/java/com/velocitypowered/proxy/network/protocol/packet/chat/legacy/LegacyChatBuilder.java similarity index 84% rename from proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/chat/legacy/LegacyChatBuilder.java rename to proxy/src/main/java/com/velocitypowered/proxy/network/protocol/packet/chat/legacy/LegacyChatBuilder.java index 32a5baabf..89fdd17a1 100644 --- a/proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/chat/legacy/LegacyChatBuilder.java +++ b/proxy/src/main/java/com/velocitypowered/proxy/network/protocol/packet/chat/legacy/LegacyChatBuilder.java @@ -15,12 +15,12 @@ * along with this program. If not, see . */ -package com.velocitypowered.proxy.protocol.packet.chat.legacy; +package com.velocitypowered.proxy.network.protocol.packet.chat.legacy; import com.velocitypowered.api.network.ProtocolVersion; -import com.velocitypowered.proxy.protocol.MinecraftPacket; -import com.velocitypowered.proxy.protocol.ProtocolUtils; -import com.velocitypowered.proxy.protocol.packet.chat.builder.ChatBuilderV2; +import com.velocitypowered.proxy.network.protocol.MinecraftPacket; +import com.velocitypowered.proxy.network.protocol.ProtocolUtils; +import com.velocitypowered.proxy.network.protocol.packet.chat.builder.ChatBuilderV2; import java.util.UUID; import net.kyori.adventure.identity.Identity; import net.kyori.adventure.text.Component; diff --git a/proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/chat/legacy/LegacyChatHandler.java b/proxy/src/main/java/com/velocitypowered/proxy/network/protocol/packet/chat/legacy/LegacyChatHandler.java similarity index 93% rename from proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/chat/legacy/LegacyChatHandler.java rename to proxy/src/main/java/com/velocitypowered/proxy/network/protocol/packet/chat/legacy/LegacyChatHandler.java index 12fc60f9f..62fd26d60 100644 --- a/proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/chat/legacy/LegacyChatHandler.java +++ b/proxy/src/main/java/com/velocitypowered/proxy/network/protocol/packet/chat/legacy/LegacyChatHandler.java @@ -15,13 +15,13 @@ * along with this program. If not, see . */ -package com.velocitypowered.proxy.protocol.packet.chat.legacy; +package com.velocitypowered.proxy.network.protocol.packet.chat.legacy; import com.velocitypowered.api.event.player.PlayerChatEvent; import com.velocitypowered.proxy.VelocityServer; import com.velocitypowered.proxy.connection.MinecraftConnection; import com.velocitypowered.proxy.connection.client.ConnectedPlayer; -import com.velocitypowered.proxy.protocol.packet.chat.ChatHandler; +import com.velocitypowered.proxy.network.protocol.packet.chat.ChatHandler; public class LegacyChatHandler implements ChatHandler { diff --git a/proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/chat/legacy/LegacyCommandHandler.java b/proxy/src/main/java/com/velocitypowered/proxy/network/protocol/packet/chat/legacy/LegacyCommandHandler.java similarity index 94% rename from proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/chat/legacy/LegacyCommandHandler.java rename to proxy/src/main/java/com/velocitypowered/proxy/network/protocol/packet/chat/legacy/LegacyCommandHandler.java index 37368f60b..c45d4998e 100644 --- a/proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/chat/legacy/LegacyCommandHandler.java +++ b/proxy/src/main/java/com/velocitypowered/proxy/network/protocol/packet/chat/legacy/LegacyCommandHandler.java @@ -15,12 +15,12 @@ * along with this program. If not, see . */ -package com.velocitypowered.proxy.protocol.packet.chat.legacy; +package com.velocitypowered.proxy.network.protocol.packet.chat.legacy; import com.velocitypowered.api.event.command.CommandExecuteEvent; import com.velocitypowered.proxy.VelocityServer; import com.velocitypowered.proxy.connection.client.ConnectedPlayer; -import com.velocitypowered.proxy.protocol.packet.chat.CommandHandler; +import com.velocitypowered.proxy.network.protocol.packet.chat.CommandHandler; import java.time.Instant; import java.util.concurrent.CompletableFuture; diff --git a/proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/chat/session/SessionChatBuilder.java b/proxy/src/main/java/com/velocitypowered/proxy/network/protocol/packet/chat/session/SessionChatBuilder.java similarity index 80% rename from proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/chat/session/SessionChatBuilder.java rename to proxy/src/main/java/com/velocitypowered/proxy/network/protocol/packet/chat/session/SessionChatBuilder.java index 74bd945f8..45f89f767 100644 --- a/proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/chat/session/SessionChatBuilder.java +++ b/proxy/src/main/java/com/velocitypowered/proxy/network/protocol/packet/chat/session/SessionChatBuilder.java @@ -15,14 +15,14 @@ * along with this program. If not, see . */ -package com.velocitypowered.proxy.protocol.packet.chat.session; +package com.velocitypowered.proxy.network.protocol.packet.chat.session; import com.velocitypowered.api.network.ProtocolVersion; -import com.velocitypowered.proxy.protocol.MinecraftPacket; -import com.velocitypowered.proxy.protocol.packet.chat.ChatType; -import com.velocitypowered.proxy.protocol.packet.chat.LastSeenMessages; -import com.velocitypowered.proxy.protocol.packet.chat.SystemChat; -import com.velocitypowered.proxy.protocol.packet.chat.builder.ChatBuilderV2; +import com.velocitypowered.proxy.network.protocol.MinecraftPacket; +import com.velocitypowered.proxy.network.protocol.packet.chat.ChatType; +import com.velocitypowered.proxy.network.protocol.packet.chat.LastSeenMessages; +import com.velocitypowered.proxy.network.protocol.packet.chat.SystemChat; +import com.velocitypowered.proxy.network.protocol.packet.chat.builder.ChatBuilderV2; import net.kyori.adventure.text.Component; public class SessionChatBuilder extends ChatBuilderV2 { diff --git a/proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/chat/session/SessionChatHandler.java b/proxy/src/main/java/com/velocitypowered/proxy/network/protocol/packet/chat/session/SessionChatHandler.java similarity index 86% rename from proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/chat/session/SessionChatHandler.java rename to proxy/src/main/java/com/velocitypowered/proxy/network/protocol/packet/chat/session/SessionChatHandler.java index 6beaf1439..441ebdbdb 100644 --- a/proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/chat/session/SessionChatHandler.java +++ b/proxy/src/main/java/com/velocitypowered/proxy/network/protocol/packet/chat/session/SessionChatHandler.java @@ -15,17 +15,17 @@ * along with this program. If not, see . */ -package com.velocitypowered.proxy.protocol.packet.chat.session; +package com.velocitypowered.proxy.network.protocol.packet.chat.session; -import static com.velocitypowered.proxy.protocol.packet.chat.keyed.KeyedChatHandler.invalidCancel; -import static com.velocitypowered.proxy.protocol.packet.chat.keyed.KeyedChatHandler.invalidChange; +import static com.velocitypowered.proxy.network.protocol.packet.chat.keyed.KeyedChatHandler.invalidCancel; +import static com.velocitypowered.proxy.network.protocol.packet.chat.keyed.KeyedChatHandler.invalidChange; import com.velocitypowered.api.event.EventManager; import com.velocitypowered.api.event.player.PlayerChatEvent; import com.velocitypowered.proxy.VelocityServer; import com.velocitypowered.proxy.connection.client.ConnectedPlayer; -import com.velocitypowered.proxy.protocol.packet.chat.ChatHandler; -import com.velocitypowered.proxy.protocol.packet.chat.ChatQueue; +import com.velocitypowered.proxy.network.protocol.packet.chat.ChatHandler; +import com.velocitypowered.proxy.network.protocol.packet.chat.ChatQueue; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; diff --git a/proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/chat/session/SessionCommandHandler.java b/proxy/src/main/java/com/velocitypowered/proxy/network/protocol/packet/chat/session/SessionCommandHandler.java similarity index 91% rename from proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/chat/session/SessionCommandHandler.java rename to proxy/src/main/java/com/velocitypowered/proxy/network/protocol/packet/chat/session/SessionCommandHandler.java index 558531b72..5425e5251 100644 --- a/proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/chat/session/SessionCommandHandler.java +++ b/proxy/src/main/java/com/velocitypowered/proxy/network/protocol/packet/chat/session/SessionCommandHandler.java @@ -15,14 +15,14 @@ * along with this program. If not, see . */ -package com.velocitypowered.proxy.protocol.packet.chat.session; +package com.velocitypowered.proxy.network.protocol.packet.chat.session; import com.velocitypowered.api.event.command.CommandExecuteEvent; import com.velocitypowered.api.network.ProtocolVersion; import com.velocitypowered.proxy.VelocityServer; import com.velocitypowered.proxy.connection.client.ConnectedPlayer; -import com.velocitypowered.proxy.protocol.packet.chat.ChatAcknowledgement; -import com.velocitypowered.proxy.protocol.packet.chat.CommandHandler; +import com.velocitypowered.proxy.network.protocol.packet.chat.ChatAcknowledgement; +import com.velocitypowered.proxy.network.protocol.packet.chat.CommandHandler; import java.util.concurrent.CompletableFuture; import net.kyori.adventure.text.Component; @@ -54,9 +54,11 @@ public class SessionCommandHandler implements CommandHandler= 0) { - return CompletableFuture.completedFuture(new ChatAcknowledgement(packet.lastSeenMessages.getOffset())); + return CompletableFuture.completedFuture( + new ChatAcknowledgement(packet.lastSeenMessages.getOffset())); } return CompletableFuture.completedFuture(null); } diff --git a/proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/chat/session/SessionPlayerChat.java b/proxy/src/main/java/com/velocitypowered/proxy/network/protocol/packet/chat/session/SessionPlayerChat.java similarity index 86% rename from proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/chat/session/SessionPlayerChat.java rename to proxy/src/main/java/com/velocitypowered/proxy/network/protocol/packet/chat/session/SessionPlayerChat.java index 3f59f29c2..fc1d23747 100644 --- a/proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/chat/session/SessionPlayerChat.java +++ b/proxy/src/main/java/com/velocitypowered/proxy/network/protocol/packet/chat/session/SessionPlayerChat.java @@ -15,13 +15,14 @@ * along with this program. If not, see . */ -package com.velocitypowered.proxy.protocol.packet.chat.session; +package com.velocitypowered.proxy.network.protocol.packet.chat.session; import com.velocitypowered.api.network.ProtocolVersion; import com.velocitypowered.proxy.connection.MinecraftSessionHandler; -import com.velocitypowered.proxy.protocol.MinecraftPacket; -import com.velocitypowered.proxy.protocol.ProtocolUtils; -import com.velocitypowered.proxy.protocol.packet.chat.LastSeenMessages; +import com.velocitypowered.proxy.network.protocol.MinecraftPacket; +import com.velocitypowered.proxy.network.protocol.ProtocolUtils; +import com.velocitypowered.proxy.network.protocol.ProtocolUtils.Direction; +import com.velocitypowered.proxy.network.protocol.packet.chat.LastSeenMessages; import io.netty.buffer.ByteBuf; import java.time.Instant; @@ -62,7 +63,7 @@ public class SessionPlayerChat implements MinecraftPacket { } @Override - public void decode(ByteBuf buf, ProtocolUtils.Direction direction, + public void decode(ByteBuf buf, Direction direction, ProtocolVersion protocolVersion) { this.message = ProtocolUtils.readString(buf, 256); this.timestamp = Instant.ofEpochMilli(buf.readLong()); diff --git a/proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/chat/session/SessionPlayerCommand.java b/proxy/src/main/java/com/velocitypowered/proxy/network/protocol/packet/chat/session/SessionPlayerCommand.java similarity index 81% rename from proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/chat/session/SessionPlayerCommand.java rename to proxy/src/main/java/com/velocitypowered/proxy/network/protocol/packet/chat/session/SessionPlayerCommand.java index 5ef83fa45..c0ea1b6d4 100644 --- a/proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/chat/session/SessionPlayerCommand.java +++ b/proxy/src/main/java/com/velocitypowered/proxy/network/protocol/packet/chat/session/SessionPlayerCommand.java @@ -15,14 +15,15 @@ * along with this program. If not, see . */ -package com.velocitypowered.proxy.protocol.packet.chat.session; +package com.velocitypowered.proxy.network.protocol.packet.chat.session; import com.google.common.collect.Lists; import com.velocitypowered.api.network.ProtocolVersion; import com.velocitypowered.proxy.connection.MinecraftSessionHandler; -import com.velocitypowered.proxy.protocol.MinecraftPacket; -import com.velocitypowered.proxy.protocol.ProtocolUtils; -import com.velocitypowered.proxy.protocol.packet.chat.LastSeenMessages; +import com.velocitypowered.proxy.network.protocol.MinecraftPacket; +import com.velocitypowered.proxy.network.protocol.ProtocolUtils; +import com.velocitypowered.proxy.network.protocol.ProtocolUtils.Direction; +import com.velocitypowered.proxy.network.protocol.packet.chat.LastSeenMessages; import com.velocitypowered.proxy.util.except.QuietDecoderException; import io.netty.buffer.ByteBuf; import java.time.Instant; @@ -37,7 +38,7 @@ public class SessionPlayerCommand implements MinecraftPacket { protected LastSeenMessages lastSeenMessages; @Override - public void decode(ByteBuf buf, ProtocolUtils.Direction direction, + public void decode(ByteBuf buf, Direction direction, ProtocolVersion protocolVersion) { this.command = ProtocolUtils.readString(buf, 256); this.timeStamp = Instant.ofEpochMilli(buf.readLong()); @@ -65,7 +66,9 @@ public class SessionPlayerCommand implements MinecraftPacket { } public boolean isSigned() { - if (salt == 0) return false; + if (salt == 0) { + return false; + } return !lastSeenMessages.isEmpty() || !argumentSignatures.isEmpty(); } @@ -76,13 +79,13 @@ public class SessionPlayerCommand implements MinecraftPacket { @Override public String toString() { - return "SessionPlayerCommand{" + - "command='" + command + '\'' + - ", timeStamp=" + timeStamp + - ", salt=" + salt + - ", argumentSignatures=" + argumentSignatures + - ", lastSeenMessages=" + lastSeenMessages + - '}'; + return "SessionPlayerCommand{" + + "command='" + command + '\'' + + ", timeStamp=" + timeStamp + + ", salt=" + salt + + ", argumentSignatures=" + argumentSignatures + + ", lastSeenMessages=" + lastSeenMessages + + '}'; } public static class ArgumentSignatures { @@ -116,11 +119,10 @@ public class SessionPlayerCommand implements MinecraftPacket { entry.encode(buf); } } + @Override public String toString() { - return "ArgumentSignatures{" + - "entries=" + entries + - '}'; + return "ArgumentSignatures{entries=" + entries + '}'; } } @@ -141,9 +143,7 @@ public class SessionPlayerCommand implements MinecraftPacket { @Override public String toString() { - return "ArgumentSignature{" + - "name='" + name + '\'' + - '}'; + return "ArgumentSignature{name='" + name + '\'' + '}'; } } } diff --git a/proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/config/ActiveFeatures.java b/proxy/src/main/java/com/velocitypowered/proxy/network/protocol/packet/config/ActiveFeatures.java similarity index 80% rename from proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/config/ActiveFeatures.java rename to proxy/src/main/java/com/velocitypowered/proxy/network/protocol/packet/config/ActiveFeatures.java index de2a5047c..8b1355fea 100644 --- a/proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/config/ActiveFeatures.java +++ b/proxy/src/main/java/com/velocitypowered/proxy/network/protocol/packet/config/ActiveFeatures.java @@ -15,12 +15,13 @@ * along with this program. If not, see . */ -package com.velocitypowered.proxy.protocol.packet.config; +package com.velocitypowered.proxy.network.protocol.packet.config; import com.velocitypowered.api.network.ProtocolVersion; import com.velocitypowered.proxy.connection.MinecraftSessionHandler; -import com.velocitypowered.proxy.protocol.MinecraftPacket; -import com.velocitypowered.proxy.protocol.ProtocolUtils; +import com.velocitypowered.proxy.network.protocol.MinecraftPacket; +import com.velocitypowered.proxy.network.protocol.ProtocolUtils; +import com.velocitypowered.proxy.network.protocol.ProtocolUtils.Direction; import io.netty.buffer.ByteBuf; import net.kyori.adventure.key.Key; @@ -45,14 +46,14 @@ public class ActiveFeatures implements MinecraftPacket { } @Override - public void decode(ByteBuf buf, ProtocolUtils.Direction direction, - ProtocolVersion protocolVersion) { + public void decode(ByteBuf buf, Direction direction, + ProtocolVersion protocolVersion) { activeFeatures = ProtocolUtils.readKeyArray(buf); } @Override public void encode(ByteBuf buf, ProtocolUtils.Direction direction, - ProtocolVersion protocolVersion) { + ProtocolVersion protocolVersion) { ProtocolUtils.writeKeyArray(buf, activeFeatures); } diff --git a/proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/config/FinishedUpdate.java b/proxy/src/main/java/com/velocitypowered/proxy/network/protocol/packet/config/FinishedUpdate.java similarity index 66% rename from proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/config/FinishedUpdate.java rename to proxy/src/main/java/com/velocitypowered/proxy/network/protocol/packet/config/FinishedUpdate.java index 866819b48..b4cfb04e7 100644 --- a/proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/config/FinishedUpdate.java +++ b/proxy/src/main/java/com/velocitypowered/proxy/network/protocol/packet/config/FinishedUpdate.java @@ -15,29 +15,29 @@ * along with this program. If not, see . */ -package com.velocitypowered.proxy.protocol.packet.config; +package com.velocitypowered.proxy.network.protocol.packet.config; import com.velocitypowered.api.network.ProtocolVersion; import com.velocitypowered.proxy.connection.MinecraftSessionHandler; -import com.velocitypowered.proxy.protocol.MinecraftPacket; -import com.velocitypowered.proxy.protocol.ProtocolUtils; +import com.velocitypowered.proxy.network.protocol.MinecraftPacket; +import com.velocitypowered.proxy.network.protocol.ProtocolUtils.Direction; import io.netty.buffer.ByteBuf; public class FinishedUpdate implements MinecraftPacket { @Override - public void decode(ByteBuf buf, ProtocolUtils.Direction direction, - ProtocolVersion protocolVersion) { + public void decode(ByteBuf buf, Direction direction, + ProtocolVersion protocolVersion) { } @Override - public void encode(ByteBuf buf, ProtocolUtils.Direction direction, - ProtocolVersion protocolVersion) { + public void encode(ByteBuf buf, Direction direction, + ProtocolVersion protocolVersion) { } @Override - public int expectedMaxLength(ByteBuf buf, ProtocolUtils.Direction direction, - ProtocolVersion version) { + public int expectedMaxLength(ByteBuf buf, Direction direction, + ProtocolVersion version) { return 0; } diff --git a/proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/config/RegistrySync.java b/proxy/src/main/java/com/velocitypowered/proxy/network/protocol/packet/config/RegistrySync.java similarity index 72% rename from proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/config/RegistrySync.java rename to proxy/src/main/java/com/velocitypowered/proxy/network/protocol/packet/config/RegistrySync.java index 74c275401..0e4088178 100644 --- a/proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/config/RegistrySync.java +++ b/proxy/src/main/java/com/velocitypowered/proxy/network/protocol/packet/config/RegistrySync.java @@ -15,13 +15,13 @@ * along with this program. If not, see . */ -package com.velocitypowered.proxy.protocol.packet.config; +package com.velocitypowered.proxy.network.protocol.packet.config; import com.velocitypowered.api.network.ProtocolVersion; import com.velocitypowered.proxy.connection.MinecraftSessionHandler; -import com.velocitypowered.proxy.protocol.MinecraftPacket; -import com.velocitypowered.proxy.protocol.ProtocolUtils; -import com.velocitypowered.proxy.protocol.util.DeferredByteBufHolder; +import com.velocitypowered.proxy.network.protocol.MinecraftPacket; +import com.velocitypowered.proxy.network.protocol.ProtocolUtils.Direction; +import com.velocitypowered.proxy.network.protocol.util.DeferredByteBufHolder; import io.netty.buffer.ByteBuf; public class RegistrySync extends DeferredByteBufHolder implements MinecraftPacket { @@ -32,14 +32,14 @@ public class RegistrySync extends DeferredByteBufHolder implements MinecraftPack // NBT change in 1.20.2 makes it difficult to parse this packet. @Override - public void decode(ByteBuf buf, ProtocolUtils.Direction direction, - ProtocolVersion protocolVersion) { + public void decode(ByteBuf buf, Direction direction, + ProtocolVersion protocolVersion) { this.replace(buf.readRetainedSlice(buf.readableBytes())); } @Override - public void encode(ByteBuf buf, ProtocolUtils.Direction direction, - ProtocolVersion protocolVersion) { + public void encode(ByteBuf buf, Direction direction, + ProtocolVersion protocolVersion) { buf.writeBytes(content()); } diff --git a/proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/config/StartUpdate.java b/proxy/src/main/java/com/velocitypowered/proxy/network/protocol/packet/config/StartUpdate.java similarity index 66% rename from proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/config/StartUpdate.java rename to proxy/src/main/java/com/velocitypowered/proxy/network/protocol/packet/config/StartUpdate.java index d1c25fa27..af18101e1 100644 --- a/proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/config/StartUpdate.java +++ b/proxy/src/main/java/com/velocitypowered/proxy/network/protocol/packet/config/StartUpdate.java @@ -15,29 +15,29 @@ * along with this program. If not, see . */ -package com.velocitypowered.proxy.protocol.packet.config; +package com.velocitypowered.proxy.network.protocol.packet.config; import com.velocitypowered.api.network.ProtocolVersion; import com.velocitypowered.proxy.connection.MinecraftSessionHandler; -import com.velocitypowered.proxy.protocol.MinecraftPacket; -import com.velocitypowered.proxy.protocol.ProtocolUtils; +import com.velocitypowered.proxy.network.protocol.MinecraftPacket; +import com.velocitypowered.proxy.network.protocol.ProtocolUtils.Direction; import io.netty.buffer.ByteBuf; public class StartUpdate implements MinecraftPacket { @Override - public void decode(ByteBuf buf, ProtocolUtils.Direction direction, - ProtocolVersion protocolVersion) { + public void decode(ByteBuf buf, Direction direction, + ProtocolVersion protocolVersion) { } @Override - public void encode(ByteBuf buf, ProtocolUtils.Direction direction, - ProtocolVersion protocolVersion) { + public void encode(ByteBuf buf, Direction direction, + ProtocolVersion protocolVersion) { } @Override - public int expectedMaxLength(ByteBuf buf, ProtocolUtils.Direction direction, - ProtocolVersion version) { + public int expectedMaxLength(ByteBuf buf, Direction direction, + ProtocolVersion version) { return 0; } diff --git a/proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/config/TagsUpdate.java b/proxy/src/main/java/com/velocitypowered/proxy/network/protocol/packet/config/TagsUpdate.java similarity index 86% rename from proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/config/TagsUpdate.java rename to proxy/src/main/java/com/velocitypowered/proxy/network/protocol/packet/config/TagsUpdate.java index 79b432158..200ce976b 100644 --- a/proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/config/TagsUpdate.java +++ b/proxy/src/main/java/com/velocitypowered/proxy/network/protocol/packet/config/TagsUpdate.java @@ -15,15 +15,15 @@ * along with this program. If not, see . */ -package com.velocitypowered.proxy.protocol.packet.config; +package com.velocitypowered.proxy.network.protocol.packet.config; import com.google.common.collect.ImmutableMap; import com.velocitypowered.api.network.ProtocolVersion; import com.velocitypowered.proxy.connection.MinecraftSessionHandler; -import com.velocitypowered.proxy.protocol.MinecraftPacket; -import com.velocitypowered.proxy.protocol.ProtocolUtils; +import com.velocitypowered.proxy.network.protocol.MinecraftPacket; +import com.velocitypowered.proxy.network.protocol.ProtocolUtils; +import com.velocitypowered.proxy.network.protocol.ProtocolUtils.Direction; import io.netty.buffer.ByteBuf; - import java.util.Map; public class TagsUpdate implements MinecraftPacket { @@ -39,8 +39,8 @@ public class TagsUpdate implements MinecraftPacket { } @Override - public void decode(ByteBuf buf, ProtocolUtils.Direction direction, - ProtocolVersion protocolVersion) { + public void decode(ByteBuf buf, Direction direction, + ProtocolVersion protocolVersion) { ImmutableMap.Builder> builder = ImmutableMap.builder(); int size = ProtocolUtils.readVarInt(buf); for (int i = 0; i < size; i++) { @@ -61,7 +61,7 @@ public class TagsUpdate implements MinecraftPacket { @Override public void encode(ByteBuf buf, ProtocolUtils.Direction direction, - ProtocolVersion protocolVersion) { + ProtocolVersion protocolVersion) { ProtocolUtils.writeVarInt(buf, tags.size()); for (Map.Entry> entry : tags.entrySet()) { ProtocolUtils.writeString(buf, entry.getKey()); diff --git a/proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/legacyping/LegacyMinecraftPingVersion.java b/proxy/src/main/java/com/velocitypowered/proxy/network/protocol/packet/legacyping/LegacyMinecraftPingVersion.java similarity index 91% rename from proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/legacyping/LegacyMinecraftPingVersion.java rename to proxy/src/main/java/com/velocitypowered/proxy/network/protocol/packet/legacyping/LegacyMinecraftPingVersion.java index d5ef296a4..85ed6814e 100644 --- a/proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/legacyping/LegacyMinecraftPingVersion.java +++ b/proxy/src/main/java/com/velocitypowered/proxy/network/protocol/packet/legacyping/LegacyMinecraftPingVersion.java @@ -15,7 +15,7 @@ * along with this program. If not, see . */ -package com.velocitypowered.proxy.protocol.packet.legacyping; +package com.velocitypowered.proxy.network.protocol.packet.legacyping; public enum LegacyMinecraftPingVersion { MINECRAFT_1_3, diff --git a/proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/title/GenericTitlePacket.java b/proxy/src/main/java/com/velocitypowered/proxy/network/protocol/packet/title/GenericTitlePacket.java similarity index 93% rename from proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/title/GenericTitlePacket.java rename to proxy/src/main/java/com/velocitypowered/proxy/network/protocol/packet/title/GenericTitlePacket.java index 02b125ab8..707818ae9 100644 --- a/proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/title/GenericTitlePacket.java +++ b/proxy/src/main/java/com/velocitypowered/proxy/network/protocol/packet/title/GenericTitlePacket.java @@ -15,11 +15,11 @@ * along with this program. If not, see . */ -package com.velocitypowered.proxy.protocol.packet.title; +package com.velocitypowered.proxy.network.protocol.packet.title; import com.velocitypowered.api.network.ProtocolVersion; -import com.velocitypowered.proxy.protocol.MinecraftPacket; -import com.velocitypowered.proxy.protocol.ProtocolUtils; +import com.velocitypowered.proxy.network.protocol.MinecraftPacket; +import com.velocitypowered.proxy.network.protocol.ProtocolUtils.Direction; import io.netty.buffer.ByteBuf; public abstract class GenericTitlePacket implements MinecraftPacket { @@ -89,7 +89,7 @@ public abstract class GenericTitlePacket implements MinecraftPacket { @Override - public final void decode(ByteBuf buf, ProtocolUtils.Direction direction, + public final void decode(ByteBuf buf, Direction direction, ProtocolVersion version) { throw new UnsupportedOperationException(); // encode only } diff --git a/proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/title/LegacyTitlePacket.java b/proxy/src/main/java/com/velocitypowered/proxy/network/protocol/packet/title/LegacyTitlePacket.java similarity index 91% rename from proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/title/LegacyTitlePacket.java rename to proxy/src/main/java/com/velocitypowered/proxy/network/protocol/packet/title/LegacyTitlePacket.java index ae4bebeeb..13a845f9f 100644 --- a/proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/title/LegacyTitlePacket.java +++ b/proxy/src/main/java/com/velocitypowered/proxy/network/protocol/packet/title/LegacyTitlePacket.java @@ -15,11 +15,12 @@ * along with this program. If not, see . */ -package com.velocitypowered.proxy.protocol.packet.title; +package com.velocitypowered.proxy.network.protocol.packet.title; import com.velocitypowered.api.network.ProtocolVersion; import com.velocitypowered.proxy.connection.MinecraftSessionHandler; -import com.velocitypowered.proxy.protocol.ProtocolUtils; +import com.velocitypowered.proxy.network.protocol.ProtocolUtils; +import com.velocitypowered.proxy.network.protocol.ProtocolUtils.Direction; import io.netty.buffer.ByteBuf; import org.checkerframework.checker.nullness.qual.Nullable; @@ -31,7 +32,7 @@ public class LegacyTitlePacket extends GenericTitlePacket { private int fadeOut; @Override - public void encode(ByteBuf buf, ProtocolUtils.Direction direction, ProtocolVersion version) { + public void encode(ByteBuf buf, Direction direction, ProtocolVersion version) { if (version.compareTo(ProtocolVersion.MINECRAFT_1_11) < 0 && getAction() == ActionType.SET_ACTION_BAR) { throw new IllegalStateException("Action bars are only supported on 1.11 and newer"); diff --git a/proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/title/TitleActionbarPacket.java b/proxy/src/main/java/com/velocitypowered/proxy/network/protocol/packet/title/TitleActionbarPacket.java similarity index 84% rename from proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/title/TitleActionbarPacket.java rename to proxy/src/main/java/com/velocitypowered/proxy/network/protocol/packet/title/TitleActionbarPacket.java index a9f01245a..258dd44d3 100644 --- a/proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/title/TitleActionbarPacket.java +++ b/proxy/src/main/java/com/velocitypowered/proxy/network/protocol/packet/title/TitleActionbarPacket.java @@ -15,11 +15,12 @@ * along with this program. If not, see . */ -package com.velocitypowered.proxy.protocol.packet.title; +package com.velocitypowered.proxy.network.protocol.packet.title; import com.velocitypowered.api.network.ProtocolVersion; import com.velocitypowered.proxy.connection.MinecraftSessionHandler; -import com.velocitypowered.proxy.protocol.ProtocolUtils; +import com.velocitypowered.proxy.network.protocol.ProtocolUtils; +import com.velocitypowered.proxy.network.protocol.ProtocolUtils.Direction; import io.netty.buffer.ByteBuf; public class TitleActionbarPacket extends GenericTitlePacket { @@ -31,7 +32,7 @@ public class TitleActionbarPacket extends GenericTitlePacket { } @Override - public void encode(ByteBuf buf, ProtocolUtils.Direction direction, ProtocolVersion version) { + public void encode(ByteBuf buf, Direction direction, ProtocolVersion version) { ProtocolUtils.writeString(buf, component); } diff --git a/proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/title/TitleClearPacket.java b/proxy/src/main/java/com/velocitypowered/proxy/network/protocol/packet/title/TitleClearPacket.java similarity index 87% rename from proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/title/TitleClearPacket.java rename to proxy/src/main/java/com/velocitypowered/proxy/network/protocol/packet/title/TitleClearPacket.java index 1b3489691..2bd3cd2a8 100644 --- a/proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/title/TitleClearPacket.java +++ b/proxy/src/main/java/com/velocitypowered/proxy/network/protocol/packet/title/TitleClearPacket.java @@ -15,11 +15,11 @@ * along with this program. If not, see . */ -package com.velocitypowered.proxy.protocol.packet.title; +package com.velocitypowered.proxy.network.protocol.packet.title; import com.velocitypowered.api.network.ProtocolVersion; import com.velocitypowered.proxy.connection.MinecraftSessionHandler; -import com.velocitypowered.proxy.protocol.ProtocolUtils; +import com.velocitypowered.proxy.network.protocol.ProtocolUtils.Direction; import io.netty.buffer.ByteBuf; public class TitleClearPacket extends GenericTitlePacket { @@ -37,7 +37,7 @@ public class TitleClearPacket extends GenericTitlePacket { } @Override - public void encode(ByteBuf buf, ProtocolUtils.Direction direction, ProtocolVersion version) { + public void encode(ByteBuf buf, Direction direction, ProtocolVersion version) { buf.writeBoolean(getAction() == ActionType.RESET); } diff --git a/proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/title/TitleSubtitlePacket.java b/proxy/src/main/java/com/velocitypowered/proxy/network/protocol/packet/title/TitleSubtitlePacket.java similarity index 84% rename from proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/title/TitleSubtitlePacket.java rename to proxy/src/main/java/com/velocitypowered/proxy/network/protocol/packet/title/TitleSubtitlePacket.java index d92a44d53..79e07abe2 100644 --- a/proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/title/TitleSubtitlePacket.java +++ b/proxy/src/main/java/com/velocitypowered/proxy/network/protocol/packet/title/TitleSubtitlePacket.java @@ -15,11 +15,12 @@ * along with this program. If not, see . */ -package com.velocitypowered.proxy.protocol.packet.title; +package com.velocitypowered.proxy.network.protocol.packet.title; import com.velocitypowered.api.network.ProtocolVersion; import com.velocitypowered.proxy.connection.MinecraftSessionHandler; -import com.velocitypowered.proxy.protocol.ProtocolUtils; +import com.velocitypowered.proxy.network.protocol.ProtocolUtils; +import com.velocitypowered.proxy.network.protocol.ProtocolUtils.Direction; import io.netty.buffer.ByteBuf; public class TitleSubtitlePacket extends GenericTitlePacket { @@ -31,7 +32,7 @@ public class TitleSubtitlePacket extends GenericTitlePacket { } @Override - public void encode(ByteBuf buf, ProtocolUtils.Direction direction, ProtocolVersion version) { + public void encode(ByteBuf buf, Direction direction, ProtocolVersion version) { ProtocolUtils.writeString(buf, component); } diff --git a/proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/title/TitleTextPacket.java b/proxy/src/main/java/com/velocitypowered/proxy/network/protocol/packet/title/TitleTextPacket.java similarity index 83% rename from proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/title/TitleTextPacket.java rename to proxy/src/main/java/com/velocitypowered/proxy/network/protocol/packet/title/TitleTextPacket.java index 8ad9b4b8b..0b98ddcfb 100644 --- a/proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/title/TitleTextPacket.java +++ b/proxy/src/main/java/com/velocitypowered/proxy/network/protocol/packet/title/TitleTextPacket.java @@ -15,11 +15,12 @@ * along with this program. If not, see . */ -package com.velocitypowered.proxy.protocol.packet.title; +package com.velocitypowered.proxy.network.protocol.packet.title; import com.velocitypowered.api.network.ProtocolVersion; import com.velocitypowered.proxy.connection.MinecraftSessionHandler; -import com.velocitypowered.proxy.protocol.ProtocolUtils; +import com.velocitypowered.proxy.network.protocol.ProtocolUtils; +import com.velocitypowered.proxy.network.protocol.ProtocolUtils.Direction; import io.netty.buffer.ByteBuf; public class TitleTextPacket extends GenericTitlePacket { @@ -31,7 +32,7 @@ public class TitleTextPacket extends GenericTitlePacket { } @Override - public void encode(ByteBuf buf, ProtocolUtils.Direction direction, ProtocolVersion version) { + public void encode(ByteBuf buf, Direction direction, ProtocolVersion version) { ProtocolUtils.writeString(buf, component); } diff --git a/proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/title/TitleTimesPacket.java b/proxy/src/main/java/com/velocitypowered/proxy/network/protocol/packet/title/TitleTimesPacket.java similarity index 89% rename from proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/title/TitleTimesPacket.java rename to proxy/src/main/java/com/velocitypowered/proxy/network/protocol/packet/title/TitleTimesPacket.java index 8764a12fa..8e7b70902 100644 --- a/proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/title/TitleTimesPacket.java +++ b/proxy/src/main/java/com/velocitypowered/proxy/network/protocol/packet/title/TitleTimesPacket.java @@ -15,11 +15,11 @@ * along with this program. If not, see . */ -package com.velocitypowered.proxy.protocol.packet.title; +package com.velocitypowered.proxy.network.protocol.packet.title; import com.velocitypowered.api.network.ProtocolVersion; import com.velocitypowered.proxy.connection.MinecraftSessionHandler; -import com.velocitypowered.proxy.protocol.ProtocolUtils; +import com.velocitypowered.proxy.network.protocol.ProtocolUtils.Direction; import io.netty.buffer.ByteBuf; public class TitleTimesPacket extends GenericTitlePacket { @@ -33,7 +33,7 @@ public class TitleTimesPacket extends GenericTitlePacket { } @Override - public void encode(ByteBuf buf, ProtocolUtils.Direction direction, ProtocolVersion version) { + public void encode(ByteBuf buf, Direction direction, ProtocolVersion version) { buf.writeInt(fadeIn); buf.writeInt(stay); buf.writeInt(fadeOut); diff --git a/proxy/src/main/java/com/velocitypowered/proxy/protocol/util/ByteBufDataInput.java b/proxy/src/main/java/com/velocitypowered/proxy/network/protocol/util/ByteBufDataInput.java similarity index 97% rename from proxy/src/main/java/com/velocitypowered/proxy/protocol/util/ByteBufDataInput.java rename to proxy/src/main/java/com/velocitypowered/proxy/network/protocol/util/ByteBufDataInput.java index 09e44ab46..54407134e 100644 --- a/proxy/src/main/java/com/velocitypowered/proxy/protocol/util/ByteBufDataInput.java +++ b/proxy/src/main/java/com/velocitypowered/proxy/network/protocol/util/ByteBufDataInput.java @@ -15,7 +15,7 @@ * along with this program. If not, see . */ -package com.velocitypowered.proxy.protocol.util; +package com.velocitypowered.proxy.network.protocol.util; import com.google.common.io.ByteArrayDataInput; import io.netty.buffer.ByteBuf; diff --git a/proxy/src/main/java/com/velocitypowered/proxy/protocol/util/ByteBufDataOutput.java b/proxy/src/main/java/com/velocitypowered/proxy/network/protocol/util/ByteBufDataOutput.java similarity index 97% rename from proxy/src/main/java/com/velocitypowered/proxy/protocol/util/ByteBufDataOutput.java rename to proxy/src/main/java/com/velocitypowered/proxy/network/protocol/util/ByteBufDataOutput.java index ad62ef64a..d27c58787 100644 --- a/proxy/src/main/java/com/velocitypowered/proxy/protocol/util/ByteBufDataOutput.java +++ b/proxy/src/main/java/com/velocitypowered/proxy/network/protocol/util/ByteBufDataOutput.java @@ -15,7 +15,7 @@ * along with this program. If not, see . */ -package com.velocitypowered.proxy.protocol.util; +package com.velocitypowered.proxy.network.protocol.util; import com.google.common.io.ByteArrayDataOutput; import io.netty.buffer.ByteBuf; diff --git a/proxy/src/main/java/com/velocitypowered/proxy/protocol/util/DeferredByteBufHolder.java b/proxy/src/main/java/com/velocitypowered/proxy/network/protocol/util/DeferredByteBufHolder.java similarity index 98% rename from proxy/src/main/java/com/velocitypowered/proxy/protocol/util/DeferredByteBufHolder.java rename to proxy/src/main/java/com/velocitypowered/proxy/network/protocol/util/DeferredByteBufHolder.java index 368ac503d..3fe39d26f 100644 --- a/proxy/src/main/java/com/velocitypowered/proxy/protocol/util/DeferredByteBufHolder.java +++ b/proxy/src/main/java/com/velocitypowered/proxy/network/protocol/util/DeferredByteBufHolder.java @@ -15,7 +15,7 @@ * along with this program. If not, see . */ -package com.velocitypowered.proxy.protocol.util; +package com.velocitypowered.proxy.network.protocol.util; import io.netty.buffer.ByteBuf; import io.netty.buffer.ByteBufHolder; diff --git a/proxy/src/main/java/com/velocitypowered/proxy/protocol/util/FaviconSerializer.java b/proxy/src/main/java/com/velocitypowered/proxy/network/protocol/util/FaviconSerializer.java similarity index 96% rename from proxy/src/main/java/com/velocitypowered/proxy/protocol/util/FaviconSerializer.java rename to proxy/src/main/java/com/velocitypowered/proxy/network/protocol/util/FaviconSerializer.java index 59e99a1d7..eebd503a8 100644 --- a/proxy/src/main/java/com/velocitypowered/proxy/protocol/util/FaviconSerializer.java +++ b/proxy/src/main/java/com/velocitypowered/proxy/network/protocol/util/FaviconSerializer.java @@ -15,7 +15,7 @@ * along with this program. If not, see . */ -package com.velocitypowered.proxy.protocol.util; +package com.velocitypowered.proxy.network.protocol.util; import com.google.gson.JsonDeserializationContext; import com.google.gson.JsonDeserializer; diff --git a/proxy/src/main/java/com/velocitypowered/proxy/protocol/util/GameProfileSerializer.java b/proxy/src/main/java/com/velocitypowered/proxy/network/protocol/util/GameProfileSerializer.java similarity index 97% rename from proxy/src/main/java/com/velocitypowered/proxy/protocol/util/GameProfileSerializer.java rename to proxy/src/main/java/com/velocitypowered/proxy/network/protocol/util/GameProfileSerializer.java index 06e75d0e6..9e3b3430b 100644 --- a/proxy/src/main/java/com/velocitypowered/proxy/protocol/util/GameProfileSerializer.java +++ b/proxy/src/main/java/com/velocitypowered/proxy/network/protocol/util/GameProfileSerializer.java @@ -15,7 +15,7 @@ * along with this program. If not, see . */ -package com.velocitypowered.proxy.protocol.util; +package com.velocitypowered.proxy.network.protocol.util; import com.google.gson.JsonDeserializationContext; import com.google.gson.JsonDeserializer; diff --git a/proxy/src/main/java/com/velocitypowered/proxy/protocol/util/NettyPreconditions.java b/proxy/src/main/java/com/velocitypowered/proxy/network/protocol/util/NettyPreconditions.java similarity index 96% rename from proxy/src/main/java/com/velocitypowered/proxy/protocol/util/NettyPreconditions.java rename to proxy/src/main/java/com/velocitypowered/proxy/network/protocol/util/NettyPreconditions.java index 91eb854dd..afdd36108 100644 --- a/proxy/src/main/java/com/velocitypowered/proxy/protocol/util/NettyPreconditions.java +++ b/proxy/src/main/java/com/velocitypowered/proxy/network/protocol/util/NettyPreconditions.java @@ -15,10 +15,10 @@ * along with this program. If not, see . */ -package com.velocitypowered.proxy.protocol.util; +package com.velocitypowered.proxy.network.protocol.util; import com.google.common.base.Strings; -import com.velocitypowered.proxy.protocol.netty.MinecraftDecoder; +import com.velocitypowered.proxy.network.pipeline.deser.MinecraftDecoder; import com.velocitypowered.proxy.util.except.QuietDecoderException; import io.netty.handler.codec.CorruptedFrameException; diff --git a/proxy/src/main/java/com/velocitypowered/proxy/protocol/util/PluginMessageUtil.java b/proxy/src/main/java/com/velocitypowered/proxy/network/protocol/util/PluginMessageUtil.java similarity index 97% rename from proxy/src/main/java/com/velocitypowered/proxy/protocol/util/PluginMessageUtil.java rename to proxy/src/main/java/com/velocitypowered/proxy/network/protocol/util/PluginMessageUtil.java index 4cf31391b..bd9829d1c 100644 --- a/proxy/src/main/java/com/velocitypowered/proxy/protocol/util/PluginMessageUtil.java +++ b/proxy/src/main/java/com/velocitypowered/proxy/network/protocol/util/PluginMessageUtil.java @@ -15,7 +15,7 @@ * along with this program. If not, see . */ -package com.velocitypowered.proxy.protocol.util; +package com.velocitypowered.proxy.network.protocol.util; import static com.google.common.base.Preconditions.checkArgument; import static com.google.common.base.Preconditions.checkNotNull; @@ -23,8 +23,8 @@ 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.PluginMessage; +import com.velocitypowered.proxy.network.protocol.ProtocolUtils; +import com.velocitypowered.proxy.network.protocol.packet.PluginMessage; import io.netty.buffer.ByteBuf; import io.netty.buffer.Unpooled; import java.nio.charset.StandardCharsets; diff --git a/proxy/src/main/java/com/velocitypowered/proxy/protocol/util/VelocityLegacyHoverEventSerializer.java b/proxy/src/main/java/com/velocitypowered/proxy/network/protocol/util/VelocityLegacyHoverEventSerializer.java similarity index 98% rename from proxy/src/main/java/com/velocitypowered/proxy/protocol/util/VelocityLegacyHoverEventSerializer.java rename to proxy/src/main/java/com/velocitypowered/proxy/network/protocol/util/VelocityLegacyHoverEventSerializer.java index e667a9b16..b03e30b47 100644 --- a/proxy/src/main/java/com/velocitypowered/proxy/protocol/util/VelocityLegacyHoverEventSerializer.java +++ b/proxy/src/main/java/com/velocitypowered/proxy/network/protocol/util/VelocityLegacyHoverEventSerializer.java @@ -15,7 +15,7 @@ * along with this program. If not, see . */ -package com.velocitypowered.proxy.protocol.util; +package com.velocitypowered.proxy.network.protocol.util; import java.io.IOException; import java.util.UUID; diff --git a/proxy/src/main/java/com/velocitypowered/proxy/network/netty/SeparatePoolInetNameResolver.java b/proxy/src/main/java/com/velocitypowered/proxy/network/util/SeparatePoolInetNameResolver.java similarity index 95% rename from proxy/src/main/java/com/velocitypowered/proxy/network/netty/SeparatePoolInetNameResolver.java rename to proxy/src/main/java/com/velocitypowered/proxy/network/util/SeparatePoolInetNameResolver.java index 2997d8408..48e1d631d 100644 --- a/proxy/src/main/java/com/velocitypowered/proxy/network/netty/SeparatePoolInetNameResolver.java +++ b/proxy/src/main/java/com/velocitypowered/proxy/network/util/SeparatePoolInetNameResolver.java @@ -15,7 +15,7 @@ * along with this program. If not, see . */ -package com.velocitypowered.proxy.network.netty; +package com.velocitypowered.proxy.network.util; import com.github.benmanes.caffeine.cache.Cache; import com.github.benmanes.caffeine.cache.Caffeine; @@ -37,9 +37,9 @@ import java.util.concurrent.RejectedExecutionException; import java.util.concurrent.TimeUnit; /** - * An implementation of {@code InetNameResolver} that performs blocking DNS name lookups - * in a separate thread, avoiding blocking the Netty threads for an extended period of time - * and without the downsides of Netty's native DNS resolver. + * An implementation of {@code InetNameResolver} that performs blocking DNS name lookups in a + * separate thread, avoiding blocking the Netty threads for an extended period of time and without + * the downsides of Netty's native DNS resolver. */ public final class SeparatePoolInetNameResolver extends InetNameResolver { diff --git a/proxy/src/main/java/com/velocitypowered/proxy/network/TransportType.java b/proxy/src/main/java/com/velocitypowered/proxy/network/util/TransportType.java similarity index 97% rename from proxy/src/main/java/com/velocitypowered/proxy/network/TransportType.java rename to proxy/src/main/java/com/velocitypowered/proxy/network/util/TransportType.java index 0608fcf1f..e7c3819d3 100644 --- a/proxy/src/main/java/com/velocitypowered/proxy/network/TransportType.java +++ b/proxy/src/main/java/com/velocitypowered/proxy/network/util/TransportType.java @@ -15,7 +15,7 @@ * along with this program. If not, see . */ -package com.velocitypowered.proxy.network; +package com.velocitypowered.proxy.network.util; import com.velocitypowered.proxy.util.concurrent.VelocityNettyThreadFactory; import io.netty.channel.Channel; @@ -136,6 +136,10 @@ public enum TransportType { return this.socketChannelFactory; } + public ChannelFactory getDatagramChannelFactory() { + return datagramChannelFactory; + } + public EventLoopGroup createEventLoopGroup(final Type type) { return this.eventLoopGroupFactory.apply(this.name, type); } diff --git a/proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/chat/ChatAcknowledgement.java b/proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/chat/ChatAcknowledgement.java deleted file mode 100644 index f1f9ad242..000000000 --- a/proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/chat/ChatAcknowledgement.java +++ /dev/null @@ -1,57 +0,0 @@ -/* - * Copyright (C) 2023 Velocity Contributors - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -package com.velocitypowered.proxy.protocol.packet.chat; - -import com.velocitypowered.api.network.ProtocolVersion; -import com.velocitypowered.proxy.connection.MinecraftSessionHandler; -import com.velocitypowered.proxy.protocol.MinecraftPacket; -import com.velocitypowered.proxy.protocol.ProtocolUtils; -import io.netty.buffer.ByteBuf; - -public class ChatAcknowledgement implements MinecraftPacket { - int offset; - - public ChatAcknowledgement(int offset) { - this.offset = offset; - } - - public ChatAcknowledgement() { - } - - @Override - public void decode(ByteBuf buf, ProtocolUtils.Direction direction, ProtocolVersion protocolVersion) { - offset = ProtocolUtils.readVarInt(buf); - } - - @Override - public void encode(ByteBuf buf, ProtocolUtils.Direction direction, ProtocolVersion protocolVersion) { - ProtocolUtils.writeVarInt(buf, offset); - } - - @Override - public boolean handle(MinecraftSessionHandler handler) { - return handler.handle(this); - } - - @Override - public String toString() { - return "ChatAcknowledgement{" + - "offset=" + offset + - '}'; - } -} diff --git a/proxy/src/main/java/com/velocitypowered/proxy/server/PingSessionHandler.java b/proxy/src/main/java/com/velocitypowered/proxy/server/PingSessionHandler.java index c3ff9f570..2388180bb 100644 --- a/proxy/src/main/java/com/velocitypowered/proxy/server/PingSessionHandler.java +++ b/proxy/src/main/java/com/velocitypowered/proxy/server/PingSessionHandler.java @@ -23,10 +23,10 @@ import com.velocitypowered.api.proxy.server.ServerPing; import com.velocitypowered.proxy.VelocityServer; import com.velocitypowered.proxy.connection.MinecraftConnection; import com.velocitypowered.proxy.connection.MinecraftSessionHandler; -import com.velocitypowered.proxy.protocol.StateRegistry; -import com.velocitypowered.proxy.protocol.packet.Handshake; -import com.velocitypowered.proxy.protocol.packet.StatusRequest; -import com.velocitypowered.proxy.protocol.packet.StatusResponse; +import com.velocitypowered.proxy.network.protocol.StateRegistry; +import com.velocitypowered.proxy.network.protocol.packet.Handshake; +import com.velocitypowered.proxy.network.protocol.packet.StatusRequest; +import com.velocitypowered.proxy.network.protocol.packet.StatusResponse; import io.netty.channel.EventLoop; import java.io.IOException; import java.net.InetSocketAddress; diff --git a/proxy/src/main/java/com/velocitypowered/proxy/server/VelocityRegisteredServer.java b/proxy/src/main/java/com/velocitypowered/proxy/server/VelocityRegisteredServer.java index 0cb7a50e1..4b9d81a0e 100644 --- a/proxy/src/main/java/com/velocitypowered/proxy/server/VelocityRegisteredServer.java +++ b/proxy/src/main/java/com/velocitypowered/proxy/server/VelocityRegisteredServer.java @@ -17,12 +17,7 @@ package com.velocitypowered.proxy.server; -import static com.velocitypowered.proxy.network.Connections.FRAME_DECODER; -import static com.velocitypowered.proxy.network.Connections.FRAME_ENCODER; import static com.velocitypowered.proxy.network.Connections.HANDLER; -import static com.velocitypowered.proxy.network.Connections.MINECRAFT_DECODER; -import static com.velocitypowered.proxy.network.Connections.MINECRAFT_ENCODER; -import static com.velocitypowered.proxy.network.Connections.READ_TIMEOUT; import com.google.common.base.Preconditions; import com.google.common.collect.ImmutableList; @@ -36,25 +31,18 @@ import com.velocitypowered.proxy.VelocityServer; import com.velocitypowered.proxy.connection.MinecraftConnection; import com.velocitypowered.proxy.connection.backend.VelocityServerConnection; import com.velocitypowered.proxy.connection.client.ConnectedPlayer; -import com.velocitypowered.proxy.protocol.ProtocolUtils; -import com.velocitypowered.proxy.protocol.StateRegistry; -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.pipeline.initializers.BackendChannelInitializer; +import com.velocitypowered.proxy.network.protocol.StateRegistry; import io.netty.buffer.ByteBuf; import io.netty.buffer.Unpooled; import io.netty.channel.Channel; import io.netty.channel.ChannelFutureListener; -import io.netty.channel.ChannelInitializer; import io.netty.channel.EventLoop; -import io.netty.handler.timeout.ReadTimeoutHandler; import java.util.Collection; import java.util.Map; import java.util.UUID; import java.util.concurrent.CompletableFuture; import java.util.concurrent.ConcurrentHashMap; -import java.util.concurrent.TimeUnit; import net.kyori.adventure.audience.Audience; import net.kyori.adventure.audience.ForwardingAudience; import org.checkerframework.checker.nullness.qual.NonNull; @@ -107,30 +95,23 @@ public class VelocityRegisteredServer implements RegisteredServer, ForwardingAud throw new IllegalStateException("No Velocity proxy instance available"); } CompletableFuture pingFuture = new CompletableFuture<>(); - server.createBootstrap(loop, serverInfo.getAddress()).handler(new ChannelInitializer<>() { - @Override - protected void initChannel(Channel ch) { - ch.pipeline().addLast(FRAME_DECODER, new MinecraftVarintFrameDecoder()) - .addLast(READ_TIMEOUT, new ReadTimeoutHandler( - pingOptions.getTimeout() == 0 - ? server.getConfiguration().getReadTimeout() - : pingOptions.getTimeout(), TimeUnit.MILLISECONDS)) - .addLast(FRAME_ENCODER, MinecraftVarintLengthEncoder.INSTANCE) - .addLast(MINECRAFT_DECODER, new MinecraftDecoder(ProtocolUtils.Direction.CLIENTBOUND)) - .addLast(MINECRAFT_ENCODER, new MinecraftEncoder(ProtocolUtils.Direction.SERVERBOUND)); - - ch.pipeline().addLast(HANDLER, new MinecraftConnection(ch, server)); - } - }).connect(serverInfo.getAddress()).addListener((ChannelFutureListener) future -> { - if (future.isSuccess()) { - MinecraftConnection conn = future.channel().pipeline().get(MinecraftConnection.class); - conn.setActiveSessionHandler(StateRegistry.HANDSHAKE, - new PingSessionHandler(pingFuture, VelocityRegisteredServer.this, conn, - pingOptions.getProtocolVersion())); - } else { - pingFuture.completeExceptionally(future.cause()); - } - }); + long timeoutMs = pingOptions.getTimeout() == 0 + ? server.getConfiguration().getReadTimeout() : pingOptions.getTimeout(); + server.createBootstrap(loop, serverInfo.getAddress()) + .handler(new BackendChannelInitializer(timeoutMs)) + .connect(serverInfo.getAddress()) + .addListener((ChannelFutureListener) future -> { + if (future.isSuccess()) { + Channel ch = future.channel(); + MinecraftConnection conn = new MinecraftConnection(ch, server); + ch.pipeline().addLast(HANDLER, conn); + conn.setActiveSessionHandler(StateRegistry.HANDSHAKE, + new PingSessionHandler(pingFuture, VelocityRegisteredServer.this, conn, + pingOptions.getProtocolVersion())); + } else { + pingFuture.completeExceptionally(future.cause()); + } + }); return pingFuture; } diff --git a/proxy/src/main/java/com/velocitypowered/proxy/tablist/InternalTabList.java b/proxy/src/main/java/com/velocitypowered/proxy/tablist/InternalTabList.java index dcf00ecae..cec065da1 100644 --- a/proxy/src/main/java/com/velocitypowered/proxy/tablist/InternalTabList.java +++ b/proxy/src/main/java/com/velocitypowered/proxy/tablist/InternalTabList.java @@ -18,9 +18,9 @@ package com.velocitypowered.proxy.tablist; import com.velocitypowered.api.proxy.player.TabList; -import com.velocitypowered.proxy.protocol.packet.LegacyPlayerListItem; -import com.velocitypowered.proxy.protocol.packet.RemovePlayerInfo; -import com.velocitypowered.proxy.protocol.packet.UpsertPlayerInfo; +import com.velocitypowered.proxy.network.protocol.packet.LegacyPlayerListItem; +import com.velocitypowered.proxy.network.protocol.packet.RemovePlayerInfo; +import com.velocitypowered.proxy.network.protocol.packet.UpsertPlayerInfo; /** * Tab list interface with methods for handling player info packets. diff --git a/proxy/src/main/java/com/velocitypowered/proxy/tablist/KeyedVelocityTabList.java b/proxy/src/main/java/com/velocitypowered/proxy/tablist/KeyedVelocityTabList.java index e24c337ed..3d00a61cd 100644 --- a/proxy/src/main/java/com/velocitypowered/proxy/tablist/KeyedVelocityTabList.java +++ b/proxy/src/main/java/com/velocitypowered/proxy/tablist/KeyedVelocityTabList.java @@ -26,8 +26,8 @@ import com.velocitypowered.api.proxy.player.TabListEntry; import com.velocitypowered.api.util.GameProfile; import com.velocitypowered.proxy.connection.MinecraftConnection; import com.velocitypowered.proxy.connection.client.ConnectedPlayer; -import com.velocitypowered.proxy.protocol.packet.LegacyPlayerListItem; -import com.velocitypowered.proxy.protocol.packet.chat.RemoteChatSession; +import com.velocitypowered.proxy.network.protocol.packet.LegacyPlayerListItem; +import com.velocitypowered.proxy.network.protocol.packet.chat.RemoteChatSession; import java.util.ArrayList; import java.util.Collection; import java.util.Collections; diff --git a/proxy/src/main/java/com/velocitypowered/proxy/tablist/KeyedVelocityTabListEntry.java b/proxy/src/main/java/com/velocitypowered/proxy/tablist/KeyedVelocityTabListEntry.java index dd1753434..0c8b89383 100644 --- a/proxy/src/main/java/com/velocitypowered/proxy/tablist/KeyedVelocityTabListEntry.java +++ b/proxy/src/main/java/com/velocitypowered/proxy/tablist/KeyedVelocityTabListEntry.java @@ -22,8 +22,8 @@ import com.velocitypowered.api.proxy.player.ChatSession; import com.velocitypowered.api.proxy.player.TabList; import com.velocitypowered.api.proxy.player.TabListEntry; import com.velocitypowered.api.util.GameProfile; -import com.velocitypowered.proxy.protocol.packet.LegacyPlayerListItem; -import com.velocitypowered.proxy.protocol.packet.chat.RemoteChatSession; +import com.velocitypowered.proxy.network.protocol.packet.LegacyPlayerListItem; +import com.velocitypowered.proxy.network.protocol.packet.chat.RemoteChatSession; import java.util.Optional; import org.checkerframework.checker.nullness.qual.Nullable; diff --git a/proxy/src/main/java/com/velocitypowered/proxy/tablist/VelocityTabList.java b/proxy/src/main/java/com/velocitypowered/proxy/tablist/VelocityTabList.java index e68ad8ced..b4b10b2a8 100644 --- a/proxy/src/main/java/com/velocitypowered/proxy/tablist/VelocityTabList.java +++ b/proxy/src/main/java/com/velocitypowered/proxy/tablist/VelocityTabList.java @@ -24,9 +24,9 @@ import com.velocitypowered.api.proxy.player.TabListEntry; import com.velocitypowered.api.util.GameProfile; import com.velocitypowered.proxy.connection.MinecraftConnection; import com.velocitypowered.proxy.connection.client.ConnectedPlayer; -import com.velocitypowered.proxy.protocol.packet.RemovePlayerInfo; -import com.velocitypowered.proxy.protocol.packet.UpsertPlayerInfo; -import com.velocitypowered.proxy.protocol.packet.chat.RemoteChatSession; +import com.velocitypowered.proxy.network.protocol.packet.RemovePlayerInfo; +import com.velocitypowered.proxy.network.protocol.packet.UpsertPlayerInfo; +import com.velocitypowered.proxy.network.protocol.packet.chat.RemoteChatSession; import java.util.ArrayList; import java.util.Collection; import java.util.Collections; diff --git a/proxy/src/main/java/com/velocitypowered/proxy/tablist/VelocityTabListEntry.java b/proxy/src/main/java/com/velocitypowered/proxy/tablist/VelocityTabListEntry.java index f8bd9760a..3dd68adb7 100644 --- a/proxy/src/main/java/com/velocitypowered/proxy/tablist/VelocityTabListEntry.java +++ b/proxy/src/main/java/com/velocitypowered/proxy/tablist/VelocityTabListEntry.java @@ -21,7 +21,7 @@ import com.velocitypowered.api.proxy.player.ChatSession; import com.velocitypowered.api.proxy.player.TabList; import com.velocitypowered.api.proxy.player.TabListEntry; import com.velocitypowered.api.util.GameProfile; -import com.velocitypowered.proxy.protocol.packet.UpsertPlayerInfo; +import com.velocitypowered.proxy.network.protocol.packet.UpsertPlayerInfo; import java.util.Optional; import net.kyori.adventure.text.Component; import org.checkerframework.checker.nullness.qual.Nullable; diff --git a/proxy/src/main/java/com/velocitypowered/proxy/tablist/VelocityTabListLegacy.java b/proxy/src/main/java/com/velocitypowered/proxy/tablist/VelocityTabListLegacy.java index 6e1777788..243ad0264 100644 --- a/proxy/src/main/java/com/velocitypowered/proxy/tablist/VelocityTabListLegacy.java +++ b/proxy/src/main/java/com/velocitypowered/proxy/tablist/VelocityTabListLegacy.java @@ -22,8 +22,8 @@ import com.velocitypowered.api.proxy.ProxyServer; import com.velocitypowered.api.proxy.player.TabListEntry; import com.velocitypowered.api.util.GameProfile; import com.velocitypowered.proxy.connection.client.ConnectedPlayer; -import com.velocitypowered.proxy.protocol.packet.LegacyPlayerListItem; -import com.velocitypowered.proxy.protocol.packet.LegacyPlayerListItem.Item; +import com.velocitypowered.proxy.network.protocol.packet.LegacyPlayerListItem; +import com.velocitypowered.proxy.network.protocol.packet.LegacyPlayerListItem.Item; import java.util.Collections; import java.util.Map; import java.util.Optional; diff --git a/proxy/src/main/java/com/velocitypowered/proxy/util/InformationUtils.java b/proxy/src/main/java/com/velocitypowered/proxy/util/InformationUtils.java index 12585d063..24c17e360 100644 --- a/proxy/src/main/java/com/velocitypowered/proxy/util/InformationUtils.java +++ b/proxy/src/main/java/com/velocitypowered/proxy/util/InformationUtils.java @@ -33,7 +33,7 @@ import com.velocitypowered.api.proxy.config.ProxyConfig; import com.velocitypowered.api.proxy.server.RegisteredServer; import com.velocitypowered.api.util.ProxyVersion; import com.velocitypowered.natives.util.Natives; -import com.velocitypowered.proxy.network.TransportType; +import com.velocitypowered.proxy.network.util.TransportType; import java.net.Inet4Address; import java.net.Inet6Address; import java.net.InetAddress; diff --git a/proxy/src/main/java/com/velocitypowered/proxy/util/VelocityChannelRegistrar.java b/proxy/src/main/java/com/velocitypowered/proxy/util/VelocityChannelRegistrar.java index 2aaf4ec51..b0897c02e 100644 --- a/proxy/src/main/java/com/velocitypowered/proxy/util/VelocityChannelRegistrar.java +++ b/proxy/src/main/java/com/velocitypowered/proxy/util/VelocityChannelRegistrar.java @@ -23,7 +23,7 @@ import com.velocitypowered.api.proxy.messages.ChannelIdentifier; import com.velocitypowered.api.proxy.messages.ChannelRegistrar; import com.velocitypowered.api.proxy.messages.LegacyChannelIdentifier; import com.velocitypowered.api.proxy.messages.MinecraftChannelIdentifier; -import com.velocitypowered.proxy.protocol.util.PluginMessageUtil; +import com.velocitypowered.proxy.network.protocol.util.PluginMessageUtil; import java.util.Collection; import java.util.HashSet; import java.util.Map; diff --git a/proxy/src/main/java/com/velocitypowered/proxy/util/bossbar/AdventureBossBarManager.java b/proxy/src/main/java/com/velocitypowered/proxy/util/bossbar/AdventureBossBarManager.java index db3560ae0..21364b170 100644 --- a/proxy/src/main/java/com/velocitypowered/proxy/util/bossbar/AdventureBossBarManager.java +++ b/proxy/src/main/java/com/velocitypowered/proxy/util/bossbar/AdventureBossBarManager.java @@ -20,7 +20,8 @@ package com.velocitypowered.proxy.util.bossbar; import com.google.common.collect.MapMaker; import com.velocitypowered.api.network.ProtocolVersion; import com.velocitypowered.proxy.connection.client.ConnectedPlayer; -import com.velocitypowered.proxy.protocol.ProtocolUtils; +import com.velocitypowered.proxy.network.protocol.ProtocolUtils; +import com.velocitypowered.proxy.network.protocol.packet.BossBarPacket; import com.velocitypowered.proxy.util.collect.Enum2IntMap; import com.velocitypowered.proxy.util.concurrent.Once; import java.util.Collections; @@ -128,8 +129,7 @@ public class AdventureBossBarManager implements BossBar.Listener { } for (ConnectedPlayer player : holder.subscribers) { Component translated = player.translateMessage(newName); - com.velocitypowered.proxy.protocol.packet.BossBar packet = holder.createTitleUpdate( - translated, player.getProtocolVersion()); + BossBarPacket packet = holder.createTitleUpdate(translated, player.getProtocolVersion()); player.getConnection().write(packet); } } @@ -140,7 +140,7 @@ public class AdventureBossBarManager implements BossBar.Listener { if (holder == null) { return; } - com.velocitypowered.proxy.protocol.packet.BossBar packet = holder + BossBarPacket packet = holder .createPercentUpdate(newPercent); for (ConnectedPlayer player : holder.subscribers) { player.getConnection().write(packet); @@ -154,7 +154,7 @@ public class AdventureBossBarManager implements BossBar.Listener { if (holder == null) { return; } - com.velocitypowered.proxy.protocol.packet.BossBar packet = holder.createColorUpdate(newColor); + BossBarPacket packet = holder.createColorUpdate(newColor); for (ConnectedPlayer player : holder.subscribers) { player.getConnection().write(packet); } @@ -167,7 +167,7 @@ public class AdventureBossBarManager implements BossBar.Listener { if (holder == null) { return; } - com.velocitypowered.proxy.protocol.packet.BossBar packet = holder + BossBarPacket packet = holder .createOverlayUpdate(newOverlay); for (ConnectedPlayer player : holder.subscribers) { player.getConnection().write(packet); @@ -181,7 +181,7 @@ public class AdventureBossBarManager implements BossBar.Listener { if (holder == null) { return; } - com.velocitypowered.proxy.protocol.packet.BossBar packet = holder.createFlagsUpdate(); + BossBarPacket packet = holder.createFlagsUpdate(); for (ConnectedPlayer player : holder.subscribers) { player.getConnection().write(packet); } @@ -203,15 +203,14 @@ public class AdventureBossBarManager implements BossBar.Listener { registrationOnce.run(() -> this.bar.addListener(AdventureBossBarManager.this)); } - com.velocitypowered.proxy.protocol.packet.BossBar createRemovePacket() { - return com.velocitypowered.proxy.protocol.packet.BossBar.createRemovePacket(this.id); + BossBarPacket createRemovePacket() { + return BossBarPacket.createRemovePacket(this.id); } - com.velocitypowered.proxy.protocol.packet.BossBar createAddPacket(ConnectedPlayer player) { - com.velocitypowered.proxy.protocol.packet.BossBar packet = new com.velocitypowered - .proxy.protocol.packet.BossBar(); + BossBarPacket createAddPacket(ConnectedPlayer player) { + BossBarPacket packet = new BossBarPacket(); packet.setUuid(this.id); - packet.setAction(com.velocitypowered.proxy.protocol.packet.BossBar.ADD); + packet.setAction(BossBarPacket.ADD); packet.setName(ProtocolUtils.getJsonChatSerializer(player.getProtocolVersion()) .serialize(player.translateMessage(bar.name()))); packet.setColor(COLORS_TO_PROTOCOL.get(bar.color())); @@ -221,55 +220,50 @@ public class AdventureBossBarManager implements BossBar.Listener { return packet; } - com.velocitypowered.proxy.protocol.packet.BossBar createPercentUpdate(float newPercent) { - com.velocitypowered.proxy.protocol.packet.BossBar packet = new com.velocitypowered - .proxy.protocol.packet.BossBar(); + BossBarPacket createPercentUpdate(float newPercent) { + BossBarPacket packet = new BossBarPacket(); packet.setUuid(this.id); - packet.setAction(com.velocitypowered.proxy.protocol.packet.BossBar.UPDATE_PERCENT); + packet.setAction(BossBarPacket.UPDATE_PERCENT); packet.setPercent(newPercent); return packet; } - com.velocitypowered.proxy.protocol.packet.BossBar createColorUpdate(Color color) { - com.velocitypowered.proxy.protocol.packet.BossBar packet = new com.velocitypowered - .proxy.protocol.packet.BossBar(); + BossBarPacket createColorUpdate(Color color) { + BossBarPacket packet = new BossBarPacket(); packet.setUuid(this.id); - packet.setAction(com.velocitypowered.proxy.protocol.packet.BossBar.UPDATE_STYLE); + packet.setAction(BossBarPacket.UPDATE_STYLE); packet.setColor(COLORS_TO_PROTOCOL.get(color)); packet.setOverlay(OVERLAY_TO_PROTOCOL.get(bar.overlay())); packet.setFlags(serializeFlags(bar.flags())); return packet; } - com.velocitypowered.proxy.protocol.packet.BossBar createTitleUpdate(Component name, + BossBarPacket createTitleUpdate(Component name, ProtocolVersion version) { - com.velocitypowered.proxy.protocol.packet.BossBar packet = new com.velocitypowered - .proxy.protocol.packet.BossBar(); + BossBarPacket packet = new BossBarPacket(); packet.setUuid(this.id); - packet.setAction(com.velocitypowered.proxy.protocol.packet.BossBar.UPDATE_NAME); + packet.setAction(BossBarPacket.UPDATE_NAME); packet.setName(ProtocolUtils.getJsonChatSerializer(version).serialize(name)); return packet; } - com.velocitypowered.proxy.protocol.packet.BossBar createFlagsUpdate() { + BossBarPacket createFlagsUpdate() { return createFlagsUpdate(bar.flags()); } - com.velocitypowered.proxy.protocol.packet.BossBar createFlagsUpdate(Set newFlags) { - com.velocitypowered.proxy.protocol.packet.BossBar packet = new com.velocitypowered - .proxy.protocol.packet.BossBar(); + BossBarPacket createFlagsUpdate(Set newFlags) { + BossBarPacket packet = new BossBarPacket(); packet.setUuid(this.id); - packet.setAction(com.velocitypowered.proxy.protocol.packet.BossBar.UPDATE_PROPERTIES); + packet.setAction(BossBarPacket.UPDATE_PROPERTIES); packet.setColor(COLORS_TO_PROTOCOL.get(this.bar.color())); packet.setFlags(this.serializeFlags(newFlags)); return packet; } - com.velocitypowered.proxy.protocol.packet.BossBar createOverlayUpdate(Overlay overlay) { - com.velocitypowered.proxy.protocol.packet.BossBar packet = new com.velocitypowered - .proxy.protocol.packet.BossBar(); + BossBarPacket createOverlayUpdate(Overlay overlay) { + BossBarPacket packet = new BossBarPacket(); packet.setUuid(this.id); - packet.setAction(com.velocitypowered.proxy.protocol.packet.BossBar.UPDATE_STYLE); + packet.setAction(BossBarPacket.UPDATE_STYLE); packet.setColor(COLORS_TO_PROTOCOL.get(bar.color())); packet.setOverlay(OVERLAY_TO_PROTOCOL.get(overlay)); return packet; diff --git a/proxy/src/test/java/com/velocitypowered/proxy/protocol/PacketRegistryTest.java b/proxy/src/test/java/com/velocitypowered/proxy/network/protocol/PacketRegistryTest.java similarity index 97% rename from proxy/src/test/java/com/velocitypowered/proxy/protocol/PacketRegistryTest.java rename to proxy/src/test/java/com/velocitypowered/proxy/network/protocol/PacketRegistryTest.java index 05a83eea1..e86d94848 100644 --- a/proxy/src/test/java/com/velocitypowered/proxy/protocol/PacketRegistryTest.java +++ b/proxy/src/test/java/com/velocitypowered/proxy/network/protocol/PacketRegistryTest.java @@ -15,7 +15,7 @@ * along with this program. If not, see . */ -package com.velocitypowered.proxy.protocol; +package com.velocitypowered.proxy.network.protocol; import static com.google.common.collect.Iterables.getLast; import static com.velocitypowered.api.network.ProtocolVersion.MINECRAFT_1_11; @@ -36,8 +36,8 @@ import static org.junit.jupiter.api.Assertions.assertNull; import static org.junit.jupiter.api.Assertions.assertThrows; import com.velocitypowered.api.network.ProtocolVersion; -import com.velocitypowered.proxy.protocol.packet.Handshake; -import com.velocitypowered.proxy.protocol.packet.StatusPing; +import com.velocitypowered.proxy.network.protocol.packet.Handshake; +import com.velocitypowered.proxy.network.protocol.packet.StatusPing; import org.junit.jupiter.api.Test; class PacketRegistryTest { diff --git a/proxy/src/test/java/com/velocitypowered/proxy/protocol/ProtocolUtilsTest.java b/proxy/src/test/java/com/velocitypowered/proxy/network/protocol/ProtocolUtilsTest.java similarity index 98% rename from proxy/src/test/java/com/velocitypowered/proxy/protocol/ProtocolUtilsTest.java rename to proxy/src/test/java/com/velocitypowered/proxy/network/protocol/ProtocolUtilsTest.java index f476de67c..a4bda0064 100644 --- a/proxy/src/test/java/com/velocitypowered/proxy/protocol/ProtocolUtilsTest.java +++ b/proxy/src/test/java/com/velocitypowered/proxy/network/protocol/ProtocolUtilsTest.java @@ -15,7 +15,7 @@ * along with this program. If not, see . */ -package com.velocitypowered.proxy.protocol; +package com.velocitypowered.proxy.network.protocol; import static org.junit.jupiter.api.Assertions.assertArrayEquals; import static org.junit.jupiter.api.Assertions.assertEquals; diff --git a/proxy/src/test/java/com/velocitypowered/proxy/protocol/util/PluginMessageUtilTest.java b/proxy/src/test/java/com/velocitypowered/proxy/network/protocol/util/PluginMessageUtilTest.java similarity index 97% rename from proxy/src/test/java/com/velocitypowered/proxy/protocol/util/PluginMessageUtilTest.java rename to proxy/src/test/java/com/velocitypowered/proxy/network/protocol/util/PluginMessageUtilTest.java index 5c5860066..bff8657d1 100644 --- a/proxy/src/test/java/com/velocitypowered/proxy/protocol/util/PluginMessageUtilTest.java +++ b/proxy/src/test/java/com/velocitypowered/proxy/network/protocol/util/PluginMessageUtilTest.java @@ -15,7 +15,7 @@ * along with this program. If not, see . */ -package com.velocitypowered.proxy.protocol.util; +package com.velocitypowered.proxy.network.protocol.util; import static org.junit.jupiter.api.Assertions.assertEquals;