3
0
Mirror von https://github.com/ViaVersion/ViaVersion.git synchronisiert 2024-12-26 00:00:28 +01:00

Replace more raw versions with ProtocolVersion

Dieser Commit ist enthalten in:
Nassim Jahnke 2024-02-13 22:48:08 +01:00
Ursprung e449599ae7
Commit dcc0642af9
Es konnte kein GPG-Schlüssel zu dieser Signatur gefunden werden
GPG-Schlüssel-ID: EF6771C01F6EF02F
32 geänderte Dateien mit 228 neuen und 188 gelöschten Zeilen

Datei anzeigen

@ -94,34 +94,36 @@ public interface ProtocolInfo {
void setServerState(State serverState);
/**
* Returns the user's release protocol version, or -1 if not set.
* Returns the user's protocol version, or null if not set.
* This is set during the {@link State#HANDSHAKE} state.
*
* @return release protocol version, or -1 if not set
* @see ProtocolVersion
* @return protocol version, may be unknown
* @see ProtocolVersion#isKnown()
*/
ProtocolVersion protocolVersion();
void setProtocolVersion(ProtocolVersion protocolVersion);
/**
* Returns the server protocol version the user is connected to.
* This is set during the {@link State#HANDSHAKE} state.
*
* @return the server protocol version the user is connected to, may be unknown
* @see ProtocolVersion#isKnown()
*/
ProtocolVersion serverProtocolVersion();
void setServerProtocolVersion(ProtocolVersion protocolVersion);
@Deprecated
default int getProtocolVersion() {
return protocolVersion() != null ? protocolVersion().getVersion() : -1;
}
/**
* Returns the user's protocol version, or null if not set.
*
* @return protocol version if set
*/
@Nullable ProtocolVersion protocolVersion();
void setProtocolVersion(int protocolVersion);
/**
* Returns the server protocol version the user is connected to, or -1 if not set.
* This is set during the {@link State#HANDSHAKE} state.
*
* @return server protocol version, or -1 if not set
*/
int getServerProtocolVersion();
void setServerProtocolVersion(int serverProtocolVersion);
@Deprecated
default int getServerProtocolVersion() {
return serverProtocolVersion() != null ? serverProtocolVersion().getVersion() : -1;
}
/**
* Returns the username associated with this connection.

Datei anzeigen

@ -23,8 +23,9 @@
package com.viaversion.viaversion.api.platform;
import com.google.gson.JsonObject;
import it.unimi.dsi.fastutil.ints.IntSortedSet;
import it.unimi.dsi.fastutil.ints.IntSortedSets;
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
import it.unimi.dsi.fastutil.objects.ObjectLinkedOpenHashSet;
import java.util.SortedSet;
public interface ViaInjector {
@ -60,7 +61,7 @@ public interface ViaInjector {
* @throws Exception if there is an error with getting this info, e.g. not binded
* @see ViaPlatform#isProxy()
*/
int getServerProtocolVersion() throws Exception;
ProtocolVersion getServerProtocolVersion() throws Exception;
/**
* Returns the supported server protocol versions.
@ -69,8 +70,10 @@ public interface ViaInjector {
* @throws Exception if there is an error with getting this info, e.g. not binded
* @see ViaPlatform#isProxy()
*/
default IntSortedSet getServerProtocolVersions() throws Exception {
return IntSortedSets.singleton(getServerProtocolVersion());
default SortedSet<ProtocolVersion> getServerProtocolVersions() throws Exception {
final SortedSet<ProtocolVersion> versions = new ObjectLinkedOpenHashSet<>();
versions.add(getServerProtocolVersion());
return versions;
}
/**

Datei anzeigen

@ -28,8 +28,10 @@ import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.EnumMap;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import org.checkerframework.checker.nullness.qual.NonNull;
import org.checkerframework.checker.nullness.qual.Nullable;
@ -37,7 +39,7 @@ import org.checkerframework.checker.nullness.qual.Nullable;
public class ProtocolVersion implements Comparable<ProtocolVersion> {
// These need to be at the top of the class to be initialized first
private static final Int2ObjectMap<ProtocolVersion> VERSIONS = new Int2ObjectOpenHashMap<>();
private static final Map<VersionType, Int2ObjectMap<ProtocolVersion>> VERSIONS = new EnumMap<>(VersionType.class);
private static final List<ProtocolVersion> VERSION_LIST = new ArrayList<>();
public static final ProtocolVersion v1_7_1 = register(4, "1.7.2-1.7.5", new VersionRange("1.7", 2, 5));
@ -106,9 +108,11 @@ public class ProtocolVersion implements Comparable<ProtocolVersion> {
*/
public static void register(ProtocolVersion protocolVersion) {
VERSION_LIST.add(protocolVersion);
VERSIONS.put(protocolVersion.getVersion(), protocolVersion);
final Int2ObjectMap<ProtocolVersion> versions = VERSIONS.computeIfAbsent(protocolVersion.versionType, $ -> new Int2ObjectOpenHashMap<>());
versions.put(protocolVersion.version, protocolVersion);
if (protocolVersion.isSnapshot()) {
VERSIONS.put(protocolVersion.getFullSnapshotVersion(), protocolVersion);
versions.put(protocolVersion.getFullSnapshotVersion(), protocolVersion);
}
}
@ -118,24 +122,36 @@ public class ProtocolVersion implements Comparable<ProtocolVersion> {
* @param version protocol version
* @return true if this protocol version has been registered
*/
public static boolean isRegistered(final VersionType versionType, final int version) {
final Int2ObjectMap<ProtocolVersion> versions = VERSIONS.get(versionType);
return versions != null && versions.containsKey(version);
}
public static boolean isRegistered(int version) {
return VERSIONS.containsKey(version);
return isRegistered(VersionType.RELEASE, version);
}
/**
* Returns a ProtocolVersion instance, even if this protocol version
* has not been registered. See {@link #isRegistered(int)} berorehand or {@link #isKnown()}.
* has not been registered. See {@link #isRegistered(VersionType, int)} berorehand or {@link #isKnown()}.
*
* @param versionType protocol version type
* @param version protocol version
* @return registered or unknown ProtocolVersion
*/
public static @NonNull ProtocolVersion getProtocol(final int version) {
final ProtocolVersion protocolVersion = VERSIONS.get(version);
public static @NonNull ProtocolVersion getProtocol(final VersionType versionType, final int version) {
final Int2ObjectMap<ProtocolVersion> versions = VERSIONS.get(versionType);
if (versions != null) {
final ProtocolVersion protocolVersion = versions.get(version);
if (protocolVersion != null) {
return protocolVersion;
} else {
}
}
return new ProtocolVersion(VersionType.SPECIAL, version, -1, "Unknown (" + version + ")", null);
}
public static @NonNull ProtocolVersion getProtocol(final int version) {
return getProtocol(VersionType.RELEASE, version);
}
/**
@ -168,7 +184,7 @@ public class ProtocolVersion implements Comparable<ProtocolVersion> {
* @return registered protocol version if present, else null
*/
public static @Nullable ProtocolVersion getClosest(String protocol) {
for (ProtocolVersion version : VERSIONS.values()) {
for (ProtocolVersion version : VERSION_LIST) {
String name = version.getName();
if (name.equals(protocol) || version.isRange() && version.getIncludedVersions().contains(protocol)) {
return version;

Datei anzeigen

@ -22,39 +22,27 @@
*/
package com.viaversion.viaversion.api.protocol.version;
import it.unimi.dsi.fastutil.ints.IntLinkedOpenHashSet;
import it.unimi.dsi.fastutil.ints.IntSortedSet;
import java.util.SortedSet;
public interface ServerProtocolVersion {
/**
* Returns the lowest supported protocol version by this server.
* This and {@link #highestSupportedVersion()} should only differ on proxy servers supporting multiple versions.
* This and {@link #highestSupportedProtocolVersion()} should only differ on proxy servers supporting multiple versions.
*
* @return lowest supported protocol version
*/
int lowestSupportedVersion();
/**
* @see #highestSupportedVersion()
*/
default ProtocolVersion lowestSupportedProtocolVersion() {
return ProtocolVersion.getProtocol(lowestSupportedVersion());
}
ProtocolVersion lowestSupportedProtocolVersion();
/**
* Returns the highest supported protocol version by this server.
* This and {@link #lowestSupportedVersion()} should only differ on proxy servers supporting multiple versions.
* This and {@link #lowestSupportedProtocolVersion()} should only differ on proxy servers supporting multiple versions.
*
* @return highest supported protocol version
*/
int highestSupportedVersion();
/**
* @see #lowestSupportedVersion()
*/
default ProtocolVersion highestSupportedProtocolVersion() {
return ProtocolVersion.getProtocol(highestSupportedVersion());
}
ProtocolVersion highestSupportedProtocolVersion();
/**
* Returns a sorted set of all supported protocol version by this server.
@ -62,7 +50,7 @@ public interface ServerProtocolVersion {
*
* @return sorted set of supported protocol versions
*/
IntSortedSet supportedVersions();
SortedSet<ProtocolVersion> supportedProtocolVersions();
/**
* Returns true if the actual protocol version has not yet been identified.
@ -71,6 +59,22 @@ public interface ServerProtocolVersion {
* @return true if set, false if unknown (yet)
*/
default boolean isKnown() {
return lowestSupportedVersion() != -1 && highestSupportedVersion() != -1;
return lowestSupportedProtocolVersion().isKnown() && highestSupportedProtocolVersion().isKnown();
}
@Deprecated
default int lowestSupportedVersion() {
return lowestSupportedProtocolVersion().getVersion();
}
@Deprecated
default int highestSupportedVersion() {
return highestSupportedProtocolVersion().getVersion();
}
@Deprecated
default IntSortedSet supportedVersions() {
return supportedProtocolVersions().stream().mapToInt(ProtocolVersion::getVersion)
.collect(IntLinkedOpenHashSet::new, IntSortedSet::add, IntSortedSet::addAll);
}
}

Datei anzeigen

@ -35,5 +35,5 @@ public interface VersionProvider extends Provider {
* @param connection connection
* @return closest server protocol version to the user's protocol version
*/
int getClosestServerProtocol(UserConnection connection) throws Exception;
ProtocolVersion getClosestServerProtocol(UserConnection connection) throws Exception;
}

Datei anzeigen

@ -30,7 +30,7 @@ fun ShadowJar.configureRelocations() {
}
fun ShadowJar.configureExcludes() {
// FastUtil - we only want object and int maps
// FastUtil - we only want object, int, and reference maps
// Object types
exclude("it/unimi/dsi/fastutil/*/*Reference*")
exclude("it/unimi/dsi/fastutil/*/*Boolean*")

Datei anzeigen

@ -43,7 +43,7 @@ public class BukkitViaAPI extends ViaAPIBase<Player> {
public int getPlayerVersion(UUID uuid) {
UserConnection connection = Via.getManager().getConnectionManager().getConnectedClient(uuid);
if (connection != null) {
return connection.getProtocolInfo().getProtocolVersion();
return connection.getProtocolInfo().protocolVersion().getVersion();
}
if (isProtocolSupport()) {

Datei anzeigen

@ -18,6 +18,7 @@
package com.viaversion.viaversion.bukkit.platform;
import com.google.common.base.Preconditions;
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
import com.viaversion.viaversion.bukkit.handlers.BukkitChannelInitializer;
import com.viaversion.viaversion.bukkit.util.NMSUtil;
import com.viaversion.viaversion.platform.LegacyViaInjector;
@ -61,13 +62,13 @@ public class BukkitViaInjector extends LegacyViaInjector {
}
@Override
public int getServerProtocolVersion() throws ReflectiveOperationException {
public ProtocolVersion getServerProtocolVersion() throws ReflectiveOperationException {
if (PaperViaInjector.PAPER_PROTOCOL_METHOD) {
//noinspection deprecation
return Bukkit.getUnsafe().getProtocolVersion();
return ProtocolVersion.getProtocol(Bukkit.getUnsafe().getProtocolVersion());
}
return HAS_WORLD_VERSION_PROTOCOL_VERSION ? cursedProtocolDetection() : veryCursedProtocolDetection();
return ProtocolVersion.getProtocol(HAS_WORLD_VERSION_PROTOCOL_VERSION ? cursedProtocolDetection() : veryCursedProtocolDetection());
}
private int cursedProtocolDetection() throws ReflectiveOperationException {

Datei anzeigen

@ -37,8 +37,8 @@ public final class BukkitAckSequenceProvider extends AckSequenceProvider {
final SequenceStorage sequenceStorage = connection.get(SequenceStorage.class);
final int previousSequence = sequenceStorage.setSequenceId(sequence);
if (previousSequence == -1) {
final int serverProtocolVersion = connection.getProtocolInfo().getServerProtocolVersion();
final long delay = serverProtocolVersion > ProtocolVersion.v1_8.getVersion() && serverProtocolVersion < ProtocolVersion.v1_14.getVersion() ? 2 : 1;
final ProtocolVersion serverProtocolVersion = connection.getProtocolInfo().serverProtocolVersion();
final long delay = serverProtocolVersion.higherThan(ProtocolVersion.v1_8) && serverProtocolVersion.lowerThan(ProtocolVersion.v1_14) ? 2 : 1;
if (plugin.isEnabled()) {
plugin.getServer().getScheduler().scheduleSyncDelayedTask(plugin, new AckSequenceTask(connection, sequenceStorage), delay);

Datei anzeigen

@ -100,7 +100,7 @@ public class BungeeServerHandler implements Listener {
}
int serverProtocolVersion = Via.proxyPlatform().protocolDetectorService().serverProtocolVersion(event.getTarget().getName());
int clientProtocolVersion = user.getProtocolInfo().getProtocolVersion();
int clientProtocolVersion = user.getProtocolInfo().protocolVersion().getVersion();
List<ProtocolPathEntry> protocols = Via.getManager().getProtocolManager().getProtocolPath(clientProtocolVersion, serverProtocolVersion);
// Check if ViaVersion can support that version
@ -172,8 +172,8 @@ public class BungeeServerHandler implements Listener {
String serverName = server.getInfo().getName();
storage.setCurrentServer(serverName);
int serverProtocolVersion = Via.proxyPlatform().protocolDetectorService().serverProtocolVersion(serverName);
if (serverProtocolVersion <= ProtocolVersion.v1_8.getVersion() && storage.getBossbar() != null) { // 1.8 doesn't have BossBar packet
ProtocolVersion serverProtocolVersion = ProtocolVersion.getProtocol(Via.proxyPlatform().protocolDetectorService().serverProtocolVersion(serverName));
if (serverProtocolVersion.lowerThanOrEquals(ProtocolVersion.v1_8) && storage.getBossbar() != null) { // 1.8 doesn't have BossBar packet
// This ensures we can encode it properly as only the 1.9 protocol is currently implemented.
if (user.getProtocolInfo().getPipeline().contains(Protocol1_9To1_8.class)) {
for (UUID uuid : storage.getBossbar()) {
@ -187,16 +187,17 @@ public class BungeeServerHandler implements Listener {
}
ProtocolInfo info = user.getProtocolInfo();
int previousServerProtocol = info.getServerProtocolVersion();
ProtocolVersion previousServerProtocol = info.serverProtocolVersion();
// Refresh the pipes
List<ProtocolPathEntry> protocolPath = Via.getManager().getProtocolManager().getProtocolPath(info.getProtocolVersion(), serverProtocolVersion);
List<ProtocolPathEntry> protocolPath = Via.getManager().getProtocolManager()
.getProtocolPath(info.protocolVersion().getVersion(), serverProtocolVersion.getVersion());
ProtocolPipeline pipeline = user.getProtocolInfo().getPipeline();
user.clearStoredObjects(true);
pipeline.cleanPipes();
if (protocolPath == null) {
// TODO Check Bungee Supported Protocols? *shrugs*
serverProtocolVersion = info.getProtocolVersion();
serverProtocolVersion = info.protocolVersion();
} else {
List<Protocol> protocols = new ArrayList<>(protocolPath.size());
for (ProtocolPathEntry entry : protocolPath) {
@ -207,13 +208,12 @@ public class BungeeServerHandler implements Listener {
info.setServerProtocolVersion(serverProtocolVersion);
// Add version-specific base Protocol
pipeline.add(Via.getManager().getProtocolManager().getBaseProtocol(serverProtocolVersion));
pipeline.add(Via.getManager().getProtocolManager().getBaseProtocol(serverProtocolVersion.getVersion()));
// Workaround 1.13 server change
int id1_13 = ProtocolVersion.v1_13.getVersion();
boolean toNewId = previousServerProtocol < id1_13 && serverProtocolVersion >= id1_13;
boolean toOldId = previousServerProtocol >= id1_13 && serverProtocolVersion < id1_13;
if (previousServerProtocol != -1 && (toNewId || toOldId)) {
boolean toNewId = previousServerProtocol.lowerThan(ProtocolVersion.v1_13) && serverProtocolVersion.higherThanOrEquals(ProtocolVersion.v1_13);
boolean toOldId = previousServerProtocol.higherThanOrEquals(ProtocolVersion.v1_13) && serverProtocolVersion.lowerThan(ProtocolVersion.v1_13);
if (previousServerProtocol.isKnown() && (toNewId || toOldId)) {
Collection<String> registeredChannels = (Collection<String>) getRegisteredChannels.invoke(event.getPlayer().getPendingConnection());
if (!registeredChannels.isEmpty()) {
Collection<String> newChannels = new HashSet<>();

Datei anzeigen

@ -21,18 +21,19 @@ import com.google.gson.JsonArray;
import com.google.gson.JsonObject;
import com.viaversion.viaversion.api.Via;
import com.viaversion.viaversion.api.platform.ViaInjector;
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
import com.viaversion.viaversion.bungee.handlers.BungeeChannelInitializer;
import com.viaversion.viaversion.util.ReflectionUtil;
import com.viaversion.viaversion.util.SetWrapper;
import io.netty.channel.Channel;
import io.netty.channel.ChannelHandler;
import io.netty.channel.ChannelInitializer;
import it.unimi.dsi.fastutil.ints.IntLinkedOpenHashSet;
import it.unimi.dsi.fastutil.ints.IntSortedSet;
import it.unimi.dsi.fastutil.objects.ObjectLinkedOpenHashSet;
import java.lang.reflect.Field;
import java.util.ArrayList;
import java.util.List;
import java.util.Set;
import java.util.SortedSet;
import net.md_5.bungee.api.ProxyServer;
public class BungeeViaInjector implements ViaInjector {
@ -111,13 +112,17 @@ public class BungeeViaInjector implements ViaInjector {
}
@Override
public int getServerProtocolVersion() throws Exception {
return getBungeeSupportedVersions().get(0);
public ProtocolVersion getServerProtocolVersion() throws Exception {
return ProtocolVersion.getProtocol(getBungeeSupportedVersions().get(0));
}
@Override
public IntSortedSet getServerProtocolVersions() throws Exception {
return new IntLinkedOpenHashSet(getBungeeSupportedVersions());
public SortedSet<ProtocolVersion> getServerProtocolVersions() throws Exception {
final SortedSet<ProtocolVersion> versions = new ObjectLinkedOpenHashSet<>();
for (final Integer version : getBungeeSupportedVersions()) {
versions.add(ProtocolVersion.getProtocol(version));
}
return versions;
}
@SuppressWarnings("unchecked")

Datei anzeigen

@ -26,6 +26,7 @@ import com.viaversion.viaversion.protocols.base.BaseVersionProvider;
import com.viaversion.viaversion.util.ReflectionUtil;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashSet;
import java.util.List;
import net.md_5.bungee.api.ProxyServer;
import net.md_5.bungee.protocol.ProtocolConstants;
@ -33,7 +34,7 @@ import net.md_5.bungee.protocol.ProtocolConstants;
public class BungeeVersionProvider extends BaseVersionProvider {
@Override
public int getClosestServerProtocol(UserConnection user) throws Exception {
public ProtocolVersion getClosestServerProtocol(UserConnection user) throws Exception {
// TODO Have one constant list forever until restart? (Might limit plugins if they change this)
List<Integer> list = ReflectionUtil.getStatic(ProtocolConstants.class, "SUPPORTED_VERSION_IDS", List.class);
List<Integer> sorted = new ArrayList<>(list);
@ -42,13 +43,14 @@ public class BungeeVersionProvider extends BaseVersionProvider {
ProtocolInfo info = user.getProtocolInfo();
// Bungee supports it
if (sorted.contains(info.getProtocolVersion())) {
return info.getProtocolVersion();
final ProtocolVersion clientProtocolVersion = info.protocolVersion();
if (new HashSet<>(sorted).contains(clientProtocolVersion.getVersion())) {
return clientProtocolVersion;
}
// Older than bungee supports, get the lowest version
if (info.getProtocolVersion() < sorted.get(0)) {
return getLowestSupportedVersion();
if (clientProtocolVersion.getVersion() < sorted.get(0)) {
return ProtocolVersion.getProtocol(getLowestSupportedVersion());
}
// Loop through all protocols to get the closest protocol id that bungee supports (and that viaversion does too)
@ -56,13 +58,13 @@ public class BungeeVersionProvider extends BaseVersionProvider {
// TODO: This needs a better fix, i.e checking ProtocolRegistry to see if it would work.
// This is more of a workaround for snapshot support by bungee.
for (Integer protocol : Lists.reverse(sorted)) {
if (info.getProtocolVersion() > protocol && ProtocolVersion.isRegistered(protocol)) {
return protocol;
if (clientProtocolVersion.getVersion() > protocol && ProtocolVersion.isRegistered(protocol)) {
return ProtocolVersion.getProtocol(protocol);
}
}
Via.getPlatform().getLogger().severe("Panic, no protocol id found for " + info.getProtocolVersion());
return info.getProtocolVersion();
Via.getPlatform().getLogger().severe("Panic, no protocol id found for " + clientProtocolVersion);
return clientProtocolVersion;
}
public static int getLowestSupportedVersion() {

Datei anzeigen

@ -42,7 +42,7 @@ public abstract class ViaAPIBase<T> implements ViaAPI<T> {
@Override
public int getPlayerVersion(UUID uuid) {
UserConnection connection = Via.getManager().getConnectionManager().getConnectedClient(uuid);
return connection != null ? connection.getProtocolInfo().getProtocolVersion() : -1;
return connection != null ? connection.getProtocolInfo().protocolVersion().getVersion() : -1;
}
@Override

Datei anzeigen

@ -49,6 +49,7 @@ import java.util.Arrays;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import java.util.SortedSet;
import java.util.logging.Level;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
@ -131,12 +132,12 @@ public class ViaManagerImpl implements ViaManager {
if (protocolVersion.isKnown()) {
if (platform.isProxy()) {
platform.getLogger().info("ViaVersion detected lowest supported version by the proxy: " + protocolVersion.lowestSupportedProtocolVersion());
platform.getLogger().info("Highest supported version by the proxy: " + ProtocolVersion.getProtocol(protocolVersion.highestSupportedVersion()));
platform.getLogger().info("Highest supported version by the proxy: " + protocolVersion.highestSupportedProtocolVersion());
if (debugHandler.enabled()) {
platform.getLogger().info("Supported version range: " + Arrays.toString(protocolVersion.supportedVersions().toArray(new int[0])));
platform.getLogger().info("Supported version range: " + Arrays.toString(protocolVersion.supportedProtocolVersions().toArray(new ProtocolVersion[0])));
}
} else {
platform.getLogger().info("ViaVersion detected server version: " + ProtocolVersion.getProtocol(protocolVersion.highestSupportedVersion()));
platform.getLogger().info("ViaVersion detected server version: " + protocolVersion.highestSupportedProtocolVersion());
}
if (!protocolManager.isWorkingPipe()) {
@ -185,13 +186,13 @@ public class ViaManagerImpl implements ViaManager {
private void loadServerProtocol() {
try {
ProtocolVersion serverProtocolVersion = ProtocolVersion.getProtocol(injector.getServerProtocolVersion());
ProtocolVersion serverProtocolVersion = injector.getServerProtocolVersion();
ServerProtocolVersion versionInfo;
if (platform.isProxy()) {
IntSortedSet supportedVersions = injector.getServerProtocolVersions();
versionInfo = new ServerProtocolVersionRange(supportedVersions.firstInt(), supportedVersions.lastInt(), supportedVersions);
SortedSet<ProtocolVersion> supportedVersions = injector.getServerProtocolVersions();
versionInfo = new ServerProtocolVersionRange(supportedVersions.first(), supportedVersions.last(), supportedVersions);
} else {
versionInfo = new ServerProtocolVersionSingleton(serverProtocolVersion.getVersion());
versionInfo = new ServerProtocolVersionSingleton(serverProtocolVersion);
}
protocolManager.setServerProtocol(versionInfo);

Datei anzeigen

@ -29,8 +29,8 @@ public class ProtocolInfoImpl implements ProtocolInfo {
private final UserConnection connection;
private State clientState = State.HANDSHAKE;
private State serverState = State.HANDSHAKE;
private int serverProtocolVersion = -1;
private ProtocolVersion protocolVersion;
private ProtocolVersion serverProtocolVersion = ProtocolVersion.unknown;
private ProtocolVersion protocolVersion = ProtocolVersion.unknown;
private String username;
private UUID uuid;
private ProtocolPipeline pipeline;
@ -71,19 +71,18 @@ public class ProtocolInfoImpl implements ProtocolInfo {
}
@Override
public void setProtocolVersion(int protocolVersion) {
this.protocolVersion = ProtocolVersion.getProtocol(protocolVersion);
public void setProtocolVersion(ProtocolVersion protocolVersion) {
this.protocolVersion = protocolVersion;
}
@Override
public int getServerProtocolVersion() {
public ProtocolVersion serverProtocolVersion() {
return serverProtocolVersion;
}
@Override
public void setServerProtocolVersion(int serverProtocolVersion) {
ProtocolVersion protocol = ProtocolVersion.getProtocol(serverProtocolVersion);
this.serverProtocolVersion = protocol.getVersion();
public void setServerProtocolVersion(ProtocolVersion serverProtocolVersion) {
this.serverProtocolVersion = serverProtocolVersion;
}
@Override

Datei anzeigen

@ -122,7 +122,7 @@ public class ProtocolManagerImpl implements ProtocolManager {
private ThreadPoolExecutor mappingLoaderExecutor;
private boolean mappingsLoaded;
private ServerProtocolVersion serverProtocolVersion = new ServerProtocolVersionSingleton(-1);
private ServerProtocolVersion serverProtocolVersion = new ServerProtocolVersionSingleton(ProtocolVersion.unknown);
private int maxPathDeltaIncrease; // Only allow lowering path entries by default
private int maxProtocolPathSize = 50;
@ -381,8 +381,8 @@ public class ProtocolManagerImpl implements ProtocolManager {
@Override
public boolean isWorkingPipe() {
for (Int2ObjectMap<Protocol> map : registryMap.values()) {
for (int protocolVersion : serverProtocolVersion.supportedVersions()) {
if (map.containsKey(protocolVersion)) {
for (ProtocolVersion protocolVersion : serverProtocolVersion.supportedProtocolVersions()) {
if (map.containsKey(protocolVersion.getVersion())) {
return true;
}
}

Datei anzeigen

@ -137,7 +137,7 @@ public class ProtocolPipelineImpl extends AbstractSimpleProtocol implements Prot
AbstractSimpleProtocol.toNiceHex(originalID),
packetWrapper.getId(),
AbstractSimpleProtocol.toNiceHex(packetWrapper.getId()),
Integer.toString(userConnection.getProtocolInfo().getProtocolVersion()),
userConnection.getProtocolInfo().protocolVersion().getName(),
packetWrapper
});
}

Datei anzeigen

@ -17,32 +17,33 @@
*/
package com.viaversion.viaversion.protocol;
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
import com.viaversion.viaversion.api.protocol.version.ServerProtocolVersion;
import it.unimi.dsi.fastutil.ints.IntSortedSet;
import java.util.SortedSet;
public class ServerProtocolVersionRange implements ServerProtocolVersion {
private final int lowestSupportedVersion;
private final int highestSupportedVersion;
private final IntSortedSet supportedVersions;
private final ProtocolVersion lowestSupportedVersion;
private final ProtocolVersion highestSupportedVersion;
private final SortedSet<ProtocolVersion> supportedVersions;
public ServerProtocolVersionRange(int lowestSupportedVersion, int highestSupportedVersion, IntSortedSet supportedVersions) {
public ServerProtocolVersionRange(ProtocolVersion lowestSupportedVersion, ProtocolVersion highestSupportedVersion, SortedSet<ProtocolVersion> supportedVersions) {
this.lowestSupportedVersion = lowestSupportedVersion;
this.highestSupportedVersion = highestSupportedVersion;
this.supportedVersions = supportedVersions;
}
@Override
public int lowestSupportedVersion() {
public ProtocolVersion lowestSupportedProtocolVersion() {
return lowestSupportedVersion;
}
@Override
public int highestSupportedVersion() {
public ProtocolVersion highestSupportedProtocolVersion() {
return highestSupportedVersion;
}
@Override
public IntSortedSet supportedVersions() {
public SortedSet<ProtocolVersion> supportedProtocolVersions() {
return supportedVersions;
}
}

Datei anzeigen

@ -17,29 +17,32 @@
*/
package com.viaversion.viaversion.protocol;
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
import com.viaversion.viaversion.api.protocol.version.ServerProtocolVersion;
import it.unimi.dsi.fastutil.ints.IntSortedSet;
import it.unimi.dsi.fastutil.ints.IntSortedSets;
import it.unimi.dsi.fastutil.objects.ObjectLinkedOpenHashSet;
import java.util.SortedSet;
public class ServerProtocolVersionSingleton implements ServerProtocolVersion {
private final int protocolVersion;
private final ProtocolVersion protocolVersion;
public ServerProtocolVersionSingleton(int protocolVersion) {
public ServerProtocolVersionSingleton(ProtocolVersion protocolVersion) {
this.protocolVersion = protocolVersion;
}
@Override
public int lowestSupportedVersion() {
public ProtocolVersion lowestSupportedProtocolVersion() {
return protocolVersion;
}
@Override
public int highestSupportedVersion() {
public ProtocolVersion highestSupportedProtocolVersion() {
return protocolVersion;
}
@Override
public IntSortedSet supportedVersions() {
return IntSortedSets.singleton(protocolVersion);
public SortedSet<ProtocolVersion> supportedProtocolVersions() {
final SortedSet<ProtocolVersion> set = new ObjectLinkedOpenHashSet<>();
set.add(protocolVersion);
return set;
}
}

Datei anzeigen

@ -37,7 +37,7 @@ import org.checkerframework.checker.nullness.qual.Nullable;
public class VersionedPacketTransformerImpl<C extends ClientboundPacketType, S extends ServerboundPacketType> implements VersionedPacketTransformer<C, S> {
private final int inputProtocolVersion;
private final int inputProtocolVersion; // TODO Use ProtocolVersion
private final Class<C> clientboundPacketsClass;
private final Class<S> serverboundPacketsClass;
@ -142,8 +142,8 @@ public class VersionedPacketTransformerImpl<C extends ClientboundPacketType, S e
PacketType packetType = packet.getPacketType();
UserConnection connection = packet.user();
boolean clientbound = packetType.direction() == Direction.CLIENTBOUND;
int serverProtocolVersion = clientbound ? this.inputProtocolVersion : connection.getProtocolInfo().getServerProtocolVersion();
int clientProtocolVersion = clientbound ? connection.getProtocolInfo().getProtocolVersion() : this.inputProtocolVersion;
int serverProtocolVersion = clientbound ? this.inputProtocolVersion : connection.getProtocolInfo().serverProtocolVersion().getVersion();
int clientProtocolVersion = clientbound ? connection.getProtocolInfo().protocolVersion().getVersion() : this.inputProtocolVersion;
// Construct protocol pipeline
List<ProtocolPathEntry> path = Via.getManager().getProtocolManager().getProtocolPath(clientProtocolVersion, serverProtocolVersion);

Datei anzeigen

@ -57,7 +57,7 @@ public class BaseProtocol extends AbstractProtocol<BaseClientboundPacket, BaseCl
int state = wrapper.passthrough(Type.VAR_INT);
ProtocolInfo info = wrapper.user().getProtocolInfo();
info.setProtocolVersion(protocolVersion);
info.setProtocolVersion(ProtocolVersion.getProtocol(protocolVersion));
// Ensure the server has a version provider
VersionProvider versionProvider = Via.getManager().getProviders().get(VersionProvider.class);
if (versionProvider == null) {
@ -66,13 +66,14 @@ public class BaseProtocol extends AbstractProtocol<BaseClientboundPacket, BaseCl
}
// Choose the pipe
int serverProtocol = versionProvider.getClosestServerProtocol(wrapper.user());
ProtocolVersion serverProtocol = versionProvider.getClosestServerProtocol(wrapper.user());
info.setServerProtocolVersion(serverProtocol);
List<ProtocolPathEntry> protocolPath = null;
// Only allow newer clients (or 1.9.2 on 1.9.4 server if the server supports it)
if (info.getProtocolVersion() >= serverProtocol || Via.getPlatform().isOldClientsAllowed()) {
protocolPath = Via.getManager().getProtocolManager().getProtocolPath(info.getProtocolVersion(), serverProtocol);
if (info.protocolVersion().higherThanOrEquals(serverProtocol) || Via.getPlatform().isOldClientsAllowed()) {
protocolPath = Via.getManager().getProtocolManager()
.getProtocolPath(info.protocolVersion().getVersion(), serverProtocol.getVersion());
}
ProtocolPipeline pipeline = wrapper.user().getProtocolInfo().getPipeline();
@ -89,15 +90,14 @@ public class BaseProtocol extends AbstractProtocol<BaseClientboundPacket, BaseCl
pipeline.add(protocols);
// Set the original snapshot version if present
ProtocolVersion protocol = ProtocolVersion.getProtocol(serverProtocol);
wrapper.set(Type.VAR_INT, 0, protocol.getOriginalVersion());
wrapper.set(Type.VAR_INT, 0, serverProtocol.getOriginalVersion());
}
// Add Base Protocol
pipeline.add(Via.getManager().getProtocolManager().getBaseProtocol(serverProtocol));
pipeline.add(Via.getManager().getProtocolManager().getBaseProtocol(serverProtocol.getVersion()));
if (Via.getManager().isDebug()) {
Via.getPlatform().getLogger().info("User connected with protocol: " + info.getProtocolVersion() + " and serverProtocol: " + info.getServerProtocolVersion());
Via.getPlatform().getLogger().info("User connected with protocol: " + info.protocolVersion() + " and serverProtocol: " + info.serverProtocolVersion());
Via.getPlatform().getLogger().info("Protocol pipeline: " + pipeline.pipes());
}
@ -108,7 +108,7 @@ public class BaseProtocol extends AbstractProtocol<BaseClientboundPacket, BaseCl
} else if (state == TRANSFER_INTENT) {
info.setState(State.LOGIN);
if (serverProtocol < ProtocolVersion.v1_20_5.getVersion()) {
if (serverProtocol.lowerThan(ProtocolVersion.v1_20_5)) {
wrapper.set(Type.VAR_INT, 1, LOGIN_INTENT);
}
}

Datei anzeigen

@ -86,7 +86,7 @@ public class BaseProtocol1_7 extends AbstractProtocol<BaseClientboundPacket, Bas
if (!Via.getAPI().getServerVersion().isKnown()) { // Set the Server protocol if the detection on startup failed
ProtocolManagerImpl protocolManager = (ProtocolManagerImpl) Via.getManager().getProtocolManager();
protocolManager.setServerProtocol(new ServerProtocolVersionSingleton(ProtocolVersion.getProtocol(protocolVersion).getVersion()));
protocolManager.setServerProtocol(new ServerProtocolVersionSingleton(ProtocolVersion.getProtocol(protocolVersion)));
}
// Ensure the server has a version provider
@ -96,23 +96,23 @@ public class BaseProtocol1_7 extends AbstractProtocol<BaseClientboundPacket, Bas
return;
}
int closestServerProtocol = versionProvider.getClosestServerProtocol(wrapper.user());
ProtocolVersion closestServerProtocol = versionProvider.getClosestServerProtocol(wrapper.user());
List<ProtocolPathEntry> protocols = null;
if (info.getProtocolVersion() >= closestServerProtocol || Via.getPlatform().isOldClientsAllowed()) {
protocols = Via.getManager().getProtocolManager().getProtocolPath(info.getProtocolVersion(), closestServerProtocol);
if (info.protocolVersion().higherThanOrEquals(closestServerProtocol) || Via.getPlatform().isOldClientsAllowed()) {
protocols = Via.getManager().getProtocolManager()
.getProtocolPath(info.protocolVersion().getVersion(), closestServerProtocol.getVersion());
}
if (protocols != null) {
if (protocolVersion == closestServerProtocol || protocolVersion == 0) { // Fix ServerListPlus
ProtocolVersion prot = ProtocolVersion.getProtocol(info.getProtocolVersion());
version.addProperty("protocol", prot.getOriginalVersion());
if (protocolVersion == closestServerProtocol.getVersion() || protocolVersion == 0) { // Fix ServerListPlus
version.addProperty("protocol", info.protocolVersion().getOriginalVersion());
}
} else {
// not compatible :(, *plays very sad violin*
wrapper.user().setActive(false);
}
if (Via.getConfig().blockedProtocolVersions().contains(info.getProtocolVersion())) {
if (Via.getConfig().blockedProtocolVersions().contains(info.protocolVersion().getVersion())) {
version.addProperty("protocol", -1); // Show blocked versions as outdated
}
@ -148,7 +148,7 @@ public class BaseProtocol1_7 extends AbstractProtocol<BaseClientboundPacket, Bas
Via.getPlatform().getLogger().log(Level.INFO, "{0} logged in with protocol {1}, Route: {2}",
new Object[]{
username,
info.getProtocolVersion(),
info.protocolVersion().getName(),
Joiner.on(", ").join(info.getPipeline().pipes(), ", ")
});
}
@ -156,7 +156,7 @@ public class BaseProtocol1_7 extends AbstractProtocol<BaseClientboundPacket, Bas
// Login Start Packet
registerServerbound(ServerboundLoginPackets.HELLO, wrapper -> {
int protocol = wrapper.user().getProtocolInfo().getProtocolVersion();
int protocol = wrapper.user().getProtocolInfo().protocolVersion().getVersion();
if (Via.getConfig().blockedProtocolVersions().contains(protocol)) {
if (!wrapper.user().getChannel().isOpen()) return;
if (!wrapper.user().shouldApplyBlockProtocol()) return;

Datei anzeigen

@ -19,12 +19,13 @@ package com.viaversion.viaversion.protocols.base;
import com.viaversion.viaversion.api.Via;
import com.viaversion.viaversion.api.connection.UserConnection;
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
import com.viaversion.viaversion.api.protocol.version.VersionProvider;
public class BaseVersionProvider implements VersionProvider {
@Override
public int getClosestServerProtocol(UserConnection connection) throws Exception {
return Via.getAPI().getServerVersion().lowestSupportedVersion();
public ProtocolVersion getClosestServerProtocol(UserConnection connection) throws Exception {
return Via.getAPI().getServerVersion().lowestSupportedProtocolVersion();
}
}

Datei anzeigen

@ -152,7 +152,7 @@ public class Protocol1_12To1_11_1 extends AbstractProtocol<ClientboundPackets1_9
clientChunks.setEnvironment(dimensionId);
// Reset recipes
if (user.getProtocolInfo().getProtocolVersion() >= ProtocolVersion.v1_13.getVersion()) {
if (user.getProtocolInfo().protocolVersion().higherThanOrEquals(ProtocolVersion.v1_13)) {
wrapper.create(ClientboundPackets1_13.DECLARE_RECIPES, packetWrapper -> packetWrapper.write(Type.VAR_INT, 0))
.scheduleSend(Protocol1_13To1_12_2.class);
}

Datei anzeigen

@ -63,7 +63,7 @@ public abstract class AbstractFenceConnectionHandler extends ConnectionHandler {
protected byte getStates(UserConnection user, Position position, int blockState) {
byte states = 0;
boolean pre1_12 = user.getProtocolInfo().getServerProtocolVersion() < ProtocolVersion.v1_12.getVersion();
boolean pre1_12 = user.getProtocolInfo().serverProtocolVersion().lowerThan(ProtocolVersion.v1_12);
if (connects(BlockFace.EAST, getBlockData(user, position.getRelative(BlockFace.EAST)), pre1_12)) states |= 1;
if (connects(BlockFace.NORTH, getBlockData(user, position.getRelative(BlockFace.NORTH)), pre1_12)) states |= 2;
if (connects(BlockFace.SOUTH, getBlockData(user, position.getRelative(BlockFace.SOUTH)), pre1_12)) states |= 4;

Datei anzeigen

@ -20,6 +20,7 @@ package com.viaversion.viaversion.protocols.protocol1_13to1_12_2.blockconnection
import com.viaversion.viaversion.api.connection.ProtocolInfo;
import com.viaversion.viaversion.api.connection.UserConnection;
import com.viaversion.viaversion.api.minecraft.Position;
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
import java.util.ArrayList;
import java.util.List;
@ -58,7 +59,7 @@ public class GlassConnectionHandler extends AbstractFenceConnectionHandler {
if (states != 0) return states;
ProtocolInfo protocolInfo = user.getProtocolInfo();
return protocolInfo.getServerProtocolVersion() <= 47
&& protocolInfo.getServerProtocolVersion() != -1 ? 0xF : states;
return protocolInfo.serverProtocolVersion().lowerThanOrEquals(ProtocolVersion.v1_8)
&& protocolInfo.serverProtocolVersion().isKnown() ? 0xF : states;
}
}

Datei anzeigen

@ -291,7 +291,7 @@ public final class Protocol1_20_2To1_20 extends AbstractProtocol<ClientboundPack
lastTags.sendLastTags(connection);
}
if (lastResourcePack != null && connection.getProtocolInfo().getProtocolVersion() == ProtocolVersion.v1_20_2.getVersion()) {
if (lastResourcePack != null && connection.getProtocolInfo().protocolVersion() == ProtocolVersion.v1_20_2) {
// The client for some reason drops the resource pack when reentering the configuration state
final PacketWrapper resourcePackPacket = PacketWrapper.create(ClientboundConfigurationPackets1_20_2.RESOURCE_PACK, connection);
resourcePackPacket.write(Type.STRING, lastResourcePack.url());

Datei anzeigen

@ -137,7 +137,7 @@ public final class DumpUtil {
playerSample.add("versions", versions);
final Map<ProtocolVersion, Integer> playerVersions = new TreeMap<>(ProtocolVersion::compareTo);
for (final UserConnection connection : Via.getManager().getConnectionManager().getConnections()) {
final ProtocolVersion protocolVersion = ProtocolVersion.getProtocol(connection.getProtocolInfo().getProtocolVersion());
final ProtocolVersion protocolVersion = connection.getProtocolInfo().protocolVersion();
playerVersions.compute(protocolVersion, (v, num) -> num != null ? num + 1 : 1);
}
for (final Map.Entry<ProtocolVersion, Integer> entry : playerVersions.entrySet()) {

Datei anzeigen

@ -17,6 +17,7 @@
*/
package com.viaversion.viaversion.sponge.platform;
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
import com.viaversion.viaversion.platform.LegacyViaInjector;
import com.viaversion.viaversion.platform.WrappedChannelInitializer;
import com.viaversion.viaversion.sponge.handlers.SpongeChannelInitializer;
@ -30,14 +31,14 @@ import org.spongepowered.api.Sponge;
public class SpongeViaInjector extends LegacyViaInjector {
@Override
public int getServerProtocolVersion() throws ReflectiveOperationException {
public ProtocolVersion getServerProtocolVersion() throws ReflectiveOperationException {
MinecraftVersion version = Sponge.platform().minecraftVersion();
// 'protocolVersion' method was exposed to the API in a 1.19.4 build and 'getProtocol' no longer exists in the impl.
try {
return (int) version.getClass().getDeclaredMethod("getProtocol").invoke(version);
return ProtocolVersion.getProtocol((int) version.getClass().getDeclaredMethod("getProtocol").invoke(version));
} catch (NoSuchMethodException e) {
return (int) version.getClass().getDeclaredMethod("protocolVersion").invoke(version);
return ProtocolVersion.getProtocol((int) version.getClass().getDeclaredMethod("protocolVersion").invoke(version));
}
}

Datei anzeigen

@ -25,13 +25,12 @@ import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
import com.viaversion.viaversion.util.ReflectionUtil;
import com.viaversion.viaversion.velocity.handlers.VelocityChannelInitializer;
import io.netty.channel.ChannelInitializer;
import it.unimi.dsi.fastutil.ints.IntLinkedOpenHashSet;
import it.unimi.dsi.fastutil.ints.IntSortedSet;
import it.unimi.dsi.fastutil.objects.ObjectLinkedOpenHashSet;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.SortedSet;
import org.jetbrains.annotations.Nullable;
public class VelocityViaInjector implements ViaInjector {
public static final Method GET_PLAYER_INFO_FORWARDING_MODE = getPlayerInfoForwardingModeMethod();
@ -78,18 +77,18 @@ public class VelocityViaInjector implements ViaInjector {
}
@Override
public int getServerProtocolVersion() throws Exception {
return getLowestSupportedProtocolVersion();
public ProtocolVersion getServerProtocolVersion() {
return ProtocolVersion.getProtocol(getLowestSupportedProtocolVersion());
}
@Override
public IntSortedSet getServerProtocolVersions() throws Exception {
public SortedSet<ProtocolVersion> getServerProtocolVersions() {
int lowestSupportedProtocolVersion = getLowestSupportedProtocolVersion();
IntSortedSet set = new IntLinkedOpenHashSet();
SortedSet<ProtocolVersion> set = new ObjectLinkedOpenHashSet<>();
for (com.velocitypowered.api.network.ProtocolVersion version : com.velocitypowered.api.network.ProtocolVersion.SUPPORTED_VERSIONS) {
if (version.getProtocol() >= lowestSupportedProtocolVersion) {
set.add(version.getProtocol());
set.add(ProtocolVersion.getProtocol(version.getProtocol()));
}
}
return set;

Datei anzeigen

@ -43,19 +43,20 @@ public class VelocityVersionProvider extends BaseVersionProvider {
}
@Override
public int getClosestServerProtocol(UserConnection user) throws Exception {
public ProtocolVersion getClosestServerProtocol(UserConnection user) throws Exception {
return user.isClientSide() ? getBackProtocol(user) : getFrontProtocol(user);
}
private int getBackProtocol(UserConnection user) throws Exception {
private ProtocolVersion getBackProtocol(UserConnection user) throws Exception {
//TODO use newly added Velocity netty event
ChannelHandler mcHandler = user.getChannel().pipeline().get("handler");
ServerConnection serverConnection = (ServerConnection) GET_ASSOCIATION.invoke(mcHandler);
return Via.proxyPlatform().protocolDetectorService().serverProtocolVersion(serverConnection.getServerInfo().getName());
final int protocolVersion = Via.proxyPlatform().protocolDetectorService().serverProtocolVersion(serverConnection.getServerInfo().getName());
return ProtocolVersion.getProtocol(protocolVersion);
}
private int getFrontProtocol(UserConnection user) throws Exception {
int playerVersion = user.getProtocolInfo().getProtocolVersion();
private ProtocolVersion getFrontProtocol(UserConnection user) throws Exception {
ProtocolVersion playerVersion = user.getProtocolInfo().protocolVersion();
IntStream versions = com.velocitypowered.api.network.ProtocolVersion.SUPPORTED_VERSIONS.stream()
.mapToInt(com.velocitypowered.api.network.ProtocolVersion::getProtocol);
@ -68,14 +69,14 @@ public class VelocityVersionProvider extends BaseVersionProvider {
}
int[] compatibleProtocols = versions.toArray();
if (Arrays.binarySearch(compatibleProtocols, playerVersion) >= 0) {
if (Arrays.binarySearch(compatibleProtocols, playerVersion.getVersion()) >= 0) {
// Velocity supports it
return playerVersion;
}
if (playerVersion < compatibleProtocols[0]) {
if (playerVersion.getVersion() < compatibleProtocols[0]) {
// Older than Velocity supports, get the lowest version
return compatibleProtocols[0];
return ProtocolVersion.getProtocol(compatibleProtocols[0]);
}
// Loop through all protocols to get the closest protocol id that Velocity supports (and that Via does too)
@ -84,8 +85,8 @@ public class VelocityVersionProvider extends BaseVersionProvider {
// This is more of a workaround for snapshot support
for (int i = compatibleProtocols.length - 1; i >= 0; i--) {
int protocol = compatibleProtocols[i];
if (playerVersion > protocol && ProtocolVersion.isRegistered(protocol)) {
return protocol;
if (playerVersion.getVersion() > protocol && ProtocolVersion.isRegistered(protocol)) {
return ProtocolVersion.getProtocol(protocol);
}
}

Datei anzeigen

@ -88,7 +88,7 @@ public final class ProtocolDetectorService extends AbstractProtocolDetectorServi
@Override
protected int lowestSupportedProtocolVersion() {
try {
return ProtocolVersion.getProtocol(Via.getManager().getInjector().getServerProtocolVersion()).getVersion();
return Via.getManager().getInjector().getServerProtocolVersion().getVersion();
} catch (final Exception e) {
e.printStackTrace();
return ProtocolVersion.v1_8.getVersion();