Before you do anything with Proton, you need a reference to ProtonManager. In your onEnable() method, store a reference to it.
public void onEnable(){
manager = Proton.getProtonManager();
}
A reference to ProtonManager will allow you to use all of Proton's API.
Forward chat messages network-wide
Create an event listener for the async chat event and broadcast your custom data there. In this case, we opted for a container class which holds the player name and message.
@EventHandler
public void onPlayerChat(AsyncPlayerChatEvent event){
PlayerMessage message = new PlayerMessage(event.getPlayer().getName(), event.getMessage());
manager.broadcast("networkchat", "chatMessage", message);
}
Here we're broadcasting to the namespace networkchat with the subject chatMessage
Listen for the broadcasted message
Here we will listen for broadcasted messages using a MessageHandler