Class PluginMessageManager
java.lang.Object
dev.magicmq.pyspigot.bukkit.manager.messaging.PluginMessageManager
Manager to interface with Spigot/Paper's plugin messaging system. Primarily used by scripts to register and unregister plugin message listeners. Can also be used to send plugin messages.
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionstatic PluginMessageManagerget()Get the singleton instance of this PluginMessageManager.getListener(dev.magicmq.pyspigot.manager.script.Script script, String channel) Get the plugin message listener for a particular channel associated with a scriptgetListeners(dev.magicmq.pyspigot.manager.script.Script script) Get all plugin message listeners associated with a script.registerListener(PyFunction function, String channel) Register a new plugin message listener to listen on the given channel.voidsendBungeeMessage(Player player, String messageType, Object... payload) Send a plugin message of the specified message type/subchannel on the "BungeeCord" channel with the specified payload.voidsendMessage(Player player, String channel, Object... payload) Send a plugin message on the specified channel with the specified payload.voidsendRawMessage(Player player, String channel, byte[] payload) Send a plugin message on the specified channel with the specified payload.voidUnregister a plugin message listener.voidunregisterListeners(dev.magicmq.pyspigot.manager.script.Script script) Unregister all plugin message listeners belonging to a script.
-
Method Details
-
sendBungeeMessage
Send a plugin message of the specified message type/subchannel on the "BungeeCord" channel with the specified payload.The payload will differ depending on the message type or subchannel and is typically a server name or player name.
- Parameters:
player- The player to use when sending the plugin messagemessageType- The message type or subchannel, for example, "Connect" or "PlayerCount"payload- The payload to send with the message
-
sendMessage
Send a plugin message on the specified channel with the specified payload. Allowed types for the payload include String, Integer, Short, Byte, Boolean, and a byte array.- Parameters:
player- The player to use when sending the plugin messagechannel- The channel to send the message onpayload- The payload to send with the message
-
sendRawMessage
Send a plugin message on the specified channel with the specified payload. The payload should be passed as a raw byte array.- Parameters:
player- The player to use when sending the plugin messagechannel- The channel to send the message onpayload- The payload to send with the message
-
registerListener
Register a new plugin message listener to listen on the given channel.Note: This should be called from scripts only!
- Parameters:
function- The function that should be called when a message is received on the channelchannel- The channel to listen on- Returns:
- The plugin message listener that was registered
-
unregisterListener
Unregister a plugin message listener.Note: This should be called from scripts only!
- Parameters:
listener- The listener to unregister
-
unregisterListeners
public void unregisterListeners(dev.magicmq.pyspigot.manager.script.Script script) Unregister all plugin message listeners belonging to a script.- Parameters:
script- The script whose plugin message listeners should be unregistered
-
getListener
public ScriptPluginMessageListener getListener(dev.magicmq.pyspigot.manager.script.Script script, String channel) Get the plugin message listener for a particular channel associated with a script- Parameters:
script- The scriptchannel- The channel- Returns:
- The listener associated with the script and channel, or null if there is none
-
getListeners
public List<ScriptPluginMessageListener> getListeners(dev.magicmq.pyspigot.manager.script.Script script) Get all plugin message listeners associated with a script.- Parameters:
script- The script to get plugin message listeners from- Returns:
- An immutable List containing all plugin message listeners associated with the script. Will return an empty list if there are no plugin message listeners associated with the script
-
get
Get the singleton instance of this PluginMessageManager.- Returns:
- The instance
-