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 MiniMessageBuilder
fromLegacyAmpersand
(@NotNull ConfigurationSection section, @NotNull String key) Parses a legacy ampersand (&) formatted message from the config located at the provided key.
BothString
andList<String>
are supported types for the config value.
For list messages, the returnedMiniMessageBuilder
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.static @NotNull MiniMessageBuilder
fromLegacyAmpersand
(@NotNull String legacy) Parses a legacy ampersand (&) string into aMiniMessageBuilder
containing the parsed line.static @NotNull MiniMessageBuilder
fromLegacyAmpersand
(@NotNull String... legacyLines) Parses a series of legacy ampersand (&) strings (treated as individual lines) into aMiniMessageBuilder
containing each parsed line.static @NotNull MiniMessageBuilder
fromLegacyAmpersand
(@NotNull Collection<String> legacyLines) Parses a collection of legacy ampersand (&) strings (treated as individual lines) into aMiniMessageBuilder
containing each parsed line.static @NotNull MiniMessageBuilder
fromLegacyAmpersand
(ConfigurationSection section, @NotNull String key) Parses a legacy ampersand (&) formatted message from the config located at the provided key.
BothString
andList<String>
are supported types for the config value.
For list messages, the returnedMiniMessageBuilder
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.static @NotNull MiniMessageBuilder
fromLegacySection
(@NotNull ConfigurationSection section, @NotNull String key) Parses a legacy section (§) formatted message from the config located at the provided key.
BothString
andList<String>
are supported types for the config value.
For list messages, the returnedMiniMessageBuilder
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.static @NotNull MiniMessageBuilder
fromLegacySection
(@NotNull String legacy) Parses a legacy section (§) string into aMiniMessageBuilder
containing the parsed line.static @NotNull MiniMessageBuilder
fromLegacySection
(@NotNull String... legacyLines) Parses a series of legacy section (§) strings (treated as individual lines) into aMiniMessageBuilder
containing each parsed line.static @NotNull MiniMessageBuilder
fromLegacySection
(@NotNull Collection<String> legacyLines) Parses a collection of legacy section (§) strings (treated as individual lines) into aMiniMessageBuilder
containing each parsed line.static @NotNull MiniMessageBuilder
fromLegacySection
(ConfigurationSection section, @NotNull String key) Parses a legacy section (§) formatted message from the config located at the provided key.
BothString
andList<String>
are supported types for the config value.
For list messages, the returnedMiniMessageBuilder
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.static @NotNull MiniMessageBuilder
fromMiniMessage
(@NotNull ConfigurationSection section, @NotNull String key) Parses a MiniMessage formatted message from the config located at the provided key.
BothString
andList<String>
are supported types for the config value.
For list messages, the returnedMiniMessageBuilder
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 §).static @NotNull MiniMessageBuilder
fromMiniMessage
(@NotNull String miniMessage) Parses a MiniMessage string into aMiniMessageBuilder
containing the parsed line.static @NotNull MiniMessageBuilder
fromMiniMessage
(@NotNull String... miniMessageLines) Parses a series of MiniMessage strings (treated as individual lines) into aMiniMessageBuilder
containing each parsed line.static @NotNull MiniMessageBuilder
fromMiniMessage
(@NotNull Collection<String> miniMessageLines) Parses a collection of MiniMessage strings (treated as individual lines) into aMiniMessageBuilder
containing each parsed line.static @NotNull MiniMessageBuilder
fromMiniMessage
(ConfigurationSection section, @NotNull String key) Parses a MiniMessage formatted message from the config located at the provided key.
BothString
andList<String>
are supported types for the config value.
For list messages, the returnedMiniMessageBuilder
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 §).@NotNull MiniMessageBuilder
Performs a plain text replacement on all lines in this builder.@NotNull MiniMessageBuilder
replaceLine
(@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 MiniMessageBuilder
replaceLine
(@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 MiniMessageBuilder
replaceLineContains
(@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 MiniMessageBuilder
replaceLineContains
(@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 MiniMessageBuilder
send
(@NotNull List<CommandSender> senders) Sends the message to a CommandSender@NotNull MiniMessageBuilder
send
(@NotNull CommandSender sender) Sends the message to a CommandSender@NotNull MiniMessageBuilder
send
(@NotNull CommandSender... senders) Sends the message to a CommandSender@NotNull MiniMessageBuilder
sendAll()
Sends the message to all Online Players (and console)@NotNull MiniMessageBuilder
sendAll
(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.
-
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 aMiniMessageBuilder
containing 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 aMiniMessageBuilder
containing 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 aMiniMessageBuilder
containing the parsed line.
Will ignore ampersand (&) codes. SeefromLegacyAmpersand(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 aMiniMessageBuilder
containing 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 aMiniMessageBuilder
containing 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 aMiniMessageBuilder
containing 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 aMiniMessageBuilder
containing 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 aMiniMessageBuilder
containing 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 aMiniMessageBuilder
containing each parsed line.
Will ignore ampersand (&) codes. SeefromLegacyAmpersand(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.
BothString
andList<String>
are supported types for the config value.
For list messages, the returnedMiniMessageBuilder
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 §). 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.
BothString
andList<String>
are supported types for the config value.
For list messages, the returnedMiniMessageBuilder
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. 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.
BothString
andList<String>
are supported types for the config value.
For list messages, the returnedMiniMessageBuilder
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. SeefromLegacyAmpersand(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.
BothString
andList<String>
are supported types for the config value.
For list messages, the returnedMiniMessageBuilder
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 §). 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.
BothString
andList<String>
are supported types for the config value.
For list messages, the returnedMiniMessageBuilder
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. 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.
BothString
andList<String>
are supported types for the config value.
For list messages, the returnedMiniMessageBuilder
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. SeefromLegacyAmpersand(ConfigurationSection, String)
for that.
-