Package com.kamikazejam.kamicommon.text
Class MiniMessageBuilder
java.lang.Object
com.kamikazejam.kamicommon.text.MiniMessageBuilder
A cross-version MiniMessage parser and messenger.
-
Method Summary
Modifier and TypeMethodDescriptionstatic @NotNull MiniMessageBuilderfromLegacyAmpersand(@NotNull ConfigurationSection section, @NotNull String key) Parses a legacy ampersand (&) formatted message from the config located at the provided key.
BothStringandList<String>are supported types for the config value.
For list messages, the returnedMiniMessageBuilderwill 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.static @NotNull MiniMessageBuilderfromLegacyAmpersand(@NotNull String legacy) Parses a legacy ampersand (&) string into aMiniMessageBuildercontaining the parsed line.static @NotNull MiniMessageBuilderfromLegacyAmpersand(@NotNull String... legacyLines) Parses a series of legacy ampersand (&) strings (treated as individual lines) into aMiniMessageBuildercontaining each parsed line.static @NotNull MiniMessageBuilderfromLegacyAmpersand(@NotNull Collection<String> legacyLines) Parses a collection of legacy ampersand (&) strings (treated as individual lines) into aMiniMessageBuildercontaining each parsed line.static @NotNull MiniMessageBuilderfromLegacyAmpersand(ConfigurationSection section, @NotNull String key) Parses a legacy ampersand (&) formatted message from the config located at the provided key.
BothStringandList<String>are supported types for the config value.
For list messages, the returnedMiniMessageBuilderwill 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.static @NotNull MiniMessageBuilderfromLegacySection(@NotNull ConfigurationSection section, @NotNull String key) Parses a legacy section (§) formatted message from the config located at the provided key.
BothStringandList<String>are supported types for the config value.
For list messages, the returnedMiniMessageBuilderwill 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.static @NotNull MiniMessageBuilderfromLegacySection(@NotNull String legacy) Parses a legacy section (§) string into aMiniMessageBuildercontaining the parsed line.static @NotNull MiniMessageBuilderfromLegacySection(@NotNull String... legacyLines) Parses a series of legacy section (§) strings (treated as individual lines) into aMiniMessageBuildercontaining each parsed line.static @NotNull MiniMessageBuilderfromLegacySection(@NotNull Collection<String> legacyLines) Parses a collection of legacy section (§) strings (treated as individual lines) into aMiniMessageBuildercontaining each parsed line.static @NotNull MiniMessageBuilderfromLegacySection(ConfigurationSection section, @NotNull String key) Parses a legacy section (§) formatted message from the config located at the provided key.
BothStringandList<String>are supported types for the config value.
For list messages, the returnedMiniMessageBuilderwill 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.static @NotNull MiniMessageBuilderfromMiniMessage(@NotNull ConfigurationSection section, @NotNull String key) Parses a MiniMessage formatted message from the config located at the provided key.
BothStringandList<String>are supported types for the config value.
For list messages, the returnedMiniMessageBuilderwill 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 §).static @NotNull MiniMessageBuilderfromMiniMessage(@NotNull String miniMessage) Parses a MiniMessage string into aMiniMessageBuildercontaining the parsed line.static @NotNull MiniMessageBuilderfromMiniMessage(@NotNull String... miniMessageLines) Parses a series of MiniMessage strings (treated as individual lines) into aMiniMessageBuildercontaining each parsed line.static @NotNull MiniMessageBuilderfromMiniMessage(@NotNull Collection<String> miniMessageLines) Parses a collection of MiniMessage strings (treated as individual lines) into aMiniMessageBuildercontaining each parsed line.static @NotNull MiniMessageBuilderfromMiniMessage(ConfigurationSection section, @NotNull String key) Parses a MiniMessage formatted message from the config located at the provided key.
BothStringandList<String>are supported types for the config value.
For list messages, the returnedMiniMessageBuilderwill 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 §).static @NotNull MiniMessageBuilderfromStringParser(@NotNull ConfigurationSection section, @NotNull String key) Parses an unknown string (formatted message) from the config located at the provided key.
BothStringandList<String>are supported types for the config value.
For list messages, the returnedMiniMessageBuilderwill contain each list entry as a separate line (component).
(Single String config values are returned as a builder with only one line.)
This conversion is handled byColoredStringParserwhich attempts to support section codes, mini message, and legacy ampersand codes.static @NotNull MiniMessageBuilderfromStringParser(@NotNull String text) Parses an unknown format string into aMiniMessageBuildercontaining the parsed line.static @NotNull MiniMessageBuilderfromStringParser(@NotNull String... miniMessageLines) Parses a series of unknown format strings (treated as individual lines) into aMiniMessageBuildercontaining each parsed line.static @NotNull MiniMessageBuilderfromStringParser(@NotNull Collection<String> miniMessageLines) Parses a collection of unknown format strings (treated as individual lines) into aMiniMessageBuildercontaining each parsed line.static @NotNull MiniMessageBuilderfromStringParser(ConfigurationSection section, @NotNull String key) Parses an unknown string (formatted message) from the config located at the provided key.
BothStringandList<String>are supported types for the config value.
For list messages, the returnedMiniMessageBuilderwill contain each list entry as a separate line (component).
(Single String config values are returned as a builder with only one line.)
This conversion is handled byColoredStringParserwhich attempts to support section codes, mini message, and legacy ampersand codes.@NotNull MiniMessageBuilderreplace(@NotNull String target, @NotNull VersionedComponent replacement) Performs a plain text replacement on all lines in this builder.
The replacement is the provided component, mapped to MiniMessage and inserted in as the replacement text.@NotNull MiniMessageBuilderPerforms a plain text replacement on all lines in this builder.@NotNull MiniMessageBuilderreplaceLine(@NotNull String target, @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.@NotNull MiniMessageBuilderreplaceLine(@NotNull String target, @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.@NotNull MiniMessageBuilderreplaceLineContains(@NotNull String target, @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.@NotNull MiniMessageBuilderreplaceLineContains(@NotNull String target, @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.@NotNull MiniMessageBuildersend(@NotNull List<CommandSender> senders) Sends the message to a CommandSender@NotNull MiniMessageBuildersend(@NotNull CommandSender sender) Sends the message to a CommandSender@NotNull MiniMessageBuildersend(@NotNull CommandSender... senders) Sends the message to a CommandSender@NotNull MiniMessageBuildersendAll()Sends the message to all Online Players (and console)@NotNull MiniMessageBuildersendAll(boolean consoleToo) Sends the message to all Online Players
-
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.
-
replace
@NotNull public @NotNull MiniMessageBuilder replace(@NotNull @NotNull String target, @NotNull @NotNull VersionedComponent replacement) Performs a plain text replacement on all lines in this builder.
The replacement is the provided component, mapped to MiniMessage and inserted in as the replacement text.- 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
Sends the message to a CommandSender- Parameters:
sender- The CommandSender to send the message to- Returns:
- The MessageBuilder instance (for chaining)
-
send
Sends the message to a CommandSender- Parameters:
senders- The CommandSender to send the message to- Returns:
- The MessageBuilder instance (for chaining)
-
send
Sends the message to a CommandSender- Parameters:
senders- The CommandSender to send the message to- Returns:
- The MessageBuilder instance (for chaining)
-
sendAll
Sends the message to all Online Players- Parameters:
consoleToo- If true, the message will also be sent to the console
-
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 aMiniMessageBuildercontaining the parsed line.
Does not convert or support legacy codes (& or §). SeefromLegacyAmpersand(String)andfromLegacySection(String)for those. -
fromLegacyAmpersand
@NotNull public static @NotNull MiniMessageBuilder fromLegacyAmpersand(@NotNull @NotNull String legacy) Parses a legacy ampersand (&) string into aMiniMessageBuildercontaining the parsed line.
Will ignore section (§) codes. SeefromLegacySection(String)for that. -
fromLegacySection
@NotNull public static @NotNull MiniMessageBuilder fromLegacySection(@NotNull @NotNull String legacy) Parses a legacy section (§) string into aMiniMessageBuildercontaining the parsed line.
Will ignore ampersand (&) codes. SeefromLegacyAmpersand(String)for that. -
fromStringParser
Parses an unknown format string into aMiniMessageBuildercontaining the parsed line.
This conversion is handled byColoredStringParserwhich attempts to support section codes, mini message, and legacy ampersand codes.- See Also:
-
fromMiniMessage
@NotNull public static @NotNull MiniMessageBuilder fromMiniMessage(@NotNull @NotNull Collection<String> miniMessageLines) Parses a collection of MiniMessage strings (treated as individual lines) into aMiniMessageBuildercontaining each parsed line.
Does not convert or support legacy codes (& or §). SeefromLegacyAmpersand(Collection)andfromLegacySection(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 aMiniMessageBuildercontaining each parsed line.
Does not convert or support legacy codes (& or §). SeefromLegacyAmpersand(String...)andfromLegacySection(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 aMiniMessageBuildercontaining each parsed line.
Will ignore section (§) codes. SeefromLegacySection(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 aMiniMessageBuildercontaining each parsed line.
Will ignore section (§) codes. SeefromLegacySection(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 aMiniMessageBuildercontaining each parsed line.
Will ignore ampersand (&) codes. SeefromLegacyAmpersand(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 aMiniMessageBuildercontaining each parsed line.
Will ignore ampersand (&) codes. SeefromLegacyAmpersand(String...)for that. -
fromStringParser
@NotNull public static @NotNull MiniMessageBuilder fromStringParser(@NotNull @NotNull Collection<String> miniMessageLines) Parses a collection of unknown format strings (treated as individual lines) into aMiniMessageBuildercontaining each parsed line.
This conversion is handled byColoredStringParserwhich attempts to support section codes, mini message, and legacy ampersand codes.- See Also:
-
fromStringParser
@NotNull public static @NotNull MiniMessageBuilder fromStringParser(@NotNull @NotNull String... miniMessageLines) Parses a series of unknown format strings (treated as individual lines) into aMiniMessageBuildercontaining each parsed line.
This conversion is handled byColoredStringParserwhich attempts to support section codes, mini message, and legacy ampersand codes.- See Also:
-
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.
BothStringandList<String>are supported types for the config value.
For list messages, the returnedMiniMessageBuilderwill 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 §). SeefromLegacyAmpersand(org.bukkit.configuration.ConfigurationSection, String)andfromLegacySection(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.
BothStringandList<String>are supported types for the config value.
For list messages, the returnedMiniMessageBuilderwill 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. SeefromLegacySection(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.
BothStringandList<String>are supported types for the config value.
For list messages, the returnedMiniMessageBuilderwill 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. SeefromLegacyAmpersand(org.bukkit.configuration.ConfigurationSection, String)for that. -
fromStringParser
@NotNull public static @NotNull MiniMessageBuilder fromStringParser(@NotNull ConfigurationSection section, @NotNull @NotNull String key) Parses an unknown string (formatted message) from the config located at the provided key.
BothStringandList<String>are supported types for the config value.
For list messages, the returnedMiniMessageBuilderwill contain each list entry as a separate line (component).
(Single String config values are returned as a builder with only one line.)
This conversion is handled byColoredStringParserwhich attempts to support section codes, mini message, and legacy ampersand codes.- See Also:
-
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.
BothStringandList<String>are supported types for the config value.
For list messages, the returnedMiniMessageBuilderwill 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 §). SeefromLegacyAmpersand(ConfigurationSection, String)andfromLegacySection(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.
BothStringandList<String>are supported types for the config value.
For list messages, the returnedMiniMessageBuilderwill 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. SeefromLegacySection(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.
BothStringandList<String>are supported types for the config value.
For list messages, the returnedMiniMessageBuilderwill 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. SeefromLegacyAmpersand(ConfigurationSection, String)for that. -
fromStringParser
@NotNull public static @NotNull MiniMessageBuilder fromStringParser(@NotNull @NotNull ConfigurationSection section, @NotNull @NotNull String key) Parses an unknown string (formatted message) from the config located at the provided key.
BothStringandList<String>are supported types for the config value.
For list messages, the returnedMiniMessageBuilderwill contain each list entry as a separate line (component).
(Single String config values are returned as a builder with only one line.)
This conversion is handled byColoredStringParserwhich attempts to support section codes, mini message, and legacy ampersand codes.- See Also:
-