org.bukkit.plugin.messaging
Class StandardMessenger

java.lang.Object
  extended by org.bukkit.plugin.messaging.StandardMessenger
All Implemented Interfaces:
Messenger

public class StandardMessenger
extends Object
implements Messenger

Standard implementation to Messenger


Field Summary
 
Fields inherited from interface org.bukkit.plugin.messaging.Messenger
MAX_CHANNEL_SIZE, MAX_MESSAGE_SIZE
 
Constructor Summary
StandardMessenger()
           
 
Method Summary
 void dispatchIncomingMessage(Player source, String channel, byte[] message)
          Dispatches the specified incoming message to any registered listeners.
 Set<PluginMessageListenerRegistration> getIncomingChannelRegistrations(Plugin plugin)
          Gets a set containing all the incoming plugin channel registrations that the specified plugin has.
 Set<PluginMessageListenerRegistration> getIncomingChannelRegistrations(Plugin plugin, String channel)
          Gets a set containing all the incoming plugin channel registrations that the specified plugin has on the requested channel.
 Set<PluginMessageListenerRegistration> getIncomingChannelRegistrations(String channel)
          Gets a set containing all the incoming plugin channel registrations that are on the requested channel.
 Set<String> getIncomingChannels()
          Gets a set containing all the incoming plugin channels.
 Set<String> getIncomingChannels(Plugin plugin)
          Gets a set containing all the incoming plugin channels that the specified plugin is registered for.
 Set<String> getOutgoingChannels()
          Gets a set containing all the outgoing plugin channels.
 Set<String> getOutgoingChannels(Plugin plugin)
          Gets a set containing all the outgoing plugin channels that the specified plugin is registered to.
 boolean isIncomingChannelRegistered(Plugin plugin, String channel)
          Checks if the specified plugin has registered to receive incoming messages through the requested channel.
 boolean isOutgoingChannelRegistered(Plugin plugin, String channel)
          Checks if the specified plugin has registered to send outgoing messages through the requested channel.
 boolean isRegistrationValid(PluginMessageListenerRegistration registration)
          Checks if the specified plugin message listener registration is valid.
 boolean isReservedChannel(String channel)
          Checks if the specified channel is a reserved name.
 PluginMessageListenerRegistration registerIncomingPluginChannel(Plugin plugin, String channel, PluginMessageListener listener)
          Registers the specific plugin for listening on the requested incoming plugin channel, allowing it to act upon any plugin messages.
 void registerOutgoingPluginChannel(Plugin plugin, String channel)
          Registers the specific plugin to the requested outgoing plugin channel, allowing it to send messages through that channel to any clients.
 void unregisterIncomingPluginChannel(Plugin plugin)
          Unregisters the specific plugin from listening on all plugin channels through all listeners.
 void unregisterIncomingPluginChannel(Plugin plugin, String channel)
          Unregisters the specific plugin from listening on the requested incoming plugin channel, no longer allowing it to act upon any plugin messages.
 void unregisterIncomingPluginChannel(Plugin plugin, String channel, 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.
 void unregisterOutgoingPluginChannel(Plugin plugin)
          Unregisters the specific plugin from all outgoing plugin channels, no longer allowing it to send any plugin messages.
 void unregisterOutgoingPluginChannel(Plugin plugin, 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 void validateChannel(String channel)
          Validates a Plugin Channel name.
static void validatePluginMessage(Messenger messenger, Plugin source, String channel, byte[] message)
          Validates the input of a Plugin Message, ensuring the arguments are all valid.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

StandardMessenger

public StandardMessenger()
Method Detail

isReservedChannel

public boolean isReservedChannel(String channel)
Description copied from interface: Messenger
Checks if the specified channel is a reserved name.

Specified by:
isReservedChannel in interface Messenger
Parameters:
channel - Channel name to check.
Returns:
True if the channel is reserved, otherwise false.

registerOutgoingPluginChannel

public void registerOutgoingPluginChannel(Plugin plugin,
                                          String channel)
Description copied from interface: Messenger
Registers the specific plugin to the requested outgoing plugin channel, allowing it to send messages through that channel to any clients.

Specified by:
registerOutgoingPluginChannel in interface Messenger
Parameters:
plugin - Plugin that wishes to send messages through the channel.
channel - Channel to register.

unregisterOutgoingPluginChannel

public void unregisterOutgoingPluginChannel(Plugin plugin,
                                            String channel)
Description copied from interface: Messenger
Unregisters the specific plugin from the requested outgoing plugin channel, no longer allowing it to send messages through that channel to any clients.

Specified by:
unregisterOutgoingPluginChannel in interface Messenger
Parameters:
plugin - Plugin that no longer wishes to send messages through the channel.
channel - Channel to unregister.

unregisterOutgoingPluginChannel

public void unregisterOutgoingPluginChannel(Plugin plugin)
Description copied from interface: Messenger
Unregisters the specific plugin from all outgoing plugin channels, no longer allowing it to send any plugin messages.

Specified by:
unregisterOutgoingPluginChannel in interface Messenger
Parameters:
plugin - Plugin that no longer wishes to send plugin messages.

registerIncomingPluginChannel

public PluginMessageListenerRegistration registerIncomingPluginChannel(Plugin plugin,
                                                                       String channel,
                                                                       PluginMessageListener listener)
Description copied from interface: Messenger
Registers the specific plugin for listening on the requested incoming plugin channel, allowing it to act upon any plugin messages.

Specified by:
registerIncomingPluginChannel in interface Messenger
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(Plugin plugin,
                                            String channel,
                                            PluginMessageListener listener)
Description copied from interface: Messenger
Unregisters 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:
unregisterIncomingPluginChannel in interface Messenger
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(Plugin plugin,
                                            String channel)
Description copied from interface: Messenger
Unregisters the specific plugin from listening on the requested incoming plugin channel, no longer allowing it to act upon any plugin messages.

Specified by:
unregisterIncomingPluginChannel in interface Messenger
Parameters:
plugin - Plugin that wishes to unregister from this channel.
channel - Channel to unregister.

unregisterIncomingPluginChannel

public void unregisterIncomingPluginChannel(Plugin plugin)
Description copied from interface: Messenger
Unregisters the specific plugin from listening on all plugin channels through all listeners.

Specified by:
unregisterIncomingPluginChannel in interface Messenger
Parameters:
plugin - Plugin that wishes to unregister from this channel.

getOutgoingChannels

public Set<String> getOutgoingChannels()
Description copied from interface: Messenger
Gets a set containing all the outgoing plugin channels.

Specified by:
getOutgoingChannels in interface Messenger
Returns:
List of all registered outgoing plugin channels.

getOutgoingChannels

public Set<String> getOutgoingChannels(Plugin plugin)
Description copied from interface: Messenger
Gets a set containing all the outgoing plugin channels that the specified plugin is registered to.

Specified by:
getOutgoingChannels in interface Messenger
Parameters:
plugin - Plugin to retrieve channels for.
Returns:
List of all registered outgoing plugin channels that a plugin is registered to.

getIncomingChannels

public Set<String> getIncomingChannels()
Description copied from interface: Messenger
Gets a set containing all the incoming plugin channels.

Specified by:
getIncomingChannels in interface Messenger
Returns:
List of all registered incoming plugin channels.

getIncomingChannels

public Set<String> getIncomingChannels(Plugin plugin)
Description copied from interface: Messenger
Gets a set containing all the incoming plugin channels that the specified plugin is registered for.

Specified by:
getIncomingChannels in interface Messenger
Parameters:
plugin - Plugin to retrieve channels for.
Returns:
List of all registered incoming plugin channels that the plugin is registered for.

getIncomingChannelRegistrations

public Set<PluginMessageListenerRegistration> getIncomingChannelRegistrations(Plugin plugin)
Description copied from interface: Messenger
Gets a set containing all the incoming plugin channel registrations that the specified plugin has.

Specified by:
getIncomingChannelRegistrations in interface Messenger
Parameters:
plugin - Plugin to retrieve registrations for.
Returns:
List of all registrations that the plugin has.

getIncomingChannelRegistrations

public Set<PluginMessageListenerRegistration> getIncomingChannelRegistrations(String channel)
Description copied from interface: Messenger
Gets a set containing all the incoming plugin channel registrations that are on the requested channel.

Specified by:
getIncomingChannelRegistrations in interface Messenger
Parameters:
channel - Channel to retrieve registrations for.
Returns:
List of all registrations that are on the channel.

getIncomingChannelRegistrations

public Set<PluginMessageListenerRegistration> getIncomingChannelRegistrations(Plugin plugin,
                                                                              String channel)
Description copied from interface: Messenger
Gets a set containing all the incoming plugin channel registrations that the specified plugin has on the requested channel.

Specified by:
getIncomingChannelRegistrations in interface Messenger
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(PluginMessageListenerRegistration registration)
Description copied from interface: Messenger
Checks 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:
isRegistrationValid in interface Messenger
Parameters:
registration - Registration to check.
Returns:
True if the registration is valid, otherwise false.

isIncomingChannelRegistered

public boolean isIncomingChannelRegistered(Plugin plugin,
                                           String channel)
Description copied from interface: Messenger
Checks if the specified plugin has registered to receive incoming messages through the requested channel.

Specified by:
isIncomingChannelRegistered in interface Messenger
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(Plugin plugin,
                                           String channel)
Description copied from interface: Messenger
Checks if the specified plugin has registered to send outgoing messages through the requested channel.

Specified by:
isOutgoingChannelRegistered in interface Messenger
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(Player source,
                                    String channel,
                                    byte[] message)
Description copied from interface: Messenger
Dispatches the specified incoming message to any registered listeners.

Specified by:
dispatchIncomingMessage in interface Messenger
Parameters:
source - Source of the message.
channel - Channel that the message was sent by.
message - Raw payload of the message.

validateChannel

public static void validateChannel(String channel)
Validates a Plugin Channel name.

Parameters:
channel - Channel name to validate.

validatePluginMessage

public static void validatePluginMessage(Messenger messenger,
                                         Plugin source,
                                         String channel,
                                         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.


Copyright © 2013. All Rights Reserved.