/** * Called when the server is enabled, to register any non registered listeners. */ public static void onServerLoaded() { for (Protocol protocol : registerList) { protocol.registerListeners(); protocol.register(Via.getManager().getProviders()); } registerList.clear(); }
/** * Register a protocol * * @param protocol The protocol to register. * @param supported Supported client versions. * @param output The output server version it converts to. */ public static void registerProtocol(Protocol protocol, List<Integer> supported, Integer output) { // Clear cache as this may make new routes. if (pathCache.size() > 0) pathCache.clear(); for (Integer version : supported) { if (!registryMap.containsKey(version)) { registryMap.put(version, new HashMap<Integer, Protocol>()); } registryMap.get(version).put(output, protocol); } if (Via.getPlatform().isPluginEnabled()) { protocol.registerListeners(); protocol.register(Via.getManager().getProviders()); refreshVersions(); } else { registerList.add(protocol); } }
/** * Registers a base protocol. * Base Protocols registered later have higher priority * Only one base protocol will be added to pipeline * * @param baseProtocol Base Protocol to register * @param supportedProtocols Versions that baseProtocol supports */ public static void registerBaseProtocol(Protocol baseProtocol, Range<Integer> supportedProtocols) { baseProtocols.add(new Pair<>(supportedProtocols, baseProtocol)); if (Via.getPlatform().isPluginEnabled()) { baseProtocol.registerListeners(); baseProtocol.register(Via.getManager().getProviders()); refreshVersions(); } else { registerList.add(baseProtocol); } }