Package net.minecraft.util
Class StringHelper
java.lang.Object
net.minecraft.util.StringHelper
Contains string-related helper methods.
- Mappings:
Namespace Name named net/minecraft/util/StringHelperintermediary net/minecraft/class_3544official azl
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic intcountLines(String text) Returns the number of linebreaks intext.static booleanendsWithLineBreak(String text) Returns true iftextends with a linebreak, false otherwise.static StringformatTicks(int ticks, float tickRate) Returns the length of thetickin the MM:SS format, where the MM is the minutes and SS is the seconds (optionally zero-padded).static booleanstatic booleanReturns true iftextisnullor empty, false otherwise.static booleanisValidChar(char c) Returns whethercis a valid character.static booleanisValidPlayerName(String name) static booleanisWhitespace(int c) static StringstripInvalidChars(String string) static StringstripInvalidChars(String string, boolean allowLinebreak) Returnsstringwith all invalid characters removed.static StringstripTextFormat(String text) Returns thetextwith all formatting codes removed.static StringReturnstexttruncated to at mostmaxLengthcharacters, optionally with ellipsis.static StringtruncateChat(String text) Returnstexttruncated to at most 256 characters without ellipsis.
-
Field Details
-
FORMATTING_CODE
- Mappings:
Namespace Name Mixin selector named FORMATTING_CODELnet/minecraft/util/StringHelper;FORMATTING_CODE:Ljava/util/regex/Pattern;intermediary field_15771Lnet/minecraft/class_3544;field_15771:Ljava/util/regex/Pattern;official aLazl;a:Ljava/util/regex/Pattern;
-
LINE_BREAK
- Mappings:
Namespace Name Mixin selector named LINE_BREAKLnet/minecraft/util/StringHelper;LINE_BREAK:Ljava/util/regex/Pattern;intermediary field_29204Lnet/minecraft/class_3544;field_29204:Ljava/util/regex/Pattern;official bLazl;b:Ljava/util/regex/Pattern;
-
ENDS_WITH_LINE_BREAK
- Mappings:
Namespace Name Mixin selector named ENDS_WITH_LINE_BREAKLnet/minecraft/util/StringHelper;ENDS_WITH_LINE_BREAK:Ljava/util/regex/Pattern;intermediary field_33559Lnet/minecraft/class_3544;field_33559:Ljava/util/regex/Pattern;official cLazl;c:Ljava/util/regex/Pattern;
-
-
Constructor Details
-
StringHelper
public StringHelper()
-
-
Method Details
-
formatTicks
Returns the length of thetickin the MM:SS format, where the MM is the minutes and SS is the seconds (optionally zero-padded).- Returns:
- the length of the
tickin the MM:SS format, where the MM is the minutes and SS is the seconds (optionally zero-padded) - Mappings:
Namespace Name Mixin selector named formatTicksLnet/minecraft/util/StringHelper;formatTicks(IF)Ljava/lang/String;intermediary method_15439Lnet/minecraft/class_3544;method_15439(IF)Ljava/lang/String;official aLazl;a(IF)Ljava/lang/String;
-
stripTextFormat
Returns thetextwith 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
textwith all formatting codes removed - See Also:
- Mappings:
Namespace Name Mixin selector named stripTextFormatLnet/minecraft/util/StringHelper;stripTextFormat(Ljava/lang/String;)Ljava/lang/String;intermediary method_15440Lnet/minecraft/class_3544;method_15440(Ljava/lang/String;)Ljava/lang/String;official aLazl;a(Ljava/lang/String;)Ljava/lang/String;
-
isEmpty
Returns true iftextisnullor empty, false otherwise.- Returns:
- true if
textisnullor empty, false otherwise - Mappings:
Namespace Name Mixin selector named isEmptyLnet/minecraft/util/StringHelper;isEmpty(Ljava/lang/String;)Zintermediary method_15438Lnet/minecraft/class_3544;method_15438(Ljava/lang/String;)Zofficial bLazl;b(Ljava/lang/String;)Z
-
truncate
Returnstexttruncated to at mostmaxLengthcharacters, optionally with ellipsis.- Returns:
texttruncated to at mostmaxLengthcharacters, optionally with ellipsis- Mappings:
Namespace Name Mixin selector named truncateLnet/minecraft/util/StringHelper;truncate(Ljava/lang/String;IZ)Ljava/lang/String;intermediary method_34963Lnet/minecraft/class_3544;method_34963(Ljava/lang/String;IZ)Ljava/lang/String;official aLazl;a(Ljava/lang/String;IZ)Ljava/lang/String;
-
countLines
Returns the number of linebreaks intext.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 named countLinesLnet/minecraft/util/StringHelper;countLines(Ljava/lang/String;)Iintermediary method_34238Lnet/minecraft/class_3544;method_34238(Ljava/lang/String;)Iofficial cLazl;c(Ljava/lang/String;)I
-
endsWithLineBreak
Returns true iftextends with a linebreak, false otherwise.A linebreak is either a CRLF sequence or a vertical tab (U+000B).
- Returns:
- true if
textends with a linebreak, false otherwise - Mappings:
Namespace Name Mixin selector named endsWithLineBreakLnet/minecraft/util/StringHelper;endsWithLineBreak(Ljava/lang/String;)Zintermediary method_36358Lnet/minecraft/class_3544;method_36358(Ljava/lang/String;)Zofficial dLazl;d(Ljava/lang/String;)Z
-
truncateChat
Returnstexttruncated to at most 256 characters without ellipsis.- Returns:
texttruncated to at most 256 characters without ellipsis- API Note:
- This is used when sending chat messages.
- Mappings:
Namespace Name Mixin selector named truncateChatLnet/minecraft/util/StringHelper;truncateChat(Ljava/lang/String;)Ljava/lang/String;intermediary method_43681Lnet/minecraft/class_3544;method_43681(Ljava/lang/String;)Ljava/lang/String;official eLazl;e(Ljava/lang/String;)Ljava/lang/String;
-
isValidChar
public static boolean isValidChar(char c) Returns whethercis a valid character.Characters are valid if they are not an ASCII control code or
§.- Returns:
- whether
cis a valid character - Mappings:
Namespace Name Mixin selector named isValidCharLnet/minecraft/util/StringHelper;isValidChar(C)Zintermediary method_57175Lnet/minecraft/class_3544;method_57175(C)Zofficial aLazl;a(C)Z
-
isValidPlayerName
- Mappings:
Namespace Name Mixin selector named isValidPlayerNameLnet/minecraft/util/StringHelper;isValidPlayerName(Ljava/lang/String;)Zintermediary method_57179Lnet/minecraft/class_3544;method_57179(Ljava/lang/String;)Zofficial fLazl;f(Ljava/lang/String;)Z
-
stripInvalidChars
- Returns:
stringwith all invalid characters, including linebreak (\n), removed- Mappings:
Namespace Name Mixin selector named stripInvalidCharsLnet/minecraft/util/StringHelper;stripInvalidChars(Ljava/lang/String;)Ljava/lang/String;intermediary method_57180Lnet/minecraft/class_3544;method_57180(Ljava/lang/String;)Ljava/lang/String;official gLazl;g(Ljava/lang/String;)Ljava/lang/String;
-
stripInvalidChars
Returnsstringwith all invalid characters removed.- Returns:
stringwith all invalid characters removed- Mappings:
Namespace Name Mixin selector named stripInvalidCharsLnet/minecraft/util/StringHelper;stripInvalidChars(Ljava/lang/String;Z)Ljava/lang/String;intermediary method_57177Lnet/minecraft/class_3544;method_57177(Ljava/lang/String;Z)Ljava/lang/String;official aLazl;a(Ljava/lang/String;Z)Ljava/lang/String;
-
isWhitespace
public static boolean isWhitespace(int c) - Mappings:
Namespace Name Mixin selector named isWhitespaceLnet/minecraft/util/StringHelper;isWhitespace(I)Zintermediary method_57176Lnet/minecraft/class_3544;method_57176(I)Zofficial aLazl;a(I)Z
-
isBlank
- Mappings:
Namespace Name Mixin selector named isBlankLnet/minecraft/util/StringHelper;isBlank(Ljava/lang/String;)Zintermediary method_57181Lnet/minecraft/class_3544;method_57181(Ljava/lang/String;)Zofficial hLazl;h(Ljava/lang/String;)Z
-