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/StringHelper
intermediary net/minecraft/class_3544
official azl
-
Field Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic int
countLines
(String text) Returns the number of linebreaks intext
.static boolean
endsWithLineBreak
(String text) Returns true iftext
ends with a linebreak, false otherwise.static String
formatTicks
(int ticks, float tickRate) Returns the length of thetick
in the MM:SS format, where the MM is the minutes and SS is the seconds (optionally zero-padded).static boolean
static boolean
Returns true iftext
isnull
or empty, false otherwise.static boolean
isValidChar
(char c) Returns whetherc
is a valid character.static boolean
isValidPlayerName
(String name) static boolean
isWhitespace
(int c) static String
stripInvalidChars
(String string) static String
stripInvalidChars
(String string, boolean allowLinebreak) Returnsstring
with all invalid characters removed.static String
stripTextFormat
(String text) Returns thetext
with all formatting codes removed.static String
Returnstext
truncated to at mostmaxLength
characters, optionally with ellipsis.static String
truncateChat
(String text) Returnstext
truncated to at most 256 characters without ellipsis.
-
Field Details
-
FORMATTING_CODE
- Mappings:
Namespace Name Mixin selector named FORMATTING_CODE
Lnet/minecraft/util/StringHelper;FORMATTING_CODE:Ljava/util/regex/Pattern;
intermediary field_15771
Lnet/minecraft/class_3544;field_15771:Ljava/util/regex/Pattern;
official a
Lazl;a:Ljava/util/regex/Pattern;
-
LINE_BREAK
- Mappings:
Namespace Name Mixin selector named LINE_BREAK
Lnet/minecraft/util/StringHelper;LINE_BREAK:Ljava/util/regex/Pattern;
intermediary field_29204
Lnet/minecraft/class_3544;field_29204:Ljava/util/regex/Pattern;
official b
Lazl;b:Ljava/util/regex/Pattern;
-
ENDS_WITH_LINE_BREAK
- Mappings:
Namespace Name Mixin selector named ENDS_WITH_LINE_BREAK
Lnet/minecraft/util/StringHelper;ENDS_WITH_LINE_BREAK:Ljava/util/regex/Pattern;
intermediary field_33559
Lnet/minecraft/class_3544;field_33559:Ljava/util/regex/Pattern;
official c
Lazl;c:Ljava/util/regex/Pattern;
-
-
Constructor Details
-
StringHelper
public StringHelper()
-
-
Method Details
-
formatTicks
Returns the length of thetick
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 named formatTicks
Lnet/minecraft/util/StringHelper;formatTicks(IF)Ljava/lang/String;
intermediary method_15439
Lnet/minecraft/class_3544;method_15439(IF)Ljava/lang/String;
official a
Lazl;a(IF)Ljava/lang/String;
-
stripTextFormat
Returns thetext
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 named stripTextFormat
Lnet/minecraft/util/StringHelper;stripTextFormat(Ljava/lang/String;)Ljava/lang/String;
intermediary method_15440
Lnet/minecraft/class_3544;method_15440(Ljava/lang/String;)Ljava/lang/String;
official a
Lazl;a(Ljava/lang/String;)Ljava/lang/String;
-
isEmpty
Returns true iftext
isnull
or empty, false otherwise.- Returns:
- true if
text
isnull
or empty, false otherwise - Mappings:
Namespace Name Mixin selector named isEmpty
Lnet/minecraft/util/StringHelper;isEmpty(Ljava/lang/String;)Z
intermediary method_15438
Lnet/minecraft/class_3544;method_15438(Ljava/lang/String;)Z
official b
Lazl;b(Ljava/lang/String;)Z
-
truncate
Returnstext
truncated to at mostmaxLength
characters, optionally with ellipsis.- Returns:
text
truncated to at mostmaxLength
characters, optionally with ellipsis- Mappings:
Namespace Name Mixin selector named truncate
Lnet/minecraft/util/StringHelper;truncate(Ljava/lang/String;IZ)Ljava/lang/String;
intermediary method_34963
Lnet/minecraft/class_3544;method_34963(Ljava/lang/String;IZ)Ljava/lang/String;
official a
Lazl;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 countLines
Lnet/minecraft/util/StringHelper;countLines(Ljava/lang/String;)I
intermediary method_34238
Lnet/minecraft/class_3544;method_34238(Ljava/lang/String;)I
official c
Lazl;c(Ljava/lang/String;)I
-
endsWithLineBreak
Returns true iftext
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 named endsWithLineBreak
Lnet/minecraft/util/StringHelper;endsWithLineBreak(Ljava/lang/String;)Z
intermediary method_36358
Lnet/minecraft/class_3544;method_36358(Ljava/lang/String;)Z
official d
Lazl;d(Ljava/lang/String;)Z
-
truncateChat
Returnstext
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 named truncateChat
Lnet/minecraft/util/StringHelper;truncateChat(Ljava/lang/String;)Ljava/lang/String;
intermediary method_43681
Lnet/minecraft/class_3544;method_43681(Ljava/lang/String;)Ljava/lang/String;
official e
Lazl;e(Ljava/lang/String;)Ljava/lang/String;
-
isValidChar
public static boolean isValidChar(char c) Returns whetherc
is a valid character.Characters are valid if they are not an ASCII control code or
§
.- Returns:
- whether
c
is a valid character - Mappings:
Namespace Name Mixin selector named isValidChar
Lnet/minecraft/util/StringHelper;isValidChar(C)Z
intermediary method_57175
Lnet/minecraft/class_3544;method_57175(C)Z
official a
Lazl;a(C)Z
-
isValidPlayerName
- Mappings:
Namespace Name Mixin selector named isValidPlayerName
Lnet/minecraft/util/StringHelper;isValidPlayerName(Ljava/lang/String;)Z
intermediary method_57179
Lnet/minecraft/class_3544;method_57179(Ljava/lang/String;)Z
official f
Lazl;f(Ljava/lang/String;)Z
-
stripInvalidChars
- Returns:
string
with all invalid characters, including linebreak (\n
), removed- Mappings:
Namespace Name Mixin selector named stripInvalidChars
Lnet/minecraft/util/StringHelper;stripInvalidChars(Ljava/lang/String;)Ljava/lang/String;
intermediary method_57180
Lnet/minecraft/class_3544;method_57180(Ljava/lang/String;)Ljava/lang/String;
official g
Lazl;g(Ljava/lang/String;)Ljava/lang/String;
-
stripInvalidChars
Returnsstring
with all invalid characters removed.- Returns:
string
with all invalid characters removed- Mappings:
Namespace Name Mixin selector named stripInvalidChars
Lnet/minecraft/util/StringHelper;stripInvalidChars(Ljava/lang/String;Z)Ljava/lang/String;
intermediary method_57177
Lnet/minecraft/class_3544;method_57177(Ljava/lang/String;Z)Ljava/lang/String;
official a
Lazl;a(Ljava/lang/String;Z)Ljava/lang/String;
-
isWhitespace
public static boolean isWhitespace(int c) - Mappings:
Namespace Name Mixin selector named isWhitespace
Lnet/minecraft/util/StringHelper;isWhitespace(I)Z
intermediary method_57176
Lnet/minecraft/class_3544;method_57176(I)Z
official a
Lazl;a(I)Z
-
isBlank
- Mappings:
Namespace Name Mixin selector named isBlank
Lnet/minecraft/util/StringHelper;isBlank(Ljava/lang/String;)Z
intermediary method_57181
Lnet/minecraft/class_3544;method_57181(Ljava/lang/String;)Z
official h
Lazl;h(Ljava/lang/String;)Z
-