Class LegacyStrings

java.lang.Object
io.github.miniplaceholders.api.utils.LegacyStrings

public final class LegacyStrings extends Object
Legacy String utilities.
Since:
3.0.0
  • Field Details

    • LEGACY_HEX_SERIALIZER

      @Deprecated(since="3.1.0") public static final net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer LEGACY_HEX_SERIALIZER
      Deprecated.
      Legacy format “support” will be removed in future versions
      Legacy serializer with hex support

      Use this as the last available alternative, it is recommended to use MiniMessage instead of this serializer

  • Method Details

    • parsePossibleLegacy

      public static Component parsePossibleLegacy(@Nullable String string)
      Parse a string with possible legacy Ampersand/Section symbols

      This method should only be used in case a String is provided from a legacy plugin/mod or legacy source, where it is very likely to get a legacy string. It is not recommended to use this method regularly in any sense

      Parameters:
      string - the string
      Returns:
      a parsed string
      Since:
      1.0.0
    • parsePossibleLegacy

      public static Component parsePossibleLegacy(@Nullable String string, Context context)
      Parse a string with possible legacy Ampersand/Section symbols using a parsing Context

      This method should only be used in case a String is provided from a legacy plugin/mod or legacy source, where it is very likely to get a legacy string. It is not recommended to use this method regularly in any sense

      Parameters:
      string - the string
      context - the provided parsing context
      Returns:
      a parsed string
      Since:
      2.2.1
    • parsePossibleLegacy

      public static Component parsePossibleLegacy(@Nullable String string, TagResolver resolver)
      Parse a string with possible legacy Ampersand/Section symbols using the provided resolver

      This method should only be used in case a String is provided from a legacy plugin/mod or legacy source, where it is very likely to get a legacy string. It is not recommended to use this method regularly in any sense

      Parameters:
      string - the string
      resolver - a resolver
      Returns:
      a parsed string
      Since:
      2.2.1
    • hasLegacyFormat

      public static boolean hasLegacyFormat(String string)
      Checks if the provided string contains legacy formatting.
      Parameters:
      string - the string input
      Returns:
      whether the string has legacy content
      Since:
      2.3.0
      See Also:
      • LegacyComponentSerializer.AMPERSAND_CHAR
      • LegacyComponentSerializer.SECTION_CHAR
    • mapLegacyOrElse

      public static <R> R mapLegacyOrElse(String string, Function<String,R> legacyMapping, Function<String,R> modernMapping)
      Maps the input to a type depending on whether it contains legacy formatting or not.
      Type Parameters:
      R - the result type
      Parameters:
      string - the string input
      legacyMapping - the mapping function in case the string contains legacy formatting
      modernMapping - the mapping function in case the string does not contain any legacy character type, being safe to use with MiniMessage
      Returns:
      the mapped result
      Since:
      2.3.0
      See Also: