[Resolved] Troubble to understand best Usage of MessageChannel and MessageReciver

Hello there,

Im working on a Plugin where we also should have different Chat Channels for easy communicating between Local (Around 50blocks), Global, Kingdom (Group), Kingdom Staff and Staff (Admins, Mods).

On my old Plugin for Bukkit and Spout i was doing it by just getting all the Players and sending them each the Message.

But now on Sponge i have seen there is king of a System for that. But as i have looked into it i was quite Confused… why it is so “complicated” to implement/understand.

I don’t see why i should also Implement a Collection and so on. It would be much easyer to have that already on the API don and just the Possibliites to add or remove a MessageReciver.

Does someone have a short Explanation on it? Or e Example i can look into?

Thanks for your help.

We have docs on this:

https://docs.spongepowered.org/stable/en/plugin/text/messagechannels.html

Collection<> is implemented by List<>. Use a List<MessageReceiver>, you don’t need to create it yourself. Alternatively, use one of the methods on the MessageChannel interface, they’ll do a lot of the work for you.

1 Like

Thanks i really oversaw it in the Docs was always just looking to the API Doc’s and also suggestions from IntelliJ IDEA.

But now as i read the Documentation on this. I see that it is eventually not a Solution i can use for me.

Is it right that a Player can just Receive Messages from ONE Channel until i change the MessageChannel on the Player to another Channel?

Edit: Nope im wrong…

I have the Members in the List and player.setChannel sets just the where the Message Input gets to.