@@ -67,6 +67,12 @@ private FormattedText(@NonNull String text, @NonNull EnumChatFormatting colorSty
67
67
this .endLine = endLine ;
68
68
}
69
69
70
+ /**
71
+ * Parse a string with minecraft style escapes (\u00a7X) into a {@link FormattedText} instance, which can then be
72
+ * used to generate chat or render-able text.
73
+ * @param text The string to parse
74
+ * @return The parsed text structure
75
+ */
70
76
public static FormattedText parse (String text ) {
71
77
EnumChatFormatting currentColorStyle = EnumChatFormatting .WHITE ;
72
78
val currentFancyStyle = new HashSet <EnumChatFormatting >();
@@ -113,6 +119,10 @@ public static FormattedText parse(String text) {
113
119
return result ;
114
120
}
115
121
122
+ /**
123
+ * Converts this text structure into a chat component that can be sent to clients.
124
+ * @return The chat component.
125
+ */
116
126
public ChatComponentText toChatText () {
117
127
val result = new ChatComponentText (endLine ? text + "\n " : "" );
118
128
val style = new ChatStyle ();
@@ -145,14 +155,34 @@ public ChatComponentText toChatText() {
145
155
return result ;
146
156
}
147
157
158
+ /**
159
+ * {@link #draw(FontRenderer, int, int, boolean)} without drop shadows.
160
+ * @param renderer The font renderer to use
161
+ * @param x Left side
162
+ * @param y Top side
163
+ */
148
164
public void draw (FontRenderer renderer , int x , int y ) {
149
165
draw (renderer , x , y , false );
150
166
}
151
167
168
+
169
+ /**
170
+ * {@link #draw(FontRenderer, int, int, boolean)} with drop shadows.
171
+ * @param renderer The font renderer to use
172
+ * @param x Left side
173
+ * @param y Top side
174
+ */
152
175
public void drawWithShadow (FontRenderer renderer , int x , int y ) {
153
176
draw (renderer , x , y , true );
154
177
}
155
178
179
+ /**
180
+ * Renders this structure as GUI text.
181
+ * @param renderer The font renderer to use
182
+ * @param x Left side
183
+ * @param y Top side
184
+ * @param shadow Whether to have drop shadow under the text
185
+ */
156
186
public void draw (FontRenderer renderer , int x , int y , boolean shadow ) {
157
187
x += renderer .drawString (text , x , y , colorMap .get (colorStyle ).getRGB (), shadow );
158
188
if (endLine )
0 commit comments