Skip to content

Commit f965d81

Browse files
committed
add javadoc
1 parent 82bd613 commit f965d81

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed

src/main/java/com/falsepattern/lib/text/FormattedText.java

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,12 @@ private FormattedText(@NonNull String text, @NonNull EnumChatFormatting colorSty
6767
this.endLine = endLine;
6868
}
6969

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+
*/
7076
public static FormattedText parse(String text) {
7177
EnumChatFormatting currentColorStyle = EnumChatFormatting.WHITE;
7278
val currentFancyStyle = new HashSet<EnumChatFormatting>();
@@ -113,6 +119,10 @@ public static FormattedText parse(String text) {
113119
return result;
114120
}
115121

122+
/**
123+
* Converts this text structure into a chat component that can be sent to clients.
124+
* @return The chat component.
125+
*/
116126
public ChatComponentText toChatText() {
117127
val result = new ChatComponentText(endLine ? text + "\n" : "");
118128
val style = new ChatStyle();
@@ -145,14 +155,34 @@ public ChatComponentText toChatText() {
145155
return result;
146156
}
147157

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+
*/
148164
public void draw(FontRenderer renderer, int x, int y) {
149165
draw(renderer, x, y, false);
150166
}
151167

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+
*/
152175
public void drawWithShadow(FontRenderer renderer, int x, int y) {
153176
draw(renderer, x, y, true);
154177
}
155178

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+
*/
156186
public void draw(FontRenderer renderer, int x, int y, boolean shadow) {
157187
x += renderer.drawString(text, x, y, colorMap.get(colorStyle).getRGB(), shadow);
158188
if (endLine)

0 commit comments

Comments
 (0)