How might someone send a message to all players but one?

I know that you can use MessageChannels to send to all people with a certain permission but I want to make sure that the sender of a command never gets that message regardless of whether or not he has the permission. Is there a way to combine multiple channels and use one to deny people who match it?
Thanks for any help :slight_smile:

I would get all players and then remove the player from the list. Then use Player.sendMessage() to send the actual message.

The code will be something like this

List<Player> list = new ArrayList(Sponge.getServer().getOnlinePlayers());
list.remove(player);
list.stream().forEach(p -> p.sendMessage(message);

You could also create a new MessageChannel for that. Exclude the player(s) you don’t want messages to receive and you’re done. This way you can reuse the channel everywhere you want during runtime.

The solution @MoseMister suggested is also just fine for this.

Perfect. Thanks guys :smile: