Interface Recipient
- All Known Implementing Classes:
Recipient.Invalid
,Recipient.Proxied
,Recipient.Valid
A sealed interface and its related types that represent different categories
of message recipients in a player message context.
This model encapsulates information about the origin of a command or message recipient and classifies it into one of three known types:
Recipient.Valid
– A recognized sender type capable of receiving messages directly (e.g.,Player
,ConsoleCommandSender
)Recipient.Proxied
– A special wrapper forProxiedCommandSender
that maintains both the proxied and originating senderRecipient.Invalid
– An unrecognized ornull
sender, with an accompanying reason
This design follows a data-driven pattern: recipients are validated and categorized
during construction via the static factory method of(CommandSender)
, which guarantees
type safety and clarity at the call site.
Typical usage:
Recipient recipient = Recipient.of(sender);
if (recipient instanceof Recipient.Sendable sendable) {
sendable.sender().sendMessage("Hello!");
}
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic final record
Represents an invalid or unrecognized message recipient.static enum
Indicates the reason aRecipient
was deemed invalid.static final record
Represents a proxied command sender (e.g., from another plugin or dispatch chain).static interface
A marker subinterface forRecipient
types that are capable of receiving messages directly.static final record
Represents a valid, recognized message recipient such as a player, console, or command block. -
Method Summary
-
Method Details
-
of
Factory method that analyzes the givenCommandSender
and returns a categorizedRecipient
instance.- If the sender is a
Player
,ConsoleCommandSender
, orBlockCommandSender
, aRecipient.Valid
recipient is returned - If the sender is a
ProxiedCommandSender
, aRecipient.Proxied
recipient is returned - If the sender is
null
, anRecipient.Invalid
recipient with reasonNULL
is returned - Otherwise, an
Recipient.Invalid
recipient with reasonOTHER
is returned
- Parameters:
sender
- theCommandSender
to classify- Returns:
- a concrete
Recipient
representing the sender’s classification
- If the sender is a
-