13
0
geforkt von Mirrors/Velocity

Updated the packet classes to include the "Packet" suffix (#1202)

* Updated the packet classes to include the "Packet" suffix

* Fixed test checkstyle
Dieser Commit ist enthalten in:
Adrian 2024-01-18 15:25:22 -05:00 committet von GitHub
Ursprung 75e24a0c59
Commit 2ac8751337
Es konnte kein GPG-Schlüssel zu dieser Signatur gefunden werden
GPG-Schlüssel-ID: B5690EEEBB952194
93 geänderte Dateien mit 881 neuen und 838 gelöschten Zeilen

Datei anzeigen

@ -48,6 +48,7 @@ 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.protocol.packet.SetCompressionPacket;
import com.velocitypowered.proxy.util.except.QuietDecoderException;
import io.netty.buffer.ByteBuf;
import io.netty.channel.Channel;
@ -501,7 +502,7 @@ public class MinecraftConnection extends ChannelInboundHandlerAdapter {
/**
* Sets the compression threshold on the connection. You are responsible for sending {@link
* com.velocitypowered.proxy.protocol.packet.SetCompression} beforehand.
* SetCompressionPacket} beforehand.
*
* @param threshold the compression threshold to use
*/

Datei anzeigen

@ -18,52 +18,52 @@
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.RemoveResourcePack;
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.AvailableCommandsPacket;
import com.velocitypowered.proxy.protocol.packet.BossBarPacket;
import com.velocitypowered.proxy.protocol.packet.ClientSettingsPacket;
import com.velocitypowered.proxy.protocol.packet.DisconnectPacket;
import com.velocitypowered.proxy.protocol.packet.EncryptionRequestPacket;
import com.velocitypowered.proxy.protocol.packet.EncryptionResponsePacket;
import com.velocitypowered.proxy.protocol.packet.HandshakePacket;
import com.velocitypowered.proxy.protocol.packet.HeaderAndFooterPacket;
import com.velocitypowered.proxy.protocol.packet.JoinGamePacket;
import com.velocitypowered.proxy.protocol.packet.KeepAlivePacket;
import com.velocitypowered.proxy.protocol.packet.LegacyHandshakePacket;
import com.velocitypowered.proxy.protocol.packet.LegacyPingPacket;
import com.velocitypowered.proxy.protocol.packet.LegacyPlayerListItemPacket;
import com.velocitypowered.proxy.protocol.packet.LoginAcknowledgedPacket;
import com.velocitypowered.proxy.protocol.packet.LoginPluginMessagePacket;
import com.velocitypowered.proxy.protocol.packet.LoginPluginResponsePacket;
import com.velocitypowered.proxy.protocol.packet.PingIdentifyPacket;
import com.velocitypowered.proxy.protocol.packet.PluginMessagePacket;
import com.velocitypowered.proxy.protocol.packet.RemovePlayerInfoPacket;
import com.velocitypowered.proxy.protocol.packet.RemoveResourcePackPacket;
import com.velocitypowered.proxy.protocol.packet.ResourcePackRequestPacket;
import com.velocitypowered.proxy.protocol.packet.ResourcePackResponsePacket;
import com.velocitypowered.proxy.protocol.packet.RespawnPacket;
import com.velocitypowered.proxy.protocol.packet.ServerDataPacket;
import com.velocitypowered.proxy.protocol.packet.ServerLoginPacket;
import com.velocitypowered.proxy.protocol.packet.ServerLoginSuccessPacket;
import com.velocitypowered.proxy.protocol.packet.SetCompressionPacket;
import com.velocitypowered.proxy.protocol.packet.StatusPingPacket;
import com.velocitypowered.proxy.protocol.packet.StatusRequestPacket;
import com.velocitypowered.proxy.protocol.packet.StatusResponsePacket;
import com.velocitypowered.proxy.protocol.packet.TabCompleteRequestPacket;
import com.velocitypowered.proxy.protocol.packet.TabCompleteResponsePacket;
import com.velocitypowered.proxy.protocol.packet.UpsertPlayerInfoPacket;
import com.velocitypowered.proxy.protocol.packet.chat.ChatAcknowledgementPacket;
import com.velocitypowered.proxy.protocol.packet.chat.PlayerChatCompletionPacket;
import com.velocitypowered.proxy.protocol.packet.chat.SystemChatPacket;
import com.velocitypowered.proxy.protocol.packet.chat.keyed.KeyedPlayerChatPacket;
import com.velocitypowered.proxy.protocol.packet.chat.keyed.KeyedPlayerCommandPacket;
import com.velocitypowered.proxy.protocol.packet.chat.legacy.LegacyChatPacket;
import com.velocitypowered.proxy.protocol.packet.chat.session.SessionPlayerChatPacket;
import com.velocitypowered.proxy.protocol.packet.chat.session.SessionPlayerCommandPacket;
import com.velocitypowered.proxy.protocol.packet.config.ActiveFeaturesPacket;
import com.velocitypowered.proxy.protocol.packet.config.FinishedUpdatePacket;
import com.velocitypowered.proxy.protocol.packet.config.RegistrySyncPacket;
import com.velocitypowered.proxy.protocol.packet.config.StartUpdatePacket;
import com.velocitypowered.proxy.protocol.packet.config.TagsUpdatePacket;
import com.velocitypowered.proxy.protocol.packet.title.LegacyTitlePacket;
import com.velocitypowered.proxy.protocol.packet.title.TitleActionbarPacket;
import com.velocitypowered.proxy.protocol.packet.title.TitleClearPacket;
@ -117,103 +117,103 @@ public interface MinecraftSessionHandler {
}
default boolean handle(AvailableCommands commands) {
default boolean handle(AvailableCommandsPacket commands) {
return false;
}
default boolean handle(BossBar packet) {
default boolean handle(BossBarPacket packet) {
return false;
}
default boolean handle(LegacyChat packet) {
default boolean handle(LegacyChatPacket packet) {
return false;
}
default boolean handle(ClientSettings packet) {
default boolean handle(ClientSettingsPacket packet) {
return false;
}
default boolean handle(Disconnect packet) {
default boolean handle(DisconnectPacket packet) {
return false;
}
default boolean handle(EncryptionRequest packet) {
default boolean handle(EncryptionRequestPacket packet) {
return false;
}
default boolean handle(EncryptionResponse packet) {
default boolean handle(EncryptionResponsePacket packet) {
return false;
}
default boolean handle(Handshake packet) {
default boolean handle(HandshakePacket packet) {
return false;
}
default boolean handle(HeaderAndFooter packet) {
default boolean handle(HeaderAndFooterPacket packet) {
return false;
}
default boolean handle(JoinGame packet) {
default boolean handle(JoinGamePacket packet) {
return false;
}
default boolean handle(KeepAlive packet) {
default boolean handle(KeepAlivePacket packet) {
return false;
}
default boolean handle(LegacyHandshake packet) {
default boolean handle(LegacyHandshakePacket packet) {
return false;
}
default boolean handle(LegacyPing packet) {
default boolean handle(LegacyPingPacket packet) {
return false;
}
default boolean handle(LoginPluginMessage packet) {
default boolean handle(LoginPluginMessagePacket packet) {
return false;
}
default boolean handle(LoginPluginResponse packet) {
default boolean handle(LoginPluginResponsePacket packet) {
return false;
}
default boolean handle(PluginMessage packet) {
default boolean handle(PluginMessagePacket packet) {
return false;
}
default boolean handle(Respawn packet) {
default boolean handle(RespawnPacket packet) {
return false;
}
default boolean handle(ServerLogin packet) {
default boolean handle(ServerLoginPacket packet) {
return false;
}
default boolean handle(ServerLoginSuccess packet) {
default boolean handle(ServerLoginSuccessPacket packet) {
return false;
}
default boolean handle(SetCompression packet) {
default boolean handle(SetCompressionPacket packet) {
return false;
}
default boolean handle(StatusPing packet) {
default boolean handle(StatusPingPacket packet) {
return false;
}
default boolean handle(StatusRequest packet) {
default boolean handle(StatusRequestPacket packet) {
return false;
}
default boolean handle(StatusResponse packet) {
default boolean handle(StatusResponsePacket packet) {
return false;
}
default boolean handle(TabCompleteRequest packet) {
default boolean handle(TabCompleteRequestPacket packet) {
return false;
}
default boolean handle(TabCompleteResponse packet) {
default boolean handle(TabCompleteResponsePacket packet) {
return false;
}
@ -241,87 +241,87 @@ public interface MinecraftSessionHandler {
return false;
}
default boolean handle(LegacyPlayerListItem packet) {
default boolean handle(LegacyPlayerListItemPacket packet) {
return false;
}
default boolean handle(ResourcePackRequest packet) {
default boolean handle(ResourcePackRequestPacket packet) {
return false;
}
default boolean handle(RemoveResourcePack packet) {
default boolean handle(RemoveResourcePackPacket packet) {
return false;
}
default boolean handle(ResourcePackResponse packet) {
default boolean handle(ResourcePackResponsePacket packet) {
return false;
}
default boolean handle(KeyedPlayerChat packet) {
default boolean handle(KeyedPlayerChatPacket packet) {
return false;
}
default boolean handle(SessionPlayerChat packet) {
default boolean handle(SessionPlayerChatPacket packet) {
return false;
}
default boolean handle(SystemChat packet) {
default boolean handle(SystemChatPacket packet) {
return false;
}
default boolean handle(KeyedPlayerCommand packet) {
default boolean handle(KeyedPlayerCommandPacket packet) {
return false;
}
default boolean handle(SessionPlayerCommand packet) {
default boolean handle(SessionPlayerCommandPacket packet) {
return false;
}
default boolean handle(PlayerChatCompletion packet) {
default boolean handle(PlayerChatCompletionPacket packet) {
return false;
}
default boolean handle(ServerData serverData) {
default boolean handle(ServerDataPacket serverData) {
return false;
}
default boolean handle(RemovePlayerInfo packet) {
default boolean handle(RemovePlayerInfoPacket packet) {
return false;
}
default boolean handle(UpsertPlayerInfo packet) {
default boolean handle(UpsertPlayerInfoPacket packet) {
return false;
}
default boolean handle(LoginAcknowledged packet) {
default boolean handle(LoginAcknowledgedPacket packet) {
return false;
}
default boolean handle(ActiveFeatures packet) {
default boolean handle(ActiveFeaturesPacket packet) {
return false;
}
default boolean handle(FinishedUpdate packet) {
default boolean handle(FinishedUpdatePacket packet) {
return false;
}
default boolean handle(RegistrySync packet) {
default boolean handle(RegistrySyncPacket packet) {
return false;
}
default boolean handle(TagsUpdate packet) {
default boolean handle(TagsUpdatePacket packet) {
return false;
}
default boolean handle(StartUpdate packet) {
default boolean handle(StartUpdatePacket packet) {
return false;
}
default boolean handle(PingIdentify pingIdentify) {
default boolean handle(PingIdentifyPacket pingIdentify) {
return false;
}
default boolean handle(ChatAcknowledgement chatAcknowledgement) {
default boolean handle(ChatAcknowledgementPacket chatAcknowledgement) {
return false;
}
}

Datei anzeigen

@ -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.protocol.packet.PluginMessagePacket;
/**
* Provides connection phase specific actions.
@ -39,7 +39,7 @@ public interface BackendConnectionPhase {
*/
default boolean handle(VelocityServerConnection server,
ConnectedPlayer player,
PluginMessage message) {
PluginMessagePacket message) {
return false;
}

Datei anzeigen

@ -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.protocol.packet.PluginMessagePacket;
/**
* Contains Vanilla {@link BackendConnectionPhase}s.
@ -47,7 +47,7 @@ public final class BackendConnectionPhases {
@Override
public boolean handle(VelocityServerConnection serverConn,
ConnectedPlayer player,
PluginMessage message) {
PluginMessagePacket message) {
// The connection may be legacy forge. If so, the Forge handler will deal with this
// for us. Otherwise, we have nothing to do.
return LegacyForgeHandshakeBackendPhase.NOT_STARTED.handle(serverConn, player, message);

Datei anzeigen

@ -40,22 +40,22 @@ 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.RemoveResourcePack;
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.AvailableCommandsPacket;
import com.velocitypowered.proxy.protocol.packet.BossBarPacket;
import com.velocitypowered.proxy.protocol.packet.ClientSettingsPacket;
import com.velocitypowered.proxy.protocol.packet.DisconnectPacket;
import com.velocitypowered.proxy.protocol.packet.KeepAlivePacket;
import com.velocitypowered.proxy.protocol.packet.LegacyPlayerListItemPacket;
import com.velocitypowered.proxy.protocol.packet.PluginMessagePacket;
import com.velocitypowered.proxy.protocol.packet.RemovePlayerInfoPacket;
import com.velocitypowered.proxy.protocol.packet.RemoveResourcePackPacket;
import com.velocitypowered.proxy.protocol.packet.ResourcePackRequestPacket;
import com.velocitypowered.proxy.protocol.packet.ResourcePackResponsePacket;
import com.velocitypowered.proxy.protocol.packet.ServerDataPacket;
import com.velocitypowered.proxy.protocol.packet.TabCompleteResponsePacket;
import com.velocitypowered.proxy.protocol.packet.UpsertPlayerInfoPacket;
import com.velocitypowered.proxy.protocol.packet.chat.ComponentHolder;
import com.velocitypowered.proxy.protocol.packet.config.StartUpdate;
import com.velocitypowered.proxy.protocol.packet.config.StartUpdatePacket;
import com.velocitypowered.proxy.protocol.util.PluginMessageUtil;
import io.netty.buffer.ByteBuf;
import io.netty.buffer.ByteBufUtil;
@ -126,7 +126,7 @@ public class BackendPlaySessionHandler implements MinecraftSessionHandler {
}
@Override
public boolean handle(StartUpdate packet) {
public boolean handle(StartUpdatePacket packet) {
MinecraftConnection smc = serverConn.ensureConnected();
smc.setAutoReading(false);
// Even when not auto reading messages are still decoded. Decode them with the correct state
@ -136,36 +136,36 @@ public class BackendPlaySessionHandler implements MinecraftSessionHandler {
}
@Override
public boolean handle(KeepAlive packet) {
public boolean handle(KeepAlivePacket packet) {
serverConn.getPendingPings().put(packet.getRandomId(), System.nanoTime());
return false; // forwards on
}
@Override
public boolean handle(ClientSettings packet) {
public boolean handle(ClientSettingsPacket packet) {
serverConn.ensureConnected().write(packet);
return true;
}
@Override
public boolean handle(Disconnect packet) {
public boolean handle(DisconnectPacket packet) {
serverConn.disconnect();
serverConn.getPlayer().handleConnectionException(serverConn.getServer(), packet, true);
return true;
}
@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
}
@Override
public boolean handle(ResourcePackRequest packet) {
public boolean handle(ResourcePackRequestPacket packet) {
ResourcePackInfo.Builder builder = new VelocityResourcePackInfo.BuilderImpl(
Preconditions.checkNotNull(packet.getUrl()))
.setId(packet.getId())
@ -196,7 +196,7 @@ public class BackendPlaySessionHandler implements MinecraftSessionHandler {
serverConn.getPlayer().queueResourcePack(toSend);
} else if (serverConn.getConnection() != null) {
serverConn.getConnection().write(new ResourcePackResponse(
serverConn.getConnection().write(new ResourcePackResponsePacket(
packet.getId(),
packet.getHash(),
PlayerResourcePackStatusEvent.Status.DECLINED
@ -204,7 +204,7 @@ public class BackendPlaySessionHandler implements MinecraftSessionHandler {
}
}, playerConnection.eventLoop()).exceptionally((ex) -> {
if (serverConn.getConnection() != null) {
serverConn.getConnection().write(new ResourcePackResponse(
serverConn.getConnection().write(new ResourcePackResponsePacket(
packet.getId(),
packet.getHash(),
PlayerResourcePackStatusEvent.Status.DECLINED
@ -218,12 +218,12 @@ public class BackendPlaySessionHandler implements MinecraftSessionHandler {
}
@Override
public boolean handle(RemoveResourcePack packet) {
public boolean handle(RemoveResourcePackPacket packet) {
return false; //TODO
}
@Override
public boolean handle(PluginMessage packet) {
public boolean handle(PluginMessagePacket packet) {
if (bungeecordMessageResponder.process(packet)) {
return true;
}
@ -234,8 +234,9 @@ public class BackendPlaySessionHandler implements MinecraftSessionHandler {
}
if (PluginMessageUtil.isMcBrand(packet)) {
PluginMessage rewritten = PluginMessageUtil.rewriteMinecraftBrand(packet, server.getVersion(),
playerConnection.getProtocolVersion());
PluginMessagePacket rewritten = PluginMessageUtil
.rewriteMinecraftBrand(packet,
server.getVersion(), playerConnection.getProtocolVersion());
playerConnection.write(rewritten);
return true;
}
@ -254,7 +255,8 @@ public class BackendPlaySessionHandler implements MinecraftSessionHandler {
PluginMessageEvent event = new PluginMessageEvent(serverConn, serverConn.getPlayer(), id, copy);
server.getEventManager().fire(event).thenAcceptAsync(pme -> {
if (pme.getResult().isAllowed() && !playerConnection.isClosed()) {
PluginMessage copied = new PluginMessage(packet.getChannel(), Unpooled.wrappedBuffer(copy));
PluginMessagePacket copied = new PluginMessagePacket(
packet.getChannel(), Unpooled.wrappedBuffer(copy));
playerConnection.write(copied);
}
}, playerConnection.eventLoop()).exceptionally((ex) -> {
@ -265,31 +267,31 @@ public class BackendPlaySessionHandler implements MinecraftSessionHandler {
}
@Override
public boolean handle(TabCompleteResponse packet) {
public boolean handle(TabCompleteResponsePacket packet) {
playerSessionHandler.handleTabCompleteResponse(packet);
return true;
}
@Override
public boolean handle(LegacyPlayerListItem packet) {
public boolean handle(LegacyPlayerListItemPacket packet) {
serverConn.getPlayer().getTabList().processLegacy(packet);
return false;
}
@Override
public boolean handle(UpsertPlayerInfo packet) {
public boolean handle(UpsertPlayerInfoPacket packet) {
serverConn.getPlayer().getTabList().processUpdate(packet);
return false;
}
@Override
public boolean handle(RemovePlayerInfo packet) {
public boolean handle(RemovePlayerInfoPacket packet) {
serverConn.getPlayer().getTabList().processRemove(packet);
return false;
}
@Override
public boolean handle(AvailableCommands commands) {
public boolean handle(AvailableCommandsPacket commands) {
RootCommandNode<CommandSource> rootNode = commands.getRootNode();
if (server.getConfiguration().isAnnounceProxyCommands()) {
// Inject commands from the proxy.
@ -308,12 +310,12 @@ public class BackendPlaySessionHandler implements MinecraftSessionHandler {
}
@Override
public boolean handle(ServerData packet) {
public boolean handle(ServerDataPacket packet) {
server.getServerListPingHandler().getInitialPing(this.serverConn.getPlayer()).thenComposeAsync(
ping -> server.getEventManager()
.fire(new ProxyPingEvent(this.serverConn.getPlayer(), ping)),
playerConnection.eventLoop()).thenAcceptAsync(pingEvent -> this.playerConnection.write(
new ServerData(new ComponentHolder(
new ServerDataPacket(new ComponentHolder(
this.serverConn.ensureConnected().getProtocolVersion(),
pingEvent.getPing().getDescriptionComponent()),
pingEvent.getPing().getFavicon().orElse(null), packet.isSecureChatEnforced())),
@ -323,8 +325,8 @@ public class BackendPlaySessionHandler implements MinecraftSessionHandler {
@Override
public void handleGeneric(MinecraftPacket packet) {
if (packet instanceof PluginMessage) {
((PluginMessage) packet).retain();
if (packet instanceof PluginMessagePacket) {
((PluginMessagePacket) packet).retain();
}
playerConnection.delayedWrite(packet);
if (++packetsFlushed >= MAXIMUM_PACKETS_TO_FLUSH) {
@ -365,7 +367,7 @@ public class BackendPlaySessionHandler implements MinecraftSessionHandler {
if (!serverConn.isGracefulDisconnect() && !exceptionTriggered) {
if (server.getConfiguration().isFailoverOnUnexpectedServerDisconnect()) {
serverConn.getPlayer().handleConnectionException(serverConn.getServer(),
Disconnect.create(ConnectionMessages.INTERNAL_SERVER_CONNECTION_ERROR,
DisconnectPacket.create(ConnectionMessages.INTERNAL_SERVER_CONNECTION_ERROR,
serverConn.getPlayer().getProtocolVersion(), false), true);
} else {
serverConn.getPlayer().disconnect(ConnectionMessages.INTERNAL_SERVER_CONNECTION_ERROR);

Datei anzeigen

@ -28,7 +28,7 @@ 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.packet.PluginMessagePacket;
import com.velocitypowered.proxy.protocol.util.ByteBufDataInput;
import com.velocitypowered.proxy.protocol.util.ByteBufDataOutput;
import com.velocitypowered.proxy.server.VelocityRegisteredServer;
@ -68,7 +68,7 @@ public class BungeeCordMessageResponder {
this.player = player;
}
public static boolean isBungeeCordMessage(PluginMessage message) {
public static boolean isBungeeCordMessage(PluginMessagePacket message) {
return MODERN_CHANNEL.getId().equals(message.getChannel()) || LEGACY_CHANNEL.getId()
.equals(message.getChannel());
}
@ -310,11 +310,11 @@ public class BungeeCordMessageResponder {
private static void sendServerResponse(ConnectedPlayer player, ByteBuf buf) {
MinecraftConnection serverConnection = player.ensureAndGetCurrentServer().ensureConnected();
String chan = getBungeeCordChannel(serverConnection.getProtocolVersion());
PluginMessage msg = new PluginMessage(chan, buf);
PluginMessagePacket msg = new PluginMessagePacket(chan, buf);
serverConnection.write(msg);
}
boolean process(PluginMessage message) {
boolean process(PluginMessagePacket message) {
if (!proxy.getConfiguration().isBungeePluginChannelEnabled()) {
return false;
}

Datei anzeigen

@ -33,15 +33,15 @@ 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.packet.DisconnectPacket;
import com.velocitypowered.proxy.protocol.packet.KeepAlivePacket;
import com.velocitypowered.proxy.protocol.packet.PluginMessagePacket;
import com.velocitypowered.proxy.protocol.packet.ResourcePackRequestPacket;
import com.velocitypowered.proxy.protocol.packet.ResourcePackResponsePacket;
import com.velocitypowered.proxy.protocol.packet.config.FinishedUpdatePacket;
import com.velocitypowered.proxy.protocol.packet.config.RegistrySyncPacket;
import com.velocitypowered.proxy.protocol.packet.config.StartUpdatePacket;
import com.velocitypowered.proxy.protocol.packet.config.TagsUpdatePacket;
import com.velocitypowered.proxy.protocol.util.PluginMessageUtil;
import java.io.IOException;
import java.util.concurrent.CompletableFuture;
@ -100,25 +100,25 @@ public class ConfigSessionHandler implements MinecraftSessionHandler {
}
@Override
public boolean handle(StartUpdate packet) {
public boolean handle(StartUpdatePacket packet) {
serverConn.ensureConnected().write(packet);
return true;
}
@Override
public boolean handle(TagsUpdate packet) {
public boolean handle(TagsUpdatePacket packet) {
serverConn.getPlayer().getConnection().write(packet);
return true;
}
@Override
public boolean handle(KeepAlive packet) {
public boolean handle(KeepAlivePacket packet) {
serverConn.ensureConnected().write(packet);
return true;
}
@Override
public boolean handle(ResourcePackRequest packet) {
public boolean handle(ResourcePackRequestPacket packet) {
final MinecraftConnection playerConnection = serverConn.getPlayer().getConnection();
ServerResourcePackSendEvent event =
@ -138,13 +138,13 @@ public class ConfigSessionHandler implements MinecraftSessionHandler {
resourcePackToApply = null;
serverConn.getPlayer().queueResourcePack(toSend);
} else if (serverConn.getConnection() != null) {
serverConn.getConnection().write(new ResourcePackResponse(packet.getId(), packet.getHash(),
PlayerResourcePackStatusEvent.Status.DECLINED));
serverConn.getConnection().write(new ResourcePackResponsePacket(
packet.getId(), packet.getHash(), PlayerResourcePackStatusEvent.Status.DECLINED));
}
}, playerConnection.eventLoop()).exceptionally((ex) -> {
if (serverConn.getConnection() != null) {
serverConn.getConnection().write(new ResourcePackResponse(packet.getId(), packet.getHash(),
PlayerResourcePackStatusEvent.Status.DECLINED));
serverConn.getConnection().write(new ResourcePackResponsePacket(
packet.getId(), packet.getHash(), PlayerResourcePackStatusEvent.Status.DECLINED));
}
logger.error("Exception while handling resource pack send for {}", playerConnection, ex);
return null;
@ -154,7 +154,7 @@ public class ConfigSessionHandler implements MinecraftSessionHandler {
}
@Override
public boolean handle(FinishedUpdate packet) {
public boolean handle(FinishedUpdatePacket packet) {
MinecraftConnection smc = serverConn.ensureConnected();
ConnectedPlayer player = serverConn.getPlayer();
ClientConfigSessionHandler configHandler =
@ -183,14 +183,14 @@ public class ConfigSessionHandler implements MinecraftSessionHandler {
}
@Override
public boolean handle(Disconnect packet) {
public boolean handle(DisconnectPacket packet) {
serverConn.disconnect();
resultFuture.complete(ConnectionRequestResults.forDisconnect(packet, serverConn.getServer()));
return true;
}
@Override
public boolean handle(PluginMessage packet) {
public boolean handle(PluginMessagePacket packet) {
if (PluginMessageUtil.isMcBrand(packet)) {
serverConn.getPlayer().getConnection().write(
PluginMessageUtil.rewriteMinecraftBrand(packet, server.getVersion(),
@ -202,7 +202,7 @@ public class ConfigSessionHandler implements MinecraftSessionHandler {
}
@Override
public boolean handle(RegistrySync packet) {
public boolean handle(RegistrySyncPacket packet) {
serverConn.getPlayer().getConnection().write(packet.retain());
return true;
}

Datei anzeigen

@ -33,13 +33,13 @@ 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.protocol.packet.DisconnectPacket;
import com.velocitypowered.proxy.protocol.packet.EncryptionRequestPacket;
import com.velocitypowered.proxy.protocol.packet.LoginAcknowledgedPacket;
import com.velocitypowered.proxy.protocol.packet.LoginPluginMessagePacket;
import com.velocitypowered.proxy.protocol.packet.LoginPluginResponsePacket;
import com.velocitypowered.proxy.protocol.packet.ServerLoginSuccessPacket;
import com.velocitypowered.proxy.protocol.packet.SetCompressionPacket;
import com.velocitypowered.proxy.util.except.QuietRuntimeException;
import io.netty.buffer.ByteBuf;
import io.netty.buffer.ByteBufUtil;
@ -77,12 +77,12 @@ public class LoginSessionHandler implements MinecraftSessionHandler {
}
@Override
public boolean handle(EncryptionRequest packet) {
public boolean handle(EncryptionRequestPacket packet) {
throw new IllegalStateException("Backend server is online-mode!");
}
@Override
public boolean handle(LoginPluginMessage packet) {
public boolean handle(LoginPluginMessagePacket packet) {
MinecraftConnection mc = serverConn.ensureConnected();
VelocityConfiguration configuration = server.getConfiguration();
if (configuration.getPlayerInfoForwardingMode() == PlayerInfoForwarding.MODERN
@ -97,13 +97,14 @@ public class LoginSessionHandler implements MinecraftSessionHandler {
serverConn.getPlayerRemoteAddressAsString(), serverConn.getPlayer(),
requestedForwardingVersion);
LoginPluginResponse response = new LoginPluginResponse(packet.getId(), true, forwardingData);
LoginPluginResponsePacket response = new LoginPluginResponsePacket(
packet.getId(), true, forwardingData);
mc.write(response);
informationForwarded = true;
} else {
// Don't understand, fire event if we have subscribers
if (!this.server.getEventManager().hasSubscribers(ServerLoginPluginMessageEvent.class)) {
mc.write(new LoginPluginResponse(packet.getId(), false, Unpooled.EMPTY_BUFFER));
mc.write(new LoginPluginResponsePacket(packet.getId(), false, Unpooled.EMPTY_BUFFER));
return true;
}
@ -114,10 +115,10 @@ public class LoginSessionHandler implements MinecraftSessionHandler {
contents, packet.getId()))
.thenAcceptAsync(event -> {
if (event.getResult().isAllowed()) {
mc.write(new LoginPluginResponse(packet.getId(), true, Unpooled
mc.write(new LoginPluginResponsePacket(packet.getId(), true, Unpooled
.wrappedBuffer(event.getResult().getResponse())));
} else {
mc.write(new LoginPluginResponse(packet.getId(), false, Unpooled.EMPTY_BUFFER));
mc.write(new LoginPluginResponsePacket(packet.getId(), false, Unpooled.EMPTY_BUFFER));
}
}, mc.eventLoop());
}
@ -125,20 +126,20 @@ public class LoginSessionHandler implements MinecraftSessionHandler {
}
@Override
public boolean handle(Disconnect packet) {
public boolean handle(DisconnectPacket packet) {
resultFuture.complete(ConnectionRequestResults.forDisconnect(packet, serverConn.getServer()));
serverConn.disconnect();
return true;
}
@Override
public boolean handle(SetCompression packet) {
public boolean handle(SetCompressionPacket packet) {
serverConn.ensureConnected().setCompressionThreshold(packet.getThreshold());
return true;
}
@Override
public boolean handle(ServerLoginSuccess packet) {
public boolean handle(ServerLoginSuccessPacket packet) {
if (server.getConfiguration().getPlayerInfoForwardingMode() == PlayerInfoForwarding.MODERN
&& !informationForwarded) {
resultFuture.complete(ConnectionRequestResults.forDisconnect(MODERN_IP_FORWARDING_FAILURE,
@ -156,7 +157,7 @@ public class LoginSessionHandler implements MinecraftSessionHandler {
smc.setActiveSessionHandler(StateRegistry.PLAY,
new TransitionSessionHandler(server, serverConn, resultFuture));
} else {
smc.write(new LoginAcknowledged());
smc.write(new LoginAcknowledgedPacket());
smc.setActiveSessionHandler(StateRegistry.CONFIG,
new ConfigSessionHandler(server, serverConn, resultFuture));
ConnectedPlayer player = serverConn.getPlayer();
@ -184,11 +185,12 @@ public class LoginSessionHandler implements MinecraftSessionHandler {
public void disconnected() {
if (server.getConfiguration().getPlayerInfoForwardingMode() == PlayerInfoForwarding.LEGACY) {
resultFuture.completeExceptionally(new QuietRuntimeException(
"The connection to the remote server was unexpectedly closed.\n"
+ "This is usually because the remote server "
+ "does not have BungeeCord IP forwarding "
+ "correctly enabled.\nSee https://velocitypowered.com/wiki/users/forwarding/ "
+ "for instructions on how to configure player info forwarding correctly."));
"""
The connection to the remote server was unexpectedly closed.
This is usually because the remote server does not have \
BungeeCord IP forwarding correctly enabled.
See https://velocitypowered.com/wiki/users/forwarding/ for instructions \
on how to configure player info forwarding correctly."""));
} else {
resultFuture.completeExceptionally(
new QuietRuntimeException("The connection to the remote server was unexpectedly closed.")

Datei anzeigen

@ -34,10 +34,10 @@ import com.velocitypowered.proxy.connection.util.ConnectionMessages;
import com.velocitypowered.proxy.connection.util.ConnectionRequestResults;
import com.velocitypowered.proxy.connection.util.ConnectionRequestResults.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.protocol.packet.DisconnectPacket;
import com.velocitypowered.proxy.protocol.packet.JoinGamePacket;
import com.velocitypowered.proxy.protocol.packet.KeepAlivePacket;
import com.velocitypowered.proxy.protocol.packet.PluginMessagePacket;
import java.io.IOException;
import java.util.concurrent.CompletableFuture;
import org.apache.logging.log4j.LogManager;
@ -83,13 +83,13 @@ public class TransitionSessionHandler implements MinecraftSessionHandler {
}
@Override
public boolean handle(KeepAlive packet) {
public boolean handle(KeepAlivePacket packet) {
serverConn.ensureConnected().write(packet);
return true;
}
@Override
public boolean handle(JoinGame packet) {
public boolean handle(JoinGamePacket packet) {
MinecraftConnection smc = serverConn.ensureConnected();
final RegisteredServer previousServer = serverConn.getPreviousServer().orElse(null);
final ConnectedPlayer player = serverConn.getPlayer();
@ -166,7 +166,7 @@ public class TransitionSessionHandler implements MinecraftSessionHandler {
}
@Override
public boolean handle(Disconnect packet) {
public boolean handle(DisconnectPacket packet) {
final MinecraftConnection connection = serverConn.ensureConnected();
serverConn.disconnect();
@ -184,7 +184,7 @@ public class TransitionSessionHandler implements MinecraftSessionHandler {
}
@Override
public boolean handle(PluginMessage packet) {
public boolean handle(PluginMessagePacket packet) {
if (bungeecordMessageResponder.process(packet)) {
return true;
}

Datei anzeigen

@ -39,9 +39,10 @@ import com.velocitypowered.proxy.connection.client.ConnectedPlayer;
import com.velocitypowered.proxy.connection.forge.modern.ModernForgeConnectionType;
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.protocol.packet.HandshakePacket;
import com.velocitypowered.proxy.protocol.packet.JoinGamePacket;
import com.velocitypowered.proxy.protocol.packet.PluginMessagePacket;
import com.velocitypowered.proxy.protocol.packet.ServerLoginPacket;
import com.velocitypowered.proxy.server.VelocityRegisteredServer;
import io.netty.buffer.ByteBuf;
import io.netty.buffer.Unpooled;
@ -179,7 +180,7 @@ public class VelocityServerConnection implements MinecraftConnectionAssociation,
proxyPlayer.getVirtualHost().orElseGet(() -> registeredServer.getServerInfo().getAddress())
.getHostString();
Handshake handshake = new Handshake();
HandshakePacket handshake = new HandshakePacket();
handshake.setNextStatus(StateRegistry.LOGIN_ID);
handshake.setProtocolVersion(protocolVersion);
if (forwardingMode == PlayerInfoForwarding.LEGACY) {
@ -203,9 +204,10 @@ public class VelocityServerConnection implements MinecraftConnectionAssociation,
mc.setActiveSessionHandler(StateRegistry.LOGIN);
if (proxyPlayer.getIdentifiedKey() == null
&& proxyPlayer.getProtocolVersion().compareTo(ProtocolVersion.MINECRAFT_1_19_3) >= 0) {
mc.delayedWrite(new ServerLogin(proxyPlayer.getUsername(), proxyPlayer.getUniqueId()));
mc.delayedWrite(new ServerLoginPacket(proxyPlayer.getUsername(), proxyPlayer.getUniqueId()));
} else {
mc.delayedWrite(new ServerLogin(proxyPlayer.getUsername(), proxyPlayer.getIdentifiedKey()));
mc.delayedWrite(new ServerLoginPacket(proxyPlayer.getUsername(),
proxyPlayer.getIdentifiedKey()));
}
mc.flush();
}
@ -282,7 +284,7 @@ public class VelocityServerConnection implements MinecraftConnectionAssociation,
MinecraftConnection mc = ensureConnected();
PluginMessage message = new PluginMessage(identifier.getId(), data);
PluginMessagePacket message = new PluginMessagePacket(identifier.getId(), data);
mc.write(message);
return true;
}
@ -342,7 +344,7 @@ public class VelocityServerConnection implements MinecraftConnectionAssociation,
}
/**
* Gets whether the {@link com.velocitypowered.proxy.protocol.packet.JoinGame} packet has been
* Gets whether the {@link JoinGamePacket} packet has been
* sent by this server.
*
* @return Whether the join has been completed.

Datei anzeigen

@ -39,9 +39,9 @@ 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.protocol.packet.LoginAcknowledgedPacket;
import com.velocitypowered.proxy.protocol.packet.ServerLoginSuccessPacket;
import com.velocitypowered.proxy.protocol.packet.SetCompressionPacket;
import io.netty.buffer.ByteBuf;
import java.util.Objects;
import java.util.Optional;
@ -132,7 +132,7 @@ public class AuthSessionHandler implements MinecraftSessionHandler {
private void startLoginCompletion(ConnectedPlayer player) {
int threshold = server.getConfiguration().getCompressionThreshold();
if (threshold >= 0 && mcConnection.getProtocolVersion().compareTo(MINECRAFT_1_8) >= 0) {
mcConnection.write(new SetCompression(threshold));
mcConnection.write(new SetCompressionPacket(threshold));
mcConnection.setCompressionThreshold(threshold);
}
VelocityConfiguration configuration = server.getConfiguration();
@ -171,7 +171,7 @@ public class AuthSessionHandler implements MinecraftSessionHandler {
}
@Override
public boolean handle(LoginAcknowledged packet) {
public boolean handle(LoginAcknowledgedPacket packet) {
if (loginState != State.SUCCESS_SENT) {
inbound.disconnect(Component.translatable("multiplayer.disconnect.invalid_player_data"));
} else {
@ -209,7 +209,7 @@ public class AuthSessionHandler implements MinecraftSessionHandler {
return;
}
ServerLoginSuccess success = new ServerLoginSuccess();
ServerLoginSuccessPacket success = new ServerLoginSuccessPacket();
success.setUsername(player.getUsername());
success.setProperties(player.getGameProfileProperties());
success.setUuid(player.getUniqueId());

Datei anzeigen

@ -26,12 +26,12 @@ import com.velocitypowered.proxy.protocol.MinecraftPacket;
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.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.packet.ClientSettingsPacket;
import com.velocitypowered.proxy.protocol.packet.KeepAlivePacket;
import com.velocitypowered.proxy.protocol.packet.PingIdentifyPacket;
import com.velocitypowered.proxy.protocol.packet.PluginMessagePacket;
import com.velocitypowered.proxy.protocol.packet.ResourcePackResponsePacket;
import com.velocitypowered.proxy.protocol.packet.config.FinishedUpdatePacket;
import com.velocitypowered.proxy.protocol.util.PluginMessageUtil;
import io.netty.buffer.ByteBuf;
import io.netty.buffer.Unpooled;
@ -75,7 +75,7 @@ public class ClientConfigSessionHandler implements MinecraftSessionHandler {
}
@Override
public boolean handle(KeepAlive packet) {
public boolean handle(KeepAlivePacket packet) {
VelocityServerConnection serverConnection = player.getConnectedServer();
if (serverConnection != null) {
Long sentTime = serverConnection.getPendingPings().remove(packet.getRandomId());
@ -91,13 +91,13 @@ public class ClientConfigSessionHandler implements MinecraftSessionHandler {
}
@Override
public boolean handle(ClientSettings packet) {
public boolean handle(ClientSettingsPacket packet) {
player.setClientSettings(packet);
return true;
}
@Override
public boolean handle(ResourcePackResponse packet) {
public boolean handle(ResourcePackResponsePacket packet) {
if (player.getConnectionInFlight() != null) {
player.getConnectionInFlight().ensureConnected().write(packet);
}
@ -105,7 +105,7 @@ public class ClientConfigSessionHandler implements MinecraftSessionHandler {
}
@Override
public boolean handle(FinishedUpdate packet) {
public boolean handle(FinishedUpdatePacket packet) {
player.getConnection()
.setActiveSessionHandler(StateRegistry.PLAY, new ClientPlaySessionHandler(server, player));
@ -114,7 +114,7 @@ public class ClientConfigSessionHandler implements MinecraftSessionHandler {
}
@Override
public boolean handle(PluginMessage packet) {
public boolean handle(PluginMessagePacket packet) {
VelocityServerConnection serverConn = player.getConnectionInFlight();
if (serverConn != null) {
if (PluginMessageUtil.isMcBrand(packet)) {
@ -132,7 +132,7 @@ public class ClientConfigSessionHandler implements MinecraftSessionHandler {
}
@Override
public boolean handle(PingIdentify packet) {
public boolean handle(PingIdentifyPacket packet) {
if (player.getConnectionInFlight() != null) {
player.getConnectionInFlight().ensureConnected().write(packet);
}
@ -149,8 +149,8 @@ public class ClientConfigSessionHandler implements MinecraftSessionHandler {
MinecraftConnection smc = serverConnection.getConnection();
if (smc != null && serverConnection.getPhase().consideredComplete()) {
if (packet instanceof PluginMessage) {
((PluginMessage) packet).retain();
if (packet instanceof PluginMessagePacket) {
((PluginMessagePacket) packet).retain();
}
smc.write(packet);
}
@ -194,13 +194,13 @@ public class ClientConfigSessionHandler implements MinecraftSessionHandler {
if (brand != null && brandChannel != null) {
ByteBuf buf = Unpooled.buffer();
ProtocolUtils.writeString(buf, brand);
PluginMessage brandPacket = new PluginMessage(brandChannel, buf);
PluginMessagePacket brandPacket = new PluginMessagePacket(brandChannel, buf);
smc.write(brandPacket);
}
player.getConnection().write(new FinishedUpdate());
player.getConnection().write(new FinishedUpdatePacket());
smc.write(new FinishedUpdate());
smc.write(new FinishedUpdatePacket());
smc.getChannel().pipeline().get(MinecraftEncoder.class).setState(StateRegistry.PLAY);
return configSwitchFuture;

Datei anzeigen

@ -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.protocol.packet.PluginMessagePacket;
/**
* Provides connection phase specific actions.
@ -38,7 +38,7 @@ public interface ClientConnectionPhase {
* @return true if handled, false otherwise.
*/
default boolean handle(ConnectedPlayer player,
PluginMessage message,
PluginMessagePacket message,
VelocityServerConnection server) {
return false;
}

Datei anzeigen

@ -40,32 +40,32 @@ 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.BossBarPacket;
import com.velocitypowered.proxy.protocol.packet.ClientSettingsPacket;
import com.velocitypowered.proxy.protocol.packet.JoinGamePacket;
import com.velocitypowered.proxy.protocol.packet.KeepAlivePacket;
import com.velocitypowered.proxy.protocol.packet.PluginMessagePacket;
import com.velocitypowered.proxy.protocol.packet.ResourcePackResponsePacket;
import com.velocitypowered.proxy.protocol.packet.RespawnPacket;
import com.velocitypowered.proxy.protocol.packet.TabCompleteRequestPacket;
import com.velocitypowered.proxy.protocol.packet.TabCompleteResponsePacket;
import com.velocitypowered.proxy.protocol.packet.TabCompleteResponsePacket.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.ComponentHolder;
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.keyed.KeyedPlayerChatPacket;
import com.velocitypowered.proxy.protocol.packet.chat.keyed.KeyedPlayerCommandPacket;
import com.velocitypowered.proxy.protocol.packet.chat.legacy.LegacyChatHandler;
import com.velocitypowered.proxy.protocol.packet.chat.legacy.LegacyChatPacket;
import com.velocitypowered.proxy.protocol.packet.chat.legacy.LegacyCommandHandler;
import com.velocitypowered.proxy.protocol.packet.chat.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.chat.session.SessionPlayerChatPacket;
import com.velocitypowered.proxy.protocol.packet.chat.session.SessionPlayerCommandPacket;
import com.velocitypowered.proxy.protocol.packet.config.FinishedUpdatePacket;
import com.velocitypowered.proxy.protocol.packet.title.GenericTitlePacket;
import com.velocitypowered.proxy.protocol.util.PluginMessageUtil;
import com.velocitypowered.proxy.util.CharacterUtil;
@ -99,9 +99,9 @@ public class ClientPlaySessionHandler implements MinecraftSessionHandler {
private final ConnectedPlayer player;
private boolean spawned = false;
private final List<UUID> serverBossBars = new ArrayList<>();
private final Queue<PluginMessage> loginPluginMessages = new ConcurrentLinkedQueue<>();
private final Queue<PluginMessagePacket> loginPluginMessages = new ConcurrentLinkedQueue<>();
private final VelocityServer server;
private @Nullable TabCompleteRequest outstandingTabComplete;
private @Nullable TabCompleteRequestPacket outstandingTabComplete;
private final ChatHandler<? extends MinecraftPacket> chatHandler;
private final CommandHandler<? extends MinecraftPacket> commandHandler;
private final ChatTimeKeeper timeKeeper = new ChatTimeKeeper();
@ -158,20 +158,20 @@ public class ClientPlaySessionHandler implements MinecraftSessionHandler {
Collection<String> channels =
server.getChannelRegistrar().getChannelsForProtocol(player.getProtocolVersion());
if (!channels.isEmpty()) {
PluginMessage register = constructChannelsPacket(player.getProtocolVersion(), channels);
PluginMessagePacket register = constructChannelsPacket(player.getProtocolVersion(), channels);
player.getConnection().write(register);
}
}
@Override
public void deactivated() {
for (PluginMessage message : loginPluginMessages) {
for (PluginMessagePacket message : loginPluginMessages) {
ReferenceCountUtil.release(message);
}
}
@Override
public boolean handle(KeepAlive packet) {
public boolean handle(KeepAlivePacket packet) {
VelocityServerConnection serverConnection = player.getConnectedServer();
if (serverConnection != null) {
Long sentTime = serverConnection.getPendingPings().remove(packet.getRandomId());
@ -187,7 +187,7 @@ public class ClientPlaySessionHandler implements MinecraftSessionHandler {
}
@Override
public boolean handle(ClientSettings packet) {
public boolean handle(ClientSettingsPacket packet) {
player.setClientSettings(packet);
VelocityServerConnection serverConnection = player.getConnectedServer();
if (serverConnection == null) {
@ -199,7 +199,7 @@ public class ClientPlaySessionHandler implements MinecraftSessionHandler {
}
@Override
public boolean handle(SessionPlayerCommand packet) {
public boolean handle(SessionPlayerCommandPacket packet) {
player.ensureAndGetCurrentServer();
if (!updateTimeKeeper(packet.getTimeStamp())) {
@ -214,7 +214,7 @@ public class ClientPlaySessionHandler implements MinecraftSessionHandler {
}
@Override
public boolean handle(SessionPlayerChat packet) {
public boolean handle(SessionPlayerChatPacket packet) {
player.ensureAndGetCurrentServer();
if (!updateTimeKeeper(packet.getTimestamp())) {
@ -229,7 +229,7 @@ public class ClientPlaySessionHandler implements MinecraftSessionHandler {
}
@Override
public boolean handle(KeyedPlayerCommand packet) {
public boolean handle(KeyedPlayerCommandPacket packet) {
player.ensureAndGetCurrentServer();
if (!updateTimeKeeper(packet.getTimestamp())) {
@ -244,7 +244,7 @@ public class ClientPlaySessionHandler implements MinecraftSessionHandler {
}
@Override
public boolean handle(KeyedPlayerChat packet) {
public boolean handle(KeyedPlayerChatPacket packet) {
player.ensureAndGetCurrentServer();
if (!updateTimeKeeper(packet.getExpiry())) {
@ -259,7 +259,7 @@ public class ClientPlaySessionHandler implements MinecraftSessionHandler {
}
@Override
public boolean handle(LegacyChat packet) {
public boolean handle(LegacyChatPacket packet) {
player.ensureAndGetCurrentServer();
String msg = packet.getMessage();
if (!validateChat(msg)) {
@ -275,7 +275,7 @@ public class ClientPlaySessionHandler implements MinecraftSessionHandler {
}
@Override
public boolean handle(TabCompleteRequest packet) {
public boolean handle(TabCompleteRequestPacket packet) {
boolean isCommand = !packet.isAssumeCommand() && packet.getCommand().startsWith("/");
if (isCommand) {
@ -286,7 +286,7 @@ public class ClientPlaySessionHandler implements MinecraftSessionHandler {
}
@Override
public boolean handle(PluginMessage packet) {
public boolean handle(PluginMessagePacket packet) {
// Handling edge case when packet with FML client handshake (state COMPLETE)
// arrives after JoinGame packet from destination server
VelocityServerConnection serverConn =
@ -356,7 +356,7 @@ public class ClientPlaySessionHandler implements MinecraftSessionHandler {
PluginMessageEvent event = new PluginMessageEvent(player, serverConn, id, copy);
server.getEventManager().fire(event).thenAcceptAsync(pme -> {
if (pme.getResult().isAllowed()) {
PluginMessage message = new PluginMessage(packet.getChannel(),
PluginMessagePacket message = new PluginMessagePacket(packet.getChannel(),
Unpooled.wrappedBuffer(copy));
if (!player.getPhase().consideredComplete() || !serverConn.getPhase()
.consideredComplete()) {
@ -379,12 +379,12 @@ public class ClientPlaySessionHandler implements MinecraftSessionHandler {
}
@Override
public boolean handle(ResourcePackResponse packet) {
public boolean handle(ResourcePackResponsePacket packet) {
return player.onResourcePackResponse(packet.getStatus());
}
@Override
public boolean handle(FinishedUpdate packet) {
public boolean handle(FinishedUpdatePacket packet) {
// Complete client switch
player.getConnection().setActiveSessionHandler(StateRegistry.CONFIG);
VelocityServerConnection serverConnection = player.getConnectedServer();
@ -413,8 +413,8 @@ public class ClientPlaySessionHandler implements MinecraftSessionHandler {
MinecraftConnection smc = serverConnection.getConnection();
if (smc != null && serverConnection.getPhase().consideredComplete()) {
if (packet instanceof PluginMessage) {
((PluginMessage) packet).retain();
if (packet instanceof PluginMessagePacket) {
((PluginMessagePacket) packet).retain();
}
smc.write(packet);
}
@ -501,7 +501,7 @@ public class ClientPlaySessionHandler implements MinecraftSessionHandler {
* @param joinGame the join game packet
* @param destination the new server we are connecting to
*/
public void handleBackendJoinGame(JoinGame joinGame, VelocityServerConnection destination) {
public void handleBackendJoinGame(JoinGamePacket joinGame, VelocityServerConnection destination) {
final MinecraftConnection serverMc = destination.ensureConnected();
if (!spawned) {
@ -529,9 +529,9 @@ public class ClientPlaySessionHandler implements MinecraftSessionHandler {
// Remove previous boss bars. These don't get cleared when sending JoinGame, thus the need to
// 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();
@ -545,7 +545,7 @@ public class ClientPlaySessionHandler implements MinecraftSessionHandler {
}
// If we had plugin messages queued during login/FML handshake, send them now.
PluginMessage pm;
PluginMessagePacket pm;
while ((pm = loginPluginMessages.poll()) != null) {
serverMc.delayedWrite(pm);
}
@ -563,7 +563,7 @@ public class ClientPlaySessionHandler implements MinecraftSessionHandler {
destination.completeJoin();
}
private void doFastClientServerSwitch(JoinGame joinGame) {
private void doFastClientServerSwitch(JoinGamePacket joinGame) {
// In order to handle switching to another server, you will need to send two packets:
//
// - The join game packet from the backend server, with a different dimension
@ -572,7 +572,7 @@ public class ClientPlaySessionHandler implements MinecraftSessionHandler {
// Most notably, by having the client accept the join game packet, we can work around the need
// to perform entity ID rewrites, eliminating potential issues from rewriting packets and
// improving compatibility with mods.
final Respawn respawn = Respawn.fromJoinGame(joinGame);
final RespawnPacket respawn = RespawnPacket.fromJoinGame(joinGame);
if (player.getProtocolVersion().compareTo(ProtocolVersion.MINECRAFT_1_16) < 0) {
// Before Minecraft 1.16, we could not switch to the same dimension without sending an
@ -584,7 +584,7 @@ public class ClientPlaySessionHandler implements MinecraftSessionHandler {
player.getConnection().delayedWrite(respawn);
}
private void doSafeClientServerSwitch(JoinGame joinGame) {
private void doSafeClientServerSwitch(JoinGamePacket joinGame) {
// Some clients do not behave well with the "fast" respawn sequence. In this case we will use
// a "safe" respawn sequence that involves sending three packets to the client. They have the
// same effect but tend to work better with buggier clients (Forge 1.8 in particular).
@ -593,12 +593,12 @@ public class ClientPlaySessionHandler implements MinecraftSessionHandler {
player.getConnection().delayedWrite(joinGame);
// Send a respawn packet in a different dimension.
final Respawn fakeSwitchPacket = Respawn.fromJoinGame(joinGame);
final RespawnPacket fakeSwitchPacket = RespawnPacket.fromJoinGame(joinGame);
fakeSwitchPacket.setDimension(joinGame.getDimension() == 0 ? -1 : 0);
player.getConnection().delayedWrite(fakeSwitchPacket);
// Now send a respawn packet in the correct dimension.
final Respawn correctSwitchPacket = Respawn.fromJoinGame(joinGame);
final RespawnPacket correctSwitchPacket = RespawnPacket.fromJoinGame(joinGame);
player.getConnection().delayedWrite(correctSwitchPacket);
}
@ -606,7 +606,7 @@ public class ClientPlaySessionHandler implements MinecraftSessionHandler {
return serverBossBars;
}
private boolean handleCommandTabComplete(TabCompleteRequest packet) {
private boolean handleCommandTabComplete(TabCompleteRequestPacket packet) {
// In 1.13+, we need to do additional work for the richer suggestions available.
String command = packet.getCommand().substring(1);
int commandEndPosition = command.indexOf(' ');
@ -643,7 +643,7 @@ public class ClientPlaySessionHandler implements MinecraftSessionHandler {
}
int startPos = packet.getCommand().lastIndexOf(' ') + 1;
if (startPos > 0) {
TabCompleteResponse resp = new TabCompleteResponse();
TabCompleteResponsePacket resp = new TabCompleteResponsePacket();
resp.setTransactionId(packet.getTransactionId());
resp.setStart(startPos);
resp.setLength(packet.getCommand().length() - startPos);
@ -658,7 +658,7 @@ public class ClientPlaySessionHandler implements MinecraftSessionHandler {
return true; // Sorry, handler; we're just gonna have to lie to you here.
}
private boolean handleRegularTabComplete(TabCompleteRequest packet) {
private boolean handleRegularTabComplete(TabCompleteRequestPacket packet) {
if (player.getProtocolVersion().compareTo(ProtocolVersion.MINECRAFT_1_13) < 0) {
// Outstanding tab completes are recorded for use with 1.12 clients and below to provide
// additional tab completion support.
@ -672,7 +672,7 @@ public class ClientPlaySessionHandler implements MinecraftSessionHandler {
*
* @param response the tab complete response from the backend
*/
public void handleTabCompleteResponse(TabCompleteResponse response) {
public void handleTabCompleteResponse(TabCompleteResponsePacket response) {
if (outstandingTabComplete != null && !outstandingTabComplete.isAssumeCommand()) {
if (outstandingTabComplete.getCommand().startsWith("/")) {
this.finishCommandTabComplete(outstandingTabComplete, response);
@ -686,7 +686,8 @@ public class ClientPlaySessionHandler implements MinecraftSessionHandler {
}
}
private void finishCommandTabComplete(TabCompleteRequest request, TabCompleteResponse response) {
private void finishCommandTabComplete(TabCompleteRequestPacket request,
TabCompleteResponsePacket response) {
String command = request.getCommand().substring(1);
server.getCommandManager().offerBrigadierSuggestions(player, command)
.thenAcceptAsync(offers -> {
@ -723,7 +724,8 @@ public class ClientPlaySessionHandler implements MinecraftSessionHandler {
});
}
private void finishRegularTabComplete(TabCompleteRequest request, TabCompleteResponse response) {
private void finishRegularTabComplete(TabCompleteRequestPacket request,
TabCompleteResponsePacket response) {
List<String> offers = new ArrayList<>();
for (Offer offer : response.getOffers()) {
offers.add(offer.getText());
@ -752,7 +754,7 @@ public class ClientPlaySessionHandler implements MinecraftSessionHandler {
if (serverConnection != null) {
MinecraftConnection connection = serverConnection.getConnection();
if (connection != null) {
PluginMessage pm;
PluginMessagePacket pm;
while ((pm = loginPluginMessages.poll()) != null) {
connection.write(pm);
}

Datei anzeigen

@ -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.protocol.packet.ClientSettingsPacket;
import java.util.Locale;
import java.util.Objects;
import org.checkerframework.checker.nullness.qual.Nullable;
@ -30,13 +30,13 @@ import org.checkerframework.checker.nullness.qual.Nullable;
public class ClientSettingsWrapper implements PlayerSettings {
static final PlayerSettings DEFAULT = new ClientSettingsWrapper(
new ClientSettings("en_US", (byte) 10, 0, true, (short) 127, 1, true, false));
new ClientSettingsPacket("en_US", (byte) 10, 0, true, (short) 127, 1, true, false));
private final ClientSettings settings;
private final ClientSettingsPacket settings;
private final SkinParts parts;
private @Nullable Locale locale;
ClientSettingsWrapper(ClientSettings settings) {
ClientSettingsWrapper(ClientSettingsPacket settings) {
this.settings = settings;
this.parts = new SkinParts((byte) settings.getSkinParts());
}

Datei anzeigen

@ -59,18 +59,18 @@ import com.velocitypowered.proxy.connection.util.ConnectionRequestResults.Impl;
import com.velocitypowered.proxy.connection.util.VelocityInboundConnection;
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.ClientSettingsPacket;
import com.velocitypowered.proxy.protocol.packet.DisconnectPacket;
import com.velocitypowered.proxy.protocol.packet.HeaderAndFooterPacket;
import com.velocitypowered.proxy.protocol.packet.KeepAlivePacket;
import com.velocitypowered.proxy.protocol.packet.PluginMessagePacket;
import com.velocitypowered.proxy.protocol.packet.ResourcePackRequestPacket;
import com.velocitypowered.proxy.protocol.packet.chat.ChatQueue;
import com.velocitypowered.proxy.protocol.packet.chat.ChatType;
import com.velocitypowered.proxy.protocol.packet.chat.ComponentHolder;
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.chat.legacy.LegacyChatPacket;
import com.velocitypowered.proxy.protocol.packet.config.StartUpdatePacket;
import com.velocitypowered.proxy.protocol.packet.title.GenericTitlePacket;
import com.velocitypowered.proxy.server.VelocityRegisteredServer;
import com.velocitypowered.proxy.tablist.InternalTabList;
@ -163,7 +163,7 @@ public class ConnectedPlayer implements MinecraftConnectionAssociation, Player,
private @Nullable String clientBrand;
private @Nullable Locale effectiveLocale;
private @Nullable IdentifiedKey playerKey;
private @Nullable ClientSettings clientSettingsPacket;
private @Nullable ClientSettingsPacket clientSettingsPacket;
private final ChatQueue chatQueue;
private final ChatBuilderFactory chatBuilderFactory;
@ -272,7 +272,7 @@ public class ConnectedPlayer implements MinecraftConnectionAssociation, Player,
return settings == null ? ClientSettingsWrapper.DEFAULT : this.settings;
}
public ClientSettings getClientSettingsPacket() {
public ClientSettingsPacket getClientSettingsPacket() {
return clientSettingsPacket;
}
@ -286,7 +286,7 @@ public class ConnectedPlayer implements MinecraftConnectionAssociation, Player,
*
* @param clientSettingsPacket the player settings packet
*/
public void setClientSettings(final ClientSettings clientSettingsPacket) {
public void setClientSettings(final ClientSettingsPacket clientSettingsPacket) {
this.clientSettingsPacket = clientSettingsPacket;
final ClientSettingsWrapper cs = new ClientSettingsWrapper(clientSettingsPacket);
this.settings = cs;
@ -383,9 +383,9 @@ public class ConnectedPlayer implements MinecraftConnectionAssociation, Player,
JsonObject object = new JsonObject();
object.addProperty("text", LegacyComponentSerializer.legacySection()
.serialize(translated));
LegacyChat legacyChat = new LegacyChat();
LegacyChatPacket legacyChat = new LegacyChatPacket();
legacyChat.setMessage(object.toString());
legacyChat.setType(LegacyChat.GAME_INFO_TYPE);
legacyChat.setType(LegacyChatPacket.GAME_INFO_TYPE);
connection.write(legacyChat);
}
}
@ -417,7 +417,7 @@ public class ConnectedPlayer implements MinecraftConnectionAssociation, Player,
this.playerListHeader = translatedHeader;
this.playerListFooter = translatedFooter;
if (this.getProtocolVersion().compareTo(ProtocolVersion.MINECRAFT_1_8) >= 0) {
this.connection.write(HeaderAndFooter.create(
this.connection.write(HeaderAndFooterPacket.create(
translatedHeader, translatedFooter, this.getProtocolVersion()));
}
}
@ -543,7 +543,7 @@ public class ConnectedPlayer implements MinecraftConnectionAssociation, Player,
public void clearPlayerListHeaderAndFooter() {
clearPlayerListHeaderAndFooterSilent();
if (this.getProtocolVersion().compareTo(ProtocolVersion.MINECRAFT_1_8) >= 0) {
this.connection.write(HeaderAndFooter.reset(this.getProtocolVersion()));
this.connection.write(HeaderAndFooterPacket.reset(this.getProtocolVersion()));
}
}
@ -578,7 +578,8 @@ public class ConnectedPlayer implements MinecraftConnectionAssociation, Player,
if (server.getConfiguration().isLogPlayerConnections()) {
logger.info(Component.text(this + " has disconnected: ").append(translated));
}
connection.closeWith(Disconnect.create(translated, this.getProtocolVersion(), duringLogin));
connection.closeWith(DisconnectPacket.create(translated,
this.getProtocolVersion(), duringLogin));
}
public @Nullable VelocityServerConnection getConnectedServer() {
@ -639,7 +640,7 @@ public class ConnectedPlayer implements MinecraftConnectionAssociation, Player,
* @param disconnect the disconnect packet
* @param safe whether or not we can safely reconnect to a new server
*/
public void handleConnectionException(RegisteredServer server, Disconnect disconnect,
public void handleConnectionException(RegisteredServer server, DisconnectPacket disconnect,
boolean safe) {
if (!isActive()) {
// If the connection is no longer active, it makes no sense to try and recover it.
@ -749,7 +750,7 @@ public class ConnectedPlayer implements MinecraftConnectionAssociation, Player,
Component reason = status.getReasonComponent()
.orElse(ConnectionMessages.INTERNAL_SERVER_CONNECTION_ERROR);
handleConnectionException(res.getServer(),
Disconnect.create(reason, getProtocolVersion(), false),
DisconnectPacket.create(reason, getProtocolVersion(), false),
((Impl) status).isSafe());
break;
case SUCCESS:
@ -921,7 +922,8 @@ public class ConnectedPlayer implements MinecraftConnectionAssociation, Player,
public boolean sendPluginMessage(ChannelIdentifier identifier, byte[] data) {
Preconditions.checkNotNull(identifier, "identifier");
Preconditions.checkNotNull(data, "data");
PluginMessage message = new PluginMessage(identifier.getId(), Unpooled.wrappedBuffer(data));
PluginMessagePacket message = new PluginMessagePacket(identifier.getId(),
Unpooled.wrappedBuffer(data));
connection.write(message);
return true;
}
@ -937,8 +939,8 @@ public class ConnectedPlayer implements MinecraftConnectionAssociation, Player,
@Override
public void spoofChatInput(String input) {
Preconditions.checkArgument(input.length() <= LegacyChat.MAX_SERVERBOUND_MESSAGE_LENGTH,
"input cannot be greater than " + LegacyChat.MAX_SERVERBOUND_MESSAGE_LENGTH
Preconditions.checkArgument(input.length() <= LegacyChatPacket.MAX_SERVERBOUND_MESSAGE_LENGTH,
"input cannot be greater than " + LegacyChatPacket.MAX_SERVERBOUND_MESSAGE_LENGTH
+ " characters in length");
if (getProtocolVersion().compareTo(ProtocolVersion.MINECRAFT_1_19) >= 0) {
this.chatQueue.hijack(getChatBuilderFactory().builder().asPlayer(this).message(input),
@ -1006,7 +1008,7 @@ public class ConnectedPlayer implements MinecraftConnectionAssociation, Player,
}
}
ResourcePackRequest request = new ResourcePackRequest();
ResourcePackRequestPacket request = new ResourcePackRequestPacket();
request.setId(queued.getId());
request.setUrl(queued.getUrl());
if (queued.getHash() != null) {
@ -1109,13 +1111,14 @@ public class ConnectedPlayer implements MinecraftConnectionAssociation, Player,
}
/**
* Sends a {@link KeepAlive} packet to the player with a random ID. The response will be ignored
* by Velocity as it will not match the ID last sent by the server.
* Sends a {@link KeepAlivePacket} packet to the player with a random ID.
* The response will be ignored by Velocity as it will not match
* the ID last sent by the server.
*/
public void sendKeepAlive() {
if (connection.getState() == StateRegistry.PLAY
|| connection.getState() == StateRegistry.CONFIG) {
KeepAlive keepAlive = new KeepAlive();
KeepAlivePacket keepAlive = new KeepAlivePacket();
keepAlive.setRandomId(ThreadLocalRandom.current().nextLong());
connection.write(keepAlive);
}
@ -1126,7 +1129,7 @@ public class ConnectedPlayer implements MinecraftConnectionAssociation, Player,
*/
public void switchToConfigState() {
CompletableFuture.runAsync(() -> {
connection.write(new StartUpdate());
connection.write(new StartUpdatePacket());
connection.getChannel().pipeline()
.get(MinecraftEncoder.class).setState(StateRegistry.CONFIG);
// Make sure we don't send any play packets to the player after update start
@ -1275,7 +1278,7 @@ public class ConnectedPlayer implements MinecraftConnectionAssociation, Player,
Component reason = status.getReasonComponent()
.orElse(ConnectionMessages.INTERNAL_SERVER_CONNECTION_ERROR);
handleConnectionException(toConnect,
Disconnect.create(reason, getProtocolVersion(), false), status.isSafe());
DisconnectPacket.create(reason, getProtocolVersion(), false), status.isSafe());
break;
default:
// The only remaining value is successful (no need to do anything!)

Datei anzeigen

@ -33,10 +33,10 @@ import com.velocitypowered.proxy.connection.forge.modern.ModernForgeConstants;
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.HandshakePacket;
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.protocol.packet.LegacyHandshakePacket;
import com.velocitypowered.proxy.protocol.packet.LegacyPingPacket;
import io.netty.buffer.ByteBuf;
import java.net.InetAddress;
import java.net.InetSocketAddress;
@ -65,7 +65,7 @@ public class HandshakeSessionHandler implements MinecraftSessionHandler {
}
@Override
public boolean handle(LegacyPing packet) {
public boolean handle(LegacyPingPacket packet) {
connection.setProtocolVersion(ProtocolVersion.LEGACY);
StatusSessionHandler handler =
new StatusSessionHandler(server, new LegacyInboundConnection(connection, packet));
@ -75,7 +75,7 @@ public class HandshakeSessionHandler implements MinecraftSessionHandler {
}
@Override
public boolean handle(LegacyHandshake packet) {
public boolean handle(LegacyHandshakePacket packet) {
connection.closeWith(LegacyDisconnect.from(Component.text(
"Your client is extremely old. Please update to a newer version of Minecraft.",
NamedTextColor.RED)
@ -84,7 +84,7 @@ public class HandshakeSessionHandler implements MinecraftSessionHandler {
}
@Override
public boolean handle(Handshake handshake) {
public boolean handle(HandshakePacket handshake) {
InitialInboundConnection ic = new InitialInboundConnection(connection,
cleanVhost(handshake.getServerAddress()), handshake);
StateRegistry nextState = getStateForProtocol(handshake.getNextStatus());
@ -123,7 +123,7 @@ public class HandshakeSessionHandler implements MinecraftSessionHandler {
}
}
private void handleLogin(Handshake handshake, InitialInboundConnection ic) {
private void handleLogin(HandshakePacket handshake, InitialInboundConnection ic) {
if (!ProtocolVersion.isSupported(handshake.getProtocolVersion())) {
ic.disconnectQuietly(Component.translatable("multiplayer.disconnect.outdated_client")
.args(Component.text(ProtocolVersion.SUPPORTED_VERSION_STRING)));
@ -153,7 +153,7 @@ public class HandshakeSessionHandler implements MinecraftSessionHandler {
new InitialLoginSessionHandler(server, connection, lic));
}
private ConnectionType getHandshakeConnectionType(Handshake handshake) {
private ConnectionType getHandshakeConnectionType(HandshakePacket handshake) {
if (handshake.getServerAddress().contains(ModernForgeConstants.MODERN_FORGE_TOKEN)
&& handshake.getProtocolVersion().compareTo(ProtocolVersion.MINECRAFT_1_20_2) >= 0) {
return new ModernForgeConnectionType(handshake.getServerAddress());
@ -212,10 +212,10 @@ public class HandshakeSessionHandler implements MinecraftSessionHandler {
private static class LegacyInboundConnection implements VelocityInboundConnection {
private final MinecraftConnection connection;
private final LegacyPing ping;
private final LegacyPingPacket ping;
private LegacyInboundConnection(MinecraftConnection connection,
LegacyPing ping) {
LegacyPingPacket ping) {
this.connection = connection;
this.ping = ping;
}

Datei anzeigen

@ -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.protocol.packet.PluginMessagePacket;
import io.netty.buffer.ByteBufUtil;
import io.netty.buffer.Unpooled;
import org.apache.logging.log4j.LogManager;
@ -47,7 +47,7 @@ public class InitialConnectSessionHandler implements MinecraftSessionHandler {
}
@Override
public boolean handle(PluginMessage packet) {
public boolean handle(PluginMessagePacket packet) {
VelocityServerConnection serverConn = player.getConnectionInFlight();
if (serverConn != null) {
if (player.getPhase().handle(player, packet, serverConn)) {
@ -70,7 +70,7 @@ public class InitialConnectSessionHandler implements MinecraftSessionHandler {
server.getEventManager().fire(event)
.thenAcceptAsync(pme -> {
if (pme.getResult().isAllowed() && serverConn.isActive()) {
PluginMessage copied = new PluginMessage(packet.getChannel(),
PluginMessagePacket copied = new PluginMessagePacket(packet.getChannel(),
Unpooled.wrappedBuffer(copy));
serverConn.ensureConnected().write(copied);
}

Datei anzeigen

@ -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.protocol.packet.DisconnectPacket;
import com.velocitypowered.proxy.protocol.packet.HandshakePacket;
import com.velocitypowered.proxy.util.ClosestLocaleMatcher;
import java.net.InetSocketAddress;
import java.util.Locale;
@ -43,10 +43,10 @@ public final class InitialInboundConnection implements VelocityInboundConnection
private final MinecraftConnection connection;
private final String cleanedAddress;
private final Handshake handshake;
private final HandshakePacket handshake;
InitialInboundConnection(MinecraftConnection connection, String cleanedAddress,
Handshake handshake) {
HandshakePacket handshake) {
this.connection = connection;
this.cleanedAddress = cleanedAddress;
this.handshake = handshake;
@ -98,7 +98,7 @@ public final class InitialInboundConnection implements VelocityInboundConnection
if (connection.server.getConfiguration().isLogPlayerConnections()) {
logger.info(Component.text(this + " has disconnected: ").append(translated));
}
connection.closeWith(Disconnect.create(translated, getProtocolVersion(), true));
connection.closeWith(DisconnectPacket.create(translated, getProtocolVersion(), true));
}
/**
@ -109,6 +109,6 @@ public final class InitialInboundConnection implements VelocityInboundConnection
public void disconnectQuietly(Component reason) {
Component translated = GlobalTranslator.render(reason, ClosestLocaleMatcher.INSTANCE
.lookupClosest(Locale.getDefault()));
connection.closeWith(Disconnect.create(translated, getProtocolVersion(), true));
connection.closeWith(DisconnectPacket.create(translated, getProtocolVersion(), true));
}
}

Datei anzeigen

@ -36,10 +36,10 @@ 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.protocol.packet.EncryptionRequestPacket;
import com.velocitypowered.proxy.protocol.packet.EncryptionResponsePacket;
import com.velocitypowered.proxy.protocol.packet.LoginPluginResponsePacket;
import com.velocitypowered.proxy.protocol.packet.ServerLoginPacket;
import io.netty.buffer.ByteBuf;
import java.net.InetSocketAddress;
import java.net.URI;
@ -71,7 +71,7 @@ public class InitialLoginSessionHandler implements MinecraftSessionHandler {
private final VelocityServer server;
private final MinecraftConnection mcConnection;
private final LoginInboundConnection inbound;
private @MonotonicNonNull ServerLogin login;
private @MonotonicNonNull ServerLoginPacket login;
private byte[] verify = EMPTY_BYTE_ARRAY;
private LoginState currentState = LoginState.LOGIN_PACKET_EXPECTED;
private boolean forceKeyAuthentication;
@ -87,7 +87,7 @@ public class InitialLoginSessionHandler implements MinecraftSessionHandler {
}
@Override
public boolean handle(ServerLogin packet) {
public boolean handle(ServerLoginPacket packet) {
assertState(LoginState.LOGIN_PACKET_EXPECTED);
this.currentState = LoginState.LOGIN_PACKET_RECEIVED;
IdentifiedKey playerKey = packet.getPlayerKey();
@ -145,7 +145,7 @@ public class InitialLoginSessionHandler implements MinecraftSessionHandler {
if (!result.isForceOfflineMode()
&& (server.getConfiguration().isOnlineMode() || result.isOnlineModeAllowed())) {
// Request encryption.
EncryptionRequest request = generateEncryptionRequest();
EncryptionRequestPacket request = generateEncryptionRequest();
this.verify = Arrays.copyOf(request.getVerifyToken(), 4);
mcConnection.write(request);
this.currentState = LoginState.ENCRYPTION_REQUEST_SENT;
@ -165,16 +165,16 @@ public class InitialLoginSessionHandler implements MinecraftSessionHandler {
}
@Override
public boolean handle(LoginPluginResponse packet) {
public boolean handle(LoginPluginResponsePacket packet) {
this.inbound.handleLoginPluginResponse(packet);
return true;
}
@Override
public boolean handle(EncryptionResponse packet) {
public boolean handle(EncryptionResponsePacket packet) {
assertState(LoginState.ENCRYPTION_REQUEST_SENT);
this.currentState = LoginState.ENCRYPTION_RESPONSE_RECEIVED;
ServerLogin login = this.login;
ServerLoginPacket login = this.login;
if (login == null) {
throw new IllegalStateException("No ServerLogin packet received yet.");
}
@ -274,11 +274,11 @@ public class InitialLoginSessionHandler implements MinecraftSessionHandler {
return true;
}
private EncryptionRequest generateEncryptionRequest() {
private EncryptionRequestPacket generateEncryptionRequest() {
byte[] verify = new byte[4];
ThreadLocalRandom.current().nextBytes(verify);
EncryptionRequest request = new EncryptionRequest();
EncryptionRequestPacket request = new EncryptionRequestPacket();
request.setPublicKey(server.getServerKeyPair().getPublic().getEncoded());
request.setVerifyToken(verify);
return request;

Datei anzeigen

@ -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.protocol.packet.LoginPluginMessagePacket;
import com.velocitypowered.proxy.protocol.packet.LoginPluginResponsePacket;
import io.netty.buffer.ByteBufUtil;
import io.netty.buffer.Unpooled;
import it.unimi.dsi.fastutil.ints.Int2ObjectMap;
@ -48,7 +48,7 @@ public class LoginInboundConnection implements LoginPhaseConnection, KeyIdentifi
private final InitialInboundConnection delegate;
private final Int2ObjectMap<MessageConsumer> outstandingResponses;
private volatile int sequenceCounter;
private final Queue<LoginPluginMessage> loginMessagesToSend;
private final Queue<LoginPluginMessagePacket> loginMessagesToSend;
private volatile Runnable onAllMessagesHandled;
private volatile boolean loginEventFired;
private @MonotonicNonNull IdentifiedKey playerKey;
@ -100,7 +100,7 @@ public class LoginInboundConnection implements LoginPhaseConnection, KeyIdentifi
final int id = SEQUENCE_UPDATER.incrementAndGet(this);
this.outstandingResponses.put(id, consumer);
final LoginPluginMessage message = new LoginPluginMessage(id, identifier.getId(),
final LoginPluginMessagePacket message = new LoginPluginMessagePacket(id, identifier.getId(),
Unpooled.wrappedBuffer(contents));
if (!this.loginEventFired) {
this.loginMessagesToSend.add(message);
@ -125,7 +125,7 @@ public class LoginInboundConnection implements LoginPhaseConnection, KeyIdentifi
this.onAllMessagesHandled = null;
}
void handleLoginPluginResponse(final LoginPluginResponse response) {
void handleLoginPluginResponse(final LoginPluginResponsePacket response) {
final MessageConsumer consumer = this.outstandingResponses.remove(response.getId());
if (consumer != null) {
try {
@ -144,7 +144,7 @@ public class LoginInboundConnection implements LoginPhaseConnection, KeyIdentifi
this.loginEventFired = true;
this.onAllMessagesHandled = onAllMessagesHandled;
if (!this.loginMessagesToSend.isEmpty()) {
LoginPluginMessage message;
LoginPluginMessagePacket message;
while ((message = this.loginMessagesToSend.poll()) != null) {
this.delegate.getConnection().delayedWrite(message);
}

Datei anzeigen

@ -23,10 +23,10 @@ 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.protocol.packet.StatusResponse;
import com.velocitypowered.proxy.protocol.packet.LegacyPingPacket;
import com.velocitypowered.proxy.protocol.packet.StatusPingPacket;
import com.velocitypowered.proxy.protocol.packet.StatusRequestPacket;
import com.velocitypowered.proxy.protocol.packet.StatusResponsePacket;
import com.velocitypowered.proxy.util.except.QuietRuntimeException;
import io.netty.buffer.ByteBuf;
import org.apache.logging.log4j.LogManager;
@ -61,7 +61,7 @@ public class StatusSessionHandler implements MinecraftSessionHandler {
}
@Override
public boolean handle(LegacyPing packet) {
public boolean handle(LegacyPingPacket packet) {
if (this.pingReceived) {
throw EXPECTED_AWAITING_REQUEST;
}
@ -79,13 +79,13 @@ public class StatusSessionHandler implements MinecraftSessionHandler {
}
@Override
public boolean handle(StatusPing packet) {
public boolean handle(StatusPingPacket packet) {
connection.closeWith(packet);
return true;
}
@Override
public boolean handle(StatusRequest packet) {
public boolean handle(StatusRequestPacket packet) {
if (this.pingReceived) {
throw EXPECTED_AWAITING_REQUEST;
}
@ -98,7 +98,7 @@ public class StatusSessionHandler implements MinecraftSessionHandler {
StringBuilder json = new StringBuilder();
VelocityServer.getPingGsonInstance(connection.getProtocolVersion())
.toJson(event.getPing(), json);
connection.write(new StatusResponse(json));
connection.write(new StatusResponsePacket(json));
},
connection.eventLoop())
.exceptionally((ex) -> {

Datei anzeigen

@ -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.protocol.packet.PluginMessagePacket;
import javax.annotation.Nullable;
/**
@ -123,7 +123,7 @@ public enum LegacyForgeHandshakeBackendPhase implements BackendConnectionPhase {
@Override
public final boolean handle(VelocityServerConnection serverConnection,
ConnectedPlayer player,
PluginMessage message) {
PluginMessagePacket message) {
if (message.getChannel().equals(LegacyForgeConstants.FORGE_LEGACY_HANDSHAKE_CHANNEL)) {
// Get the phase and check if we need to start the next phase.
LegacyForgeHandshakeBackendPhase newPhase = getNewPhase(serverConnection, message);
@ -177,7 +177,7 @@ public enum LegacyForgeHandshakeBackendPhase implements BackendConnectionPhase {
* @return The phase to transition to, which may be the same as before.
*/
private LegacyForgeHandshakeBackendPhase getNewPhase(VelocityServerConnection serverConnection,
PluginMessage packet) {
PluginMessagePacket packet) {
if (packetToAdvanceOn != null
&& LegacyForgeUtil.getHandshakePacketDiscriminator(packet) == packetToAdvanceOn) {
LegacyForgeHandshakeBackendPhase phaseToTransitionTo = nextPhase();

Datei anzeigen

@ -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.protocol.packet.PluginMessagePacket;
import java.util.List;
import javax.annotation.Nullable;
@ -56,7 +56,7 @@ public enum LegacyForgeHandshakeClientPhase implements ClientConnectionPhase {
@Override
boolean onHandle(ConnectedPlayer player,
PluginMessage message,
PluginMessagePacket message,
MinecraftConnection backendConn) {
// If we stay in this phase, we do nothing because it means the packet wasn't handled.
// Returning false indicates this
@ -88,7 +88,7 @@ public enum LegacyForgeHandshakeClientPhase implements ClientConnectionPhase {
@Override
boolean onHandle(ConnectedPlayer player,
PluginMessage message,
PluginMessagePacket message,
MinecraftConnection backendConn) {
// Read the mod list if we haven't already.
if (!player.getModInfo().isPresent()) {
@ -157,7 +157,7 @@ public enum LegacyForgeHandshakeClientPhase implements ClientConnectionPhase {
@Override
boolean onHandle(ConnectedPlayer player,
PluginMessage message,
PluginMessagePacket message,
MinecraftConnection backendConn) {
super.onHandle(player, message, backendConn);
@ -190,7 +190,7 @@ public enum LegacyForgeHandshakeClientPhase implements ClientConnectionPhase {
@Override
public final boolean handle(ConnectedPlayer player,
PluginMessage message,
PluginMessagePacket message,
VelocityServerConnection server) {
if (server != null) {
MinecraftConnection backendConn = server.getConnection();
@ -220,7 +220,7 @@ public enum LegacyForgeHandshakeClientPhase implements ClientConnectionPhase {
* @return true if handled, false otherwise.
*/
boolean onHandle(ConnectedPlayer player,
PluginMessage message,
PluginMessagePacket message,
MinecraftConnection backendConn) {
// Send the packet on to the server.
backendConn.write(message.retain());
@ -249,7 +249,7 @@ public enum LegacyForgeHandshakeClientPhase implements ClientConnectionPhase {
* @param packet The packet
* @return The phase to transition to, which may be the same as before.
*/
private LegacyForgeHandshakeClientPhase getNewPhase(PluginMessage packet) {
private LegacyForgeHandshakeClientPhase getNewPhase(PluginMessagePacket packet) {
if (packetToAdvanceOn != null
&& LegacyForgeUtil.getHandshakePacketDiscriminator(packet) == packetToAdvanceOn) {
return nextPhase();

Datei anzeigen

@ -25,7 +25,7 @@ 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.protocol.packet.PluginMessagePacket;
import io.netty.buffer.ByteBuf;
import io.netty.buffer.Unpooled;
import java.util.List;
@ -42,7 +42,7 @@ class LegacyForgeUtil {
* @param message The message to analyse
* @return The discriminator
*/
static byte getHandshakePacketDiscriminator(PluginMessage message) {
static byte getHandshakePacketDiscriminator(PluginMessagePacket message) {
Preconditions.checkArgument(message.getChannel().equals(FORGE_LEGACY_HANDSHAKE_CHANNEL));
Preconditions.checkArgument(message.content().isReadable());
return message.content().getByte(0);
@ -54,7 +54,7 @@ class LegacyForgeUtil {
* @param message The message
* @return The list of mods. May be empty.
*/
static List<ModInfo.Mod> readModList(PluginMessage message) {
static List<ModInfo.Mod> readModList(PluginMessagePacket message) {
Preconditions.checkNotNull(message, "message");
Preconditions.checkArgument(message.getChannel().equals(FORGE_LEGACY_HANDSHAKE_CHANNEL),
"message is not a FML HS plugin message");
@ -82,8 +82,8 @@ class LegacyForgeUtil {
*
* @return A copy of the reset packet
*/
static PluginMessage resetPacket() {
PluginMessage msg = new PluginMessage();
static PluginMessagePacket resetPacket() {
PluginMessagePacket msg = new PluginMessagePacket();
msg.setChannel(FORGE_LEGACY_HANDSHAKE_CHANNEL);
msg.replace(Unpooled.wrappedBuffer(FORGE_LEGACY_HANDSHAKE_RESET_DATA.clone()));
return msg;

Datei anzeigen

@ -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.protocol.packet.DisconnectPacket;
import java.util.Optional;
import javax.annotation.Nullable;
import net.kyori.adventure.text.Component;
@ -62,11 +62,11 @@ public class ConnectionRequestResults {
return new Impl(Status.SERVER_DISCONNECTED, component, server, true);
}
public static Impl forDisconnect(Disconnect disconnect, RegisteredServer server) {
public static Impl forDisconnect(DisconnectPacket disconnect, RegisteredServer server) {
return forDisconnect(disconnect.getReason().getComponent(), server);
}
public static Impl forUnsafeDisconnect(Disconnect disconnect, RegisteredServer server) {
public static Impl forUnsafeDisconnect(DisconnectPacket disconnect, RegisteredServer server) {
return new Impl(Status.SERVER_DISCONNECTED, disconnect.getReason().getComponent(), server,
false);
}

Datei anzeigen

@ -46,50 +46,50 @@ import static com.velocitypowered.proxy.protocol.ProtocolUtils.Direction.CLIENTB
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.RemoveResourcePack;
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.AvailableCommandsPacket;
import com.velocitypowered.proxy.protocol.packet.BossBarPacket;
import com.velocitypowered.proxy.protocol.packet.ClientSettingsPacket;
import com.velocitypowered.proxy.protocol.packet.DisconnectPacket;
import com.velocitypowered.proxy.protocol.packet.EncryptionRequestPacket;
import com.velocitypowered.proxy.protocol.packet.EncryptionResponsePacket;
import com.velocitypowered.proxy.protocol.packet.HandshakePacket;
import com.velocitypowered.proxy.protocol.packet.HeaderAndFooterPacket;
import com.velocitypowered.proxy.protocol.packet.JoinGamePacket;
import com.velocitypowered.proxy.protocol.packet.KeepAlivePacket;
import com.velocitypowered.proxy.protocol.packet.LegacyPlayerListItemPacket;
import com.velocitypowered.proxy.protocol.packet.LoginAcknowledgedPacket;
import com.velocitypowered.proxy.protocol.packet.LoginPluginMessagePacket;
import com.velocitypowered.proxy.protocol.packet.LoginPluginResponsePacket;
import com.velocitypowered.proxy.protocol.packet.PingIdentifyPacket;
import com.velocitypowered.proxy.protocol.packet.PluginMessagePacket;
import com.velocitypowered.proxy.protocol.packet.RemovePlayerInfoPacket;
import com.velocitypowered.proxy.protocol.packet.RemoveResourcePackPacket;
import com.velocitypowered.proxy.protocol.packet.ResourcePackRequestPacket;
import com.velocitypowered.proxy.protocol.packet.ResourcePackResponsePacket;
import com.velocitypowered.proxy.protocol.packet.RespawnPacket;
import com.velocitypowered.proxy.protocol.packet.ServerDataPacket;
import com.velocitypowered.proxy.protocol.packet.ServerLoginPacket;
import com.velocitypowered.proxy.protocol.packet.ServerLoginSuccessPacket;
import com.velocitypowered.proxy.protocol.packet.SetCompressionPacket;
import com.velocitypowered.proxy.protocol.packet.StatusPingPacket;
import com.velocitypowered.proxy.protocol.packet.StatusRequestPacket;
import com.velocitypowered.proxy.protocol.packet.StatusResponsePacket;
import com.velocitypowered.proxy.protocol.packet.TabCompleteRequestPacket;
import com.velocitypowered.proxy.protocol.packet.TabCompleteResponsePacket;
import com.velocitypowered.proxy.protocol.packet.UpsertPlayerInfoPacket;
import com.velocitypowered.proxy.protocol.packet.chat.ChatAcknowledgementPacket;
import com.velocitypowered.proxy.protocol.packet.chat.PlayerChatCompletionPacket;
import com.velocitypowered.proxy.protocol.packet.chat.SystemChatPacket;
import com.velocitypowered.proxy.protocol.packet.chat.keyed.KeyedPlayerChatPacket;
import com.velocitypowered.proxy.protocol.packet.chat.keyed.KeyedPlayerCommandPacket;
import com.velocitypowered.proxy.protocol.packet.chat.legacy.LegacyChatPacket;
import com.velocitypowered.proxy.protocol.packet.chat.session.SessionPlayerChatPacket;
import com.velocitypowered.proxy.protocol.packet.chat.session.SessionPlayerCommandPacket;
import com.velocitypowered.proxy.protocol.packet.config.ActiveFeaturesPacket;
import com.velocitypowered.proxy.protocol.packet.config.FinishedUpdatePacket;
import com.velocitypowered.proxy.protocol.packet.config.RegistrySyncPacket;
import com.velocitypowered.proxy.protocol.packet.config.StartUpdatePacket;
import com.velocitypowered.proxy.protocol.packet.config.TagsUpdatePacket;
import com.velocitypowered.proxy.protocol.packet.title.LegacyTitlePacket;
import com.velocitypowered.proxy.protocol.packet.title.TitleActionbarPacket;
import com.velocitypowered.proxy.protocol.packet.title.TitleClearPacket;
@ -116,57 +116,73 @@ public enum StateRegistry {
HANDSHAKE {
{
serverbound.register(Handshake.class, Handshake::new,
serverbound.register(HandshakePacket.class, HandshakePacket::new,
map(0x00, MINECRAFT_1_7_2, false));
}
},
STATUS {
{
serverbound.register(
StatusRequest.class, () -> StatusRequest.INSTANCE, map(0x00, MINECRAFT_1_7_2, false));
serverbound.register(StatusPing.class, StatusPing::new, map(0x01, MINECRAFT_1_7_2, false));
StatusRequestPacket.class, () -> StatusRequestPacket.INSTANCE,
map(0x00, MINECRAFT_1_7_2, false));
serverbound.register(StatusPingPacket.class, StatusPingPacket::new,
map(0x01, MINECRAFT_1_7_2, false));
clientbound.register(
StatusResponse.class, StatusResponse::new, map(0x00, MINECRAFT_1_7_2, false));
clientbound.register(StatusPing.class, StatusPing::new, map(0x01, MINECRAFT_1_7_2, false));
StatusResponsePacket.class, StatusResponsePacket::new,
map(0x00, MINECRAFT_1_7_2, false));
clientbound.register(StatusPingPacket.class, StatusPingPacket::new,
map(0x01, MINECRAFT_1_7_2, false));
}
},
CONFIG {
{
serverbound.register(
ClientSettings.class, ClientSettings::new, map(0x00, MINECRAFT_1_20_2, false));
ClientSettingsPacket.class, ClientSettingsPacket::new,
map(0x00, MINECRAFT_1_20_2, false));
serverbound.register(
PluginMessage.class, PluginMessage::new, map(0x01, MINECRAFT_1_20_2, false));
PluginMessagePacket.class, PluginMessagePacket::new,
map(0x01, MINECRAFT_1_20_2, false));
serverbound.register(
FinishedUpdate.class, FinishedUpdate::new, map(0x02, MINECRAFT_1_20_2, false));
serverbound.register(KeepAlive.class, KeepAlive::new, map(0x03, MINECRAFT_1_20_2, false));
FinishedUpdatePacket.class, FinishedUpdatePacket::new,
map(0x02, MINECRAFT_1_20_2, false));
serverbound.register(KeepAlivePacket.class, KeepAlivePacket::new,
map(0x03, MINECRAFT_1_20_2, false));
serverbound.register(
PingIdentify.class, PingIdentify::new, map(0x04, MINECRAFT_1_20_2, false));
PingIdentifyPacket.class, PingIdentifyPacket::new,
map(0x04, MINECRAFT_1_20_2, false));
serverbound.register(
ResourcePackResponse.class,
ResourcePackResponse::new,
ResourcePackResponsePacket.class,
ResourcePackResponsePacket::new,
map(0x05, MINECRAFT_1_20_2, false));
clientbound.register(
PluginMessage.class, PluginMessage::new, map(0x00, MINECRAFT_1_20_2, false));
PluginMessagePacket.class, PluginMessagePacket::new,
map(0x00, MINECRAFT_1_20_2, false));
clientbound.register(
Disconnect.class, () -> new Disconnect(false), map(0x01, MINECRAFT_1_20_2, false));
DisconnectPacket.class, () -> new DisconnectPacket(false),
map(0x01, MINECRAFT_1_20_2, false));
clientbound.register(
FinishedUpdate.class, FinishedUpdate::new, map(0x02, MINECRAFT_1_20_2, false));
clientbound.register(KeepAlive.class, KeepAlive::new, map(0x03, MINECRAFT_1_20_2, false));
FinishedUpdatePacket.class, FinishedUpdatePacket::new,
map(0x02, MINECRAFT_1_20_2, false));
clientbound.register(KeepAlivePacket.class, KeepAlivePacket::new,
map(0x03, MINECRAFT_1_20_2, false));
clientbound.register(
PingIdentify.class, PingIdentify::new, map(0x04, MINECRAFT_1_20_2, false));
PingIdentifyPacket.class, PingIdentifyPacket::new,
map(0x04, MINECRAFT_1_20_2, false));
clientbound.register(
RegistrySync.class, RegistrySync::new, map(0x05, MINECRAFT_1_20_2, false));
RegistrySyncPacket.class, RegistrySyncPacket::new,
map(0x05, MINECRAFT_1_20_2, false));
clientbound.register(
RemoveResourcePack.class, RemoveResourcePack::new, map(0x06, MINECRAFT_1_20_3, false));
clientbound.register(ResourcePackRequest.class, ResourcePackRequest::new,
RemoveResourcePackPacket.class, RemoveResourcePackPacket::new,
map(0x06, MINECRAFT_1_20_3, false));
clientbound.register(ResourcePackRequestPacket.class, ResourcePackRequestPacket::new,
map(0x06, MINECRAFT_1_20_2, false),
map(0x07, MINECRAFT_1_20_3, false));
clientbound.register(ActiveFeatures.class, ActiveFeatures::new,
clientbound.register(ActiveFeaturesPacket.class, ActiveFeaturesPacket::new,
map(0x07, MINECRAFT_1_20_2, false),
map(0x08, MINECRAFT_1_20_3, false));
clientbound.register(TagsUpdate.class, TagsUpdate::new,
clientbound.register(TagsUpdatePacket.class, TagsUpdatePacket::new,
map(0x08, MINECRAFT_1_20_2, false),
map(0x09, MINECRAFT_1_20_3, false));
}
@ -176,7 +192,7 @@ public enum StateRegistry {
serverbound.fallback = false;
clientbound.fallback = false;
serverbound.register(TabCompleteRequest.class, TabCompleteRequest::new,
serverbound.register(TabCompleteRequestPacket.class, TabCompleteRequestPacket::new,
map(0x14, MINECRAFT_1_7_2, false),
map(0x01, MINECRAFT_1_9, false),
map(0x02, MINECRAFT_1_12, false),
@ -189,32 +205,32 @@ public enum StateRegistry {
map(0x09, MINECRAFT_1_19_4, false),
map(0x0A, MINECRAFT_1_20_2, false));
serverbound.register(
LegacyChat.class,
LegacyChat::new,
LegacyChatPacket.class,
LegacyChatPacket::new,
map(0x01, MINECRAFT_1_7_2, false),
map(0x02, MINECRAFT_1_9, false),
map(0x03, MINECRAFT_1_12, false),
map(0x02, MINECRAFT_1_12_1, false),
map(0x03, MINECRAFT_1_14, MINECRAFT_1_18_2, false));
serverbound.register(
ChatAcknowledgement.class,
ChatAcknowledgement::new,
ChatAcknowledgementPacket.class,
ChatAcknowledgementPacket::new,
map(0x03, MINECRAFT_1_19_3, false));
serverbound.register(KeyedPlayerCommand.class, KeyedPlayerCommand::new,
serverbound.register(KeyedPlayerCommandPacket.class, KeyedPlayerCommandPacket::new,
map(0x03, MINECRAFT_1_19, false),
map(0x04, MINECRAFT_1_19_1, MINECRAFT_1_19_1, false));
serverbound.register(KeyedPlayerChat.class, KeyedPlayerChat::new,
serverbound.register(KeyedPlayerChatPacket.class, KeyedPlayerChatPacket::new,
map(0x04, MINECRAFT_1_19, false),
map(0x05, MINECRAFT_1_19_1, MINECRAFT_1_19_1, false));
serverbound.register(SessionPlayerCommand.class, SessionPlayerCommand::new,
serverbound.register(SessionPlayerCommandPacket.class, SessionPlayerCommandPacket::new,
map(0x04, MINECRAFT_1_19_3, false));
serverbound.register(
SessionPlayerChat.class,
SessionPlayerChat::new,
SessionPlayerChatPacket.class,
SessionPlayerChatPacket::new,
map(0x05, MINECRAFT_1_19_3, false));
serverbound.register(
ClientSettings.class,
ClientSettings::new,
ClientSettingsPacket.class,
ClientSettingsPacket::new,
map(0x15, MINECRAFT_1_7_2, false),
map(0x04, MINECRAFT_1_9, false),
map(0x05, MINECRAFT_1_12, false),
@ -226,8 +242,8 @@ public enum StateRegistry {
map(0x08, MINECRAFT_1_19_4, false),
map(0x09, MINECRAFT_1_20_2, false));
serverbound.register(
PluginMessage.class,
PluginMessage::new,
PluginMessagePacket.class,
PluginMessagePacket::new,
map(0x17, MINECRAFT_1_7_2, false),
map(0x09, MINECRAFT_1_9, false),
map(0x0A, MINECRAFT_1_12, false),
@ -242,8 +258,8 @@ public enum StateRegistry {
map(0x0F, MINECRAFT_1_20_2, false),
map(0x10, MINECRAFT_1_20_3, false));
serverbound.register(
KeepAlive.class,
KeepAlive::new,
KeepAlivePacket.class,
KeepAlivePacket::new,
map(0x00, MINECRAFT_1_7_2, false),
map(0x0B, MINECRAFT_1_9, false),
map(0x0C, MINECRAFT_1_12, false),
@ -259,8 +275,8 @@ public enum StateRegistry {
map(0x14, MINECRAFT_1_20_2, false),
map(0x15, MINECRAFT_1_20_3, false));
serverbound.register(
ResourcePackResponse.class,
ResourcePackResponse::new,
ResourcePackResponsePacket.class,
ResourcePackResponsePacket::new,
map(0x19, MINECRAFT_1_8, false),
map(0x16, MINECRAFT_1_9, false),
map(0x18, MINECRAFT_1_12, false),
@ -273,11 +289,12 @@ public enum StateRegistry {
map(0x27, MINECRAFT_1_20_2, false),
map(0x28, MINECRAFT_1_20_3, false));
serverbound.register(
FinishedUpdate.class, FinishedUpdate::new, map(0x0B, MINECRAFT_1_20_2, false));
FinishedUpdatePacket.class, FinishedUpdatePacket::new,
map(0x0B, MINECRAFT_1_20_2, false));
clientbound.register(
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),
@ -286,15 +303,15 @@ public enum StateRegistry {
map(0x0B, MINECRAFT_1_19_4, false),
map(0x0A, MINECRAFT_1_20_2, false));
clientbound.register(
LegacyChat.class,
LegacyChat::new,
LegacyChatPacket.class,
LegacyChatPacket::new,
map(0x02, MINECRAFT_1_7_2, true),
map(0x0F, MINECRAFT_1_9, true),
map(0x0E, MINECRAFT_1_13, true),
map(0x0F, MINECRAFT_1_15, true),
map(0x0E, MINECRAFT_1_16, true),
map(0x0F, MINECRAFT_1_17, MINECRAFT_1_18_2, true));
clientbound.register(TabCompleteResponse.class, TabCompleteResponse::new,
clientbound.register(TabCompleteResponsePacket.class, TabCompleteResponsePacket::new,
map(0x3A, MINECRAFT_1_7_2, false),
map(0x0E, MINECRAFT_1_9, false),
map(0x10, MINECRAFT_1_13, false),
@ -307,8 +324,8 @@ public enum StateRegistry {
map(0x0F, MINECRAFT_1_19_4, false),
map(0x10, MINECRAFT_1_20_2, false));
clientbound.register(
AvailableCommands.class,
AvailableCommands::new,
AvailableCommandsPacket.class,
AvailableCommandsPacket::new,
map(0x11, MINECRAFT_1_13, false),
map(0x12, MINECRAFT_1_15, false),
map(0x11, MINECRAFT_1_16, false),
@ -319,8 +336,8 @@ public enum StateRegistry {
map(0x10, MINECRAFT_1_19_4, false),
map(0x11, MINECRAFT_1_20_2, false));
clientbound.register(
PluginMessage.class,
PluginMessage::new,
PluginMessagePacket.class,
PluginMessagePacket::new,
map(0x3F, MINECRAFT_1_7_2, false),
map(0x18, MINECRAFT_1_9, false),
map(0x19, MINECRAFT_1_13, false),
@ -335,8 +352,8 @@ public enum StateRegistry {
map(0x17, MINECRAFT_1_19_4, false),
map(0x18, MINECRAFT_1_20_2, false));
clientbound.register(
Disconnect.class,
() -> new Disconnect(false),
DisconnectPacket.class,
() -> new DisconnectPacket(false),
map(0x40, MINECRAFT_1_7_2, false),
map(0x1A, MINECRAFT_1_9, false),
map(0x1B, MINECRAFT_1_13, false),
@ -351,8 +368,8 @@ public enum StateRegistry {
map(0x1A, MINECRAFT_1_19_4, false),
map(0x1B, MINECRAFT_1_20_2, false));
clientbound.register(
KeepAlive.class,
KeepAlive::new,
KeepAlivePacket.class,
KeepAlivePacket::new,
map(0x00, MINECRAFT_1_7_2, false),
map(0x1F, MINECRAFT_1_9, false),
map(0x21, MINECRAFT_1_13, false),
@ -367,8 +384,8 @@ public enum StateRegistry {
map(0x23, MINECRAFT_1_19_4, false),
map(0x24, MINECRAFT_1_20_2, false));
clientbound.register(
JoinGame.class,
JoinGame::new,
JoinGamePacket.class,
JoinGamePacket::new,
map(0x01, MINECRAFT_1_7_2, false),
map(0x23, MINECRAFT_1_9, false),
map(0x25, MINECRAFT_1_13, false),
@ -383,8 +400,8 @@ public enum StateRegistry {
map(0x28, MINECRAFT_1_19_4, false),
map(0x29, MINECRAFT_1_20_2, false));
clientbound.register(
Respawn.class,
Respawn::new,
RespawnPacket.class,
RespawnPacket::new,
map(0x07, MINECRAFT_1_7_2, true),
map(0x33, MINECRAFT_1_9, true),
map(0x34, MINECRAFT_1_12, true),
@ -402,12 +419,12 @@ public enum StateRegistry {
map(0x43, MINECRAFT_1_20_2, true),
map(0x45, MINECRAFT_1_20_3, true));
clientbound.register(
RemoveResourcePack.class,
RemoveResourcePack::new,
RemoveResourcePackPacket.class,
RemoveResourcePackPacket::new,
map(0x43, MINECRAFT_1_20_3, false));
clientbound.register(
ResourcePackRequest.class,
ResourcePackRequest::new,
ResourcePackRequestPacket.class,
ResourcePackRequestPacket::new,
map(0x48, MINECRAFT_1_8, false),
map(0x32, MINECRAFT_1_9, false),
map(0x33, MINECRAFT_1_12, false),
@ -425,8 +442,8 @@ public enum StateRegistry {
map(0x42, MINECRAFT_1_20_2, false),
map(0x44, MINECRAFT_1_20_3, false));
clientbound.register(
HeaderAndFooter.class,
HeaderAndFooter::new,
HeaderAndFooterPacket.class,
HeaderAndFooterPacket::new,
map(0x47, MINECRAFT_1_8, true),
map(0x48, MINECRAFT_1_9, true),
map(0x47, MINECRAFT_1_9_4, true),
@ -502,8 +519,8 @@ public enum StateRegistry {
map(0x0E, MINECRAFT_1_19_4, true),
map(0x0F, MINECRAFT_1_20_2, true));
clientbound.register(
LegacyPlayerListItem.class,
LegacyPlayerListItem::new,
LegacyPlayerListItemPacket.class,
LegacyPlayerListItemPacket::new,
map(0x38, MINECRAFT_1_7_2, false),
map(0x2D, MINECRAFT_1_9, false),
map(0x2E, MINECRAFT_1_12_1, false),
@ -515,19 +532,19 @@ public enum StateRegistry {
map(0x36, MINECRAFT_1_17, false),
map(0x34, MINECRAFT_1_19, false),
map(0x37, MINECRAFT_1_19_1, MINECRAFT_1_19_1, false));
clientbound.register(RemovePlayerInfo.class, RemovePlayerInfo::new,
clientbound.register(RemovePlayerInfoPacket.class, RemovePlayerInfoPacket::new,
map(0x35, MINECRAFT_1_19_3, false),
map(0x39, MINECRAFT_1_19_4, false),
map(0x3B, MINECRAFT_1_20_2, false));
clientbound.register(
UpsertPlayerInfo.class,
UpsertPlayerInfo::new,
UpsertPlayerInfoPacket.class,
UpsertPlayerInfoPacket::new,
map(0x36, MINECRAFT_1_19_3, false),
map(0x3A, MINECRAFT_1_19_4, false),
map(0x3C, MINECRAFT_1_20_2, false));
clientbound.register(
SystemChat.class,
SystemChat::new,
SystemChatPacket.class,
SystemChatPacket::new,
map(0x5F, MINECRAFT_1_19, true),
map(0x62, MINECRAFT_1_19_1, true),
map(0x60, MINECRAFT_1_19_3, true),
@ -535,15 +552,15 @@ public enum StateRegistry {
map(0x67, MINECRAFT_1_20_2, true),
map(0x69, MINECRAFT_1_20_3, true));
clientbound.register(
PlayerChatCompletion.class,
PlayerChatCompletion::new,
PlayerChatCompletionPacket.class,
PlayerChatCompletionPacket::new,
map(0x15, MINECRAFT_1_19_1, true),
map(0x14, MINECRAFT_1_19_3, true),
map(0x16, MINECRAFT_1_19_4, true),
map(0x17, MINECRAFT_1_20_2, true));
clientbound.register(
ServerData.class,
ServerData::new,
ServerDataPacket.class,
ServerDataPacket::new,
map(0x3F, MINECRAFT_1_19, false),
map(0x42, MINECRAFT_1_19_1, false),
map(0x41, MINECRAFT_1_19_3, false),
@ -551,32 +568,43 @@ public enum StateRegistry {
map(0x47, MINECRAFT_1_20_2, false),
map(0x49, MINECRAFT_1_20_3, false));
clientbound.register(
StartUpdate.class,
StartUpdate::new,
StartUpdatePacket.class,
StartUpdatePacket::new,
map(0x65, MINECRAFT_1_20_2, false),
map(0x67, MINECRAFT_1_20_3, false));
}
},
LOGIN {
{
serverbound.register(ServerLogin.class, ServerLogin::new, map(0x00, MINECRAFT_1_7_2, false));
serverbound.register(ServerLoginPacket.class,
ServerLoginPacket::new,
map(0x00, MINECRAFT_1_7_2, false));
serverbound.register(
EncryptionResponse.class, EncryptionResponse::new, map(0x01, MINECRAFT_1_7_2, false));
EncryptionResponsePacket.class, EncryptionResponsePacket::new,
map(0x01, MINECRAFT_1_7_2, false));
serverbound.register(
LoginPluginResponse.class, LoginPluginResponse::new, map(0x02, MINECRAFT_1_13, false));
LoginPluginResponsePacket.class, LoginPluginResponsePacket::new,
map(0x02, MINECRAFT_1_13, false));
serverbound.register(
LoginAcknowledged.class, LoginAcknowledged::new, map(0x03, MINECRAFT_1_20_2, false));
LoginAcknowledgedPacket.class, LoginAcknowledgedPacket::new,
map(0x03, MINECRAFT_1_20_2, false));
clientbound.register(
Disconnect.class, () -> new Disconnect(true), map(0x00, MINECRAFT_1_7_2, false));
DisconnectPacket.class, () -> new DisconnectPacket(true),
map(0x00, MINECRAFT_1_7_2, false));
clientbound.register(
EncryptionRequest.class, EncryptionRequest::new, map(0x01, MINECRAFT_1_7_2, false));
EncryptionRequestPacket.class, EncryptionRequestPacket::new,
map(0x01, MINECRAFT_1_7_2, false));
clientbound.register(
ServerLoginSuccess.class, ServerLoginSuccess::new, map(0x02, MINECRAFT_1_7_2, false));
ServerLoginSuccessPacket.class, ServerLoginSuccessPacket::new,
map(0x02, MINECRAFT_1_7_2, false));
clientbound.register(
SetCompression.class, SetCompression::new, map(0x03, MINECRAFT_1_8, false));
SetCompressionPacket.class, SetCompressionPacket::new,
map(0x03, MINECRAFT_1_8, false));
clientbound.register(
LoginPluginMessage.class, LoginPluginMessage::new, map(0x04, MINECRAFT_1_13, false));
LoginPluginMessagePacket.class,
LoginPluginMessagePacket::new,
map(0x04, MINECRAFT_1_13, false));
}
};

Datei anzeigen

@ -19,8 +19,8 @@ package com.velocitypowered.proxy.protocol.netty;
import static com.velocitypowered.proxy.protocol.util.NettyPreconditions.checkFrame;
import com.velocitypowered.proxy.protocol.packet.LegacyHandshake;
import com.velocitypowered.proxy.protocol.packet.LegacyPing;
import com.velocitypowered.proxy.protocol.packet.LegacyHandshakePacket;
import com.velocitypowered.proxy.protocol.packet.LegacyPingPacket;
import com.velocitypowered.proxy.protocol.packet.legacyping.LegacyMinecraftPingVersion;
import io.netty.buffer.ByteBuf;
import io.netty.channel.ChannelHandlerContext;
@ -52,13 +52,13 @@ public class LegacyPingDecoder extends ByteToMessageDecoder {
if (first == 0xfe) {
// possibly a ping
if (!in.isReadable()) {
out.add(new LegacyPing(LegacyMinecraftPingVersion.MINECRAFT_1_3));
out.add(new LegacyPingPacket(LegacyMinecraftPingVersion.MINECRAFT_1_3));
return;
}
short next = in.readUnsignedByte();
if (next == 1 && !in.isReadable()) {
out.add(new LegacyPing(LegacyMinecraftPingVersion.MINECRAFT_1_4));
out.add(new LegacyPingPacket(LegacyMinecraftPingVersion.MINECRAFT_1_4));
return;
}
@ -66,14 +66,14 @@ public class LegacyPingDecoder extends ByteToMessageDecoder {
out.add(readExtended16Data(in));
} else if (first == 0x02 && in.isReadable()) {
in.skipBytes(in.readableBytes());
out.add(new LegacyHandshake());
out.add(new LegacyHandshakePacket());
} else {
in.readerIndex(originalReaderIndex);
ctx.pipeline().remove(this);
}
}
private static LegacyPing readExtended16Data(ByteBuf in) {
private static LegacyPingPacket readExtended16Data(ByteBuf in) {
in.skipBytes(1);
String channelName = readLegacyString(in);
if (!channelName.equals(MC_1_6_CHANNEL)) {
@ -83,7 +83,7 @@ public class LegacyPingDecoder extends ByteToMessageDecoder {
String hostname = readLegacyString(in);
int port = in.readInt();
return new LegacyPing(LegacyMinecraftPingVersion.MINECRAFT_1_6, InetSocketAddress
return new LegacyPingPacket(LegacyMinecraftPingVersion.MINECRAFT_1_6, InetSocketAddress
.createUnresolved(hostname, port));
}

Datei anzeigen

@ -53,7 +53,7 @@ import java.util.concurrent.CompletableFuture;
import org.checkerframework.checker.nullness.qual.MonotonicNonNull;
import org.checkerframework.checker.nullness.qual.Nullable;
public class AvailableCommands implements MinecraftPacket {
public class AvailableCommandsPacket implements MinecraftPacket {
private static final Command<CommandSource> PLACEHOLDER_COMMAND = source -> 0;

Datei anzeigen

@ -26,7 +26,7 @@ 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;
@ -192,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;

Datei anzeigen

@ -26,7 +26,7 @@ import java.util.Objects;
import org.checkerframework.checker.nullness.qual.Nullable;
public class ClientSettings implements MinecraftPacket {
public class ClientSettingsPacket implements MinecraftPacket {
private @Nullable String locale;
private byte viewDistance;
private int chatVisibility;
@ -37,10 +37,10 @@ public class ClientSettings implements MinecraftPacket {
private boolean chatFilteringEnabled; // Added in 1.17
private boolean clientListingAllowed; // Added in 1.18, overwrites server-list "anonymous" mode
public ClientSettings() {
public ClientSettingsPacket() {
}
public ClientSettings(String locale, byte viewDistance, int chatVisibility, boolean chatColors,
public ClientSettingsPacket(String locale, byte viewDistance, int chatVisibility, boolean chatColors,
short skinParts, int mainHand, boolean chatFilteringEnabled, boolean clientListingAllowed) {
this.locale = locale;
this.viewDistance = viewDistance;
@ -194,7 +194,7 @@ public class ClientSettings implements MinecraftPacket {
if (o == null || getClass() != o.getClass()) {
return false;
}
final ClientSettings that = (ClientSettings) o;
final ClientSettingsPacket that = (ClientSettingsPacket) o;
return viewDistance == that.viewDistance
&& chatVisibility == that.chatVisibility
&& chatColors == that.chatColors

Datei anzeigen

@ -27,16 +27,16 @@ import io.netty.buffer.ByteBuf;
import net.kyori.adventure.text.Component;
import org.checkerframework.checker.nullness.qual.Nullable;
public class Disconnect implements MinecraftPacket {
public class DisconnectPacket implements MinecraftPacket {
private @Nullable ComponentHolder reason;
private final boolean login;
public Disconnect(boolean login) {
public DisconnectPacket(boolean login) {
this.login = login;
}
private Disconnect(boolean login, ComponentHolder reason) {
private DisconnectPacket(boolean login, ComponentHolder reason) {
this.login = login;
this.reason = Preconditions.checkNotNull(reason, "reason");
}
@ -74,8 +74,8 @@ public class Disconnect implements MinecraftPacket {
return handler.handle(this);
}
public static Disconnect create(Component component, ProtocolVersion version, boolean login) {
public static DisconnectPacket create(Component component, ProtocolVersion version, boolean login) {
Preconditions.checkNotNull(component, "component");
return new Disconnect(login, new ComponentHolder(login ? ProtocolVersion.MINECRAFT_1_20_2 : version, component));
return new DisconnectPacket(login, new ComponentHolder(login ? ProtocolVersion.MINECRAFT_1_20_2 : version, component));
}
}

Datei anzeigen

@ -26,7 +26,7 @@ import com.velocitypowered.proxy.protocol.ProtocolUtils;
import io.netty.buffer.ByteBuf;
import java.util.Arrays;
public class EncryptionRequest implements MinecraftPacket {
public class EncryptionRequestPacket implements MinecraftPacket {
private String serverId = "";
private byte[] publicKey = EMPTY_BYTE_ARRAY;

Datei anzeigen

@ -30,9 +30,9 @@ import org.checkerframework.checker.nullness.qual.Nullable;
import java.util.Arrays;
public class EncryptionResponse implements MinecraftPacket {
public class EncryptionResponsePacket implements MinecraftPacket {
private final static QuietDecoderException NO_SALT = new QuietDecoderException(
private static final QuietDecoderException NO_SALT = new QuietDecoderException(
"Encryption response didn't contain salt");
private byte[] sharedSecret = EMPTY_BYTE_ARRAY;

Datei anzeigen

@ -25,7 +25,7 @@ import com.velocitypowered.proxy.protocol.MinecraftPacket;
import com.velocitypowered.proxy.protocol.ProtocolUtils;
import io.netty.buffer.ByteBuf;
public class Handshake implements MinecraftPacket {
public class HandshakePacket implements MinecraftPacket {
// This size was chosen to ensure Forge clients can still connect even with very long hostnames.
// While DNS technically allows any character to be used, in practice ASCII is used.

Datei anzeigen

@ -26,16 +26,16 @@ import com.velocitypowered.proxy.protocol.packet.chat.ComponentHolder;
import io.netty.buffer.ByteBuf;
import net.kyori.adventure.text.Component;
public class HeaderAndFooter implements MinecraftPacket {
public class HeaderAndFooterPacket implements MinecraftPacket {
private final ComponentHolder header;
private final ComponentHolder footer;
public HeaderAndFooter() {
public HeaderAndFooterPacket() {
throw new UnsupportedOperationException("Decode is not implemented");
}
public HeaderAndFooter(ComponentHolder header, ComponentHolder footer) {
public HeaderAndFooterPacket(ComponentHolder header, ComponentHolder footer) {
this.header = Preconditions.checkNotNull(header, "header");
this.footer = Preconditions.checkNotNull(footer, "footer");
}
@ -64,14 +64,14 @@ public class HeaderAndFooter implements MinecraftPacket {
return handler.handle(this);
}
public static HeaderAndFooter create(Component header,
public static HeaderAndFooterPacket create(Component header,
Component footer, ProtocolVersion protocolVersion) {
return new HeaderAndFooter(new ComponentHolder(protocolVersion, header),
return new HeaderAndFooterPacket(new ComponentHolder(protocolVersion, header),
new ComponentHolder(protocolVersion, footer));
}
public static HeaderAndFooter reset(ProtocolVersion version) {
public static HeaderAndFooterPacket reset(ProtocolVersion version) {
ComponentHolder empty = new ComponentHolder(version, Component.empty());
return new HeaderAndFooter(empty, empty);
return new HeaderAndFooterPacket(empty, empty);
}
}

Datei anzeigen

@ -28,7 +28,7 @@ import net.kyori.adventure.nbt.BinaryTagIO;
import net.kyori.adventure.nbt.CompoundBinaryTag;
import org.checkerframework.checker.nullness.qual.Nullable;
public class JoinGame implements MinecraftPacket {
public class JoinGamePacket implements MinecraftPacket {
private static final BinaryTagIO.Reader JOINGAME_READER = BinaryTagIO.reader(4 * 1024 * 1024);
private int entityId;

Datei anzeigen

@ -23,7 +23,7 @@ import com.velocitypowered.proxy.protocol.MinecraftPacket;
import com.velocitypowered.proxy.protocol.ProtocolUtils;
import io.netty.buffer.ByteBuf;
public class KeepAlive implements MinecraftPacket {
public class KeepAlivePacket implements MinecraftPacket {
private long randomId;

Datei anzeigen

@ -23,7 +23,7 @@ import com.velocitypowered.proxy.protocol.MinecraftPacket;
import com.velocitypowered.proxy.protocol.ProtocolUtils;
import io.netty.buffer.ByteBuf;
public class LegacyHandshake implements MinecraftPacket {
public class LegacyHandshakePacket implements MinecraftPacket {
@Override
public void decode(ByteBuf buf, ProtocolUtils.Direction direction, ProtocolVersion version) {

Datei anzeigen

@ -26,17 +26,17 @@ import io.netty.buffer.ByteBuf;
import java.net.InetSocketAddress;
import org.checkerframework.checker.nullness.qual.Nullable;
public class LegacyPing implements MinecraftPacket {
public class LegacyPingPacket implements MinecraftPacket {
private final LegacyMinecraftPingVersion version;
private final @Nullable InetSocketAddress vhost;
public LegacyPing(LegacyMinecraftPingVersion version) {
public LegacyPingPacket(LegacyMinecraftPingVersion version) {
this.version = version;
this.vhost = null;
}
public LegacyPing(LegacyMinecraftPingVersion version, InetSocketAddress vhost) {
public LegacyPingPacket(LegacyMinecraftPingVersion version, InetSocketAddress vhost) {
this.version = version;
this.vhost = vhost;
}

Datei anzeigen

@ -33,7 +33,7 @@ import net.kyori.adventure.text.Component;
import net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer;
import org.checkerframework.checker.nullness.qual.Nullable;
public class LegacyPlayerListItem implements MinecraftPacket {
public class LegacyPlayerListItemPacket implements MinecraftPacket {
public static final int ADD_PLAYER = 0;
public static final int UPDATE_GAMEMODE = 1;
@ -43,12 +43,12 @@ public class LegacyPlayerListItem implements MinecraftPacket {
private int action;
private final List<Item> items = new ArrayList<>();
public LegacyPlayerListItem(int action, List<Item> items) {
public LegacyPlayerListItemPacket(int action, List<Item> items) {
this.action = action;
this.items.addAll(items);
}
public LegacyPlayerListItem() {
public LegacyPlayerListItemPacket() {
}
public int getAction() {

Datei anzeigen

@ -23,7 +23,7 @@ import com.velocitypowered.proxy.protocol.MinecraftPacket;
import com.velocitypowered.proxy.protocol.ProtocolUtils;
import io.netty.buffer.ByteBuf;
public class LoginAcknowledged implements MinecraftPacket {
public class LoginAcknowledgedPacket implements MinecraftPacket {
@Override
public void decode(ByteBuf buf, ProtocolUtils.Direction direction,

Datei anzeigen

@ -26,16 +26,16 @@ import io.netty.buffer.ByteBuf;
import io.netty.buffer.Unpooled;
import org.checkerframework.checker.nullness.qual.Nullable;
public class LoginPluginMessage extends DeferredByteBufHolder implements MinecraftPacket {
public class LoginPluginMessagePacket extends DeferredByteBufHolder implements MinecraftPacket {
private int id;
private @Nullable String channel;
public LoginPluginMessage() {
public LoginPluginMessagePacket() {
super(null);
}
public LoginPluginMessage(int id, @Nullable String channel, ByteBuf data) {
public LoginPluginMessagePacket(int id, @Nullable String channel, ByteBuf data) {
super(data);
this.id = id;
this.channel = channel;

Datei anzeigen

@ -26,16 +26,16 @@ import io.netty.buffer.ByteBuf;
import io.netty.buffer.Unpooled;
import org.checkerframework.checker.nullness.qual.MonotonicNonNull;
public class LoginPluginResponse extends DeferredByteBufHolder implements MinecraftPacket {
public class LoginPluginResponsePacket extends DeferredByteBufHolder implements MinecraftPacket {
private int id;
private boolean success;
public LoginPluginResponse() {
public LoginPluginResponsePacket() {
super(Unpooled.EMPTY_BUFFER);
}
public LoginPluginResponse(int id, boolean success, @MonotonicNonNull ByteBuf buf) {
public LoginPluginResponsePacket(int id, boolean success, @MonotonicNonNull ByteBuf buf) {
super(buf);
this.id = id;
this.success = success;

Datei anzeigen

@ -23,7 +23,7 @@ import com.velocitypowered.proxy.protocol.MinecraftPacket;
import com.velocitypowered.proxy.protocol.ProtocolUtils;
import io.netty.buffer.ByteBuf;
public class PingIdentify implements MinecraftPacket {
public class PingIdentifyPacket implements MinecraftPacket {
private int id;

Datei anzeigen

@ -28,15 +28,15 @@ import io.netty.buffer.ByteBuf;
import org.checkerframework.checker.nullness.qual.MonotonicNonNull;
import org.checkerframework.checker.nullness.qual.Nullable;
public class PluginMessage extends DeferredByteBufHolder implements MinecraftPacket {
public class PluginMessagePacket extends DeferredByteBufHolder implements MinecraftPacket {
private @Nullable String channel;
public PluginMessage() {
public PluginMessagePacket() {
super(null);
}
public PluginMessage(String channel,
public PluginMessagePacket(String channel,
@MonotonicNonNull ByteBuf backing) {
super(backing);
this.channel = channel;
@ -105,42 +105,42 @@ public class PluginMessage extends DeferredByteBufHolder implements MinecraftPac
}
@Override
public PluginMessage copy() {
return (PluginMessage) super.copy();
public PluginMessagePacket copy() {
return (PluginMessagePacket) super.copy();
}
@Override
public PluginMessage duplicate() {
return (PluginMessage) super.duplicate();
public PluginMessagePacket duplicate() {
return (PluginMessagePacket) super.duplicate();
}
@Override
public PluginMessage retainedDuplicate() {
return (PluginMessage) super.retainedDuplicate();
public PluginMessagePacket retainedDuplicate() {
return (PluginMessagePacket) super.retainedDuplicate();
}
@Override
public PluginMessage replace(ByteBuf content) {
return (PluginMessage) super.replace(content);
public PluginMessagePacket replace(ByteBuf content) {
return (PluginMessagePacket) super.replace(content);
}
@Override
public PluginMessage retain() {
return (PluginMessage) super.retain();
public PluginMessagePacket retain() {
return (PluginMessagePacket) super.retain();
}
@Override
public PluginMessage retain(int increment) {
return (PluginMessage) super.retain(increment);
public PluginMessagePacket retain(int increment) {
return (PluginMessagePacket) super.retain(increment);
}
@Override
public PluginMessage touch() {
return (PluginMessage) super.touch();
public PluginMessagePacket touch() {
return (PluginMessagePacket) super.touch();
}
@Override
public PluginMessage touch(Object hint) {
return (PluginMessage) super.touch(hint);
public PluginMessagePacket touch(Object hint) {
return (PluginMessagePacket) super.touch(hint);
}
}

Datei anzeigen

@ -27,15 +27,15 @@ import java.util.ArrayList;
import java.util.Collection;
import java.util.UUID;
public class RemovePlayerInfo implements MinecraftPacket {
public class RemovePlayerInfoPacket implements MinecraftPacket {
private Collection<UUID> profilesToRemove;
public RemovePlayerInfo() {
public RemovePlayerInfoPacket() {
this.profilesToRemove = new ArrayList<>();
}
public RemovePlayerInfo(Collection<UUID> profilesToRemove) {
public RemovePlayerInfoPacket(Collection<UUID> profilesToRemove) {
this.profilesToRemove = profilesToRemove;
}

Datei anzeigen

@ -26,14 +26,14 @@ import io.netty.buffer.ByteBuf;
import java.util.UUID;
public class RemoveResourcePack implements MinecraftPacket {
public class RemoveResourcePackPacket implements MinecraftPacket {
private UUID id;
public RemoveResourcePack() {
public RemoveResourcePackPacket() {
}
public RemoveResourcePack(UUID id) {
public RemoveResourcePackPacket(UUID id) {
this.id = id;
}

Datei anzeigen

@ -34,7 +34,7 @@ import org.checkerframework.checker.nullness.qual.Nullable;
import java.util.UUID;
import java.util.regex.Pattern;
public class ResourcePackRequest implements MinecraftPacket {
public class ResourcePackRequestPacket implements MinecraftPacket {
private @MonotonicNonNull UUID id; // 1.20.3+
private @MonotonicNonNull String url;

Datei anzeigen

@ -28,16 +28,16 @@ import org.checkerframework.checker.nullness.qual.MonotonicNonNull;
import java.util.UUID;
public class ResourcePackResponse implements MinecraftPacket {
public class ResourcePackResponsePacket implements MinecraftPacket {
private UUID id;
private String hash = "";
private @MonotonicNonNull Status status;
public ResourcePackResponse() {
public ResourcePackResponsePacket() {
}
public ResourcePackResponse(UUID id, String hash, @MonotonicNonNull Status status) {
public ResourcePackResponsePacket(UUID id, String hash, @MonotonicNonNull Status status) {
this.id = id;
this.hash = hash;
this.status = status;

Datei anzeigen

@ -28,7 +28,7 @@ import net.kyori.adventure.nbt.BinaryTagIO;
import net.kyori.adventure.nbt.CompoundBinaryTag;
import org.checkerframework.checker.nullness.qual.Nullable;
public class Respawn implements MinecraftPacket {
public class RespawnPacket implements MinecraftPacket {
private int dimension;
private long partialHashedSeed;
@ -42,10 +42,10 @@ public class Respawn implements MinecraftPacket {
private @Nullable Pair<String, Long> lastDeathPosition; // 1.19+
private int portalCooldown; // 1.20+
public Respawn() {
public RespawnPacket() {
}
public Respawn(int dimension, long partialHashedSeed, short difficulty, short gamemode,
public RespawnPacket(int dimension, long partialHashedSeed, short difficulty, short gamemode,
String levelType, byte dataToKeep, DimensionInfo dimensionInfo,
short previousGamemode, CompoundBinaryTag currentDimensionData,
@Nullable Pair<String, Long> lastDeathPosition, int portalCooldown) {
@ -62,8 +62,8 @@ public class Respawn implements MinecraftPacket {
this.portalCooldown = portalCooldown;
}
public static Respawn fromJoinGame(JoinGame joinGame) {
return new Respawn(joinGame.getDimension(), joinGame.getPartialHashedSeed(),
public static RespawnPacket fromJoinGame(JoinGamePacket joinGame) {
return new RespawnPacket(joinGame.getDimension(), joinGame.getPartialHashedSeed(),
joinGame.getDifficulty(), joinGame.getGamemode(), joinGame.getLevelType(),
(byte) 0, joinGame.getDimensionInfo(), joinGame.getPreviousGamemode(),
joinGame.getCurrentDimensionData(), joinGame.getLastDeathPosition(), joinGame.getPortalCooldown());

Datei anzeigen

@ -28,16 +28,16 @@ import org.jetbrains.annotations.Nullable;
import java.nio.charset.StandardCharsets;
import java.util.Base64;
public class ServerData implements MinecraftPacket {
public class ServerDataPacket implements MinecraftPacket {
private @Nullable ComponentHolder description;
private @Nullable Favicon favicon;
private boolean secureChatEnforced; // Added in 1.19.1
public ServerData() {
public ServerDataPacket() {
}
public ServerData(@Nullable ComponentHolder description, @Nullable Favicon favicon,
public ServerDataPacket(@Nullable ComponentHolder description, @Nullable Favicon favicon,
boolean secureChatEnforced) {
this.description = description;
this.favicon = favicon;

Datei anzeigen

@ -30,7 +30,7 @@ import org.checkerframework.checker.nullness.qual.Nullable;
import java.util.UUID;
public class ServerLogin implements MinecraftPacket {
public class ServerLoginPacket implements MinecraftPacket {
private static final QuietDecoderException EMPTY_USERNAME = new QuietDecoderException(
"Empty username!");
@ -39,15 +39,15 @@ public class ServerLogin implements MinecraftPacket {
private @Nullable IdentifiedKey playerKey; // Introduced in 1.19.3
private @Nullable UUID holderUuid; // Used for key revision 2
public ServerLogin() {
public ServerLoginPacket() {
}
public ServerLogin(String username, @Nullable IdentifiedKey playerKey) {
public ServerLoginPacket(String username, @Nullable IdentifiedKey playerKey) {
this.username = Preconditions.checkNotNull(username, "username");
this.playerKey = playerKey;
}
public ServerLogin(String username, @Nullable UUID holderUuid) {
public ServerLoginPacket(String username, @Nullable UUID holderUuid) {
this.username = Preconditions.checkNotNull(username, "username");
this.holderUuid = holderUuid;
this.playerKey = null;

Datei anzeigen

@ -29,7 +29,7 @@ import java.util.List;
import java.util.UUID;
import org.checkerframework.checker.nullness.qual.Nullable;
public class ServerLoginSuccess implements MinecraftPacket {
public class ServerLoginSuccessPacket implements MinecraftPacket {
private @Nullable UUID uuid;
private @Nullable String username;

Datei anzeigen

@ -23,14 +23,14 @@ import com.velocitypowered.proxy.protocol.MinecraftPacket;
import com.velocitypowered.proxy.protocol.ProtocolUtils;
import io.netty.buffer.ByteBuf;
public class SetCompression implements MinecraftPacket {
public class SetCompressionPacket implements MinecraftPacket {
private int threshold;
public SetCompression() {
public SetCompressionPacket() {
}
public SetCompression(int threshold) {
public SetCompressionPacket(int threshold) {
this.threshold = threshold;
}

Datei anzeigen

@ -24,7 +24,7 @@ import com.velocitypowered.proxy.protocol.ProtocolUtils;
import com.velocitypowered.proxy.protocol.ProtocolUtils.Direction;
import io.netty.buffer.ByteBuf;
public class StatusPing implements MinecraftPacket {
public class StatusPingPacket implements MinecraftPacket {
private long randomId;

Datei anzeigen

@ -24,11 +24,11 @@ import com.velocitypowered.proxy.protocol.ProtocolUtils;
import com.velocitypowered.proxy.protocol.ProtocolUtils.Direction;
import io.netty.buffer.ByteBuf;
public class StatusRequest implements MinecraftPacket {
public class StatusRequestPacket implements MinecraftPacket {
public static final StatusRequest INSTANCE = new StatusRequest();
public static final StatusRequestPacket INSTANCE = new StatusRequestPacket();
private StatusRequest() {
private StatusRequestPacket() {
}

Datei anzeigen

@ -24,14 +24,14 @@ import com.velocitypowered.proxy.protocol.ProtocolUtils;
import io.netty.buffer.ByteBuf;
import org.checkerframework.checker.nullness.qual.Nullable;
public class StatusResponse implements MinecraftPacket {
public class StatusResponsePacket implements MinecraftPacket {
private @Nullable CharSequence status;
public StatusResponse() {
public StatusResponsePacket() {
}
public StatusResponse(CharSequence status) {
public StatusResponsePacket(CharSequence status) {
this.status = status;
}

Datei anzeigen

@ -29,7 +29,7 @@ import com.velocitypowered.proxy.protocol.ProtocolUtils;
import io.netty.buffer.ByteBuf;
import org.checkerframework.checker.nullness.qual.Nullable;
public class TabCompleteRequest implements MinecraftPacket {
public class TabCompleteRequestPacket implements MinecraftPacket {
private static final int VANILLA_MAX_TAB_COMPLETE_LEN = 2048;

Datei anzeigen

@ -30,7 +30,7 @@ import java.util.ArrayList;
import java.util.List;
import org.checkerframework.checker.nullness.qual.Nullable;
public class TabCompleteResponse implements MinecraftPacket {
public class TabCompleteResponsePacket implements MinecraftPacket {
private int transactionId;
private int start;

Datei anzeigen

@ -34,22 +34,22 @@ import java.util.List;
import java.util.UUID;
import org.jetbrains.annotations.Nullable;
public class UpsertPlayerInfo implements MinecraftPacket {
public class UpsertPlayerInfoPacket implements MinecraftPacket {
private final EnumSet<Action> actions;
private final List<Entry> entries;
public UpsertPlayerInfo() {
public UpsertPlayerInfoPacket() {
this.actions = EnumSet.noneOf(Action.class);
this.entries = new ArrayList<>();
}
public UpsertPlayerInfo(Action action) {
public UpsertPlayerInfoPacket(Action action) {
this.actions = EnumSet.of(action);
this.entries = new ArrayList<>();
}
public UpsertPlayerInfo(EnumSet<Action> actions, List<Entry> entries) {
public UpsertPlayerInfoPacket(EnumSet<Action> actions, List<Entry> entries) {
this.actions = actions;
this.entries = entries;
}

Datei anzeigen

@ -23,14 +23,14 @@ import com.velocitypowered.proxy.protocol.MinecraftPacket;
import com.velocitypowered.proxy.protocol.ProtocolUtils;
import io.netty.buffer.ByteBuf;
public class ChatAcknowledgement implements MinecraftPacket {
public class ChatAcknowledgementPacket implements MinecraftPacket {
int offset;
public ChatAcknowledgement(int offset) {
public ChatAcknowledgementPacket(int offset) {
this.offset = offset;
}
public ChatAcknowledgement() {
public ChatAcknowledgementPacket() {
}
@Override

Datei anzeigen

@ -23,7 +23,7 @@ import com.velocitypowered.proxy.protocol.MinecraftPacket;
import com.velocitypowered.proxy.protocol.ProtocolUtils;
import io.netty.buffer.ByteBuf;
public class PlayerChatCompletion implements MinecraftPacket {
public class PlayerChatCompletionPacket implements MinecraftPacket {
private String[] completions;
private Action action;

Datei anzeigen

@ -23,12 +23,12 @@ import com.velocitypowered.proxy.protocol.MinecraftPacket;
import com.velocitypowered.proxy.protocol.ProtocolUtils;
import io.netty.buffer.ByteBuf;
public class SystemChat implements MinecraftPacket {
public class SystemChatPacket implements MinecraftPacket {
public SystemChat() {
public SystemChatPacket() {
}
public SystemChat(ComponentHolder component, ChatType type) {
public SystemChatPacket(ComponentHolder component, ChatType type) {
this.component = component;
this.type = type;
}

Datei anzeigen

@ -22,7 +22,7 @@ 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.ComponentHolder;
import com.velocitypowered.proxy.protocol.packet.chat.SystemChat;
import com.velocitypowered.proxy.protocol.packet.chat.SystemChatPacket;
import com.velocitypowered.proxy.protocol.packet.chat.builder.ChatBuilderV2;
import net.kyori.adventure.text.Component;
@ -36,16 +36,16 @@ public class KeyedChatBuilder extends ChatBuilderV2 {
public MinecraftPacket toClient() {
// This is temporary
Component msg = component == null ? Component.text(message) : component;
return new SystemChat(new ComponentHolder(version, msg), type == ChatType.CHAT ? ChatType.SYSTEM : type);
return new SystemChatPacket(new ComponentHolder(version, msg), type == ChatType.CHAT ? ChatType.SYSTEM : type);
}
@Override
public MinecraftPacket toServer() {
if (message.startsWith("/")) {
return new KeyedPlayerCommand(message.substring(1), ImmutableList.of(), timestamp);
return new KeyedPlayerCommandPacket(message.substring(1), ImmutableList.of(), timestamp);
} else {
// This will produce an error on the server, but needs to be here.
KeyedPlayerChat v1Chat = new KeyedPlayerChat(message);
KeyedPlayerChatPacket v1Chat = new KeyedPlayerChatPacket(message);
v1Chat.setExpiry(this.timestamp);
return v1Chat;
}

Datei anzeigen

@ -31,7 +31,7 @@ import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
public class KeyedChatHandler implements
com.velocitypowered.proxy.protocol.packet.chat.ChatHandler<KeyedPlayerChat> {
com.velocitypowered.proxy.protocol.packet.chat.ChatHandler<KeyedPlayerChatPacket> {
private static final Logger logger = LogManager.getLogger(KeyedChatHandler.class);
@ -44,8 +44,8 @@ public class KeyedChatHandler implements
}
@Override
public Class<KeyedPlayerChat> packetClass() {
return KeyedPlayerChat.class;
public Class<KeyedPlayerChatPacket> packetClass() {
return KeyedPlayerChatPacket.class;
}
public static void invalidCancel(Logger logger, ConnectedPlayer player) {
@ -65,7 +65,7 @@ public class KeyedChatHandler implements
}
@Override
public void handlePlayerChatInternal(KeyedPlayerChat packet) {
public void handlePlayerChatInternal(KeyedPlayerChatPacket packet) {
ChatQueue chatQueue = this.player.getChatQueue();
EventManager eventManager = this.server.getEventManager();
PlayerChatEvent toSend = new PlayerChatEvent(player, packet.getMessage());
@ -99,7 +99,7 @@ public class KeyedChatHandler implements
);
}
private Function<PlayerChatEvent, MinecraftPacket> handleOldSignedChat(KeyedPlayerChat packet) {
private Function<PlayerChatEvent, MinecraftPacket> handleOldSignedChat(KeyedPlayerChatPacket packet) {
IdentifiedKey playerKey = this.player.getIdentifiedKey();
assert playerKey != null;
return pme -> {

Datei anzeigen

@ -26,7 +26,7 @@ import com.velocitypowered.proxy.protocol.packet.chat.builder.ChatBuilderV2;
import java.util.concurrent.CompletableFuture;
import net.kyori.adventure.text.Component;
public class KeyedCommandHandler implements CommandHandler<KeyedPlayerCommand> {
public class KeyedCommandHandler implements CommandHandler<KeyedPlayerCommandPacket> {
private final ConnectedPlayer player;
private final VelocityServer server;
@ -37,12 +37,12 @@ public class KeyedCommandHandler implements CommandHandler<KeyedPlayerCommand> {
}
@Override
public Class<KeyedPlayerCommand> packetClass() {
return KeyedPlayerCommand.class;
public Class<KeyedPlayerCommandPacket> packetClass() {
return KeyedPlayerCommandPacket.class;
}
@Override
public void handlePlayerCommandInternal(KeyedPlayerCommand packet) {
public void handlePlayerCommandInternal(KeyedPlayerCommandPacket packet) {
queueCommandResult(this.server, this.player, event -> {
CommandExecuteEvent.CommandResult result = event.getResult();
IdentifiedKey playerKey = player.getIdentifiedKey();

Datei anzeigen

@ -29,7 +29,7 @@ import io.netty.buffer.ByteBuf;
import java.time.Instant;
import org.checkerframework.checker.nullness.qual.Nullable;
public class KeyedPlayerChat implements MinecraftPacket {
public class KeyedPlayerChatPacket implements MinecraftPacket {
private String message;
private boolean signedPreview;
@ -45,10 +45,10 @@ public class KeyedPlayerChat implements MinecraftPacket {
public static final QuietDecoderException INVALID_PREVIOUS_MESSAGES =
new QuietDecoderException("Invalid previous messages");
public KeyedPlayerChat() {
public KeyedPlayerChatPacket() {
}
public KeyedPlayerChat(String message) {
public KeyedPlayerChatPacket(String message) {
this.message = message;
this.unsigned = true;
}

Datei anzeigen

@ -17,8 +17,8 @@
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;
import static com.velocitypowered.proxy.protocol.packet.chat.keyed.KeyedPlayerChatPacket.INVALID_PREVIOUS_MESSAGES;
import static com.velocitypowered.proxy.protocol.packet.chat.keyed.KeyedPlayerChatPacket.MAXIMUM_PREVIOUS_MESSAGE_COUNT;
import com.google.common.collect.ImmutableMap;
import com.velocitypowered.api.network.ProtocolVersion;
@ -35,7 +35,7 @@ import java.util.List;
import java.util.Map;
import org.checkerframework.checker.nullness.qual.Nullable;
public class KeyedPlayerCommand implements MinecraftPacket {
public class KeyedPlayerCommandPacket implements MinecraftPacket {
private static final int MAX_NUM_ARGUMENTS = 8;
private static final int MAX_LENGTH_ARGUMENTS = 16;
@ -63,17 +63,17 @@ public class KeyedPlayerCommand implements MinecraftPacket {
return command;
}
public KeyedPlayerCommand() {
public KeyedPlayerCommandPacket() {
}
/**
* Creates an {@link KeyedPlayerCommand} packet based on a command and list of arguments.
* Creates an {@link KeyedPlayerCommandPacket} packet based on a command and list of arguments.
*
* @param command the command to run
* @param arguments the arguments of the command
* @param timestamp the timestamp of the command execution
*/
public KeyedPlayerCommand(String command, List<String> arguments, Instant timestamp) {
public KeyedPlayerCommandPacket(String command, List<String> arguments, Instant timestamp) {
this.unsigned = true;
ImmutableMap.Builder<String, byte[]> builder = ImmutableMap.builder();
arguments.forEach(entry -> builder.put(entry, EncryptionUtils.EMPTY));

Datei anzeigen

@ -38,13 +38,13 @@ public class LegacyChatBuilder extends ChatBuilderV2 {
: senderIdentity.uuid()) : sender.getUniqueId();
Component msg = component == null ? Component.text(message) : component;
return new LegacyChat(ProtocolUtils.getJsonChatSerializer(version).serialize(msg), type.getId(),
return new LegacyChatPacket(ProtocolUtils.getJsonChatSerializer(version).serialize(msg), type.getId(),
identity);
}
@Override
public MinecraftPacket toServer() {
LegacyChat chat = new LegacyChat();
LegacyChatPacket chat = new LegacyChatPacket();
chat.setMessage(message);
return chat;
}

Datei anzeigen

@ -23,7 +23,7 @@ import com.velocitypowered.proxy.connection.MinecraftConnection;
import com.velocitypowered.proxy.connection.client.ConnectedPlayer;
import com.velocitypowered.proxy.protocol.packet.chat.ChatHandler;
public class LegacyChatHandler implements ChatHandler<LegacyChat> {
public class LegacyChatHandler implements ChatHandler<LegacyChatPacket> {
private final VelocityServer server;
private final ConnectedPlayer player;
@ -34,12 +34,12 @@ public class LegacyChatHandler implements ChatHandler<LegacyChat> {
}
@Override
public Class<LegacyChat> packetClass() {
return LegacyChat.class;
public Class<LegacyChatPacket> packetClass() {
return LegacyChatPacket.class;
}
@Override
public void handlePlayerChatInternal(LegacyChat packet) {
public void handlePlayerChatInternal(LegacyChatPacket packet) {
MinecraftConnection serverConnection = player.ensureAndGetCurrentServer().ensureConnected();
if (serverConnection == null) {
return;

Datei anzeigen

@ -25,7 +25,7 @@ import io.netty.buffer.ByteBuf;
import java.util.UUID;
import org.checkerframework.checker.nullness.qual.Nullable;
public class LegacyChat implements MinecraftPacket {
public class LegacyChatPacket implements MinecraftPacket {
public static final byte CHAT_TYPE = (byte) 0;
public static final byte SYSTEM_TYPE = (byte) 1;
@ -38,13 +38,13 @@ public class LegacyChat implements MinecraftPacket {
private byte type;
private @Nullable UUID sender;
public LegacyChat() {
public LegacyChatPacket() {
}
/**
* Creates a Chat packet.
*/
public LegacyChat(String message, byte type, UUID sender) {
public LegacyChatPacket(String message, byte type, UUID sender) {
this.message = message;
this.type = type;
this.sender = sender;

Datei anzeigen

@ -24,7 +24,7 @@ import com.velocitypowered.proxy.protocol.packet.chat.CommandHandler;
import java.time.Instant;
import java.util.concurrent.CompletableFuture;
public class LegacyCommandHandler implements CommandHandler<LegacyChat> {
public class LegacyCommandHandler implements CommandHandler<LegacyChatPacket> {
private final ConnectedPlayer player;
private final VelocityServer server;
@ -35,12 +35,12 @@ public class LegacyCommandHandler implements CommandHandler<LegacyChat> {
}
@Override
public Class<LegacyChat> packetClass() {
return LegacyChat.class;
public Class<LegacyChatPacket> packetClass() {
return LegacyChatPacket.class;
}
@Override
public void handlePlayerCommandInternal(LegacyChat packet) {
public void handlePlayerCommandInternal(LegacyChatPacket packet) {
String command = packet.getMessage().substring(1);
queueCommandResult(this.server, this.player, event -> {
CommandExecuteEvent.CommandResult result = event.getResult();

Datei anzeigen

@ -22,7 +22,7 @@ import com.velocitypowered.proxy.protocol.MinecraftPacket;
import com.velocitypowered.proxy.protocol.packet.chat.ChatType;
import com.velocitypowered.proxy.protocol.packet.chat.ComponentHolder;
import com.velocitypowered.proxy.protocol.packet.chat.LastSeenMessages;
import com.velocitypowered.proxy.protocol.packet.chat.SystemChat;
import com.velocitypowered.proxy.protocol.packet.chat.SystemChatPacket;
import com.velocitypowered.proxy.protocol.packet.chat.builder.ChatBuilderV2;
import net.kyori.adventure.text.Component;
@ -36,21 +36,21 @@ public class SessionChatBuilder extends ChatBuilderV2 {
public MinecraftPacket toClient() {
// This is temporary
Component msg = component == null ? Component.text(message) : component;
return new SystemChat(new ComponentHolder(version, msg), type == ChatType.CHAT ? ChatType.SYSTEM : type);
return new SystemChatPacket(new ComponentHolder(version, msg), type == ChatType.CHAT ? ChatType.SYSTEM : type);
}
@Override
public MinecraftPacket toServer() {
if (message.startsWith("/")) {
SessionPlayerCommand command = new SessionPlayerCommand();
SessionPlayerCommandPacket command = new SessionPlayerCommandPacket();
command.command = message.substring(1);
command.salt = 0L;
command.timeStamp = timestamp;
command.argumentSignatures = new SessionPlayerCommand.ArgumentSignatures();
command.argumentSignatures = new SessionPlayerCommandPacket.ArgumentSignatures();
command.lastSeenMessages = new LastSeenMessages();
return command;
} else {
SessionPlayerChat chat = new SessionPlayerChat();
SessionPlayerChatPacket chat = new SessionPlayerChatPacket();
chat.message = message;
chat.signed = false;
chat.signature = new byte[0];

Datei anzeigen

@ -29,7 +29,7 @@ import com.velocitypowered.proxy.protocol.packet.chat.ChatQueue;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
public class SessionChatHandler implements ChatHandler<SessionPlayerChat> {
public class SessionChatHandler implements ChatHandler<SessionPlayerChatPacket> {
private static final Logger logger = LogManager.getLogger(SessionChatHandler.class);
@ -42,12 +42,12 @@ public class SessionChatHandler implements ChatHandler<SessionPlayerChat> {
}
@Override
public Class<SessionPlayerChat> packetClass() {
return SessionPlayerChat.class;
public Class<SessionPlayerChatPacket> packetClass() {
return SessionPlayerChatPacket.class;
}
@Override
public void handlePlayerChatInternal(SessionPlayerChat packet) {
public void handlePlayerChatInternal(SessionPlayerChatPacket packet) {
ChatQueue chatQueue = this.player.getChatQueue();
EventManager eventManager = this.server.getEventManager();
PlayerChatEvent toSend = new PlayerChatEvent(player, packet.getMessage());

Datei anzeigen

@ -21,12 +21,12 @@ 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.ChatAcknowledgementPacket;
import com.velocitypowered.proxy.protocol.packet.chat.CommandHandler;
import java.util.concurrent.CompletableFuture;
import net.kyori.adventure.text.Component;
public class SessionCommandHandler implements CommandHandler<SessionPlayerCommand> {
public class SessionCommandHandler implements CommandHandler<SessionPlayerCommandPacket> {
private final ConnectedPlayer player;
private final VelocityServer server;
@ -37,12 +37,12 @@ public class SessionCommandHandler implements CommandHandler<SessionPlayerComman
}
@Override
public Class<SessionPlayerCommand> packetClass() {
return SessionPlayerCommand.class;
public Class<SessionPlayerCommandPacket> packetClass() {
return SessionPlayerCommandPacket.class;
}
@Override
public void handlePlayerCommandInternal(SessionPlayerCommand packet) {
public void handlePlayerCommandInternal(SessionPlayerCommandPacket packet) {
queueCommandResult(this.server, this.player, event -> {
CommandExecuteEvent.CommandResult result = event.getResult();
if (result == CommandExecuteEvent.CommandResult.denied()) {
@ -56,7 +56,7 @@ public class SessionCommandHandler implements CommandHandler<SessionPlayerComman
}
// We seemingly can't actually do this if signed args exist, if not, we can probs keep stuff happy
if (player.getProtocolVersion().compareTo(ProtocolVersion.MINECRAFT_1_19_3) >= 0) {
return CompletableFuture.completedFuture(new ChatAcknowledgement(packet.lastSeenMessages.getOffset()));
return CompletableFuture.completedFuture(new ChatAcknowledgementPacket(packet.lastSeenMessages.getOffset()));
}
return CompletableFuture.completedFuture(null);
}
@ -109,7 +109,7 @@ public class SessionCommandHandler implements CommandHandler<SessionPlayerComman
}
}
if (player.getProtocolVersion().compareTo(ProtocolVersion.MINECRAFT_1_19_3) >= 0) {
return new ChatAcknowledgement(packet.lastSeenMessages.getOffset());
return new ChatAcknowledgementPacket(packet.lastSeenMessages.getOffset());
}
return null;
});

Datei anzeigen

@ -25,7 +25,7 @@ import com.velocitypowered.proxy.protocol.packet.chat.LastSeenMessages;
import io.netty.buffer.ByteBuf;
import java.time.Instant;
public class SessionPlayerChat implements MinecraftPacket {
public class SessionPlayerChatPacket implements MinecraftPacket {
protected String message;
protected Instant timestamp;
@ -34,7 +34,7 @@ public class SessionPlayerChat implements MinecraftPacket {
protected byte[] signature;
protected LastSeenMessages lastSeenMessages;
public SessionPlayerChat() {
public SessionPlayerChatPacket() {
}
public String getMessage() {

Datei anzeigen

@ -28,7 +28,7 @@ import io.netty.buffer.ByteBuf;
import java.time.Instant;
import java.util.List;
public class SessionPlayerCommand implements MinecraftPacket {
public class SessionPlayerCommandPacket implements MinecraftPacket {
protected String command;
protected Instant timeStamp;
@ -131,7 +131,7 @@ public class SessionPlayerCommand implements MinecraftPacket {
public ArgumentSignature(ByteBuf buf) {
name = ProtocolUtils.readString(buf, 16);
signature = SessionPlayerChat.readMessageSignature(buf);
signature = SessionPlayerChatPacket.readMessageSignature(buf);
}
public void encode(ByteBuf buf) {

Datei anzeigen

@ -24,15 +24,15 @@ import com.velocitypowered.proxy.protocol.ProtocolUtils;
import io.netty.buffer.ByteBuf;
import net.kyori.adventure.key.Key;
public class ActiveFeatures implements MinecraftPacket {
public class ActiveFeaturesPacket implements MinecraftPacket {
private Key[] activeFeatures;
public ActiveFeatures(Key[] activeFeatures) {
public ActiveFeaturesPacket(Key[] activeFeatures) {
this.activeFeatures = activeFeatures;
}
public ActiveFeatures() {
public ActiveFeaturesPacket() {
this.activeFeatures = new Key[0];
}

Datei anzeigen

@ -23,7 +23,7 @@ import com.velocitypowered.proxy.protocol.MinecraftPacket;
import com.velocitypowered.proxy.protocol.ProtocolUtils;
import io.netty.buffer.ByteBuf;
public class FinishedUpdate implements MinecraftPacket {
public class FinishedUpdatePacket implements MinecraftPacket {
@Override
public void decode(ByteBuf buf, ProtocolUtils.Direction direction,

Datei anzeigen

@ -24,9 +24,9 @@ import com.velocitypowered.proxy.protocol.ProtocolUtils;
import com.velocitypowered.proxy.protocol.util.DeferredByteBufHolder;
import io.netty.buffer.ByteBuf;
public class RegistrySync extends DeferredByteBufHolder implements MinecraftPacket {
public class RegistrySyncPacket extends DeferredByteBufHolder implements MinecraftPacket {
public RegistrySync() {
public RegistrySyncPacket() {
super(null);
}

Datei anzeigen

@ -23,7 +23,7 @@ import com.velocitypowered.proxy.protocol.MinecraftPacket;
import com.velocitypowered.proxy.protocol.ProtocolUtils;
import io.netty.buffer.ByteBuf;
public class StartUpdate implements MinecraftPacket {
public class StartUpdatePacket implements MinecraftPacket {
@Override
public void decode(ByteBuf buf, ProtocolUtils.Direction direction,

Datei anzeigen

@ -26,15 +26,15 @@ import io.netty.buffer.ByteBuf;
import java.util.Map;
public class TagsUpdate implements MinecraftPacket {
public class TagsUpdatePacket implements MinecraftPacket {
private Map<String, Map<String, int[]>> tags;
public TagsUpdate(Map<String, Map<String, int[]>> tags) {
public TagsUpdatePacket(Map<String, Map<String, int[]>> tags) {
this.tags = tags;
}
public TagsUpdate() {
public TagsUpdatePacket() {
this.tags = Map.of();
}

Datei anzeigen

@ -24,7 +24,7 @@ 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.protocol.packet.PluginMessagePacket;
import io.netty.buffer.ByteBuf;
import io.netty.buffer.Unpooled;
import java.nio.charset.StandardCharsets;
@ -55,7 +55,7 @@ public final class PluginMessageUtil {
* @param message the plugin message
* @return whether or not this is a brand plugin message
*/
public static boolean isMcBrand(PluginMessage message) {
public static boolean isMcBrand(PluginMessagePacket message) {
checkNotNull(message, "message");
return message.getChannel().equals(BRAND_CHANNEL_LEGACY) || message.getChannel()
.equals(BRAND_CHANNEL);
@ -67,7 +67,7 @@ public final class PluginMessageUtil {
* @param message the plugin message
* @return whether we are registering plugin channels or not
*/
public static boolean isRegister(PluginMessage message) {
public static boolean isRegister(PluginMessagePacket message) {
checkNotNull(message, "message");
return message.getChannel().equals(REGISTER_CHANNEL_LEGACY) || message.getChannel()
.equals(REGISTER_CHANNEL);
@ -79,7 +79,7 @@ public final class PluginMessageUtil {
* @param message the plugin message
* @return whether we are unregistering plugin channels or not
*/
public static boolean isUnregister(PluginMessage message) {
public static boolean isUnregister(PluginMessagePacket message) {
checkNotNull(message, "message");
return message.getChannel().equals(UNREGISTER_CHANNEL_LEGACY) || message.getChannel()
.equals(UNREGISTER_CHANNEL);
@ -91,7 +91,7 @@ public final class PluginMessageUtil {
* @param message the message to get the channels from
* @return the channels, as an immutable list
*/
public static List<String> getChannels(PluginMessage message) {
public static List<String> getChannels(PluginMessagePacket message) {
checkNotNull(message, "message");
checkArgument(isRegister(message) || isUnregister(message), "Unknown channel type %s",
message.getChannel());
@ -111,7 +111,7 @@ public final class PluginMessageUtil {
* @param channels the channels to register
* @return the plugin message to send
*/
public static PluginMessage constructChannelsPacket(ProtocolVersion protocolVersion,
public static PluginMessagePacket constructChannelsPacket(ProtocolVersion protocolVersion,
Collection<String> channels) {
checkNotNull(channels, "channels");
checkArgument(!channels.isEmpty(), "no channels specified");
@ -119,7 +119,7 @@ public final class PluginMessageUtil {
? REGISTER_CHANNEL : REGISTER_CHANNEL_LEGACY;
ByteBuf contents = Unpooled.buffer();
contents.writeCharSequence(String.join("\0", channels), StandardCharsets.UTF_8);
return new PluginMessage(channelName, contents);
return new PluginMessagePacket(channelName, contents);
}
/**
@ -129,7 +129,8 @@ public final class PluginMessageUtil {
* @param version the proxy version
* @return the rewritten plugin message
*/
public static PluginMessage rewriteMinecraftBrand(PluginMessage message, ProxyVersion version,
public static PluginMessagePacket rewriteMinecraftBrand(PluginMessagePacket message,
ProxyVersion version,
ProtocolVersion protocolVersion) {
checkNotNull(message, "message");
checkNotNull(version, "version");
@ -145,7 +146,7 @@ public final class PluginMessageUtil {
rewrittenBuf.writeCharSequence(rewrittenBrand, StandardCharsets.UTF_8);
}
return new PluginMessage(message.getChannel(), rewrittenBuf);
return new PluginMessagePacket(message.getChannel(), rewrittenBuf);
}
/**

Datei anzeigen

@ -24,9 +24,9 @@ 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.protocol.packet.HandshakePacket;
import com.velocitypowered.proxy.protocol.packet.StatusRequestPacket;
import com.velocitypowered.proxy.protocol.packet.StatusResponsePacket;
import io.netty.channel.EventLoop;
import java.io.IOException;
import java.util.concurrent.CompletableFuture;
@ -53,7 +53,7 @@ public class PingSessionHandler implements MinecraftSessionHandler {
@Override
public void activated() {
Handshake handshake = new Handshake();
HandshakePacket handshake = new HandshakePacket();
handshake.setNextStatus(StateRegistry.STATUS_ID);
handshake.setServerAddress(server.getServerInfo().getAddress().getHostString());
handshake.setPort(server.getServerInfo().getAddress().getPort());
@ -62,13 +62,13 @@ public class PingSessionHandler implements MinecraftSessionHandler {
connection.setActiveSessionHandler(StateRegistry.STATUS);
connection.setState(StateRegistry.STATUS);
connection.delayedWrite(StatusRequest.INSTANCE);
connection.delayedWrite(StatusRequestPacket.INSTANCE);
connection.flush();
}
@Override
public boolean handle(StatusResponse packet) {
public boolean handle(StatusResponsePacket packet) {
// All good!
completed = true;
connection.close(true);

Datei anzeigen

@ -19,9 +19,9 @@ package com.velocitypowered.proxy.tablist;
import com.velocitypowered.api.proxy.Player;
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.protocol.packet.LegacyPlayerListItemPacket;
import com.velocitypowered.proxy.protocol.packet.RemovePlayerInfoPacket;
import com.velocitypowered.proxy.protocol.packet.UpsertPlayerInfoPacket;
/**
* Tab list interface with methods for handling player info packets.
@ -30,13 +30,13 @@ public interface InternalTabList extends TabList {
Player getPlayer();
default void processLegacy(LegacyPlayerListItem packet) {
default void processLegacy(LegacyPlayerListItemPacket packet) {
}
default void processUpdate(UpsertPlayerInfo infoPacket) {
default void processUpdate(UpsertPlayerInfoPacket infoPacket) {
}
default void processRemove(RemovePlayerInfo infoPacket) {
default void processRemove(RemovePlayerInfoPacket infoPacket) {
}
void clearAllSilent();

Datei anzeigen

@ -26,7 +26,7 @@ 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.LegacyPlayerListItemPacket;
import com.velocitypowered.proxy.protocol.packet.chat.RemoteChatSession;
import java.util.ArrayList;
import java.util.Collection;
@ -87,9 +87,9 @@ public class KeyedVelocityTabList implements InternalTabList {
Preconditions.checkArgument(entry instanceof KeyedVelocityTabListEntry,
"Not a Velocity tab list entry");
LegacyPlayerListItem.Item packetItem = LegacyPlayerListItem.Item.from(entry);
LegacyPlayerListItemPacket.Item packetItem = LegacyPlayerListItemPacket.Item.from(entry);
connection.write(
new LegacyPlayerListItem(LegacyPlayerListItem.ADD_PLAYER,
new LegacyPlayerListItemPacket(LegacyPlayerListItemPacket.ADD_PLAYER,
Collections.singletonList(packetItem)));
entries.put(entry.getProfile().getId(), (KeyedVelocityTabListEntry) entry);
}
@ -100,9 +100,9 @@ public class KeyedVelocityTabList implements InternalTabList {
TabListEntry entry = entries.remove(uuid);
if (entry != null) {
LegacyPlayerListItem.Item packetItem = LegacyPlayerListItem.Item.from(entry);
LegacyPlayerListItemPacket.Item packetItem = LegacyPlayerListItemPacket.Item.from(entry);
connection.write(
new LegacyPlayerListItem(LegacyPlayerListItem.REMOVE_PLAYER,
new LegacyPlayerListItemPacket(LegacyPlayerListItemPacket.REMOVE_PLAYER,
Collections.singletonList(packetItem)));
}
@ -131,12 +131,13 @@ public class KeyedVelocityTabList implements InternalTabList {
if (listEntries.isEmpty()) {
return;
}
List<LegacyPlayerListItem.Item> items = new ArrayList<>(listEntries.size());
List<LegacyPlayerListItemPacket.Item> items = new ArrayList<>(listEntries.size());
for (TabListEntry value : listEntries) {
items.add(LegacyPlayerListItem.Item.from(value));
items.add(LegacyPlayerListItemPacket.Item.from(value));
}
clearAllSilent();
connection.delayedWrite(new LegacyPlayerListItem(LegacyPlayerListItem.REMOVE_PLAYER, items));
connection.delayedWrite(new LegacyPlayerListItemPacket(
LegacyPlayerListItemPacket.REMOVE_PLAYER, items));
}
@Override
@ -165,19 +166,20 @@ public class KeyedVelocityTabList implements InternalTabList {
}
@Override
public void processLegacy(LegacyPlayerListItem packet) {
public void processLegacy(LegacyPlayerListItemPacket packet) {
// Packets are already forwarded on, so no need to do that here
for (LegacyPlayerListItem.Item item : packet.getItems()) {
for (LegacyPlayerListItemPacket.Item item : packet.getItems()) {
UUID uuid = item.getUuid();
assert uuid != null : "1.7 tab list entry given to modern tab list handler!";
if (packet.getAction() != LegacyPlayerListItem.ADD_PLAYER && !entries.containsKey(uuid)) {
if (packet.getAction() != LegacyPlayerListItemPacket.ADD_PLAYER
&& !entries.containsKey(uuid)) {
// Sometimes UPDATE_GAMEMODE is sent before ADD_PLAYER so don't want to warn here
continue;
}
switch (packet.getAction()) {
case LegacyPlayerListItem.ADD_PLAYER: {
case LegacyPlayerListItemPacket.ADD_PLAYER: {
// ensure that name and properties are available
String name = item.getName();
List<GameProfile.Property> properties = item.getProperties();
@ -195,24 +197,24 @@ public class KeyedVelocityTabList implements InternalTabList {
.build());
break;
}
case LegacyPlayerListItem.REMOVE_PLAYER:
case LegacyPlayerListItemPacket.REMOVE_PLAYER:
entries.remove(uuid);
break;
case LegacyPlayerListItem.UPDATE_DISPLAY_NAME: {
case LegacyPlayerListItemPacket.UPDATE_DISPLAY_NAME: {
KeyedVelocityTabListEntry entry = entries.get(uuid);
if (entry != null) {
entry.setDisplayNameInternal(item.getDisplayName());
}
break;
}
case LegacyPlayerListItem.UPDATE_LATENCY: {
case LegacyPlayerListItemPacket.UPDATE_LATENCY: {
KeyedVelocityTabListEntry entry = entries.get(uuid);
if (entry != null) {
entry.setLatencyInternal(item.getLatency());
}
break;
}
case LegacyPlayerListItem.UPDATE_GAMEMODE: {
case LegacyPlayerListItemPacket.UPDATE_GAMEMODE: {
KeyedVelocityTabListEntry entry = entries.get(uuid);
if (entry != null) {
entry.setGameModeInternal(item.getGameMode());
@ -228,7 +230,7 @@ public class KeyedVelocityTabList implements InternalTabList {
void updateEntry(int action, TabListEntry entry) {
if (entries.containsKey(entry.getProfile().getId())) {
LegacyPlayerListItem.Item packetItem = LegacyPlayerListItem.Item.from(entry);
LegacyPlayerListItemPacket.Item packetItem = LegacyPlayerListItemPacket.Item.from(entry);
IdentifiedKey selectedKey = packetItem.getPlayerKey();
Optional<Player> existing = proxyServer.getPlayer(entry.getProfile().getId());
@ -245,7 +247,7 @@ public class KeyedVelocityTabList implements InternalTabList {
packetItem.setPlayerKey(null);
}
connection.write(new LegacyPlayerListItem(action, Collections.singletonList(packetItem)));
connection.write(new LegacyPlayerListItemPacket(action, List.of(packetItem)));
}
}
}

Datei anzeigen

@ -22,7 +22,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.LegacyPlayerListItem;
import com.velocitypowered.proxy.protocol.packet.LegacyPlayerListItemPacket;
import com.velocitypowered.proxy.protocol.packet.chat.RemoteChatSession;
import java.util.Optional;
import org.checkerframework.checker.nullness.qual.Nullable;
@ -68,7 +68,7 @@ public class KeyedVelocityTabListEntry implements TabListEntry {
@Override
public TabListEntry setDisplayName(net.kyori.adventure.text.@Nullable Component displayName) {
this.displayName = displayName;
tabList.updateEntry(LegacyPlayerListItem.UPDATE_DISPLAY_NAME, this);
tabList.updateEntry(LegacyPlayerListItemPacket.UPDATE_DISPLAY_NAME, this);
return this;
}
@ -84,7 +84,7 @@ public class KeyedVelocityTabListEntry implements TabListEntry {
@Override
public TabListEntry setLatency(int latency) {
this.latency = latency;
tabList.updateEntry(LegacyPlayerListItem.UPDATE_LATENCY, this);
tabList.updateEntry(LegacyPlayerListItemPacket.UPDATE_LATENCY, this);
return this;
}
@ -100,7 +100,7 @@ public class KeyedVelocityTabListEntry implements TabListEntry {
@Override
public TabListEntry setGameMode(int gameMode) {
this.gameMode = gameMode;
tabList.updateEntry(LegacyPlayerListItem.UPDATE_GAMEMODE, this);
tabList.updateEntry(LegacyPlayerListItemPacket.UPDATE_GAMEMODE, this);
return this;
}

Datei anzeigen

@ -26,13 +26,12 @@ import com.velocitypowered.api.util.GameProfile;
import com.velocitypowered.proxy.connection.MinecraftConnection;
import com.velocitypowered.proxy.connection.client.ConnectedPlayer;
import com.velocitypowered.proxy.console.VelocityConsole;
import com.velocitypowered.proxy.protocol.packet.RemovePlayerInfo;
import com.velocitypowered.proxy.protocol.packet.UpsertPlayerInfo;
import com.velocitypowered.proxy.protocol.packet.RemovePlayerInfoPacket;
import com.velocitypowered.proxy.protocol.packet.UpsertPlayerInfoPacket;
import com.velocitypowered.proxy.protocol.packet.chat.ComponentHolder;
import com.velocitypowered.proxy.protocol.packet.chat.RemoteChatSession;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.EnumSet;
import java.util.List;
import java.util.Map;
@ -94,8 +93,10 @@ public class VelocityTabList implements InternalTabList {
entry1.getLatency(), entry1.getGameMode(), entry1.getChatSession(), entry1.isListed());
}
EnumSet<UpsertPlayerInfo.Action> actions = EnumSet.noneOf(UpsertPlayerInfo.Action.class);
UpsertPlayerInfo.Entry playerInfoEntry = new UpsertPlayerInfo.Entry(entry.getProfile().getId());
EnumSet<UpsertPlayerInfoPacket.Action> actions = EnumSet
.noneOf(UpsertPlayerInfoPacket.Action.class);
UpsertPlayerInfoPacket.Entry playerInfoEntry = new UpsertPlayerInfoPacket
.Entry(entry.getProfile().getId());
Preconditions.checkNotNull(entry.getProfile(), "Profile cannot be null");
Preconditions.checkNotNull(entry.getProfile().getId(), "Profile ID cannot be null");
@ -109,7 +110,7 @@ public class VelocityTabList implements InternalTabList {
}
if (!Objects.equals(previousEntry.getDisplayNameComponent().orElse(null),
entry.getDisplayNameComponent().orElse(null))) {
actions.add(UpsertPlayerInfo.Action.UPDATE_DISPLAY_NAME);
actions.add(UpsertPlayerInfoPacket.Action.UPDATE_DISPLAY_NAME);
playerInfoEntry.setDisplayName(entry.getDisplayNameComponent().isEmpty()
?
null :
@ -118,32 +119,32 @@ public class VelocityTabList implements InternalTabList {
);
}
if (!Objects.equals(previousEntry.getLatency(), entry.getLatency())) {
actions.add(UpsertPlayerInfo.Action.UPDATE_LATENCY);
actions.add(UpsertPlayerInfoPacket.Action.UPDATE_LATENCY);
playerInfoEntry.setLatency(entry.getLatency());
}
if (!Objects.equals(previousEntry.getGameMode(), entry.getGameMode())) {
actions.add(UpsertPlayerInfo.Action.UPDATE_GAME_MODE);
actions.add(UpsertPlayerInfoPacket.Action.UPDATE_GAME_MODE);
playerInfoEntry.setGameMode(entry.getGameMode());
}
if (!Objects.equals(previousEntry.isListed(), entry.isListed())) {
actions.add(UpsertPlayerInfo.Action.UPDATE_LISTED);
actions.add(UpsertPlayerInfoPacket.Action.UPDATE_LISTED);
playerInfoEntry.setListed(entry.isListed());
}
if (!Objects.equals(previousEntry.getChatSession(), entry.getChatSession())) {
ChatSession from = entry.getChatSession();
if (from != null) {
actions.add(UpsertPlayerInfo.Action.INITIALIZE_CHAT);
actions.add(UpsertPlayerInfoPacket.Action.INITIALIZE_CHAT);
playerInfoEntry.setChatSession(
new RemoteChatSession(from.getSessionId(), from.getIdentifiedKey()));
}
}
} else {
actions.addAll(EnumSet.of(UpsertPlayerInfo.Action.ADD_PLAYER,
UpsertPlayerInfo.Action.UPDATE_LATENCY,
UpsertPlayerInfo.Action.UPDATE_LISTED));
actions.addAll(EnumSet.of(UpsertPlayerInfoPacket.Action.ADD_PLAYER,
UpsertPlayerInfoPacket.Action.UPDATE_LATENCY,
UpsertPlayerInfoPacket.Action.UPDATE_LISTED));
playerInfoEntry.setProfile(entry.getProfile());
if (entry.getDisplayNameComponent().isPresent()) {
actions.add(UpsertPlayerInfo.Action.UPDATE_DISPLAY_NAME);
actions.add(UpsertPlayerInfoPacket.Action.UPDATE_DISPLAY_NAME);
playerInfoEntry.setDisplayName(entry.getDisplayNameComponent().isEmpty()
?
null :
@ -152,24 +153,24 @@ public class VelocityTabList implements InternalTabList {
);
}
if (entry.getChatSession() != null) {
actions.add(UpsertPlayerInfo.Action.INITIALIZE_CHAT);
actions.add(UpsertPlayerInfoPacket.Action.INITIALIZE_CHAT);
ChatSession from = entry.getChatSession();
playerInfoEntry.setChatSession(
new RemoteChatSession(from.getSessionId(), from.getIdentifiedKey()));
}
if (entry.getGameMode() != -1 && entry.getGameMode() != 256) {
actions.add(UpsertPlayerInfo.Action.UPDATE_GAME_MODE);
actions.add(UpsertPlayerInfoPacket.Action.UPDATE_GAME_MODE);
playerInfoEntry.setGameMode(entry.getGameMode());
}
playerInfoEntry.setLatency(entry.getLatency());
playerInfoEntry.setListed(entry.isListed());
}
this.connection.write(new UpsertPlayerInfo(actions, List.of(playerInfoEntry)));
this.connection.write(new UpsertPlayerInfoPacket(actions, List.of(playerInfoEntry)));
}
@Override
public Optional<TabListEntry> removeEntry(UUID uuid) {
this.connection.write(new RemovePlayerInfo(List.of(uuid)));
this.connection.write(new RemovePlayerInfoPacket(List.of(uuid)));
return Optional.ofNullable(this.entries.remove(uuid));
}
@ -190,7 +191,8 @@ public class VelocityTabList implements InternalTabList {
@Override
public void clearAll() {
this.connection.delayedWrite(new RemovePlayerInfo(new ArrayList<>(this.entries.keySet())));
this.connection.delayedWrite(new RemovePlayerInfoPacket(
new ArrayList<>(this.entries.keySet())));
clearAllSilent();
}
@ -208,30 +210,30 @@ public class VelocityTabList implements InternalTabList {
}
@Override
public void processUpdate(UpsertPlayerInfo infoPacket) {
for (UpsertPlayerInfo.Entry entry : infoPacket.getEntries()) {
public void processUpdate(UpsertPlayerInfoPacket infoPacket) {
for (UpsertPlayerInfoPacket.Entry entry : infoPacket.getEntries()) {
processUpsert(infoPacket.getActions(), entry);
}
}
protected UpsertPlayerInfo.Entry createRawEntry(VelocityTabListEntry entry) {
protected UpsertPlayerInfoPacket.Entry createRawEntry(VelocityTabListEntry entry) {
Preconditions.checkNotNull(entry, "entry");
Preconditions.checkNotNull(entry.getProfile(), "Profile cannot be null");
Preconditions.checkNotNull(entry.getProfile().getId(), "Profile ID cannot be null");
return new UpsertPlayerInfo.Entry(entry.getProfile().getId());
return new UpsertPlayerInfoPacket.Entry(entry.getProfile().getId());
}
protected void emitActionRaw(UpsertPlayerInfo.Action action, UpsertPlayerInfo.Entry entry) {
this.connection.write(
new UpsertPlayerInfo(EnumSet.of(action), Collections.singletonList(entry)));
protected void emitActionRaw(UpsertPlayerInfoPacket.Action action,
UpsertPlayerInfoPacket.Entry entry) {
this.connection.write(new UpsertPlayerInfoPacket(EnumSet.of(action), List.of(entry)));
}
private void processUpsert(EnumSet<UpsertPlayerInfo.Action> actions,
UpsertPlayerInfo.Entry entry) {
private void processUpsert(EnumSet<UpsertPlayerInfoPacket.Action> actions,
UpsertPlayerInfoPacket.Entry entry) {
Preconditions.checkNotNull(entry.getProfileId(), "Profile ID cannot be null");
UUID profileId = entry.getProfileId();
VelocityTabListEntry currentEntry = this.entries.get(profileId);
if (actions.contains(UpsertPlayerInfo.Action.ADD_PLAYER)) {
if (actions.contains(UpsertPlayerInfoPacket.Action.ADD_PLAYER)) {
if (currentEntry == null) {
this.entries.put(profileId,
currentEntry = new VelocityTabListEntry(
@ -253,26 +255,26 @@ public class VelocityTabList implements InternalTabList {
entry);
return;
}
if (actions.contains(UpsertPlayerInfo.Action.UPDATE_GAME_MODE)) {
if (actions.contains(UpsertPlayerInfoPacket.Action.UPDATE_GAME_MODE)) {
currentEntry.setGameModeWithoutUpdate(entry.getGameMode());
}
if (actions.contains(UpsertPlayerInfo.Action.UPDATE_LATENCY)) {
if (actions.contains(UpsertPlayerInfoPacket.Action.UPDATE_LATENCY)) {
currentEntry.setLatencyWithoutUpdate(entry.getLatency());
}
if (actions.contains(UpsertPlayerInfo.Action.UPDATE_DISPLAY_NAME)) {
if (actions.contains(UpsertPlayerInfoPacket.Action.UPDATE_DISPLAY_NAME)) {
currentEntry.setDisplayNameWithoutUpdate(entry.getDisplayName() != null
? entry.getDisplayName().getComponent() : null);
}
if (actions.contains(UpsertPlayerInfo.Action.INITIALIZE_CHAT)) {
if (actions.contains(UpsertPlayerInfoPacket.Action.INITIALIZE_CHAT)) {
currentEntry.setChatSession(entry.getChatSession());
}
if (actions.contains(UpsertPlayerInfo.Action.UPDATE_LISTED)) {
if (actions.contains(UpsertPlayerInfoPacket.Action.UPDATE_LISTED)) {
currentEntry.setListedWithoutUpdate(entry.isListed());
}
}
@Override
public void processRemove(RemovePlayerInfo infoPacket) {
public void processRemove(RemovePlayerInfoPacket infoPacket) {
for (UUID uuid : infoPacket.getProfilesToRemove()) {
this.entries.remove(uuid);
}

Datei anzeigen

@ -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.protocol.packet.UpsertPlayerInfoPacket;
import com.velocitypowered.proxy.protocol.packet.chat.ComponentHolder;
import java.util.Optional;
import net.kyori.adventure.text.Component;
@ -78,14 +78,14 @@ public class VelocityTabListEntry implements TabListEntry {
@Override
public TabListEntry setDisplayName(@Nullable Component displayName) {
this.displayName = displayName;
UpsertPlayerInfo.Entry upsertEntry = this.tabList.createRawEntry(this);
UpsertPlayerInfoPacket.Entry upsertEntry = this.tabList.createRawEntry(this);
upsertEntry.setDisplayName(
displayName == null
?
null :
new ComponentHolder(this.tabList.getPlayer().getProtocolVersion(), displayName)
);
this.tabList.emitActionRaw(UpsertPlayerInfo.Action.UPDATE_DISPLAY_NAME, upsertEntry);
this.tabList.emitActionRaw(UpsertPlayerInfoPacket.Action.UPDATE_DISPLAY_NAME, upsertEntry);
return this;
}
@ -101,9 +101,9 @@ public class VelocityTabListEntry implements TabListEntry {
@Override
public TabListEntry setLatency(int latency) {
this.latency = latency;
UpsertPlayerInfo.Entry upsertEntry = this.tabList.createRawEntry(this);
UpsertPlayerInfoPacket.Entry upsertEntry = this.tabList.createRawEntry(this);
upsertEntry.setLatency(latency);
this.tabList.emitActionRaw(UpsertPlayerInfo.Action.UPDATE_LATENCY, upsertEntry);
this.tabList.emitActionRaw(UpsertPlayerInfoPacket.Action.UPDATE_LATENCY, upsertEntry);
return this;
}
@ -119,9 +119,9 @@ public class VelocityTabListEntry implements TabListEntry {
@Override
public TabListEntry setGameMode(int gameMode) {
this.gameMode = gameMode;
UpsertPlayerInfo.Entry upsertEntry = this.tabList.createRawEntry(this);
UpsertPlayerInfoPacket.Entry upsertEntry = this.tabList.createRawEntry(this);
upsertEntry.setGameMode(gameMode);
this.tabList.emitActionRaw(UpsertPlayerInfo.Action.UPDATE_GAME_MODE, upsertEntry);
this.tabList.emitActionRaw(UpsertPlayerInfoPacket.Action.UPDATE_GAME_MODE, upsertEntry);
return this;
}
@ -141,9 +141,9 @@ public class VelocityTabListEntry implements TabListEntry {
@Override
public VelocityTabListEntry setListed(boolean listed) {
this.listed = listed;
UpsertPlayerInfo.Entry upsertEntry = this.tabList.createRawEntry(this);
UpsertPlayerInfoPacket.Entry upsertEntry = this.tabList.createRawEntry(this);
upsertEntry.setListed(listed);
this.tabList.emitActionRaw(UpsertPlayerInfo.Action.UPDATE_LISTED, upsertEntry);
this.tabList.emitActionRaw(UpsertPlayerInfoPacket.Action.UPDATE_LISTED, upsertEntry);
return this;
}

Datei anzeigen

@ -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.protocol.packet.LegacyPlayerListItemPacket;
import com.velocitypowered.proxy.protocol.packet.LegacyPlayerListItemPacket.Item;
import java.util.Collections;
import java.util.Map;
import java.util.Optional;
@ -68,8 +68,9 @@ public class VelocityTabListLegacy extends KeyedVelocityTabList {
@Override
public void clearAll() {
for (TabListEntry value : entries.values()) {
connection.delayedWrite(new LegacyPlayerListItem(LegacyPlayerListItem.REMOVE_PLAYER,
Collections.singletonList(LegacyPlayerListItem.Item.from(value))));
connection.delayedWrite(new LegacyPlayerListItemPacket(
LegacyPlayerListItemPacket.REMOVE_PLAYER,
Collections.singletonList(LegacyPlayerListItemPacket.Item.from(value))));
}
clearAllSilent();
}
@ -81,11 +82,11 @@ public class VelocityTabListLegacy extends KeyedVelocityTabList {
}
@Override
public void processLegacy(LegacyPlayerListItem packet) {
public void processLegacy(LegacyPlayerListItemPacket packet) {
Item item = packet.getItems().get(0); // Only one item per packet in 1.7
switch (packet.getAction()) {
case LegacyPlayerListItem.ADD_PLAYER:
case LegacyPlayerListItemPacket.ADD_PLAYER:
if (nameMapping.containsKey(item.getName())) { // ADD_PLAYER also used for updating ping
KeyedVelocityTabListEntry entry = entries.get(nameMapping.get(item.getName()));
if (entry != null) {
@ -101,7 +102,7 @@ public class VelocityTabListLegacy extends KeyedVelocityTabList {
.build());
}
break;
case LegacyPlayerListItem.REMOVE_PLAYER:
case LegacyPlayerListItemPacket.REMOVE_PLAYER:
UUID removedUuid = nameMapping.remove(item.getName());
if (removedUuid != null) {
entries.remove(removedUuid);
@ -117,12 +118,13 @@ public class VelocityTabListLegacy extends KeyedVelocityTabList {
void updateEntry(int action, TabListEntry entry) {
if (entries.containsKey(entry.getProfile().getId())) {
switch (action) {
case LegacyPlayerListItem.UPDATE_LATENCY:
case LegacyPlayerListItem.UPDATE_DISPLAY_NAME: // Add here because we removed beforehand
case LegacyPlayerListItemPacket.UPDATE_LATENCY:
// Add here because we removed beforehand
case LegacyPlayerListItemPacket.UPDATE_DISPLAY_NAME:
connection
.write(new LegacyPlayerListItem(LegacyPlayerListItem.ADD_PLAYER,
.write(new LegacyPlayerListItemPacket(LegacyPlayerListItemPacket.ADD_PLAYER,
// ADD_PLAYER also updates ping
Collections.singletonList(LegacyPlayerListItem.Item.from(entry))));
Collections.singletonList(LegacyPlayerListItemPacket.Item.from(entry))));
break;
default:
// Can't do anything else

Datei anzeigen

@ -20,6 +20,7 @@ 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.packet.BossBarPacket;
import com.velocitypowered.proxy.protocol.packet.chat.ComponentHolder;
import com.velocitypowered.proxy.util.collect.Enum2IntMap;
import com.velocitypowered.proxy.util.concurrent.Once;
@ -128,7 +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(
BossBarPacket packet = holder.createTitleUpdate(
translated, player.getProtocolVersion());
player.getConnection().write(packet);
}
@ -140,7 +141,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 +155,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 +168,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 +182,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 +204,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(
new ComponentHolder(player.getProtocolVersion(), player.translateMessage(bar.name())));
packet.setColor(COLORS_TO_PROTOCOL.get(bar.color()));
@ -221,55 +221,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(new ComponentHolder(version, name));
return packet;
}
com.velocitypowered.proxy.protocol.packet.BossBar createFlagsUpdate() {
BossBarPacket createFlagsUpdate() {
return createFlagsUpdate(bar.flags());
}
com.velocitypowered.proxy.protocol.packet.BossBar createFlagsUpdate(Set<Flag> newFlags) {
com.velocitypowered.proxy.protocol.packet.BossBar packet = new com.velocitypowered
.proxy.protocol.packet.BossBar();
BossBarPacket createFlagsUpdate(Set<Flag> 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;

Datei anzeigen

@ -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.protocol.packet.HandshakePacket;
import com.velocitypowered.proxy.protocol.packet.StatusPingPacket;
import org.junit.jupiter.api.Test;
class PacketRegistryTest {
@ -45,7 +45,7 @@ class PacketRegistryTest {
private StateRegistry.PacketRegistry setupRegistry() {
StateRegistry.PacketRegistry registry = new StateRegistry.PacketRegistry(
ProtocolUtils.Direction.CLIENTBOUND, StateRegistry.PLAY);
registry.register(Handshake.class, Handshake::new,
registry.register(HandshakePacket.class, HandshakePacket::new,
new StateRegistry.PacketMapping(0x01, MINECRAFT_1_8, null, false),
new StateRegistry.PacketMapping(0x00, MINECRAFT_1_12, null, false),
new StateRegistry.PacketMapping(0x00, MINECRAFT_1_15, MINECRAFT_1_16, false));
@ -57,7 +57,7 @@ class PacketRegistryTest {
StateRegistry.PacketRegistry registry = setupRegistry();
MinecraftPacket packet = registry.getProtocolRegistry(MINECRAFT_1_12).createPacket(0);
assertNotNull(packet, "Packet was not found in registry");
assertEquals(Handshake.class, packet.getClass(), "Registry returned wrong class");
assertEquals(HandshakePacket.class, packet.getClass(), "Registry returned wrong class");
assertEquals(0, registry.getProtocolRegistry(MINECRAFT_1_12).getPacketId(packet),
"Registry did not return the correct packet ID");
@ -68,7 +68,7 @@ class PacketRegistryTest {
StateRegistry.PacketRegistry registry = setupRegistry();
MinecraftPacket packet = registry.getProtocolRegistry(MINECRAFT_1_12_1).createPacket(0);
assertNotNull(packet, "Packet was not found in registry");
assertEquals(Handshake.class, packet.getClass(), "Registry returned wrong class");
assertEquals(HandshakePacket.class, packet.getClass(), "Registry returned wrong class");
assertEquals(0, registry.getProtocolRegistry(MINECRAFT_1_12_1).getPacketId(packet),
"Registry did not return the correct packet ID");
assertEquals(0, registry.getProtocolRegistry(MINECRAFT_1_14_2).getPacketId(packet),
@ -86,9 +86,10 @@ class PacketRegistryTest {
StateRegistry.PacketRegistry registry = new StateRegistry.PacketRegistry(
ProtocolUtils.Direction.CLIENTBOUND, StateRegistry.PLAY);
assertThrows(IllegalArgumentException.class,
() -> registry.register(Handshake.class, Handshake::new));
() -> registry.register(HandshakePacket.class, HandshakePacket::new));
assertThrows(IllegalArgumentException.class,
() -> registry.getProtocolRegistry(ProtocolVersion.UNKNOWN).getPacketId(new Handshake()));
() -> registry.getProtocolRegistry(ProtocolVersion.UNKNOWN)
.getPacketId(new HandshakePacket()));
}
@Test
@ -96,18 +97,18 @@ class PacketRegistryTest {
StateRegistry.PacketRegistry registry = new StateRegistry.PacketRegistry(
ProtocolUtils.Direction.CLIENTBOUND, StateRegistry.PLAY);
assertThrows(IllegalArgumentException.class,
() -> registry.register(Handshake.class, Handshake::new,
() -> registry.register(HandshakePacket.class, HandshakePacket::new,
new StateRegistry.PacketMapping(0x01, MINECRAFT_1_13, null, false),
new StateRegistry.PacketMapping(0x00, MINECRAFT_1_8, null, false)));
assertThrows(IllegalArgumentException.class,
() -> registry.register(Handshake.class, Handshake::new,
() -> registry.register(HandshakePacket.class, HandshakePacket::new,
new StateRegistry.PacketMapping(0x01, MINECRAFT_1_13, null, false),
new StateRegistry.PacketMapping(0x01, MINECRAFT_1_13, null, false)));
assertThrows(IllegalArgumentException.class,
() -> registry.register(Handshake.class, Handshake::new,
() -> registry.register(HandshakePacket.class, HandshakePacket::new,
new StateRegistry.PacketMapping(0x01, MINECRAFT_1_13, MINECRAFT_1_8, false)));
assertThrows(IllegalArgumentException.class,
() -> registry.register(Handshake.class, Handshake::new,
() -> registry.register(HandshakePacket.class, HandshakePacket::new,
new StateRegistry.PacketMapping(0x01, MINECRAFT_1_8, MINECRAFT_1_14, false),
new StateRegistry.PacketMapping(0x00, MINECRAFT_1_16, null, false)));
}
@ -116,13 +117,13 @@ class PacketRegistryTest {
void failOnDuplicate() {
StateRegistry.PacketRegistry registry = new StateRegistry.PacketRegistry(
ProtocolUtils.Direction.CLIENTBOUND, StateRegistry.PLAY);
registry.register(Handshake.class, Handshake::new,
registry.register(HandshakePacket.class, HandshakePacket::new,
new StateRegistry.PacketMapping(0x00, MINECRAFT_1_8, null, false));
assertThrows(IllegalArgumentException.class,
() -> registry.register(Handshake.class, Handshake::new,
() -> registry.register(HandshakePacket.class, HandshakePacket::new,
new StateRegistry.PacketMapping(0x01, MINECRAFT_1_12, null, false)));
assertThrows(IllegalArgumentException.class,
() -> registry.register(StatusPing.class, StatusPing::new,
() -> registry.register(StatusPingPacket.class, StatusPingPacket::new,
new StateRegistry.PacketMapping(0x00, MINECRAFT_1_13, null, false)));
}
@ -130,7 +131,7 @@ class PacketRegistryTest {
void shouldNotFailWhenRegisterLatestProtocolVersion() {
StateRegistry.PacketRegistry registry = new StateRegistry.PacketRegistry(
ProtocolUtils.Direction.CLIENTBOUND, StateRegistry.PLAY);
assertDoesNotThrow(() -> registry.register(Handshake.class, Handshake::new,
assertDoesNotThrow(() -> registry.register(HandshakePacket.class, HandshakePacket::new,
new StateRegistry.PacketMapping(0x00, MINECRAFT_1_8, null, false),
new StateRegistry.PacketMapping(0x01, getLast(ProtocolVersion.SUPPORTED_VERSIONS),
null, false)));
@ -140,19 +141,19 @@ class PacketRegistryTest {
void registrySuppliesCorrectPacketsByProtocol() {
StateRegistry.PacketRegistry registry = new StateRegistry.PacketRegistry(
ProtocolUtils.Direction.CLIENTBOUND, StateRegistry.PLAY);
registry.register(Handshake.class, Handshake::new,
registry.register(HandshakePacket.class, HandshakePacket::new,
new StateRegistry.PacketMapping(0x00, MINECRAFT_1_12, null, false),
new StateRegistry.PacketMapping(0x01, MINECRAFT_1_12_1, null, false),
new StateRegistry.PacketMapping(0x02, MINECRAFT_1_13, null, false));
assertEquals(Handshake.class,
assertEquals(HandshakePacket.class,
registry.getProtocolRegistry(MINECRAFT_1_12).createPacket(0x00).getClass());
assertEquals(Handshake.class,
assertEquals(HandshakePacket.class,
registry.getProtocolRegistry(MINECRAFT_1_12_1).createPacket(0x01).getClass());
assertEquals(Handshake.class,
assertEquals(HandshakePacket.class,
registry.getProtocolRegistry(MINECRAFT_1_12_2).createPacket(0x01).getClass());
assertEquals(Handshake.class,
assertEquals(HandshakePacket.class,
registry.getProtocolRegistry(MINECRAFT_1_13).createPacket(0x02).getClass());
assertEquals(Handshake.class,
assertEquals(HandshakePacket.class,
registry.getProtocolRegistry(MINECRAFT_1_14_2).createPacket(0x02).getClass());
}
}