Class LegacyCodeUpdaterHook

java.lang.Object
me.bristermitten.mittenlib.lang.format.hook.LegacyCodeUpdaterHook
All Implemented Interfaces:
FormattingHook

public class LegacyCodeUpdaterHook extends Object implements 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 Details

    • LegacyCodeUpdaterHook

      public LegacyCodeUpdaterHook()
  • Method Details

    • shouldRegister

      public boolean shouldRegister()
      Description copied from interface: FormattingHook
      If 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 avoid ClassNotFoundExceptions, or checking the server version. If conditional formatting is desired, do this in FormattingHook.format(String, OfflinePlayer), and return the unchanged input if the hook should not be used.
      Specified by:
      shouldRegister in interface FormattingHook
      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: FormattingHook
      Format a String, returning the formatted String. This method should generally be idempotent, and should not be called if FormattingHook.shouldRegister() returns false.
      Specified by:
      format in interface FormattingHook
      Parameters:
      message - the message to format
      player - the player to format for. This can be used for player-specific formatting, such as PlaceholderAPI
      Returns:
      the formatted String