java.lang.Object
com.winterhavenmc.library.messagebuilder.core.message.ValidMessage
All Implemented Interfaces:
Message

public final class ValidMessage extends Object implements Message
A concrete implementation of Message representing a fully constructed, resolvable, and sendable message.

This class encapsulates all components required to render and dispatch a message:

  • A recipient
  • A messageKey identifying the template
  • A Pipeline to handle rendering and delivery
  • A com.winterhavenmc.library.messagebuilder.pipeline.maps.MacroObjectMap macro object map holding values to be substituted into the message
The recipient is also automatically added as a macro object under the string [RECIPIENT}.
See Also:
  • Constructor Details

    • ValidMessage

      public ValidMessage(org.bukkit.plugin.Plugin plugin, Recipient.Sendable recipient, ValidMessageKey messageKey, Pipeline messagePipeline)
      Class constructor
      Parameters:
      recipient - message recipient
      messageKey - message identifier
      messagePipeline - the message processor that will receive the message when the send method is called
  • Method Details

    • setMacro

      public <K extends Enum<K>, V> Message setMacro(K macro, V value)
      Description copied from interface: Message
      Associates a macro string with a value for later substitution during message rendering.
      Specified by:
      setMacro in interface Message
      Type Parameters:
      K - the enum type of the macro
      V - the value type
      Parameters:
      macro - the macro string to assign
      value - the value to associate with the macro
      Returns:
      the same Message instance, for fluent chaining
    • setMacro

      public <K extends Enum<K>, V> Message setMacro(int quantity, K macro, V value)
      Description copied from interface: Message
      Associates a macro string with a value and explicit quantity, useful for pluralization or contextual substitution that depends on numeric counts.
      Specified by:
      setMacro in interface Message
      Type Parameters:
      K - the enum type of the macro
      V - the value type
      Parameters:
      quantity - the quantity associated with the value
      macro - the macro string
      value - the object to associate
      Returns:
      the same Message instance, for fluent chaining
    • setMacro

      public <K extends Enum<K>> Message setMacro(K macro, Duration duration, ChronoUnit lowerBound)
      Description copied from interface: Message
      Associates a duration with the given macro string, using a defined precision.
      Specified by:
      setMacro in interface Message
      Type Parameters:
      K - the enum type of the macro
      Parameters:
      macro - the macro string
      duration - the Duration to be formatted and resolved
      lowerBound - the ChronoUnit to control formatting granularity
      Returns:
      the same Message instance, for fluent chaining
    • send

      public boolean send()
      Description copied from interface: Message
      Sends the composed message to the resolved recipient, if valid.

      No-op if the message is invalid or the recipient is missing or unsupported.

      Specified by:
      send in interface Message
    • getMessageKey

      public ValidMessageKey getMessageKey()
      Description copied from interface: Message
      Returns the ValidMessageKey identifying the message template used in composition.
      Specified by:
      getMessageKey in interface Message
      Returns:
      the message string
    • getRecipient

      public Recipient.Sendable getRecipient()
      Description copied from interface: Message
      Returns the Recipient.Sendable to whom the message will be sent.
      Specified by:
      getRecipient in interface Message
      Returns:
      the message recipient
    • getObjectMap

      public MacroObjectMap getObjectMap()
      Description copied from interface: Message
      Returns the MacroObjectMap of macro values bound to this message.
      Specified by:
      getObjectMap in interface Message
      Returns:
      the macro object map