Java Code Examples for org.spongepowered.api.text.channel.MessageChannel#getMembers()

The following examples show how to use org.spongepowered.api.text.channel.MessageChannel#getMembers() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ChatMessageListener.java    From EagleFactions with MIT License 6 votes vote down vote up
private MessageChannel hideMessageForPlayersInFactionChat(final MessageChannel messageChannel)
{
    final Collection<MessageReceiver> chatMembers = messageChannel.getMembers();
    final Set<MessageReceiver> newReceivers = new HashSet<>(chatMembers);
    for(final MessageReceiver messageReceiver : chatMembers)
    {
        if(!(messageReceiver instanceof Player))
            continue;

        final Player receiver = (Player) messageReceiver;

        if(EagleFactionsPlugin.CHAT_LIST.containsKey(receiver.getUniqueId()) && EagleFactionsPlugin.CHAT_LIST.get(receiver.getUniqueId()) != ChatEnum.GLOBAL)
        {
            newReceivers.remove(receiver);
        }
    }
    return MessageChannel.fixed(newReceivers);
}
 
Example 2
Source File: CacheService.java    From Web-API with MIT License 5 votes vote down vote up
@Listener(order = Order.POST)
public void onMessage(MessageChannelEvent event) {
    Optional<Player> player = event.getCause().first(Player.class);

    MessageChannel channel = event.getChannel().orElse(event.getOriginalChannel());
    CachedMessage msg = player.isPresent() ?
            new CachedChatMessage(player.get(), channel.getMembers(), event.getMessage()) :
            new CachedMessage(channel.getMembers(), event.getMessage());
    messages.add(msg);

    while (messages.size() > numChatMessages) {
        messages.poll();
    }
}