diff --git a/src/de/steamwar/bungeecore/listeners/mods/FMLPing.java b/src/de/steamwar/bungeecore/listeners/mods/FMLPing.java index c7f68c8..a8b5994 100644 --- a/src/de/steamwar/bungeecore/listeners/mods/FMLPing.java +++ b/src/de/steamwar/bungeecore/listeners/mods/FMLPing.java @@ -20,10 +20,7 @@ package de.steamwar.bungeecore.listeners.mods; import net.md_5.bungee.api.ServerPing; -import java.util.ArrayList; -import java.util.LinkedHashMap; -import java.util.List; -import java.util.Map; +import java.util.*; public class FMLPing extends ServerPing { @@ -43,44 +40,26 @@ public class FMLPing extends ServerPing { channels.add(new ForgeChannel("minecraft:unregister")); channels.add(new ForgeChannel("minecraft:register")); channels.add(new ForgeChannel("fml:handshake")); - mods.add(new ForgeMod("minecraft", ProtocolVersion.getVersion(versionNumber).toString())); + mods.add(new ForgeMod("minecraft", ProtocolVersion.getVersion(versionNumber))); mods.add(new ForgeMod("forge", "ANY")); } - public enum ProtocolVersion { - MINECRAFT_1_18(757), - MINECRAFT_1_17_1(756), - MINECRAFT_1_16_5(754), - MINECRAFT_1_15_2(578), - MINECRAFT_1_14_4(498), - MINECRAFT_1_13(393), - UNKNOWN(0); + public final static class ProtocolVersion { - private int number; - - ProtocolVersion(int versionNumber) { - this.number = versionNumber; - } - - private static Map numbers; + private static final HashMap versions; static { - numbers = new LinkedHashMap<>(); - for(ProtocolVersion version : values()) { - numbers.put(version.number, version); - } + versions = new HashMap(); + versions.put(757, "1.18"); + versions.put(756, "1.17.1"); + versions.put(754, "1.16.5"); + versions.put(578, "1.15.2"); + versions.put(498, "1.14.1"); + versions.put(393, "1.13"); } - public static ProtocolVersion getVersion(int versionNumber) { - ProtocolVersion protocolVersion = numbers.get(versionNumber); - if (protocolVersion != null) { - return protocolVersion; - } - return UNKNOWN; - } - - public String toString() { - return name().replace("MINECRAFT_", "").replace("_", "."); + public static String getVersion(int version) { + return versions.get(version); } }