From 1856fb6aada04ea4e006295e71b6b14377eaa3eb Mon Sep 17 00:00:00 2001 From: Andrew Steinborn Date: Thu, 13 Dec 2018 05:24:37 -0500 Subject: [PATCH] ProtocolVersion#SUPPORTED_VERSIONS --- .../api/network/ProtocolVersion.java | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/api/src/main/java/com/velocitypowered/api/network/ProtocolVersion.java b/api/src/main/java/com/velocitypowered/api/network/ProtocolVersion.java index c3ca74271..18763a2c8 100644 --- a/api/src/main/java/com/velocitypowered/api/network/ProtocolVersion.java +++ b/api/src/main/java/com/velocitypowered/api/network/ProtocolVersion.java @@ -1,8 +1,11 @@ package com.velocitypowered.api.network; import com.google.common.collect.ImmutableMap; +import com.google.common.collect.Sets; +import java.util.EnumSet; import java.util.HashMap; import java.util.Map; +import java.util.Set; /** * Represents each Minecraft protocol version. @@ -57,6 +60,23 @@ public enum ProtocolVersion { ID_TO_PROTOCOL_CONSTANT = ImmutableMap.copyOf(versions); } + /** + * A set containing all the protocols that the proxy actually supports, excluding special-purpose + * "versions" like {@link #LEGACY} and {@link #UNKNOWN}. + */ + public static final Set SUPPORTED_VERSIONS; + + static { + Set versions = EnumSet.noneOf(ProtocolVersion.class); + for (ProtocolVersion value : values()) { + if (!value.isUnknown() && !value.isLegacy()) { + versions.add(value); + } + } + + SUPPORTED_VERSIONS = Sets.immutableEnumSet(versions); + } + ProtocolVersion(int protocol, String name) { this.protocol = protocol; this.name = name;