@Test void register() { VelocityChannelRegistrar registrar = new VelocityChannelRegistrar(); registrar.register(MODERN, SIMPLE_LEGACY); assertEquals(ImmutableSet.of(MODERN.getId(), SIMPLE_LEGACY_REMAPPED), registrar .getModernChannelIds()); assertEquals(ImmutableSet.of(SIMPLE_LEGACY.getId(), MODERN.getId()), registrar .getLegacyChannelIds()); }
@Override public void register(ChannelIdentifier... identifiers) { for (ChannelIdentifier identifier : identifiers) { Preconditions.checkArgument(identifier instanceof LegacyChannelIdentifier || identifier instanceof MinecraftChannelIdentifier, "identifier is unknown"); } for (ChannelIdentifier identifier : identifiers) { if (identifier instanceof MinecraftChannelIdentifier) { identifierMap.put(identifier.getId(), identifier); } else { String rewritten = PluginMessageUtil.transformLegacyToModernChannel(identifier.getId()); identifierMap.put(identifier.getId(), identifier); identifierMap.put(rewritten, identifier); } } }
VelocityChannelRegistrar implements ChannelRegistrar { @Override public void register(ChannelIdentifier... identifiers) { for (ChannelIdentifier identifier : identifiers) { Preconditions.checkArgument(identifier instanceof LegacyChannelIdentifier || identifier instanceof MinecraftChannelIdentifier, "identifier is unknown"); } for (ChannelIdentifier identifier : identifiers) { if (identifier instanceof MinecraftChannelIdentifier) { identifierMap.put(identifier.getId(), identifier); } else { String rewritten = PluginMessageUtil.transformLegacyToModernChannel(identifier.getId()); identifierMap.put(identifier.getId(), identifier); identifierMap.put(rewritten, identifier); } } } }
VelocityChannelRegistrar implements ChannelRegistrar { @Override public void register(ChannelIdentifier... identifiers) { for (ChannelIdentifier identifier : identifiers) { Preconditions.checkArgument(identifier instanceof LegacyChannelIdentifier || identifier instanceof MinecraftChannelIdentifier, "identifier is unknown"); } for (ChannelIdentifier identifier : identifiers) { if (identifier instanceof MinecraftChannelIdentifier) { identifierMap.put(identifier.getId(), identifier); } else { String rewritten = PluginMessageUtil.transformLegacyToModernChannel(identifier.getId()); identifierMap.put(identifier.getId(), identifier); identifierMap.put(rewritten, identifier); } } }  }
VelocityChannelRegistrar implements ChannelRegistrar { @Override public void register(ChannelIdentifier... identifiers) { for (ChannelIdentifier identifier : identifiers) { Preconditions.checkArgument(identifier instanceof LegacyChannelIdentifier || identifier instanceof MinecraftChannelIdentifier, "identifier is unknown"); } for (ChannelIdentifier identifier : identifiers) { if (identifier instanceof MinecraftChannelIdentifier) { identifierMap.put(identifier.getId(), identifier); } else { String rewritten = PluginMessageUtil.transformLegacyToModernChannel(identifier.getId()); identifierMap.put(identifier.getId(), identifier); identifierMap.put(rewritten, identifier); } } }  @Override void register(ChannelIdentifier... identifiers); @Override void unregister(ChannelIdentifier... identifiers); Collection<String> getLegacyChannelIds(); Collection<String> getModernChannelIds(); @Nullable ChannelIdentifier getFromId(String id); Collection<String> getChannelsForProtocol(ProtocolVersion protocolVersion); }
VelocityChannelRegistrar implements ChannelRegistrar { @Override public void register(ChannelIdentifier... identifiers) { for (ChannelIdentifier identifier : identifiers) { Preconditions.checkArgument(identifier instanceof LegacyChannelIdentifier || identifier instanceof MinecraftChannelIdentifier, "identifier is unknown"); } for (ChannelIdentifier identifier : identifiers) { if (identifier instanceof MinecraftChannelIdentifier) { identifierMap.put(identifier.getId(), identifier); } else { String rewritten = PluginMessageUtil.transformLegacyToModernChannel(identifier.getId()); identifierMap.put(identifier.getId(), identifier); identifierMap.put(rewritten, identifier); } } }  @Override void register(ChannelIdentifier... identifiers); @Override void unregister(ChannelIdentifier... identifiers); Collection<String> getLegacyChannelIds(); Collection<String> getModernChannelIds(); @Nullable ChannelIdentifier getFromId(String id); Collection<String> getChannelsForProtocol(ProtocolVersion protocolVersion);  }