Record Class Messages

java.lang.Object
java.lang.Record
dev.despical.pixelpainter.config.Messages
Record Components:
templates - message keys mapped to MiniMessage templates

public record Messages(Map<String,String> templates) extends Record
Loads Adventure MiniMessage templates and renders configured command output.

Bundled defaults fill absent keys; configured values must be strings with valid strict MiniMessage syntax. The template map is copied before publication. Templates use {name} placeholders: ordinary values are inserted as literal text, while explicit Adventure components keep their formatting and interactions. Players receive centered panels for keys that have a -title companion; the console receives the same text unformatted.

  • Constructor Summary

    Constructors
    Constructor
    Description
    Messages(Map<String,String> templates)
    Copies templates so caller mutations cannot alter the active messages.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    actionBar(org.bukkit.command.CommandSender sender, String key, Object... replacements)
    Shows a message in a player's action bar; the console receives it as plain text.
    final boolean
    Indicates whether some other object is "equal to" this one.
    net.kyori.adventure.text.Component
    get(String key, Object... replacements)
    Renders a template with placeholders.
    boolean
    has(String key)
    Checks whether a message exists.
    final int
    Returns a hash code value for this object.
    static Messages
    load(Path file)
    Merges the configured file with defaults and validates every template.
    void
    panel(org.bukkit.command.CommandSender sender, String key, net.kyori.adventure.text.Component action, Object... replacements)
    Renders a centered title and body with an optional action row.
    void
    reply(org.bukkit.command.CommandSender sender, net.kyori.adventure.text.Component component)
    Delivers a component to a player, or unformatted non-empty lines to the console.
    void
    send(org.bukkit.command.CommandSender sender, String key, Object... replacements)
    Sends a message, as a centered panel when it has a -title companion.
    Returns the value of the templates record component.
    text(String key, Object... replacements)
    Renders a template as plain text.
    final String
    Returns a string representation of this record class.

    Methods inherited from class Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait
  • Constructor Details

    • Messages

      public Messages(Map<String,String> templates)
      Copies templates so caller mutations cannot alter the active messages.
  • Method Details

    • load

      public static Messages load(Path file) throws Exception
      Merges the configured file with defaults and validates every template.
      Parameters:
      file - message YAML file
      Returns:
      copied and validated templates
      Throws:
      Exception - if the file, value types or MiniMessage syntax are invalid
    • get

      public net.kyori.adventure.text.Component get(String key, Object... replacements)
      Renders a template with placeholders.
      Parameters:
      key - message key
      replacements - alternating placeholder names and values; a Component keeps its interactions, any other value is inserted as literal text
      Returns:
      rendered Adventure component
      Throws:
      IllegalArgumentException - if the key is unknown or the pairs are incomplete
    • text

      public String text(String key, Object... replacements)
      Renders a template as plain text.
      Parameters:
      key - message key
      replacements - alternating placeholder names and values
      Returns:
      rendered text without formatting or interactions
    • has

      public boolean has(String key)
      Checks whether a message exists.
      Parameters:
      key - message key
      Returns:
      whether the template is defined
    • reply

      public void reply(org.bukkit.command.CommandSender sender, net.kyori.adventure.text.Component component)
      Delivers a component to a player, or unformatted non-empty lines to the console.
      Parameters:
      sender - command audience
      component - rendered message
    • actionBar

      public void actionBar(org.bukkit.command.CommandSender sender, String key, Object... replacements)
      Shows a message in a player's action bar; the console receives it as plain text.
      Parameters:
      sender - command audience
      key - message key
      replacements - alternating placeholder names and values
    • send

      public void send(org.bukkit.command.CommandSender sender, String key, Object... replacements)
      Sends a message, as a centered panel when it has a -title companion.
      Parameters:
      sender - command audience
      key - message key
      replacements - alternating placeholder names and values
    • panel

      public void panel(org.bukkit.command.CommandSender sender, String key, net.kyori.adventure.text.Component action, Object... replacements)
      Renders a centered title and body with an optional action row.
      Parameters:
      sender - command audience
      key - message key whose -title companion is the heading
      action - optional action component; Component.empty() omits it
      replacements - alternating placeholder names and values
    • toString

      public final String toString()
      Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • hashCode

      public final int hashCode()
      Returns a hash code value for this object. The value is derived from the hash code of each of the record components.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • equals

      public final boolean equals(Object o)
      Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. All components in this record class are compared with Objects::equals(Object,Object).
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.
    • templates

      public Map<String,String> templates()
      Returns the value of the templates record component.
      Returns:
      the value of the templates record component