Enum Class MessageExample

java.lang.Object
java.lang.Enum<MessageExample>
one.tranic.t.base.message.MessageExample
All Implemented Interfaces:
Serializable, Comparable<MessageExample>, Constable

public enum MessageExample extends Enum<MessageExample>
The MessageExample enum defines a set of predefined message keys used for retrieving and formatting text-based messages.

It is only used as your own MessageKey reference. Please do not use it directly in your own project. You should copy it and add your own keys.

Each enum constant is associated with a unique key, which serves as the identifier for a specific message.

  • Enum Constant Details

  • Method Details

    • values

      public static MessageExample[] values()
      Returns an array containing the constants of this enum class, in the order they are declared.
      Returns:
      an array containing the constants of this enum class, in the order they are declared
    • valueOf

      public static MessageExample valueOf(String name)
      Returns the enum constant of this class with the specified name. The string must match exactly an identifier used to declare an enum constant in this class. (Extraneous whitespace characters are not permitted.)
      Parameters:
      name - the name of the enum constant to be returned.
      Returns:
      the enum constant with the specified name
      Throws:
      IllegalArgumentException - if this enum class has no constant with the specified name
      NullPointerException - if the argument is null
    • getKey

      public String getKey()
      Retrieves the key associated with this MessageExample instance.
      Returns:
      the key as a String that uniquely identifies this message
    • format

      public net.kyori.adventure.text.Component format(Object... args)
      Formats a message using the provided arguments and resolves placeholders.

      If no arguments are provided, it simply retrieves and returns the message associated with the current object key.

      Parameters:
      args - the arguments used to populate placeholders in the message. This can be an array of MessageFormat or MessageFormatString objects.
      Returns:
      a Component representing the formatted message with resolved placeholders.
      Throws:
      IllegalArgumentException - if the arguments are not of type MessageFormat[] or MessageFormatString[].
    • getValue

      public String getValue()
      Retrieves the message string associated with this enum constant.

      The message is fetched using the key corresponding to the enum constant from the internal messages map, and is guaranteed to be non-null.

      Returns:
      the non-null message string associated with the enum constant
      Throws:
      NullPointerException - if no message is found for the enum constant
    • formatString

      public String formatString(Object... args)
      Formats a string representation of a message using specified arguments.

      The method utilizes the legacy section serialization format to convert the formatted Component returned by the format method into a string.

      Parameters:
      args - the arguments to be used for formatting the message. The arguments can be of various types, including MessageFormat or MessageFormatString arrays.
      Returns:
      the serialized string representation of the formatted message
    • formatBungee

      public net.md_5.bungee.api.chat.BaseComponent[] formatBungee(Object... args)
      Converts the given arguments into an array of BungeeCord BaseComponents using legacy text formatting, but only if the current platform is BungeeCord.
      Parameters:
      args - the arguments to format into a legacy text string and convert to BungeeCord BaseComponents
      Returns:
      an array of BungeeCord BaseComponents representing the formatted text, or null if the current platform is not BungeeCord