All Known Implementing Classes:
Recipient.Invalid, Recipient.Proxied, Recipient.Valid

public sealed interface Recipient permits Recipient.Valid, Recipient.Proxied, Recipient.Invalid
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 for ProxiedCommandSender that maintains both the proxied and originating sender
  • Recipient.Invalid – An unrecognized or null 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 Classes
    Modifier and Type
    Interface
    Description
    static final record 
    Represents an invalid or unrecognized message recipient.
    static enum 
    Indicates the reason a Recipient was deemed invalid.
    static final record 
    Represents a proxied command sender (e.g., from another plugin or dispatch chain).
    static interface 
    A marker subinterface for Recipient 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

    Static Methods
    Modifier and Type
    Method
    Description
    static Recipient
    of(org.bukkit.command.CommandSender sender)
    Factory method that analyzes the given CommandSender and returns a categorized Recipient instance.
  • Method Details

    • of

      static Recipient of(org.bukkit.command.CommandSender sender)
      Factory method that analyzes the given CommandSender and returns a categorized Recipient instance.
      • If the sender is a Player, ConsoleCommandSender, or BlockCommandSender, a Recipient.Valid recipient is returned
      • If the sender is a ProxiedCommandSender, a Recipient.Proxied recipient is returned
      • If the sender is null, an Recipient.Invalid recipient with reason NULL is returned
      • Otherwise, an Recipient.Invalid recipient with reason OTHER is returned
      Parameters:
      sender - the CommandSender to classify
      Returns:
      a concrete Recipient representing the sender’s classification