public static ChannelRegistrar getChannelRegistrar() { return getGame().getChannelRegistrar(); }
@Listener public void onServerAboutToStart(GameAboutToStartServerEvent event) { // register plugin message channel channel = game.getChannelRegistrar().createRawChannel(this, BridgeProtocolConstants.CHANNEL); channel.addListener(Platform.Type.SERVER, (data, connection, side) -> { if (connection instanceof PlayerConnection) { Player player = ((PlayerConnection) connection).getPlayer(); DataInput input = new DataInputStream(new ChannelBufInputStream(data)); try { bridge.onMessage(player, input); } catch (Throwable e) { rlExecutor.execute(() -> { logger.error("Unexpected error", e); }); } } }); // init bridge initBridge(); }