Package org.bukkit.plugin.messaging
Class StandardMessenger
- java.lang.Object
-
- org.bukkit.plugin.messaging.StandardMessenger
-
-
Field Summary
-
Fields inherited from interface org.bukkit.plugin.messaging.Messenger
MAX_CHANNEL_SIZE, MAX_MESSAGE_SIZE
-
-
Constructor Summary
Constructors Constructor Description StandardMessenger()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description voiddispatchIncomingMessage(@NotNull Player source, @NotNull String channel, @org.jetbrains.annotations.NotNull byte[] message)Dispatches the specified incoming message to any registered listeners.@NotNull Set<PluginMessageListenerRegistration>getIncomingChannelRegistrations(@NotNull String channel)Gets a set containing all the incoming plugin channel registrations that are on the requested channel.@NotNull Set<PluginMessageListenerRegistration>getIncomingChannelRegistrations(@NotNull Plugin plugin)Gets a set containing all the incoming plugin channel registrations that the specified plugin has.@NotNull Set<PluginMessageListenerRegistration>getIncomingChannelRegistrations(@NotNull Plugin plugin, @NotNull String channel)Gets a set containing all the incoming plugin channel registrations that the specified plugin has on the requested channel.@NotNull Set<String>getIncomingChannels()Gets a set containing all the incoming plugin channels.@NotNull Set<String>getIncomingChannels(@NotNull Plugin plugin)Gets a set containing all the incoming plugin channels that the specified plugin is registered for.@NotNull Set<String>getOutgoingChannels()Gets a set containing all the outgoing plugin channels.@NotNull Set<String>getOutgoingChannels(@NotNull Plugin plugin)Gets a set containing all the outgoing plugin channels that the specified plugin is registered to.booleanisIncomingChannelRegistered(@NotNull Plugin plugin, @NotNull String channel)Checks if the specified plugin has registered to receive incoming messages through the requested channel.booleanisOutgoingChannelRegistered(@NotNull Plugin plugin, @NotNull String channel)Checks if the specified plugin has registered to send outgoing messages through the requested channel.booleanisRegistrationValid(@NotNull PluginMessageListenerRegistration registration)Checks if the specified plugin message listener registration is valid.booleanisReservedChannel(@NotNull String channel)Checks if the specified channel is a reserved name.@NotNull PluginMessageListenerRegistrationregisterIncomingPluginChannel(@NotNull Plugin plugin, @NotNull String channel, @NotNull PluginMessageListener listener)Registers the specific plugin for listening on the requested incoming plugin channel, allowing it to act upon any plugin messages.voidregisterOutgoingPluginChannel(@NotNull Plugin plugin, @NotNull String channel)Registers the specific plugin to the requested outgoing plugin channel, allowing it to send messages through that channel to any clients.voidunregisterIncomingPluginChannel(@NotNull Plugin plugin)Unregisters the specific plugin from listening on all plugin channels through all listeners.voidunregisterIncomingPluginChannel(@NotNull Plugin plugin, @NotNull String channel)Unregisters the specific plugin from listening on the requested incoming plugin channel, no longer allowing it to act upon any plugin messages.voidunregisterIncomingPluginChannel(@NotNull Plugin plugin, @NotNull String channel, @NotNull PluginMessageListener listener)Unregisters the specific plugin's listener from listening on the requested incoming plugin channel, no longer allowing it to act upon any plugin messages.voidunregisterOutgoingPluginChannel(@NotNull Plugin plugin)Unregisters the specific plugin from all outgoing plugin channels, no longer allowing it to send any plugin messages.voidunregisterOutgoingPluginChannel(@NotNull Plugin plugin, @NotNull String channel)Unregisters the specific plugin from the requested outgoing plugin channel, no longer allowing it to send messages through that channel to any clients.static @NotNull StringvalidateAndCorrectChannel(@NotNull String channel)Deprecated.not an API methodstatic voidvalidateChannel(@NotNull String channel)Deprecated.not an API methodstatic voidvalidatePluginMessage(@NotNull Messenger messenger, @NotNull Plugin source, @NotNull String channel, @org.jetbrains.annotations.NotNull byte[] message)Validates the input of a Plugin Message, ensuring the arguments are all valid.
-
-
-
Method Detail
-
isReservedChannel
public boolean isReservedChannel(@NotNull @NotNull String channel)Description copied from interface:MessengerChecks if the specified channel is a reserved name.
All channels within the "minecraft" namespace except for "minecraft:brand" are reserved.- Specified by:
isReservedChannelin interfaceMessenger- Parameters:
channel- Channel name to check.- Returns:
- True if the channel is reserved, otherwise false.
-
registerOutgoingPluginChannel
public void registerOutgoingPluginChannel(@NotNull @NotNull Plugin plugin, @NotNull @NotNull String channel)Description copied from interface:MessengerRegisters the specific plugin to the requested outgoing plugin channel, allowing it to send messages through that channel to any clients.- Specified by:
registerOutgoingPluginChannelin interfaceMessenger- Parameters:
plugin- Plugin that wishes to send messages through the channel.channel- Channel to register.
-
unregisterOutgoingPluginChannel
public void unregisterOutgoingPluginChannel(@NotNull @NotNull Plugin plugin, @NotNull @NotNull String channel)Description copied from interface:MessengerUnregisters the specific plugin from the requested outgoing plugin channel, no longer allowing it to send messages through that channel to any clients.- Specified by:
unregisterOutgoingPluginChannelin interfaceMessenger- Parameters:
plugin- Plugin that no longer wishes to send messages through the channel.channel- Channel to unregister.
-
unregisterOutgoingPluginChannel
public void unregisterOutgoingPluginChannel(@NotNull @NotNull Plugin plugin)Description copied from interface:MessengerUnregisters the specific plugin from all outgoing plugin channels, no longer allowing it to send any plugin messages.- Specified by:
unregisterOutgoingPluginChannelin interfaceMessenger- Parameters:
plugin- Plugin that no longer wishes to send plugin messages.
-
registerIncomingPluginChannel
@NotNull public @NotNull PluginMessageListenerRegistration registerIncomingPluginChannel(@NotNull @NotNull Plugin plugin, @NotNull @NotNull String channel, @NotNull @NotNull PluginMessageListener listener)
Description copied from interface:MessengerRegisters the specific plugin for listening on the requested incoming plugin channel, allowing it to act upon any plugin messages.- Specified by:
registerIncomingPluginChannelin interfaceMessenger- Parameters:
plugin- Plugin that wishes to register to this channel.channel- Channel to register.listener- Listener to receive messages on.- Returns:
- The resulting registration that was made as a result of this method.
-
unregisterIncomingPluginChannel
public void unregisterIncomingPluginChannel(@NotNull @NotNull Plugin plugin, @NotNull @NotNull String channel, @NotNull @NotNull PluginMessageListener listener)Description copied from interface:MessengerUnregisters the specific plugin's listener from listening on the requested incoming plugin channel, no longer allowing it to act upon any plugin messages.- Specified by:
unregisterIncomingPluginChannelin interfaceMessenger- Parameters:
plugin- Plugin that wishes to unregister from this channel.channel- Channel to unregister.listener- Listener to stop receiving messages on.
-
unregisterIncomingPluginChannel
public void unregisterIncomingPluginChannel(@NotNull @NotNull Plugin plugin, @NotNull @NotNull String channel)Description copied from interface:MessengerUnregisters the specific plugin from listening on the requested incoming plugin channel, no longer allowing it to act upon any plugin messages.- Specified by:
unregisterIncomingPluginChannelin interfaceMessenger- Parameters:
plugin- Plugin that wishes to unregister from this channel.channel- Channel to unregister.
-
unregisterIncomingPluginChannel
public void unregisterIncomingPluginChannel(@NotNull @NotNull Plugin plugin)Description copied from interface:MessengerUnregisters the specific plugin from listening on all plugin channels through all listeners.- Specified by:
unregisterIncomingPluginChannelin interfaceMessenger- Parameters:
plugin- Plugin that wishes to unregister from this channel.
-
getOutgoingChannels
@NotNull public @NotNull Set<String> getOutgoingChannels()
Description copied from interface:MessengerGets a set containing all the outgoing plugin channels.- Specified by:
getOutgoingChannelsin interfaceMessenger- Returns:
- List of all registered outgoing plugin channels.
-
getOutgoingChannels
@NotNull public @NotNull Set<String> getOutgoingChannels(@NotNull @NotNull Plugin plugin)
Description copied from interface:MessengerGets a set containing all the outgoing plugin channels that the specified plugin is registered to.- Specified by:
getOutgoingChannelsin interfaceMessenger- Parameters:
plugin- Plugin to retrieve channels for.- Returns:
- List of all registered outgoing plugin channels that a plugin is registered to.
-
getIncomingChannels
@NotNull public @NotNull Set<String> getIncomingChannels()
Description copied from interface:MessengerGets a set containing all the incoming plugin channels.- Specified by:
getIncomingChannelsin interfaceMessenger- Returns:
- List of all registered incoming plugin channels.
-
getIncomingChannels
@NotNull public @NotNull Set<String> getIncomingChannels(@NotNull @NotNull Plugin plugin)
Description copied from interface:MessengerGets a set containing all the incoming plugin channels that the specified plugin is registered for.- Specified by:
getIncomingChannelsin interfaceMessenger- Parameters:
plugin- Plugin to retrieve channels for.- Returns:
- List of all registered incoming plugin channels that the plugin is registered for.
-
getIncomingChannelRegistrations
@NotNull public @NotNull Set<PluginMessageListenerRegistration> getIncomingChannelRegistrations(@NotNull @NotNull Plugin plugin)
Description copied from interface:MessengerGets a set containing all the incoming plugin channel registrations that the specified plugin has.- Specified by:
getIncomingChannelRegistrationsin interfaceMessenger- Parameters:
plugin- Plugin to retrieve registrations for.- Returns:
- List of all registrations that the plugin has.
-
getIncomingChannelRegistrations
@NotNull public @NotNull Set<PluginMessageListenerRegistration> getIncomingChannelRegistrations(@NotNull @NotNull String channel)
Description copied from interface:MessengerGets a set containing all the incoming plugin channel registrations that are on the requested channel.- Specified by:
getIncomingChannelRegistrationsin interfaceMessenger- Parameters:
channel- Channel to retrieve registrations for.- Returns:
- List of all registrations that are on the channel.
-
getIncomingChannelRegistrations
@NotNull public @NotNull Set<PluginMessageListenerRegistration> getIncomingChannelRegistrations(@NotNull @NotNull Plugin plugin, @NotNull @NotNull String channel)
Description copied from interface:MessengerGets a set containing all the incoming plugin channel registrations that the specified plugin has on the requested channel.- Specified by:
getIncomingChannelRegistrationsin interfaceMessenger- Parameters:
plugin- Plugin to retrieve registrations for.channel- Channel to filter registrations by.- Returns:
- List of all registrations that the plugin has.
-
isRegistrationValid
public boolean isRegistrationValid(@NotNull @NotNull PluginMessageListenerRegistration registration)Description copied from interface:MessengerChecks if the specified plugin message listener registration is valid.A registration is considered valid if it has not be unregistered and that the plugin is still enabled.
- Specified by:
isRegistrationValidin interfaceMessenger- Parameters:
registration- Registration to check.- Returns:
- True if the registration is valid, otherwise false.
-
isIncomingChannelRegistered
public boolean isIncomingChannelRegistered(@NotNull @NotNull Plugin plugin, @NotNull @NotNull String channel)Description copied from interface:MessengerChecks if the specified plugin has registered to receive incoming messages through the requested channel.- Specified by:
isIncomingChannelRegisteredin interfaceMessenger- Parameters:
plugin- Plugin to check registration for.channel- Channel to test for.- Returns:
- True if the channel is registered, else false.
-
isOutgoingChannelRegistered
public boolean isOutgoingChannelRegistered(@NotNull @NotNull Plugin plugin, @NotNull @NotNull String channel)Description copied from interface:MessengerChecks if the specified plugin has registered to send outgoing messages through the requested channel.- Specified by:
isOutgoingChannelRegisteredin interfaceMessenger- Parameters:
plugin- Plugin to check registration for.channel- Channel to test for.- Returns:
- True if the channel is registered, else false.
-
dispatchIncomingMessage
public void dispatchIncomingMessage(@NotNull @NotNull Player source, @NotNull @NotNull String channel, @NotNull @org.jetbrains.annotations.NotNull byte[] message)Description copied from interface:MessengerDispatches the specified incoming message to any registered listeners.- Specified by:
dispatchIncomingMessagein interfaceMessenger- Parameters:
source- Source of the message.channel- Channel that the message was sent by.message- Raw payload of the message.
-
validateChannel
@Deprecated public static void validateChannel(@NotNull @NotNull String channel)
Deprecated.not an API methodValidates a Plugin Channel name.- Parameters:
channel- Channel name to validate.
-
validateAndCorrectChannel
@Deprecated @NotNull public static @NotNull String validateAndCorrectChannel(@NotNull @NotNull String channel)
Deprecated.not an API methodValidates and corrects a Plugin Channel name. Method is not reentrant / idempotent.- Parameters:
channel- Channel name to validate.- Returns:
- corrected channel name
-
validatePluginMessage
public static void validatePluginMessage(@NotNull @NotNull Messenger messenger, @NotNull @NotNull Plugin source, @NotNull @NotNull String channel, @NotNull @org.jetbrains.annotations.NotNull byte[] message)Validates the input of a Plugin Message, ensuring the arguments are all valid.- Parameters:
messenger- Messenger to use for validation.source- Source plugin of the Message.channel- Plugin Channel to send the message by.message- Raw message payload to send.- Throws:
IllegalArgumentException- Thrown if the source plugin is disabled.IllegalArgumentException- Thrown if source, channel or message is null.MessageTooLargeException- Thrown if the message is too big.ChannelNameTooLongException- Thrown if the channel name is too long.ChannelNotRegisteredException- Thrown if the channel is not registered for this plugin.
-
-