Class LegacyCodeUpdaterHook
java.lang.Object
me.bristermitten.mittenlib.lang.format.hook.LegacyCodeUpdaterHook
- All Implemented Interfaces:
FormattingHook
A
FormattingHook that replaces legacy color codes with their MiniMessage equivalent. This
insures that formatting still works when other hooks might return a legacy code (for example from
PlaceholderAPI)-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescription@NotNull Stringformat(@NotNull String message, @Nullable OfflinePlayer player) Format a String, returning the formatted String.booleanIf the hook should be used.
-
Constructor Details
-
LegacyCodeUpdaterHook
public LegacyCodeUpdaterHook()
-
-
Method Details
-
shouldRegister
public boolean shouldRegister()Description copied from interface:FormattingHookIf the hook should be used. This should generally be called once per format process. Note that this method does not accept any parameters. It should be used as a pre-check to determine if the hook should be used at all, rather than conditional based on the input. For example, checking if an API (e.g. PlaceholderAPI) is present on the server before running any formatting to avoidClassNotFoundExceptions, or checking the server version. If conditional formatting is desired, do this inFormattingHook.format(String, OfflinePlayer), and return the unchanged input if the hook should not be used.- Specified by:
shouldRegisterin interfaceFormattingHook- Returns:
- if the hook should be used for this format process
-
format
@NotNull public @NotNull String format(@NotNull @NotNull String message, @Nullable @Nullable OfflinePlayer player) Description copied from interface:FormattingHookFormat a String, returning the formatted String. This method should generally be idempotent, and should not be called ifFormattingHook.shouldRegister()returns false.- Specified by:
formatin interfaceFormattingHook- Parameters:
message- the message to formatplayer- the player to format for. This can be used for player-specific formatting, such as PlaceholderAPI- Returns:
- the formatted String
-