From 1e9a8ba4155cb711749fd9fb2023afb8f3c410d4 Mon Sep 17 00:00:00 2001 From: apple502j <33279053+apple502j@users.noreply.github.com> Date: Wed, 20 Oct 2021 23:36:14 +0900 Subject: [PATCH] Rename ChatUtil, add javadoc (#2771) * Rename ChatUtil, add javadoc * Apply suggestions from code review Co-authored-by: liach <7806504+liach@users.noreply.github.com> Co-authored-by: enbrain <69905075+enbrain@users.noreply.github.com> Co-authored-by: liach <7806504+liach@users.noreply.github.com> Co-authored-by: enbrain <69905075+enbrain@users.noreply.github.com> --- mappings/net/minecraft/util/ChatUtil.mapping | 18 ---------- .../net/minecraft/util/Formatting.mapping | 26 ++++++++++++++ .../net/minecraft/util/StringHelper.mapping | 35 +++++++++++++++++++ 3 files changed, 61 insertions(+), 18 deletions(-) delete mode 100644 mappings/net/minecraft/util/ChatUtil.mapping create mode 100644 mappings/net/minecraft/util/StringHelper.mapping diff --git a/mappings/net/minecraft/util/ChatUtil.mapping b/mappings/net/minecraft/util/ChatUtil.mapping deleted file mode 100644 index d7f2e99665..0000000000 --- a/mappings/net/minecraft/util/ChatUtil.mapping +++ /dev/null @@ -1,18 +0,0 @@ -CLASS net/minecraft/class_3544 net/minecraft/util/ChatUtil - FIELD field_15771 PATTERN Ljava/util/regex/Pattern; - FIELD field_29204 LINE_BREAK Ljava/util/regex/Pattern; - FIELD field_33559 ENDS_WITH_LINE_BREAK Ljava/util/regex/Pattern; - METHOD method_15438 isEmpty (Ljava/lang/String;)Z - ARG 0 text - METHOD method_15439 ticksToString (I)Ljava/lang/String; - ARG 0 ticks - METHOD method_15440 stripTextFormat (Ljava/lang/String;)Ljava/lang/String; - ARG 0 text - METHOD method_34238 countLines (Ljava/lang/String;)I - ARG 0 text - METHOD method_34963 truncate (Ljava/lang/String;IZ)Ljava/lang/String; - ARG 0 text - ARG 1 maxLength - ARG 2 addEllipsis - METHOD method_36358 endsWithLineBreak (Ljava/lang/String;)Z - ARG 0 text diff --git a/mappings/net/minecraft/util/Formatting.mapping b/mappings/net/minecraft/util/Formatting.mapping index 4e0a2ff25f..fe6a3eb3aa 100644 --- a/mappings/net/minecraft/util/Formatting.mapping +++ b/mappings/net/minecraft/util/Formatting.mapping @@ -1,4 +1,10 @@ CLASS net/minecraft/class_124 net/minecraft/util/Formatting + COMMENT An enum holding formattings. + COMMENT + COMMENT

There are two types of formattings, color and modifier. Color formattings + COMMENT are associated with a specific color, while modifier formattings modify the + COMMENT style, such as by bolding the text. {@link #RESET} is a special formatting + COMMENT and is not classified as either of these two. FIELD field_1052 BY_NAME Ljava/util/Map; FIELD field_1053 colorValue Ljava/lang/Integer; FIELD field_1057 name Ljava/lang/String; @@ -7,6 +13,7 @@ CLASS net/minecraft/class_124 net/minecraft/util/Formatting FIELD field_1069 stringValue Ljava/lang/String; FIELD field_1071 colorIndex I FIELD field_1081 modifier Z + FIELD field_33292 FORMATTING_CODE_PREFIX C METHOD (Ljava/lang/String;ILjava/lang/String;CILjava/lang/Integer;)V ARG 3 name ARG 4 code @@ -23,25 +30,44 @@ CLASS net/minecraft/class_124 net/minecraft/util/Formatting ARG 6 colorIndex ARG 7 colorValue METHOD method_36145 getCode ()C + COMMENT {@return the code to be placed after the {@value FORMATTING_CODE_PREFIX} when this format is converted to a string} METHOD method_531 (Lnet/minecraft/class_124;)Ljava/lang/String; ARG 0 f METHOD method_532 getColorValue ()Ljava/lang/Integer; + COMMENT {@return the color of the formatted text, or {@code null} if the formatting + COMMENT has no associated color} METHOD method_533 byName (Ljava/lang/String;)Lnet/minecraft/class_124; + COMMENT {@return the formatting with the name {@code name}, or {@code null} if there is none} ARG 0 name METHOD method_534 byColorIndex (I)Lnet/minecraft/class_124; + COMMENT {@return the formatting with the color index {@code colorIndex}, + COMMENT or {@code null} if there is none} ARG 0 colorIndex METHOD method_535 sanitize (Ljava/lang/String;)Ljava/lang/String; ARG 0 name METHOD method_536 getColorIndex ()I + COMMENT {@return the color index for the formatting, or {@code -1} to indicate no color} + COMMENT + COMMENT @apiNote This is also used to calculate scoreboard team display slot IDs. METHOD method_537 getName ()Ljava/lang/String; + COMMENT {@return the name of the formatting} METHOD method_539 strip (Ljava/lang/String;)Ljava/lang/String; + COMMENT {@return the {@code text} with all formatting codes removed} + COMMENT + COMMENT @see StringHelper#stripTextFormat ARG 0 string METHOD method_540 getNames (ZZ)Ljava/util/Collection; + COMMENT {@return the list of formattings matching the given condition} ARG 0 colors + COMMENT whether or not to include color formattings ARG 1 modifiers + COMMENT whether or not to include modifier formattings METHOD method_541 (Lnet/minecraft/class_124;)Lnet/minecraft/class_124; ARG 0 f METHOD method_542 isModifier ()Z + COMMENT {@return true if the formatting is a modifier, false otherwise} METHOD method_543 isColor ()Z + COMMENT {@return true if the formatting is associated with a color, false otherwise} METHOD method_544 byCode (C)Lnet/minecraft/class_124; + COMMENT {@return the formatting with the code {@code code}, or {@code null} if there is none} ARG 0 code diff --git a/mappings/net/minecraft/util/StringHelper.mapping b/mappings/net/minecraft/util/StringHelper.mapping new file mode 100644 index 0000000000..f94b2d9307 --- /dev/null +++ b/mappings/net/minecraft/util/StringHelper.mapping @@ -0,0 +1,35 @@ +CLASS net/minecraft/class_3544 net/minecraft/util/StringHelper + FIELD field_15771 FORMATTING_CODE Ljava/util/regex/Pattern; + FIELD field_29204 LINE_BREAK Ljava/util/regex/Pattern; + FIELD field_33559 ENDS_WITH_LINE_BREAK Ljava/util/regex/Pattern; + METHOD method_15438 isEmpty (Ljava/lang/String;)Z + COMMENT {@return true if {@code text} is {@code null} or empty, false otherwise} + ARG 0 text + METHOD method_15439 formatTicks (I)Ljava/lang/String; + COMMENT {@return the length of the {@code tick} in the MM:SS format, where + COMMENT the MM is the minutes and SS is the seconds (optionally zero-padded)} + ARG 0 ticks + METHOD method_15440 stripTextFormat (Ljava/lang/String;)Ljava/lang/String; + COMMENT {@return the {@code text} with all formatting codes removed} + COMMENT + COMMENT

A formatting code is the character {@code ยง} followed by + COMMENT a numeric character or a letter A to F, K to O, or R. + COMMENT + COMMENT @see Formatting#strip + ARG 0 text + METHOD method_34238 countLines (Ljava/lang/String;)I + COMMENT {@return the number of linebreaks in {@code text}} + COMMENT + COMMENT

A linebreak is either a CRLF sequence or a vertical tab (U+000B). + ARG 0 text + METHOD method_34963 truncate (Ljava/lang/String;IZ)Ljava/lang/String; + COMMENT {@return {@code text} truncated to at most {@code maxLength} characters, + COMMENT optionally with ellipsis} + ARG 0 text + ARG 1 maxLength + ARG 2 addEllipsis + METHOD method_36358 endsWithLineBreak (Ljava/lang/String;)Z + COMMENT {@return true if {@code text} ends with a linebreak, false otherwise} + COMMENT + COMMENT

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