Class MessageDispatcher

java.lang.Object
net.flectone.pulse.execution.dispatcher.MessageDispatcher

public class MessageDispatcher extends Object
Dispatcher responsible for routing and sending messages to players. Handles message formatting, filtering, and event dispatching through the messaging pipeline.
Since:
1.8.2
  • Constructor Details

  • Method Details

    • dispatchError

      public <L extends LocalizationSetting, E extends EventMetadata<L>> E dispatchError(ModuleLocalization<L> module, E eventMetadata)
      Dispatches an error message using the specified module localization.
      Type Parameters:
      L - Type of localization setting
      Parameters:
      module - The module containing localization settings
      eventMetadata - Metadata containing event information and context
      Returns:
      Event metadata with receiver list
    • dispatch

      public <L extends LocalizationSetting, E extends EventMetadata<L>> E dispatch(ModuleLocalization<L> module, E eventMetadata)
      Dispatches a message using the module's name as the identifier.
      Type Parameters:
      L - Type of localization setting
      Parameters:
      module - The module containing localization settings
      eventMetadata - Metadata containing event information and context
      Returns:
      Event metadata with receiver list
    • dispatch

      public <L extends LocalizationSetting, E extends EventMetadata<L>> E dispatch(ModuleName moduleName, ModuleLocalization<L> module, E eventMetadata)
      Dispatches a message to all eligible receivers based on the provided metadata. Creates receiver list and routes the message through the dispatch pipeline.
      Type Parameters:
      L - Type of localization setting
      Parameters:
      moduleName - The name identifier for the module
      module - The module containing localization settings
      eventMetadata - Metadata containing event information and context
      Returns:
      Event metadata with receiver list
    • dispatchForReceivers

      public <L extends LocalizationSetting, E extends EventMetadata<L>> E dispatchForReceivers(ModuleName moduleName, ModuleLocalization<L> module, E eventMetadata)
      Dispatches a message to pre-configured receivers with Folia region-aware scheduling. Ensures thread-safe execution by running in the appropriate region context.
      Type Parameters:
      L - Type of localization setting
      Parameters:
      moduleName - The name identifier for the module
      module - The module containing localization settings
      eventMetadata - Metadata containing event information and pre-configured receivers
      Returns:
      Event metadata with receiver list
    • dispatch

      public MessageSendEvent dispatch(MessageSendEvent messageSendEvent)
      Directly dispatches a pre-built message send event through the event system.
      Parameters:
      messageSendEvent - The message send event to dispatch
      Returns:
      The dispatched message send event
    • createReceivers

      public <L extends LocalizationSetting, E extends EventMetadata<L>> E createReceivers(ModuleLocalization<L> module, E eventMetadata)
      Creates and populates the receiver list for the message event based on filtering criteria. Applies player filters, range filters, and module settings checks to determine eligible receivers.
      Type Parameters:
      L - Type of localization setting
      E - Type of event metadata extending EventMetadata
      Parameters:
      module - The module containing localization settings
      eventMetadata - Metadata containing event information and filtering criteria
      Returns:
      Event metadata with populated receiver list, or original metadata if canceled
    • createReceivers

      public <L extends LocalizationSetting, E extends EventMetadata<L>> E createReceivers(ModuleName moduleName, ModuleLocalization<L> module, E eventMetadata)
      Creates and populates the receiver list with module name specification. Filters players based on multiple criteria including range, settings, and custom filters. Triggers a MessagePrepareEvent that may cancel the message if sent to Proxy.
      Type Parameters:
      L - Type of localization setting
      E - Type of event metadata extending EventMetadata
      Parameters:
      moduleName - The name identifier for the module
      module - The module containing localization settings
      eventMetadata - Metadata containing event information and filtering criteria
      Returns:
      Event metadata with populated receiver list, or original metadata if canceled
    • createMessageEvent

      public <L extends LocalizationSetting> MessageSendEvent createMessageEvent(FPlayer fReceiver, ModuleName moduleName, ModuleLocalization<L> module, EventMetadata<L> eventMetadata)
      Creates a complete message send event for a specific receiver. Builds formatted message components including main message, format wrapper, and destination subtext.
      Type Parameters:
      L - Type of localization setting
      Parameters:
      fReceiver - The player receiving the message
      moduleName - The name identifier for the module
      module - The module containing localization settings
      eventMetadata - Metadata containing event information and message content
      Returns:
      A fully constructed MessageSendEvent ready for dispatch