Mirror von
https://github.com/PaperMC/Velocity.git
synchronisiert 2024-11-16 21:10:30 +01:00
Start destruction
Dieser Commit ist enthalten in:
Ursprung
19abb9094e
Commit
726d56eb6a
@ -9,66 +9,78 @@ package com.velocitypowered.api.network;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import com.google.common.collect.Sets;
|
||||
import java.util.EnumSet;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
|
||||
/**
|
||||
* Represents each Minecraft protocol version.
|
||||
*/
|
||||
public enum ProtocolVersion {
|
||||
UNKNOWN(-1, "Unknown"),
|
||||
LEGACY(-2, "Legacy"),
|
||||
MINECRAFT_1_7_2(4,
|
||||
"1.7.2", "1.7.3", "1.7.4", "1.7.5"),
|
||||
MINECRAFT_1_7_6(5,
|
||||
"1.7.6", "1.7.7", "1.7.8", "1.7.9", "1.7.10"),
|
||||
MINECRAFT_1_8(47,
|
||||
"1.8", "1.8.1", "1.8.2", "1.8.3", "1.8.4", "1.8.5", "1.8.6", "1.8.7", "1.8.8", "1.8.9"),
|
||||
MINECRAFT_1_9(107, "1.9"),
|
||||
MINECRAFT_1_9_1(108, "1.9.1"),
|
||||
MINECRAFT_1_9_2(109, "1.9.2"),
|
||||
MINECRAFT_1_9_4(110, "1.9.3", "1.9.4"),
|
||||
MINECRAFT_1_10(210, "1.10", "1.10.1", "1.10.2"),
|
||||
MINECRAFT_1_11(315, "1.11"),
|
||||
MINECRAFT_1_11_1(316, "1.11.1", "1.11.2"),
|
||||
MINECRAFT_1_12(335, "1.12"),
|
||||
MINECRAFT_1_12_1(338, "1.12.1"),
|
||||
MINECRAFT_1_12_2(340, "1.12.2"),
|
||||
MINECRAFT_1_13(393, "1.13"),
|
||||
MINECRAFT_1_13_1(401, "1.13.1"),
|
||||
MINECRAFT_1_13_2(404, "1.13.2"),
|
||||
MINECRAFT_1_14(477, "1.14"),
|
||||
MINECRAFT_1_14_1(480, "1.14.1"),
|
||||
MINECRAFT_1_14_2(485, "1.14.2"),
|
||||
MINECRAFT_1_14_3(490, "1.14.3"),
|
||||
MINECRAFT_1_14_4(498, "1.14.4"),
|
||||
MINECRAFT_1_15(573, "1.15"),
|
||||
MINECRAFT_1_15_1(575, "1.15.1"),
|
||||
MINECRAFT_1_15_2(578, "1.15.2"),
|
||||
MINECRAFT_1_16(735, "1.16"),
|
||||
MINECRAFT_1_16_1(736, "1.16.1"),
|
||||
MINECRAFT_1_16_2(751, "1.16.2"),
|
||||
MINECRAFT_1_16_3(753, "1.16.3"),
|
||||
MINECRAFT_1_16_4(754, "1.16.4", "1.16.5"),
|
||||
MINECRAFT_1_17(755, "1.17"),
|
||||
MINECRAFT_1_17_1(756, "1.17.1"),
|
||||
MINECRAFT_1_18(757, "1.18", "1.18.1"),
|
||||
MINECRAFT_1_18_2(758, "1.18.2"),
|
||||
MINECRAFT_1_19(759, "1.19"),
|
||||
MINECRAFT_1_19_1(760, "1.19.1", "1.19.2"),
|
||||
MINECRAFT_1_19_3(761, "1.19.3"),
|
||||
MINECRAFT_1_19_4(762, "1.19.4"),
|
||||
MINECRAFT_1_20(763, "1.20", "1.20.1");
|
||||
public class ProtocolVersion {
|
||||
|
||||
@Deprecated
|
||||
private static final AtomicInteger REGISTER_COUNTER = new AtomicInteger();
|
||||
private static final Map<Integer, ProtocolVersion> protocols = new HashMap<>(); // TODO: Move internally and FU?
|
||||
|
||||
public static ProtocolVersion UNKNOWN = register(new ProtocolVersion(-1, "Unknown"));
|
||||
public static ProtocolVersion LEGACY = register(new ProtocolVersion(-2, "Legacy"));
|
||||
public static ProtocolVersion MINECRAFT_1_7_2 = register(new ProtocolVersion(4, "1.7.2", "1.7.3", "1.7.4", "1.7.5"));
|
||||
public static ProtocolVersion MINECRAFT_1_7_6 = register(new ProtocolVersion(5, "1.7.6", "1.7.7", "1.7.8", "1.7.9", "1.7.10"));
|
||||
public static ProtocolVersion MINECRAFT_1_8 = register(new ProtocolVersion(47, "1.8", "1.8.1", "1.8.2", "1.8.3", "1.8.4", "1.8.5", "1.8.6", "1.8.7", "1.8.8", "1.8.9"));
|
||||
public static ProtocolVersion MINECRAFT_1_9 = register(new ProtocolVersion(107, "1.9"));
|
||||
public static ProtocolVersion MINECRAFT_1_9_1 = register(new ProtocolVersion(108, "1.9.1"));
|
||||
public static ProtocolVersion MINECRAFT_1_9_2 = register(new ProtocolVersion(109, "1.9.2"));
|
||||
public static ProtocolVersion MINECRAFT_1_9_4 = register(new ProtocolVersion(110, "1.9.3", "1.9.4"));
|
||||
public static ProtocolVersion MINECRAFT_1_10 = register(new ProtocolVersion(210, "1.10", "1.10.1", "1.10.2"));
|
||||
public static ProtocolVersion MINECRAFT_1_11 = register(new ProtocolVersion(315, "1.11"));
|
||||
public static ProtocolVersion MINECRAFT_1_11_1 = register(new ProtocolVersion(316, "1.11.1", "1.11.2"));
|
||||
public static ProtocolVersion MINECRAFT_1_12 = register(new ProtocolVersion(335, "1.12"));
|
||||
public static ProtocolVersion MINECRAFT_1_12_1 = register(new ProtocolVersion(338, "1.12.1"));
|
||||
public static ProtocolVersion MINECRAFT_1_12_2 = register(new ProtocolVersion(340, "1.12.2"));
|
||||
public static ProtocolVersion MINECRAFT_1_13 = register(new ProtocolVersion(393, "1.13"));
|
||||
public static ProtocolVersion MINECRAFT_1_13_1 = register(new ProtocolVersion(401, "1.13.1"));
|
||||
public static ProtocolVersion MINECRAFT_1_13_2 = register(new ProtocolVersion(404, "1.13.2"));
|
||||
public static ProtocolVersion MINECRAFT_1_14 = register(new ProtocolVersion(477, "1.14"));
|
||||
public static ProtocolVersion MINECRAFT_1_14_1 = register(new ProtocolVersion(480, "1.14.1"));
|
||||
public static ProtocolVersion MINECRAFT_1_14_2 = register(new ProtocolVersion(485, "1.14.2"));
|
||||
public static ProtocolVersion MINECRAFT_1_14_3 = register(new ProtocolVersion(490, "1.14.3"));
|
||||
public static ProtocolVersion MINECRAFT_1_14_4 = register(new ProtocolVersion(498, "1.14.4"));
|
||||
public static ProtocolVersion MINECRAFT_1_15 = register(new ProtocolVersion(573, "1.15"));
|
||||
public static ProtocolVersion MINECRAFT_1_15_1 = register(new ProtocolVersion(575, "1.15.1"));
|
||||
public static ProtocolVersion MINECRAFT_1_15_2 = register(new ProtocolVersion(578, "1.15.2"));
|
||||
public static ProtocolVersion MINECRAFT_1_16 = register(new ProtocolVersion(735, "1.16"));
|
||||
public static ProtocolVersion MINECRAFT_1_16_1 = register(new ProtocolVersion(736, "1.16.1"));
|
||||
public static ProtocolVersion MINECRAFT_1_16_2 = register(new ProtocolVersion(751, "1.16.2"));
|
||||
public static ProtocolVersion MINECRAFT_1_16_3 = register(new ProtocolVersion(753, "1.16.3"));
|
||||
public static ProtocolVersion MINECRAFT_1_16_4 = register(new ProtocolVersion(754, "1.16.4", "1.16.5"));
|
||||
public static ProtocolVersion MINECRAFT_1_17 = register(new ProtocolVersion(755, "1.17"));
|
||||
public static ProtocolVersion MINECRAFT_1_17_1 = register(new ProtocolVersion(756, "1.17.1"));
|
||||
public static ProtocolVersion MINECRAFT_1_18 = register(new ProtocolVersion(757, "1.18", "1.18.1"));
|
||||
public static ProtocolVersion MINECRAFT_1_18_2 = register(new ProtocolVersion(758, "1.18.2"));
|
||||
public static ProtocolVersion MINECRAFT_1_19 = register(new ProtocolVersion(759, "1.19"));
|
||||
public static ProtocolVersion MINECRAFT_1_19_1 = register(new ProtocolVersion(760, "1.19.1", "1.19.2"));
|
||||
public static ProtocolVersion MINECRAFT_1_19_3 = register(new ProtocolVersion(761, "1.19.3"));
|
||||
public static ProtocolVersion MINECRAFT_1_19_4 = register(new ProtocolVersion(762, "1.19.4"));
|
||||
public static ProtocolVersion MINECRAFT_1_20 = register(new ProtocolVersion(763, "1.20", "1.20.1"));
|
||||
|
||||
private static ProtocolVersion register(ProtocolVersion protocolversion) {
|
||||
protocols.put(protocolversion.protocol != -1 ? protocolversion.protocol : protocolversion.snapshotProtocol, protocolversion);
|
||||
return protocolversion;
|
||||
}
|
||||
|
||||
private static final int SNAPSHOT_BIT = 30;
|
||||
|
||||
private final int protocol;
|
||||
private final int snapshotProtocol;
|
||||
private final String[] names;
|
||||
// Because we need a replacement for ordinals...
|
||||
@Deprecated
|
||||
private final int registered;
|
||||
|
||||
/**
|
||||
* Represents the lowest supported version.
|
||||
@ -113,14 +125,18 @@ public enum ProtocolVersion {
|
||||
public static final Set<ProtocolVersion> SUPPORTED_VERSIONS;
|
||||
|
||||
static {
|
||||
Set<ProtocolVersion> versions = EnumSet.noneOf(ProtocolVersion.class);
|
||||
Set<ProtocolVersion> versions = new HashSet<>();
|
||||
for (ProtocolVersion value : values()) {
|
||||
if (!value.isUnknown() && !value.isLegacy()) {
|
||||
versions.add(value);
|
||||
}
|
||||
}
|
||||
|
||||
SUPPORTED_VERSIONS = Sets.immutableEnumSet(versions);
|
||||
SUPPORTED_VERSIONS = Collections.unmodifiableSet(versions);
|
||||
}
|
||||
|
||||
public static ProtocolVersion[] values() {
|
||||
return protocols.values().toArray(new ProtocolVersion[0]);
|
||||
}
|
||||
|
||||
ProtocolVersion(int protocol, String... names) {
|
||||
@ -136,6 +152,7 @@ public enum ProtocolVersion {
|
||||
|
||||
this.protocol = protocol;
|
||||
this.names = names;
|
||||
this.registered = REGISTER_COUNTER.getAndIncrement();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -242,4 +259,9 @@ public enum ProtocolVersion {
|
||||
public String toString() {
|
||||
return getVersionIntroducedIn();
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public int compareTo(ProtocolVersion protocolVersion) {
|
||||
return this.registered - protocolVersion.registered;
|
||||
}
|
||||
}
|
||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren