Interface PluginMessenger
public interface PluginMessenger
Listens to plugin message channels, for one plugin: what it listens to is released when the plugin is
disabled.
The server announces every channel it listens to, so that clients and proxies know they can send on
it, and keeps announcing new channels to the players already in the game. Messages are sent with
Player.sendPluginMessage(Key, byte[]), on any channel, without declaring it first.
- Since:
- 0.1.0
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intThe most bytes a message received from a player can hold.static final intThe most bytes a message sent to a player can hold.static final KeyThe channel on which clients and proxies announce the channels they listen to, handled by the server: nothing can listen or send on it.static final KeyThe channel on which clients and proxies withdraw the channels they listened to, handled by the server: nothing can listen or send on it. -
Method Summary
Modifier and TypeMethodDescriptionchannels()Gets the channels the server listens to, those of every plugin.listen(Key channel, PluginMessageListener listener) Listens to a channel.
-
Field Details
-
MAX_SENT_SIZE
static final int MAX_SENT_SIZEThe most bytes a message sent to a player can hold.- Since:
- 0.1.0
- See Also:
-
MAX_RECEIVED_SIZE
static final int MAX_RECEIVED_SIZEThe most bytes a message received from a player can hold.- Since:
- 0.1.0
- See Also:
-
REGISTER
The channel on which clients and proxies announce the channels they listen to, handled by the server: nothing can listen or send on it.- Since:
- 0.1.0
-
UNREGISTER
The channel on which clients and proxies withdraw the channels they listened to, handled by the server: nothing can listen or send on it.- Since:
- 0.1.0
-
-
Method Details
-
listen
Listens to a channel.listenerreceives the messages players send on the channel while they are in the game, on the network thread: it must not block, and hands any work on the world over to the right thread. Several listeners, of one plugin or several, can listen to the same channel.A message can come from the player's client as well as from the proxy: never trust it blindly.
- Parameters:
channel- the channellistener- what to do with each message- Returns:
- the subscription, to stop listening before the plugin is disabled
- Throws:
IllegalArgumentException- ifchannelorlisteneris null, or if the channel isREGISTERorUNREGISTER- Since:
- 0.1.0
-
channels
-