Class MiniMessageBuilder

java.lang.Object
com.kamikazejam.kamicommon.text.MiniMessageBuilder

public class MiniMessageBuilder extends Object
A cross-version MiniMessage parser and messenger.
  • Method Details

    • replace

      @NotNull public @NotNull MiniMessageBuilder replace(@NotNull @NotNull String target, @NotNull @NotNull String replacement)
      Performs a plain text replacement on all lines in this builder.
      Returns:
      This builder, for chaining.
    • replaceLine

      @NotNull public @NotNull MiniMessageBuilder replaceLine(@NotNull @NotNull String target, @NotNull @NotNull List<VersionedComponent> replacement)
      Performs a plain text line replacement for all lines matching the target in this builder.
      More specifically, every line that matches the target (case-insensitive, color-stripped) will be replaced with the provided replacement lines.
      Returns:
      This builder, for chaining.
      See Also:
    • replaceLine

      @NotNull public @NotNull MiniMessageBuilder replaceLine(@NotNull @NotNull String target, @NotNull @NotNull List<VersionedComponent> replacement, boolean caseSensitive)
      Performs a plain text line replacement for all lines matching the target in this builder.
      More specifically, every line that matches the target (color-stripped) will be replaced with the provided replacement lines.
      Parameters:
      caseSensitive - If true, the match will be case-sensitive. If false, it will be case-insensitive.
      Returns:
      This builder, for chaining.
    • replaceLineContains

      @NotNull public @NotNull MiniMessageBuilder replaceLineContains(@NotNull @NotNull String target, @NotNull @NotNull List<VersionedComponent> replacement)
      Performs a plain text line replacement for all lines containing the target in this builder.
      More specifically, every line that contains the target (case-insensitive, color-stripped) will be replaced with the provided replacement lines.
      Returns:
      This builder, for chaining.
      See Also:
    • replaceLineContains

      @NotNull public @NotNull MiniMessageBuilder replaceLineContains(@NotNull @NotNull String target, @NotNull @NotNull List<VersionedComponent> replacement, boolean caseSensitive)
      Performs a plain text line replacement for all lines containing the target in this builder.
      More specifically, every line that contains the target (color-stripped) will be replaced with the provided replacement lines.
      Parameters:
      caseSensitive - If true, the match will be case-sensitive. If false, it will be case-insensitive.
      Returns:
      This builder, for chaining.
    • send

      @NotNull public @NotNull MiniMessageBuilder send(@NotNull @NotNull CommandSender sender)
      Sends the message to a CommandSender
      Parameters:
      sender - The CommandSender to send the message to
      Returns:
      The MessageBuilder instance (for chaining)
    • send

      @NotNull public @NotNull MiniMessageBuilder send(@NotNull @NotNull CommandSender... senders)
      Sends the message to a CommandSender
      Parameters:
      senders - The CommandSender to send the message to
      Returns:
      The MessageBuilder instance (for chaining)
    • send

      @NotNull public @NotNull MiniMessageBuilder send(@NotNull @NotNull List<CommandSender> senders)
      Sends the message to a CommandSender
      Parameters:
      senders - The CommandSender to send the message to
      Returns:
      The MessageBuilder instance (for chaining)
    • sendAll

      @NotNull public @NotNull MiniMessageBuilder sendAll(boolean consoleToo)
      Sends the message to all Online Players
      Parameters:
      consoleToo - If true, the message will also be sent to the console
    • sendAll

      @NotNull public @NotNull MiniMessageBuilder sendAll()
      Sends the message to all Online Players (and console)
    • fromMiniMessage

      @NotNull public static @NotNull MiniMessageBuilder fromMiniMessage(@NotNull @NotNull String miniMessage)
      Parses a MiniMessage string into a MiniMessageBuilder containing the parsed line.
      Does not convert or support legacy codes (& or §). See fromLegacyAmpersand(String) and fromLegacySection(String) for those.
    • fromLegacyAmpersand

      @NotNull public static @NotNull MiniMessageBuilder fromLegacyAmpersand(@NotNull @NotNull String legacy)
      Parses a legacy ampersand (&) string into a MiniMessageBuilder containing the parsed line.
      Will ignore section (§) codes. See fromLegacySection(String) for that.
    • fromLegacySection

      @NotNull public static @NotNull MiniMessageBuilder fromLegacySection(@NotNull @NotNull String legacy)
      Parses a legacy section (§) string into a MiniMessageBuilder containing the parsed line.
      Will ignore ampersand (&) codes. See fromLegacyAmpersand(String) for that.
    • fromMiniMessage

      @NotNull public static @NotNull MiniMessageBuilder fromMiniMessage(@NotNull @NotNull Collection<String> miniMessageLines)
      Parses a collection of MiniMessage strings (treated as individual lines) into a MiniMessageBuilder containing each parsed line.
      Does not convert or support legacy codes (& or §). See fromLegacyAmpersand(Collection) and fromLegacySection(Collection) for those.
    • fromMiniMessage

      @NotNull public static @NotNull MiniMessageBuilder fromMiniMessage(@NotNull @NotNull String... miniMessageLines)
      Parses a series of MiniMessage strings (treated as individual lines) into a MiniMessageBuilder containing each parsed line.
      Does not convert or support legacy codes (& or §). See fromLegacyAmpersand(String...) and fromLegacySection(String...) for those.
    • fromLegacyAmpersand

      @NotNull public static @NotNull MiniMessageBuilder fromLegacyAmpersand(@NotNull @NotNull Collection<String> legacyLines)
      Parses a collection of legacy ampersand (&) strings (treated as individual lines) into a MiniMessageBuilder containing each parsed line.
      Will ignore section (§) codes. See fromLegacySection(Collection) for that.
    • fromLegacyAmpersand

      @NotNull public static @NotNull MiniMessageBuilder fromLegacyAmpersand(@NotNull @NotNull String... legacyLines)
      Parses a series of legacy ampersand (&) strings (treated as individual lines) into a MiniMessageBuilder containing each parsed line.
      Will ignore section (§) codes. See fromLegacySection(String...) for that.
    • fromLegacySection

      @NotNull public static @NotNull MiniMessageBuilder fromLegacySection(@NotNull @NotNull Collection<String> legacyLines)
      Parses a collection of legacy section (§) strings (treated as individual lines) into a MiniMessageBuilder containing each parsed line.
      Will ignore ampersand (&) codes. See fromLegacyAmpersand(Collection) for that.
    • fromLegacySection

      @NotNull public static @NotNull MiniMessageBuilder fromLegacySection(@NotNull @NotNull String... legacyLines)
      Parses a series of legacy section (§) strings (treated as individual lines) into a MiniMessageBuilder containing each parsed line.
      Will ignore ampersand (&) codes. See fromLegacyAmpersand(String...) for that.
    • fromMiniMessage

      @NotNull public static @NotNull MiniMessageBuilder fromMiniMessage(@NotNull ConfigurationSection section, @NotNull @NotNull String key)
      Parses a MiniMessage formatted message from the config located at the provided key.

      Both String and List<String> are supported types for the config value.
      For list messages, the returned MiniMessageBuilder will contain each list entry as a separate line (component).
      (Single String config values are returned as a builder with only one line.)

      Does not convert or support legacy codes (& or §). See fromLegacyAmpersand(org.bukkit.configuration.ConfigurationSection, String) and fromLegacySection(ConfigurationSection, String) for those.
    • fromLegacyAmpersand

      @NotNull public static @NotNull MiniMessageBuilder fromLegacyAmpersand(@NotNull ConfigurationSection section, @NotNull @NotNull String key)
      Parses a legacy ampersand (&) formatted message from the config located at the provided key.

      Both String and List<String> are supported types for the config value.
      For list messages, the returned MiniMessageBuilder will contain each list entry as a separate line (component).
      (Single String config values are returned as a builder with only one line.)

      Will ignore section (§) codes. See fromLegacySection(org.bukkit.configuration.ConfigurationSection, String) for that.
    • fromLegacySection

      @NotNull public static @NotNull MiniMessageBuilder fromLegacySection(@NotNull ConfigurationSection section, @NotNull @NotNull String key)
      Parses a legacy section (§) formatted message from the config located at the provided key.

      Both String and List<String> are supported types for the config value.
      For list messages, the returned MiniMessageBuilder will contain each list entry as a separate line (component).
      (Single String config values are returned as a builder with only one line.)

      Will ignore ampersand (&) codes. See fromLegacyAmpersand(org.bukkit.configuration.ConfigurationSection, String) for that.
    • fromMiniMessage

      @NotNull public static @NotNull MiniMessageBuilder fromMiniMessage(@NotNull @NotNull ConfigurationSection section, @NotNull @NotNull String key)
      Parses a MiniMessage formatted message from the config located at the provided key.

      Both String and List<String> are supported types for the config value.
      For list messages, the returned MiniMessageBuilder will contain each list entry as a separate line (component).
      (Single String config values are returned as a builder with only one line.)

      Does not convert or support legacy codes (& or §). See fromLegacyAmpersand(ConfigurationSection, String) and fromLegacySection(ConfigurationSection, String) for those.
    • fromLegacyAmpersand

      @NotNull public static @NotNull MiniMessageBuilder fromLegacyAmpersand(@NotNull @NotNull ConfigurationSection section, @NotNull @NotNull String key)
      Parses a legacy ampersand (&) formatted message from the config located at the provided key.

      Both String and List<String> are supported types for the config value.
      For list messages, the returned MiniMessageBuilder will contain each list entry as a separate line (component).
      (Single String config values are returned as a builder with only one line.)

      Will ignore section (§) codes. See fromLegacySection(ConfigurationSection, String) for that.
    • fromLegacySection

      @NotNull public static @NotNull MiniMessageBuilder fromLegacySection(@NotNull @NotNull ConfigurationSection section, @NotNull @NotNull String key)
      Parses a legacy section (§) formatted message from the config located at the provided key.

      Both String and List<String> are supported types for the config value.
      For list messages, the returned MiniMessageBuilder will contain each list entry as a separate line (component).
      (Single String config values are returned as a builder with only one line.)

      Will ignore ampersand (&) codes. See fromLegacyAmpersand(ConfigurationSection, String) for that.