13
0
geforkt von Mirrors/Velocity

Resolve some warnings.

Dieser Commit ist enthalten in:
Andrew Steinborn 2018-12-25 01:47:36 -05:00
Ursprung 2ab84f3775
Commit e34d68e81a
10 geänderte Dateien mit 80 neuen und 50 gelöschten Zeilen

Datei anzeigen

@ -17,6 +17,11 @@ public enum ProtocolUtils {
; ;
private static final int DEFAULT_MAX_STRING_SIZE = 65536; // 64KiB private static final int DEFAULT_MAX_STRING_SIZE = 65536; // 64KiB
/**
* Reads a Minecraft-style VarInt from the specified {@code buf}.
* @param buf the buffer to read from
* @return the decoded VarInt
*/
public static int readVarInt(ByteBuf buf) { public static int readVarInt(ByteBuf buf) {
int i = 0; int i = 0;
int j = 0; int j = 0;
@ -33,6 +38,11 @@ public enum ProtocolUtils {
return i; return i;
} }
/**
* Writes a Minecraft-style VarInt to the specified {@code buf}.
* @param buf the buffer to read from
* @param value the integer to write
*/
public static void writeVarInt(ByteBuf buf, int value) { public static void writeVarInt(ByteBuf buf, int value) {
while (true) { while (true) {
if ((value & 0xFFFFFF80) == 0) { if ((value & 0xFFFFFF80) == 0) {
@ -49,6 +59,13 @@ public enum ProtocolUtils {
return readString(buf, DEFAULT_MAX_STRING_SIZE); return readString(buf, DEFAULT_MAX_STRING_SIZE);
} }
/**
* Reads a VarInt length-prefixed string from the {@code buf}, making sure to not go over
* {@code cap} size.
* @param buf the buffer to read from
* @param cap the maximum size of the string, in UTF-8 character length
* @return the decoded string
*/
public static String readString(ByteBuf buf, int cap) { public static String readString(ByteBuf buf, int cap) {
int length = readVarInt(buf); int length = readVarInt(buf);
checkArgument(length >= 0, "Got a negative-length string (%s)", length); checkArgument(length >= 0, "Got a negative-length string (%s)", length);
@ -140,7 +157,7 @@ public enum ProtocolUtils {
public StateRegistry.PacketRegistry.ProtocolRegistry getProtocolRegistry(StateRegistry state, public StateRegistry.PacketRegistry.ProtocolRegistry getProtocolRegistry(StateRegistry state,
ProtocolVersion protocolVersion) { ProtocolVersion protocolVersion) {
return (this == SERVERBOUND ? state.SERVERBOUND : state.CLIENTBOUND) return (this == SERVERBOUND ? state.serverbound : state.clientbound)
.getProtocolRegistry(protocolVersion); .getProtocolRegistry(protocolVersion);
} }
} }

Datei anzeigen

@ -1,6 +1,5 @@
package com.velocitypowered.proxy.protocol; package com.velocitypowered.proxy.protocol;
import static com.velocitypowered.proxy.protocol.ProtocolUtils.Direction;
import static com.velocitypowered.api.network.ProtocolVersion.MINECRAFT_1_10; import static com.velocitypowered.api.network.ProtocolVersion.MINECRAFT_1_10;
import static com.velocitypowered.api.network.ProtocolVersion.MINECRAFT_1_11; import static com.velocitypowered.api.network.ProtocolVersion.MINECRAFT_1_11;
import static com.velocitypowered.api.network.ProtocolVersion.MINECRAFT_1_11_1; import static com.velocitypowered.api.network.ProtocolVersion.MINECRAFT_1_11_1;
@ -16,10 +15,9 @@ import static com.velocitypowered.api.network.ProtocolVersion.MINECRAFT_1_9_1;
import static com.velocitypowered.api.network.ProtocolVersion.MINECRAFT_1_9_2; import static com.velocitypowered.api.network.ProtocolVersion.MINECRAFT_1_9_2;
import static com.velocitypowered.api.network.ProtocolVersion.MINECRAFT_1_9_4; import static com.velocitypowered.api.network.ProtocolVersion.MINECRAFT_1_9_4;
import static com.velocitypowered.api.network.ProtocolVersion.MINIMUM_VERSION; import static com.velocitypowered.api.network.ProtocolVersion.MINIMUM_VERSION;
import static com.velocitypowered.proxy.protocol.ProtocolUtils.Direction;
import com.google.common.collect.ImmutableBiMap;
import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
import com.velocitypowered.api.network.ProtocolVersion; import com.velocitypowered.api.network.ProtocolVersion;
import com.velocitypowered.proxy.protocol.packet.BossBar; import com.velocitypowered.proxy.protocol.packet.BossBar;
import com.velocitypowered.proxy.protocol.packet.Chat; import com.velocitypowered.proxy.protocol.packet.Chat;
@ -59,111 +57,111 @@ public enum StateRegistry {
HANDSHAKE { HANDSHAKE {
{ {
SERVERBOUND.register(Handshake.class, Handshake::new, serverbound.register(Handshake.class, Handshake::new,
genericMappings(0x00)); genericMappings(0x00));
} }
}, },
STATUS { STATUS {
{ {
SERVERBOUND.register(StatusRequest.class, () -> StatusRequest.INSTANCE, serverbound.register(StatusRequest.class, () -> StatusRequest.INSTANCE,
genericMappings(0x00)); genericMappings(0x00));
SERVERBOUND.register(StatusPing.class, StatusPing::new, serverbound.register(StatusPing.class, StatusPing::new,
genericMappings(0x01)); genericMappings(0x01));
CLIENTBOUND.register(StatusResponse.class, StatusResponse::new, clientbound.register(StatusResponse.class, StatusResponse::new,
genericMappings(0x00)); genericMappings(0x00));
CLIENTBOUND.register(StatusPing.class, StatusPing::new, clientbound.register(StatusPing.class, StatusPing::new,
genericMappings(0x01)); genericMappings(0x01));
} }
}, },
PLAY { PLAY {
{ {
SERVERBOUND.fallback = false; serverbound.fallback = false;
CLIENTBOUND.fallback = false; clientbound.fallback = false;
SERVERBOUND.register(TabCompleteRequest.class, TabCompleteRequest::new, serverbound.register(TabCompleteRequest.class, TabCompleteRequest::new,
map(0x14, MINECRAFT_1_8, false), map(0x14, MINECRAFT_1_8, false),
map(0x01, MINECRAFT_1_9, false), map(0x01, MINECRAFT_1_9, false),
map(0x02, MINECRAFT_1_12, false), map(0x02, MINECRAFT_1_12, false),
map(0x01, MINECRAFT_1_12_1, false)); map(0x01, MINECRAFT_1_12_1, false));
SERVERBOUND.register(Chat.class, Chat::new, serverbound.register(Chat.class, Chat::new,
map(0x01, MINECRAFT_1_8, false), map(0x01, MINECRAFT_1_8, false),
map(0x02, MINECRAFT_1_9, false), map(0x02, MINECRAFT_1_9, false),
map(0x03, MINECRAFT_1_12, false), map(0x03, MINECRAFT_1_12, false),
map(0x02, MINECRAFT_1_12_1, false), map(0x02, MINECRAFT_1_12_1, false),
map(0x02, MINECRAFT_1_13, false)); map(0x02, MINECRAFT_1_13, false));
SERVERBOUND.register(ClientSettings.class, ClientSettings::new, serverbound.register(ClientSettings.class, ClientSettings::new,
map(0x15, MINECRAFT_1_8, false), map(0x15, MINECRAFT_1_8, false),
map(0x04, MINECRAFT_1_9, false), map(0x04, MINECRAFT_1_9, false),
map(0x05, MINECRAFT_1_12, false), map(0x05, MINECRAFT_1_12, false),
map(0x04, MINECRAFT_1_12_1, false), map(0x04, MINECRAFT_1_12_1, false),
map(0x04, MINECRAFT_1_13, false)); map(0x04, MINECRAFT_1_13, false));
SERVERBOUND.register(PluginMessage.class, PluginMessage::new, serverbound.register(PluginMessage.class, PluginMessage::new,
map(0x17, MINECRAFT_1_8, false), map(0x17, MINECRAFT_1_8, false),
map(0x09, MINECRAFT_1_9, false), map(0x09, MINECRAFT_1_9, false),
map(0x0A, MINECRAFT_1_12, false), map(0x0A, MINECRAFT_1_12, false),
map(0x09, MINECRAFT_1_12_1, false), map(0x09, MINECRAFT_1_12_1, false),
map(0x0A, MINECRAFT_1_13, false)); map(0x0A, MINECRAFT_1_13, false));
SERVERBOUND.register(KeepAlive.class, KeepAlive::new, serverbound.register(KeepAlive.class, KeepAlive::new,
map(0x00, MINECRAFT_1_8, false), map(0x00, MINECRAFT_1_8, false),
map(0x0B, MINECRAFT_1_9, false), map(0x0B, MINECRAFT_1_9, false),
map(0x0C, MINECRAFT_1_12, false), map(0x0C, MINECRAFT_1_12, false),
map(0x0B, MINECRAFT_1_12_1, false), map(0x0B, MINECRAFT_1_12_1, false),
map(0x0E, MINECRAFT_1_13, false)); map(0x0E, MINECRAFT_1_13, false));
CLIENTBOUND.register(BossBar.class, BossBar::new, clientbound.register(BossBar.class, BossBar::new,
map(0x0C, MINECRAFT_1_9, false), map(0x0C, MINECRAFT_1_9, false),
map(0x0C, MINECRAFT_1_12, false), map(0x0C, MINECRAFT_1_12, false),
map(0x0C, MINECRAFT_1_13, false)); map(0x0C, MINECRAFT_1_13, false));
CLIENTBOUND.register(Chat.class, Chat::new, clientbound.register(Chat.class, Chat::new,
map(0x02, MINECRAFT_1_8, true), map(0x02, MINECRAFT_1_8, true),
map(0x0F, MINECRAFT_1_9, true), map(0x0F, MINECRAFT_1_9, true),
map(0x0F, MINECRAFT_1_12, true), map(0x0F, MINECRAFT_1_12, true),
map(0x0E, MINECRAFT_1_13, true)); map(0x0E, MINECRAFT_1_13, true));
CLIENTBOUND.register(TabCompleteResponse.class, TabCompleteResponse::new, clientbound.register(TabCompleteResponse.class, TabCompleteResponse::new,
map(0x3A, MINECRAFT_1_8, false), map(0x3A, MINECRAFT_1_8, false),
map(0x0E, MINECRAFT_1_9, false), map(0x0E, MINECRAFT_1_9, false),
map(0x0E, MINECRAFT_1_12, false)); map(0x0E, MINECRAFT_1_12, false));
CLIENTBOUND.register(PluginMessage.class, PluginMessage::new, clientbound.register(PluginMessage.class, PluginMessage::new,
map(0x3F, MINECRAFT_1_8, false), map(0x3F, MINECRAFT_1_8, false),
map(0x18, MINECRAFT_1_9, false), map(0x18, MINECRAFT_1_9, false),
map(0x18, MINECRAFT_1_12, false), map(0x18, MINECRAFT_1_12, false),
map(0x19, MINECRAFT_1_13, false)); map(0x19, MINECRAFT_1_13, false));
CLIENTBOUND.register(Disconnect.class, Disconnect::new, clientbound.register(Disconnect.class, Disconnect::new,
map(0x40, MINECRAFT_1_8, false), map(0x40, MINECRAFT_1_8, false),
map(0x1A, MINECRAFT_1_9, false), map(0x1A, MINECRAFT_1_9, false),
map(0x1A, MINECRAFT_1_12, false), map(0x1A, MINECRAFT_1_12, false),
map(0x1B, MINECRAFT_1_13, false)); map(0x1B, MINECRAFT_1_13, false));
CLIENTBOUND.register(KeepAlive.class, KeepAlive::new, clientbound.register(KeepAlive.class, KeepAlive::new,
map(0x00, MINECRAFT_1_8, false), map(0x00, MINECRAFT_1_8, false),
map(0x1F, MINECRAFT_1_9, false), map(0x1F, MINECRAFT_1_9, false),
map(0x1F, MINECRAFT_1_12, false), map(0x1F, MINECRAFT_1_12, false),
map(0x21, MINECRAFT_1_13, false)); map(0x21, MINECRAFT_1_13, false));
CLIENTBOUND.register(JoinGame.class, JoinGame::new, clientbound.register(JoinGame.class, JoinGame::new,
map(0x01, MINECRAFT_1_8, false), map(0x01, MINECRAFT_1_8, false),
map(0x23, MINECRAFT_1_9, false), map(0x23, MINECRAFT_1_9, false),
map(0x23, MINECRAFT_1_12, false), map(0x23, MINECRAFT_1_12, false),
map(0x25, MINECRAFT_1_13, false)); map(0x25, MINECRAFT_1_13, false));
CLIENTBOUND.register(Respawn.class, Respawn::new, clientbound.register(Respawn.class, Respawn::new,
map(0x07, MINECRAFT_1_8, true), map(0x07, MINECRAFT_1_8, true),
map(0x33, MINECRAFT_1_9, true), map(0x33, MINECRAFT_1_9, true),
map(0x34, MINECRAFT_1_12, true), map(0x34, MINECRAFT_1_12, true),
map(0x35, MINECRAFT_1_12_2, true), map(0x35, MINECRAFT_1_12_2, true),
map(0x38, MINECRAFT_1_13, true)); map(0x38, MINECRAFT_1_13, true));
CLIENTBOUND.register(HeaderAndFooter.class, HeaderAndFooter::new, clientbound.register(HeaderAndFooter.class, HeaderAndFooter::new,
map(0x47, MINECRAFT_1_8, true), map(0x47, MINECRAFT_1_8, true),
map(0x48, MINECRAFT_1_9, true), map(0x48, MINECRAFT_1_9, true),
map(0x47, MINECRAFT_1_9_4, true), map(0x47, MINECRAFT_1_9_4, true),
map(0x49, MINECRAFT_1_12, true), map(0x49, MINECRAFT_1_12, true),
map(0x4A, MINECRAFT_1_12_1, true), map(0x4A, MINECRAFT_1_12_1, true),
map(0x4E, MINECRAFT_1_13, true)); map(0x4E, MINECRAFT_1_13, true));
CLIENTBOUND.register(TitlePacket.class, TitlePacket::new, clientbound.register(TitlePacket.class, TitlePacket::new,
map(0x45, MINECRAFT_1_8, true), map(0x45, MINECRAFT_1_8, true),
map(0x45, MINECRAFT_1_9, true), map(0x45, MINECRAFT_1_9, true),
map(0x47, MINECRAFT_1_12, true), map(0x47, MINECRAFT_1_12, true),
map(0x48, MINECRAFT_1_12_1, true), map(0x48, MINECRAFT_1_12_1, true),
map(0x4B, MINECRAFT_1_13, true)); map(0x4B, MINECRAFT_1_13, true));
CLIENTBOUND.register(PlayerListItem.class, PlayerListItem::new, clientbound.register(PlayerListItem.class, PlayerListItem::new,
map(0x38, MINECRAFT_1_8, false), map(0x38, MINECRAFT_1_8, false),
map(0x2D, MINECRAFT_1_9, false), map(0x2D, MINECRAFT_1_9, false),
map(0x2D, MINECRAFT_1_12, false), map(0x2D, MINECRAFT_1_12, false),
@ -173,30 +171,30 @@ public enum StateRegistry {
}, },
LOGIN { LOGIN {
{ {
SERVERBOUND.register(ServerLogin.class, ServerLogin::new, serverbound.register(ServerLogin.class, ServerLogin::new,
genericMappings(0x00)); genericMappings(0x00));
SERVERBOUND.register(EncryptionResponse.class, EncryptionResponse::new, serverbound.register(EncryptionResponse.class, EncryptionResponse::new,
genericMappings(0x01)); genericMappings(0x01));
SERVERBOUND.register(LoginPluginResponse.class, LoginPluginResponse::new, serverbound.register(LoginPluginResponse.class, LoginPluginResponse::new,
map(0x02, MINECRAFT_1_13, false)); map(0x02, MINECRAFT_1_13, false));
CLIENTBOUND.register(Disconnect.class, Disconnect::new, clientbound.register(Disconnect.class, Disconnect::new,
genericMappings(0x00)); genericMappings(0x00));
CLIENTBOUND.register(EncryptionRequest.class, EncryptionRequest::new, clientbound.register(EncryptionRequest.class, EncryptionRequest::new,
genericMappings(0x01)); genericMappings(0x01));
CLIENTBOUND.register(ServerLoginSuccess.class, ServerLoginSuccess::new, clientbound.register(ServerLoginSuccess.class, ServerLoginSuccess::new,
genericMappings(0x02)); genericMappings(0x02));
CLIENTBOUND.register(SetCompression.class, SetCompression::new, clientbound.register(SetCompression.class, SetCompression::new,
genericMappings(0x03)); genericMappings(0x03));
CLIENTBOUND.register(LoginPluginMessage.class, LoginPluginMessage::new, clientbound.register(LoginPluginMessage.class, LoginPluginMessage::new,
map(0x04, MINECRAFT_1_13, false)); map(0x04, MINECRAFT_1_13, false));
} }
}; };
public static final int STATUS_ID = 1; public static final int STATUS_ID = 1;
public static final int LOGIN_ID = 2; public static final int LOGIN_ID = 2;
public final PacketRegistry CLIENTBOUND = new PacketRegistry(Direction.CLIENTBOUND); public final PacketRegistry clientbound = new PacketRegistry(Direction.CLIENTBOUND);
public final PacketRegistry SERVERBOUND = new PacketRegistry(Direction.SERVERBOUND); public final PacketRegistry serverbound = new PacketRegistry(Direction.SERVERBOUND);
public static class PacketRegistry { public static class PacketRegistry {

Datei anzeigen

@ -7,10 +7,10 @@ import com.google.common.cache.Cache;
import com.google.common.cache.CacheBuilder; import com.google.common.cache.CacheBuilder;
import com.google.common.collect.ImmutableSet; import com.google.common.collect.ImmutableSet;
import com.velocitypowered.api.event.query.ProxyQueryEvent; import com.velocitypowered.api.event.query.ProxyQueryEvent;
import com.velocitypowered.api.network.ProtocolVersion;
import com.velocitypowered.api.plugin.PluginContainer; import com.velocitypowered.api.plugin.PluginContainer;
import com.velocitypowered.api.proxy.Player; import com.velocitypowered.api.proxy.Player;
import com.velocitypowered.api.proxy.server.QueryResponse; import com.velocitypowered.api.proxy.server.QueryResponse;
import com.velocitypowered.api.network.ProtocolVersion;
import com.velocitypowered.proxy.VelocityServer; import com.velocitypowered.proxy.VelocityServer;
import io.netty.buffer.ByteBuf; import io.netty.buffer.ByteBuf;
import io.netty.channel.ChannelHandlerContext; import io.netty.channel.ChannelHandlerContext;

Datei anzeigen

@ -12,7 +12,7 @@ public class LegacyDisconnect {
} }
/** /**
* Converts a legacy response into a disconnect packet. * Converts a legacy response into an legacy disconnect packet.
* @param response the response to convert * @param response the response to convert
* @return the disconnect packet * @return the disconnect packet
*/ */
@ -28,8 +28,16 @@ public class LegacyDisconnect {
return new LegacyDisconnect(kickMessage); return new LegacyDisconnect(kickMessage);
} }
/**
* Converts a {@link TextComponent} into a legacy disconnect packet.
* @param component the component to convert
* @return the disconnect packet
*/
public static LegacyDisconnect from(TextComponent component) { public static LegacyDisconnect from(TextComponent component) {
return new LegacyDisconnect(ComponentSerializers.LEGACY.serialize(component)); // We intentionally use the legacy serializers, because the old clients can't understand JSON.
@SuppressWarnings("deprecated")
String serialized = ComponentSerializers.LEGACY.serialize(component);
return new LegacyDisconnect(serialized);
} }
public String getReason() { public String getReason() {

Datei anzeigen

@ -9,12 +9,12 @@ import io.netty.buffer.ByteBuf;
public class LegacyHandshake implements MinecraftPacket { public class LegacyHandshake implements MinecraftPacket {
@Override @Override
public void decode(ByteBuf buf, ProtocolUtils.Direction direction, ProtocolVersion protocolVersion) { public void decode(ByteBuf buf, ProtocolUtils.Direction direction, ProtocolVersion version) {
throw new UnsupportedOperationException(); throw new UnsupportedOperationException();
} }
@Override @Override
public void encode(ByteBuf buf, ProtocolUtils.Direction direction, ProtocolVersion protocolVersion) { public void encode(ByteBuf buf, ProtocolUtils.Direction direction, ProtocolVersion version) {
throw new UnsupportedOperationException(); throw new UnsupportedOperationException();
} }

Datei anzeigen

@ -9,12 +9,12 @@ import io.netty.buffer.ByteBuf;
public class LegacyPing implements MinecraftPacket { public class LegacyPing implements MinecraftPacket {
@Override @Override
public void decode(ByteBuf buf, ProtocolUtils.Direction direction, ProtocolVersion protocolVersion) { public void decode(ByteBuf buf, ProtocolUtils.Direction direction, ProtocolVersion version) {
throw new UnsupportedOperationException(); throw new UnsupportedOperationException();
} }
@Override @Override
public void encode(ByteBuf buf, ProtocolUtils.Direction direction, ProtocolVersion protocolVersion) { public void encode(ByteBuf buf, ProtocolUtils.Direction direction, ProtocolVersion version) {
throw new UnsupportedOperationException(); throw new UnsupportedOperationException();
} }

Datei anzeigen

@ -1,9 +1,9 @@
package com.velocitypowered.proxy.protocol.packet; package com.velocitypowered.proxy.protocol.packet;
import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableList;
import com.velocitypowered.api.network.ProtocolVersion;
import com.velocitypowered.api.proxy.player.TabListEntry; import com.velocitypowered.api.proxy.player.TabListEntry;
import com.velocitypowered.api.util.GameProfile; import com.velocitypowered.api.util.GameProfile;
import com.velocitypowered.api.network.ProtocolVersion;
import com.velocitypowered.proxy.connection.MinecraftSessionHandler; import com.velocitypowered.proxy.connection.MinecraftSessionHandler;
import com.velocitypowered.proxy.protocol.MinecraftPacket; import com.velocitypowered.proxy.protocol.MinecraftPacket;
import com.velocitypowered.proxy.protocol.ProtocolUtils; import com.velocitypowered.proxy.protocol.ProtocolUtils;

Datei anzeigen

@ -5,8 +5,8 @@ import static com.google.common.base.Preconditions.checkNotNull;
import com.google.common.base.Preconditions; import com.google.common.base.Preconditions;
import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableList;
import com.velocitypowered.api.util.ProxyVersion;
import com.velocitypowered.api.network.ProtocolVersion; import com.velocitypowered.api.network.ProtocolVersion;
import com.velocitypowered.api.util.ProxyVersion;
import com.velocitypowered.proxy.protocol.ProtocolUtils; import com.velocitypowered.proxy.protocol.ProtocolUtils;
import com.velocitypowered.proxy.protocol.packet.PluginMessage; import com.velocitypowered.proxy.protocol.packet.PluginMessage;
import io.netty.buffer.ByteBuf; import io.netty.buffer.ByteBuf;

Datei anzeigen

@ -4,7 +4,6 @@ import com.google.common.base.Preconditions;
import com.velocitypowered.api.proxy.player.TabList; import com.velocitypowered.api.proxy.player.TabList;
import com.velocitypowered.api.proxy.player.TabListEntry; import com.velocitypowered.api.proxy.player.TabListEntry;
import com.velocitypowered.api.util.GameProfile; import com.velocitypowered.api.util.GameProfile;
import com.velocitypowered.api.util.UuidUtils;
import com.velocitypowered.proxy.connection.MinecraftConnection; import com.velocitypowered.proxy.connection.MinecraftConnection;
import com.velocitypowered.proxy.protocol.packet.HeaderAndFooter; import com.velocitypowered.proxy.protocol.packet.HeaderAndFooter;
import com.velocitypowered.proxy.protocol.packet.PlayerListItem; import com.velocitypowered.proxy.protocol.packet.PlayerListItem;
@ -87,11 +86,11 @@ public class VelocityTabList implements TabList {
} }
public void processBackendPacket(PlayerListItem packet) { public void processBackendPacket(PlayerListItem packet) {
//Packets are already forwarded on, so no need to do that here // Packets are already forwarded on, so no need to do that here
for (PlayerListItem.Item item : packet.getItems()) { for (PlayerListItem.Item item : packet.getItems()) {
UUID uuid = item.getUuid(); UUID uuid = item.getUuid();
if (packet.getAction() != PlayerListItem.ADD_PLAYER && !entries.containsKey(uuid)) { if (packet.getAction() != PlayerListItem.ADD_PLAYER && !entries.containsKey(uuid)) {
//Sometimes UPDATE_GAMEMODE is sent before ADD_PLAYER so don't want to warn here // Sometimes UPDATE_GAMEMODE is sent before ADD_PLAYER so don't want to warn here
continue; continue;
} }
@ -136,6 +135,9 @@ public class VelocityTabList implements TabList {
} }
break; break;
} }
default:
// Nothing we can do here
break;
} }
} }
} }

Datei anzeigen

@ -2,6 +2,7 @@ package com.velocitypowered.proxy.util;
import com.google.common.base.Preconditions; import com.google.common.base.Preconditions;
import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableList;
import com.velocitypowered.api.network.ProtocolVersion;
import com.velocitypowered.api.proxy.messages.ChannelIdentifier; import com.velocitypowered.api.proxy.messages.ChannelIdentifier;
import com.velocitypowered.api.proxy.messages.ChannelRegistrar; import com.velocitypowered.api.proxy.messages.ChannelRegistrar;
import com.velocitypowered.api.proxy.messages.LegacyChannelIdentifier; import com.velocitypowered.api.proxy.messages.LegacyChannelIdentifier;
@ -12,7 +13,6 @@ import java.util.Collection;
import java.util.Map; import java.util.Map;
import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentHashMap;
import com.velocitypowered.api.network.ProtocolVersion;
import org.checkerframework.checker.nullness.qual.Nullable; import org.checkerframework.checker.nullness.qual.Nullable;
public class VelocityChannelRegistrar implements ChannelRegistrar { public class VelocityChannelRegistrar implements ChannelRegistrar {
@ -72,6 +72,11 @@ public class VelocityChannelRegistrar implements ChannelRegistrar {
return identifierMap.get(id); return identifierMap.get(id);
} }
/**
* Returns all the channel names to register depending on the Minecraft protocol version.
* @param protocolVersion the protocol version in use
* @return the list of channels to register
*/
public Collection<String> getChannelsForProtocol(ProtocolVersion protocolVersion) { public Collection<String> getChannelsForProtocol(ProtocolVersion protocolVersion) {
if (protocolVersion.compareTo(ProtocolVersion.MINECRAFT_1_13) >= 0) { if (protocolVersion.compareTo(ProtocolVersion.MINECRAFT_1_13) >= 0) {
return getModernChannelIds(); return getModernChannelIds();