@Test void transformLegacyToModernChannelRewritesGeneral() { assertEquals("legacy:example", PluginMessageUtil .transformLegacyToModernChannel("Example")); assertEquals("legacy:pskeepalive", PluginMessageUtil .transformLegacyToModernChannel("PS|KeepAlive")); }
public static String transformLegacyToModernChannel(String name) { checkNotNull(name, "name"); if (name.indexOf(':') != -1) { return name; } switch (name) { case REGISTER_CHANNEL_LEGACY: return REGISTER_CHANNEL; case UNREGISTER_CHANNEL_LEGACY: return UNREGISTER_CHANNEL; case BRAND_CHANNEL_LEGACY: return BRAND_CHANNEL; case "BungeeCord": return "bungeecord:main"; default: String lower = name.toLowerCase(Locale.ROOT); return "legacy:" + INVALID_IDENTIFIER_REGEX.matcher(lower).replaceAll(""); } }
PluginMessageUtil { public static String transformLegacyToModernChannel(String name) { checkNotNull(name, "name"); if (name.indexOf(':') != -1) { return name; } switch (name) { case REGISTER_CHANNEL_LEGACY: return REGISTER_CHANNEL; case UNREGISTER_CHANNEL_LEGACY: return UNREGISTER_CHANNEL; case BRAND_CHANNEL_LEGACY: return BRAND_CHANNEL; case "BungeeCord": return "bungeecord:main"; default: String lower = name.toLowerCase(Locale.ROOT); return "legacy:" + INVALID_IDENTIFIER_REGEX.matcher(lower).replaceAll(""); } } }
PluginMessageUtil { public static String transformLegacyToModernChannel(String name) { checkNotNull(name, "name"); if (name.indexOf(':') != -1) { return name; } switch (name) { case REGISTER_CHANNEL_LEGACY: return REGISTER_CHANNEL; case UNREGISTER_CHANNEL_LEGACY: return UNREGISTER_CHANNEL; case BRAND_CHANNEL_LEGACY: return BRAND_CHANNEL; case "BungeeCord": return "bungeecord:main"; default: String lower = name.toLowerCase(Locale.ROOT); return "legacy:" + INVALID_IDENTIFIER_REGEX.matcher(lower).replaceAll(""); } } private  PluginMessageUtil(); }
PluginMessageUtil { public static String transformLegacyToModernChannel(String name) { checkNotNull(name, "name"); if (name.indexOf(':') != -1) { return name; } switch (name) { case REGISTER_CHANNEL_LEGACY: return REGISTER_CHANNEL; case UNREGISTER_CHANNEL_LEGACY: return UNREGISTER_CHANNEL; case BRAND_CHANNEL_LEGACY: return BRAND_CHANNEL; case "BungeeCord": return "bungeecord:main"; default: String lower = name.toLowerCase(Locale.ROOT); return "legacy:" + INVALID_IDENTIFIER_REGEX.matcher(lower).replaceAll(""); } } private  PluginMessageUtil(); static boolean isMcBrand(PluginMessage message); static boolean isRegister(PluginMessage message); static boolean isUnregister(PluginMessage message); static boolean isLegacyRegister(PluginMessage message); static boolean isLegacyUnregister(PluginMessage message); static List<String> getChannels(PluginMessage message); static PluginMessage constructChannelsPacket(ProtocolVersion protocolVersion,
                                                      Collection<String> channels); static PluginMessage rewriteMinecraftBrand(PluginMessage message, ProxyVersion version); static String transformLegacyToModernChannel(String name); }
PluginMessageUtil { public static String transformLegacyToModernChannel(String name) { checkNotNull(name, "name"); if (name.indexOf(':') != -1) { return name; } switch (name) { case REGISTER_CHANNEL_LEGACY: return REGISTER_CHANNEL; case UNREGISTER_CHANNEL_LEGACY: return UNREGISTER_CHANNEL; case BRAND_CHANNEL_LEGACY: return BRAND_CHANNEL; case "BungeeCord": return "bungeecord:main"; default: String lower = name.toLowerCase(Locale.ROOT); return "legacy:" + INVALID_IDENTIFIER_REGEX.matcher(lower).replaceAll(""); } } private  PluginMessageUtil(); static boolean isMcBrand(PluginMessage message); static boolean isRegister(PluginMessage message); static boolean isUnregister(PluginMessage message); static boolean isLegacyRegister(PluginMessage message); static boolean isLegacyUnregister(PluginMessage message); static List<String> getChannels(PluginMessage message); static PluginMessage constructChannelsPacket(ProtocolVersion protocolVersion,
                                                      Collection<String> channels); static PluginMessage rewriteMinecraftBrand(PluginMessage message, ProxyVersion version); static String transformLegacyToModernChannel(String name);  }