Class Message

java.lang.Object
one.tranic.t.base.message.Message

public class Message extends Object
  • Constructor Details

    • Message

      public Message()
  • Method Details

    • getMessageImpl

      public static MessageImpl getMessageImpl()
    • setMessageImpl

      public static void setMessageImpl(MessageImpl messageImpl)
    • getMessages

      public static Map<Object,String> getMessages()
      Retrieves the map of messages associated with their respective keys.
      Returns:
      a map where the keys are of type T and the values are message strings
    • getSupportedLocales

      public static List<Locale> getSupportedLocales()
      Retrieves a list of supported locales.
      Returns:
      a list of Locale objects representing the supported locales
    • setMessage

      public static void setMessage(Object key, String message)
      Sets a message for the given key.
      Parameters:
      key - the key associated with the message; must not be null
      message - the message to be associated with the key; must not be null
    • getMessage

      public static String getMessage(Object key)
      Retrieves the message associated with the provided key from the internal messages map.
      Parameters:
      key - the key whose associated message is to be retrieved; must not be null
      Returns:
      the message string associated with the specified key, or null if no message is found
    • loadAllMessage

      public static void loadAllMessage(@NotNull @NotNull Object object)
    • reloadMessages

      public static void reloadMessages()
    • registerLocale

      public boolean registerLocale(Locale locale)
      Registers a new locale to the list of supported locales.
      Parameters:
      locale - the locale to be registered; must not be null
      Returns:
      true if the locale was successfully added to the list of supported locales, false if the locale is already present in the list
    • isSupportedLocale

      public boolean isSupportedLocale(Locale locale)
      Checks if the specified locale is supported.
      Parameters:
      locale - the Locale to be checked; must not be null
      Returns:
      true if the specified locale is supported, false otherwise
    • resetMessages

      public void resetMessages()
      Clears all the messages stored in the internal messages map.

      This method removes all key-value pairs from the map used to store messages, effectively resetting it to an empty state. It is typically used when a fresh start or reloading of messages is required.

    • resetSupportedLocales

      public void resetSupportedLocales()
      Clears all currently supported locales from the list of registered locales. This method effectively resets the state of supported locales by removing all previously added entries from the internal list.

      It is useful in scenarios where a complete reconfiguration or reset of supported locales is required.

    • toString

      public String toString(@NotNull @NotNull net.kyori.adventure.text.Component component)
      Converts a Component into its string representation using the legacy section serialization format.
      Parameters:
      component - the Component to be serialized; must not be null
      Returns:
      the serialized string representation of the given Component
    • toBaseComponent

      public net.md_5.bungee.api.chat.BaseComponent[] toBaseComponent(@NotNull @NotNull String message)
      Converts a legacy text string into an array of BaseComponent objects. If the current platform is not BungeeCord, the method returns null.
      Parameters:
      message - the legacy text string to be converted; must not be null
      Returns:
      an array of BaseComponent objects representing the converted text, or null if the platform is not BungeeCord
    • toBaseComponent

      public net.md_5.bungee.api.chat.BaseComponent[] toBaseComponent(@NotNull @NotNull net.kyori.adventure.text.Component component)
      Converts a Component to an array of BaseComponent.

      This method leverages the toString(Component) method to serialize the input Component into a legacy string format and then transforms it into BungeeCord's Component array representation.

      Parameters:
      component - The Component to be converted. Must not be null.
      Returns:
      An array of BaseComponent representing the provided Component, or null if a non-BungeeCord platform is detected.