Class StringHelper

java.lang.Object
net.minecraft.util.StringHelper

public class StringHelper extends Object
Contains string-related helper methods.
Mappings:
Namespace Name
official aps
intermediary net/minecraft/class_3544
named net/minecraft/util/StringHelper
  • Field Details

    • FORMATTING_CODE

      private static final Pattern FORMATTING_CODE
      Mappings:
      Namespace Name Mixin selector
      official a Laps;a:Ljava/util/regex/Pattern;
      intermediary field_15771 Lnet/minecraft/class_3544;field_15771:Ljava/util/regex/Pattern;
      named FORMATTING_CODE Lnet/minecraft/util/StringHelper;FORMATTING_CODE:Ljava/util/regex/Pattern;
    • LINE_BREAK

      private static final Pattern LINE_BREAK
      Mappings:
      Namespace Name Mixin selector
      official b Laps;b:Ljava/util/regex/Pattern;
      intermediary field_29204 Lnet/minecraft/class_3544;field_29204:Ljava/util/regex/Pattern;
      named LINE_BREAK Lnet/minecraft/util/StringHelper;LINE_BREAK:Ljava/util/regex/Pattern;
    • ENDS_WITH_LINE_BREAK

      private static final Pattern ENDS_WITH_LINE_BREAK
      Mappings:
      Namespace Name Mixin selector
      official c Laps;c:Ljava/util/regex/Pattern;
      intermediary field_33559 Lnet/minecraft/class_3544;field_33559:Ljava/util/regex/Pattern;
      named ENDS_WITH_LINE_BREAK Lnet/minecraft/util/StringHelper;ENDS_WITH_LINE_BREAK:Ljava/util/regex/Pattern;
  • Constructor Details

    • StringHelper

      public StringHelper()
  • Method Details

    • formatTicks

      public static String formatTicks(int ticks)
      Returns the length of the tick in the MM:SS format, where the MM is the minutes and SS is the seconds (optionally zero-padded).
      Returns:
      the length of the tick in the MM:SS format, where the MM is the minutes and SS is the seconds (optionally zero-padded)
      Mappings:
      Namespace Name Mixin selector
      official a Laps;a(I)Ljava/lang/String;
      intermediary method_15439 Lnet/minecraft/class_3544;method_15439(I)Ljava/lang/String;
      named formatTicks Lnet/minecraft/util/StringHelper;formatTicks(I)Ljava/lang/String;
    • stripTextFormat

      public static String stripTextFormat(String text)
      Returns the text with all formatting codes removed.

      A formatting code is the character ยง followed by a numeric character or a letter A to F, K to O, or R.

      Returns:
      the text with all formatting codes removed
      See Also:
      Mappings:
      Namespace Name Mixin selector
      official a Laps;a(Ljava/lang/String;)Ljava/lang/String;
      intermediary method_15440 Lnet/minecraft/class_3544;method_15440(Ljava/lang/String;)Ljava/lang/String;
      named stripTextFormat Lnet/minecraft/util/StringHelper;stripTextFormat(Ljava/lang/String;)Ljava/lang/String;
    • isEmpty

      public static boolean isEmpty(@Nullable @Nullable String text)
      Returns true if text is null or empty, false otherwise.
      Returns:
      true if text is null or empty, false otherwise
      Mappings:
      Namespace Name Mixin selector
      official b Laps;b(Ljava/lang/String;)Z
      intermediary method_15438 Lnet/minecraft/class_3544;method_15438(Ljava/lang/String;)Z
      named isEmpty Lnet/minecraft/util/StringHelper;isEmpty(Ljava/lang/String;)Z
    • truncate

      public static String truncate(String text, int maxLength, boolean addEllipsis)
      Returns text truncated to at most maxLength characters, optionally with ellipsis.
      Returns:
      text truncated to at most maxLength characters, optionally with ellipsis
      Mappings:
      Namespace Name Mixin selector
      official a Laps;a(Ljava/lang/String;IZ)Ljava/lang/String;
      intermediary method_34963 Lnet/minecraft/class_3544;method_34963(Ljava/lang/String;IZ)Ljava/lang/String;
      named truncate Lnet/minecraft/util/StringHelper;truncate(Ljava/lang/String;IZ)Ljava/lang/String;
    • countLines

      public static int countLines(String text)
      Returns the number of linebreaks in text.

      A linebreak is either a CRLF sequence or a vertical tab (U+000B).

      Returns:
      the number of linebreaks in text
      Mappings:
      Namespace Name Mixin selector
      official c Laps;c(Ljava/lang/String;)I
      intermediary method_34238 Lnet/minecraft/class_3544;method_34238(Ljava/lang/String;)I
      named countLines Lnet/minecraft/util/StringHelper;countLines(Ljava/lang/String;)I
    • endsWithLineBreak

      public static boolean endsWithLineBreak(String text)
      Returns true if text ends with a linebreak, false otherwise.

      A linebreak is either a CRLF sequence or a vertical tab (U+000B).

      Returns:
      true if text ends with a linebreak, false otherwise
      Mappings:
      Namespace Name Mixin selector
      official d Laps;d(Ljava/lang/String;)Z
      intermediary method_36358 Lnet/minecraft/class_3544;method_36358(Ljava/lang/String;)Z
      named endsWithLineBreak Lnet/minecraft/util/StringHelper;endsWithLineBreak(Ljava/lang/String;)Z
    • truncateChat

      public static String truncateChat(String text)
      Returns text truncated to at most 256 characters without ellipsis.
      Returns:
      text truncated to at most 256 characters without ellipsis
      API Note:
      This is used when sending chat messages.
      Mappings:
      Namespace Name Mixin selector
      official e Laps;e(Ljava/lang/String;)Ljava/lang/String;
      intermediary method_43681 Lnet/minecraft/class_3544;method_43681(Ljava/lang/String;)Ljava/lang/String;
      named truncateChat Lnet/minecraft/util/StringHelper;truncateChat(Ljava/lang/String;)Ljava/lang/String;