Class MessageContext

java.lang.Object
org.nuclos.api.context.MessageContext

public class MessageContext extends Object
MessageContext adds support for sending commands to the client.
  • Constructor Details

    • MessageContext

      MessageContext()
  • Method Details

    • setMessageContextService

      public void setMessageContextService(MessageContextService service)
    • sendMessage

      public static void sendMessage(String message)
      Sends a message to the client.
      Parameters:
      message - The message text to send
    • sendMessage

      public static void sendMessage(boolean translateAndRememberWithGeneratedKey, String message)
      Sends a message to the client.
      Parameters:
      translateAndRememberWithGeneratedKey - If true, translate and remember with a generated key
      message - The message text to send
    • sendMessage

      public static void sendMessage(boolean translateAndRememberWithGeneratedKey, String message, Locale sourceLocale)
      Sends a message to the client with translation option for a specific locale.
      Parameters:
      translateAndRememberWithGeneratedKey - If true, translate and remember with a generated key
      message - The message text to send
      sourceLocale - The locale of the text
    • sendMessage

      public static void sendMessage(boolean translateAndRememberWithGeneratedKey, String message, NuclosLocale sourceLocale)
      Sends a message to the client with translation option for a specific Nuclos locale.
      Parameters:
      translateAndRememberWithGeneratedKey - If true, translate and remember with a generated key
      message - The message text to send
      sourceLocale - The NuclosLocale of the text
    • sendMessageDoNotTranslate

      public static void sendMessageDoNotTranslate(String message)
      Sends a message to the client without translation.
      Parameters:
      message - The message text to send without translation
    • sendMessage

      public static void sendMessage(DoNotTranslate message)
      Sends a message to the client without translation.
      Parameters:
      message - The message to send without translation
    • sendMessage

      public static void sendMessage(String message, String title)
      Sends a message with a title to the client.
      Parameters:
      message - The message text to send
      title - The title for the message
    • sendMessage

      public static void sendMessage(boolean translateAndRememberWithGeneratedKey, String message, String title)
      Sends a message with a title to the client.
      Parameters:
      translateAndRememberWithGeneratedKey - If true, translate and remember with a generated key
      message - The message text to send
      title - The title for the message
    • sendMessage

      public static void sendMessage(boolean translateAndRememberWithGeneratedKey, String message, String title, Locale sourceLocale)
      Sends a message with a title to the client with translation option for a specific locale.
      Parameters:
      translateAndRememberWithGeneratedKey - If true, translate and remember with a generated key
      message - The message text to send
      title - The title for the message
      sourceLocale - The locale of the text
    • sendMessageDoNotTranslate

      public static void sendMessageDoNotTranslate(String message, String title)
      Sends a message with a title to the client without translation.
      Parameters:
      message - The message text to send without translation
      title - The title for the message without translation
    • sendMessage

      public static void sendMessage(DoNotTranslate message, DoNotTranslate title)
      Sends a message with a title to the client without translation.
      Parameters:
      message - The message to send without translation
      title - The title for the message without translation
    • sendMessage

      public static void sendMessage(String key, String message, String title)
      Sends a message with a title to the client using a specific localization key.
      Parameters:
      key - The localization key to use
      message - The message text to send
      title - The title for the message
    • sendMessage

      public static void sendMessage(String key, String message, String title, Locale sourceLocale)
      Sends a message with a title to the client using a specific localization key and locale.
      Parameters:
      key - The localization key to use
      message - The message text to send
      title - The title for the message
      sourceLocale - The locale of the text
    • sendMessage

      public static void sendMessage(String key, String message, String title, NuclosLocale sourceLocale)
      Sends a message with a title to the client using a specific localization key and Nuclos locale.
      Parameters:
      key - The localization key to use
      message - The message text to send
      title - The title for the message
      sourceLocale - The NuclosLocale of the text
    • sendProgress

      public static void sendProgress(int percent, String message)
      Sends a progress update to the client.
      Parameters:
      percent - The progress percentage (0-100)
      message - The progress message text
    • sendProgressDoNotTranslate

      public static void sendProgressDoNotTranslate(int percent, String message)
      Sends a progress update to the client without translation.
      Parameters:
      percent - The progress percentage (0-100)
      message - The progress message text without translation
    • sendProgress

      public static void sendProgress(int percent, DoNotTranslate message)
      Sends a progress update to the client without translation.
      Parameters:
      percent - The progress percentage (0-100)
      message - The progress message without translation
    • sendProgress

      public static void sendProgress(int percent, boolean translateAndRememberWithGeneratedKey, String message, Locale sourceLocale)
      Sends a progress update to the client with translation option for a specific locale.
      Parameters:
      percent - The progress percentage (0-100)
      translateAndRememberWithGeneratedKey - If true, translate and remember with a generated key
      message - The progress message text
      sourceLocale - The locale of the text
    • sendProgress

      public static void sendProgress(int percent, boolean translateAndRememberWithGeneratedKey, String message, NuclosLocale sourceLocale)
      Sends a progress update to the client with translation option for a specific Nuclos locale.
      Parameters:
      percent - The progress percentage (0-100)
      translateAndRememberWithGeneratedKey - If true, translate and remember with a generated key
      message - The progress message text
      sourceLocale - The NuclosLocale of the text
    • sendProgress

      public static void sendProgress(int percent, String key, String message, Locale sourceLocale)
      Sends a progress update to the client using a specific localization key and locale.
      Parameters:
      percent - The progress percentage (0-100)
      key - The localization key to use
      message - The progress message text
      sourceLocale - The locale of the text
    • sendProgress

      public static void sendProgress(int percent, String key, String message, NuclosLocale sourceLocale)
      Sends a progress update to the client using a specific localization key and Nuclos locale.
      Parameters:
      percent - The progress percentage (0-100)
      key - The localization key to use
      message - The progress message text
      sourceLocale - The NuclosLocale of the text
    • sendClose

      public static void sendClose()
      Sends an CloseCommand to the client.
    • sendCommand

      public static void sendCommand(Command command)
      Sends the given command to the client.
      Parameters:
      command -
    • withMessageArgs

      public static MessageContext.WithArgs withMessageArgs(Object... messageArgs)
      Creates a new WithArgs instance with the specified message arguments. Allows for fluent method chaining when sending messages with arguments.
      Parameters:
      messageArgs - The arguments to use for message formatting
      Returns:
      A new WithArgs instance
    • withTitleArgs

      public static MessageContext.WithArgs withTitleArgs(Object... titleArgs)
      Creates a new WithArgs instance with the specified title arguments. Allows for fluent method chaining when sending messages with arguments.
      Parameters:
      titleArgs - The arguments to use for title formatting
      Returns:
      A new WithArgs instance