From 85c6238d68ba996a60a92d08b0449240ba885047 Mon Sep 17 00:00:00 2001 From: Leymooo Date: Mon, 27 May 2019 16:21:32 +0300 Subject: [PATCH] 1.14.2 support --- .../velocitypowered/api/network/ProtocolVersion.java | 7 ++++--- .../velocitypowered/proxy/protocol/StateRegistry.java | 11 +++++++---- 2 files changed, 11 insertions(+), 7 deletions(-) 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 9687902f3..268e3a99c 100644 --- a/api/src/main/java/com/velocitypowered/api/network/ProtocolVersion.java +++ b/api/src/main/java/com/velocitypowered/api/network/ProtocolVersion.java @@ -28,8 +28,9 @@ public enum ProtocolVersion { 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_1(480, "1.14.1"), + MINECRAFT_1_14_2(485, "1.14.2"); + private final int protocol; private final String name; @@ -40,7 +41,7 @@ public enum ProtocolVersion { /** * Represents the highest supported version. */ - public static final ProtocolVersion MAXIMUM_VERSION = MINECRAFT_1_14_1; + public static final ProtocolVersion MAXIMUM_VERSION = values()[values().length - 1]; /** * The user-friendly representation of the lowest and highest supported versions. diff --git a/proxy/src/main/java/com/velocitypowered/proxy/protocol/StateRegistry.java b/proxy/src/main/java/com/velocitypowered/proxy/protocol/StateRegistry.java index b34f47518..58cf30d19 100644 --- a/proxy/src/main/java/com/velocitypowered/proxy/protocol/StateRegistry.java +++ b/proxy/src/main/java/com/velocitypowered/proxy/protocol/StateRegistry.java @@ -11,6 +11,7 @@ import static com.velocitypowered.api.network.ProtocolVersion.MINECRAFT_1_13_1; import static com.velocitypowered.api.network.ProtocolVersion.MINECRAFT_1_13_2; import static com.velocitypowered.api.network.ProtocolVersion.MINECRAFT_1_14; import static com.velocitypowered.api.network.ProtocolVersion.MINECRAFT_1_14_1; +import static com.velocitypowered.api.network.ProtocolVersion.MINECRAFT_1_14_2; import static com.velocitypowered.api.network.ProtocolVersion.MINECRAFT_1_8; import static com.velocitypowered.api.network.ProtocolVersion.MINECRAFT_1_9; import static com.velocitypowered.api.network.ProtocolVersion.MINECRAFT_1_9_1; @@ -94,7 +95,7 @@ public enum StateRegistry { map(0x02, MINECRAFT_1_12, false), map(0x01, MINECRAFT_1_12_1, false), map(0x05, MINECRAFT_1_13, false), - map(0x06, MINECRAFT_1_14, false)); + map(0x06, MINECRAFT_1_14, false)); serverbound.register(Chat.class, Chat::new, map(0x01, MINECRAFT_1_8, false), map(0x02, MINECRAFT_1_9, false), @@ -254,7 +255,7 @@ public enum StateRegistry { LINKED_PROTOCOL_VERSIONS.put(MINECRAFT_1_12, EnumSet.of(MINECRAFT_1_12_1)); LINKED_PROTOCOL_VERSIONS.put(MINECRAFT_1_12_1, EnumSet.of(MINECRAFT_1_12_2)); LINKED_PROTOCOL_VERSIONS.put(MINECRAFT_1_13, EnumSet.of(MINECRAFT_1_13_1, MINECRAFT_1_13_2)); - LINKED_PROTOCOL_VERSIONS.put(MINECRAFT_1_14, EnumSet.of(MINECRAFT_1_14_1)); + LINKED_PROTOCOL_VERSIONS.put(MINECRAFT_1_14, EnumSet.of(MINECRAFT_1_14_1, MINECRAFT_1_14_2)); } private final Direction direction; @@ -286,7 +287,7 @@ public enum StateRegistry { }

void register(Class

clazz, Supplier

packetSupplier, - PacketMapping... mappings) { + PacketMapping... mappings) { if (mappings.length == 0) { throw new IllegalArgumentException("At least one mapping must be provided."); } @@ -332,6 +333,7 @@ public enum StateRegistry { /** * Attempts to create a packet from the specified {@code id}. + * * @param id the packet ID * @return the packet instance, or {@code null} if the ID is not registered */ @@ -345,6 +347,7 @@ public enum StateRegistry { /** * Attempts to look up the packet ID for an {@code packet}. + * * @param packet the packet to look up * @return the packet ID * @throws IllegalArgumentException if the packet ID is not found @@ -416,7 +419,7 @@ public enum StateRegistry { } private static PacketMapping[] genericMappings(int id) { - return new PacketMapping[]{ + return new PacketMapping[] { map(id, MINECRAFT_1_8, false), map(id, MINECRAFT_1_9, false), map(id, MINECRAFT_1_12, false),