use of org.lanternpowered.server.network.message.Message in project LanternServer by LanternPowered.
the class LanternChannelRegistrar method sendPayloadToAll.
void sendPayloadToAll(String channel, Consumer<ByteBuffer> payload) {
checkNotNull(payload, "payload");
final Iterator<Player> players = this.server.getOnlinePlayers().stream().filter(player -> ((LanternPlayer) player).getConnection().getRegisteredChannels().contains(channel)).iterator();
if (players.hasNext()) {
final ByteBuffer buf = ByteBufferAllocator.unpooled().buffer();
payload.accept(buf);
final Message msg = new MessagePlayInOutChannelPayload(channel, buf);
players.forEachRemaining(player -> ((LanternPlayer) player).getConnection().send(msg));
}
}
Aggregations