Class SimpleMessageRecipient
java.lang.Object
com.earth2me.essentials.messaging.SimpleMessageRecipient
- All Implemented Interfaces:
IMessageRecipient
,MailSender
Represents a simple reusable implementation of
IMessageRecipient
. This class provides functionality for the following methods:
IMessageRecipient.sendMessage(IMessageRecipient, String)
IMessageRecipient.onReceiveMessage(IMessageRecipient, String)
IMessageRecipient.getReplyRecipient()
IMessageRecipient.setReplyRecipient(IMessageRecipient)
parent
must implement the following methods to prevent overflow:
IMessageRecipient.sendMessage(String)
IMessageRecipient.getName()
IMessageRecipient.getDisplayName()
IMessageRecipient.isReachable()
The reply-recipient is wrapped in a WeakReference
.
-
Nested Class Summary
Nested classes/interfaces inherited from interface com.earth2me.essentials.messaging.IMessageRecipient
IMessageRecipient.MessageResponse
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionReturns the display name of this recipient.getName()
Returns the name of this recipient.Returns theIMessageRecipient
this recipient should send replies to.protected static User
getUser
(IMessageRecipient recipient) getUUID()
Gets theUUID
of thisMailSender
or null if this sender doesn't have a UUID.boolean
isHiddenFrom
(Player player) boolean
Returns whether this recipient is reachable.onReceiveMessage
(IMessageRecipient sender, String message) This method is called when this recipient is receiving a message from anotherIMessageRecipient
.sendMessage
(IMessageRecipient recipient, String message) This method is called when thisIMessageRecipient
is sending a message to anotherIMessageRecipient
.void
sendMessage
(String message) Sends (prints) a message to this recipient.void
Sends a translated message to this recipient.void
setReplyRecipient
(IMessageRecipient replyRecipient) Sets theIMessageRecipient
this recipient should send replies to.Translates a message.
-
Constructor Details
-
SimpleMessageRecipient
-
-
Method Details
-
getUser
-
sendMessage
Description copied from interface:IMessageRecipient
Sends (prints) a message to this recipient.- Specified by:
sendMessage
in interfaceIMessageRecipient
- Parameters:
message
- message
-
sendTl
Description copied from interface:IMessageRecipient
Sends a translated message to this recipient.- Specified by:
sendTl
in interfaceIMessageRecipient
- Parameters:
tlKey
- keyargs
- arguments
-
tlSender
Description copied from interface:IMessageRecipient
Translates a message.- Specified by:
tlSender
in interfaceIMessageRecipient
- Parameters:
tlKey
- keyargs
- arguments- Returns:
- translated message
-
getName
Description copied from interface:IMessageRecipient
Returns the name of this recipient. This name is typically used internally to identify this recipient.- Specified by:
getName
in interfaceIMessageRecipient
- Specified by:
getName
in interfaceMailSender
- Returns:
- name of this recipient
- See Also:
-
getUUID
Description copied from interface:MailSender
Gets theUUID
of thisMailSender
or null if this sender doesn't have a UUID.- Specified by:
getUUID
in interfaceMailSender
- Returns:
- The sender's
UUID
or null if N/A.
-
getDisplayName
Description copied from interface:IMessageRecipient
Returns the display name of this recipient. This name is typically used when formatting messages.- Specified by:
getDisplayName
in interfaceIMessageRecipient
- Returns:
- display name of this recipient
-
sendMessage
Description copied from interface:IMessageRecipient
This method is called when thisIMessageRecipient
is sending a message to anotherIMessageRecipient
.The
IMessageRecipient.MessageResponse
that is returned is used to determine what exactly should happen in theIMessageRecipient.sendMessage(IMessageRecipient, String)
implementation by thesender
.- Specified by:
sendMessage
in interfaceIMessageRecipient
- Parameters:
recipient
- recipient to receive themessage
message
- message to send- Returns:
- the response of the message
-
onReceiveMessage
Description copied from interface:IMessageRecipient
This method is called when this recipient is receiving a message from anotherIMessageRecipient
.The
IMessageRecipient.MessageResponse
that is returned is used to determine what exactly should happen in theIMessageRecipient.sendMessage(IMessageRecipient, String)
implementation by thesender
.This method should only be called by
IMessageRecipient.sendMessage(IMessageRecipient, String)
.- Specified by:
onReceiveMessage
in interfaceIMessageRecipient
- Parameters:
sender
- sender of themessage
message
- message being received- Returns:
- the response of the message
-
isReachable
public boolean isReachable()Description copied from interface:IMessageRecipient
Returns whether this recipient is reachable. A case where the recipient is not reachable is if they are offline.- Specified by:
isReachable
in interfaceIMessageRecipient
- Returns:
- whether this recipient is reachable
-
getReplyRecipient
Returns theIMessageRecipient
this recipient should send replies to.This
SimpleMessageRecipient
implementation stores the a weak reference to the recipient.- Specified by:
getReplyRecipient
in interfaceIMessageRecipient
- Returns:
- message recipient
-
setReplyRecipient
Sets theIMessageRecipient
this recipient should send replies to.This
SimpleMessageRecipient
implementation stores the a weak reference to the recipient.- Specified by:
setReplyRecipient
in interfaceIMessageRecipient
- Parameters:
replyRecipient
- message recipient to set
-
isHiddenFrom
- Specified by:
isHiddenFrom
in interfaceIMessageRecipient
-