From b6944bbec272ba339aff78fb1cd7453521368523 Mon Sep 17 00:00:00 2001 From: Andrew Steinborn Date: Fri, 28 Dec 2018 13:08:22 -0500 Subject: [PATCH] Use EnumSet in StateRegistry.PacketRegistry. --- .../proxy/protocol/StateRegistry.java | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) 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 50201daa2..882c9af1d 100644 --- a/proxy/src/main/java/com/velocitypowered/proxy/protocol/StateRegistry.java +++ b/proxy/src/main/java/com/velocitypowered/proxy/protocol/StateRegistry.java @@ -198,18 +198,17 @@ public enum StateRegistry { public static class PacketRegistry { - private static final Map> LINKED_PROTOCOL_VERSIONS + private static final Map> LINKED_PROTOCOL_VERSIONS = new EnumMap<>(ProtocolVersion.class); static { - LINKED_PROTOCOL_VERSIONS.put(MINECRAFT_1_9, ImmutableList.of(MINECRAFT_1_9_1, MINECRAFT_1_9_2, + LINKED_PROTOCOL_VERSIONS.put(MINECRAFT_1_9, EnumSet.of(MINECRAFT_1_9_1, MINECRAFT_1_9_2, MINECRAFT_1_9_4)); - LINKED_PROTOCOL_VERSIONS.put(MINECRAFT_1_9_4, ImmutableList.of(MINECRAFT_1_10, MINECRAFT_1_11, + LINKED_PROTOCOL_VERSIONS.put(MINECRAFT_1_9_4, EnumSet.of(MINECRAFT_1_10, MINECRAFT_1_11, MINECRAFT_1_11_1)); - LINKED_PROTOCOL_VERSIONS.put(MINECRAFT_1_12, ImmutableList.of(MINECRAFT_1_12_1)); - LINKED_PROTOCOL_VERSIONS.put(MINECRAFT_1_12_1, ImmutableList.of(MINECRAFT_1_12_2)); - LINKED_PROTOCOL_VERSIONS.put(MINECRAFT_1_13, ImmutableList.of(MINECRAFT_1_13_1, - MINECRAFT_1_13_2)); + 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)); } private final Direction direction; @@ -256,11 +255,10 @@ public enum StateRegistry { } registry.packetClassToId.put(clazz, mapping.id); - List linked = LINKED_PROTOCOL_VERSIONS.get(mapping.protocolVersion); + Collection linked = LINKED_PROTOCOL_VERSIONS.get(mapping.protocolVersion); if (linked != null) { links: - for (int i = 0; i < linked.size(); i++) { - ProtocolVersion linkedVersion = linked.get(i); + for (ProtocolVersion linkedVersion : linked) { // Make sure that later mappings override this one. for (PacketMapping m : mappings) { if (linkedVersion == m.protocolVersion) {