Skip to content

Commit 71ef137

Browse files
committed
improve the javadocs and add text offer the created TextOverlay
Fixed some typos in the javadocs and made add text so you could set propitiates to your text after it added to the list.
1 parent 383cae5 commit 71ef137

File tree

2 files changed

+15
-12
lines changed

2 files changed

+15
-12
lines changed

Item Creator/src/main/java/org/broken/arrow/library/itemcreator/meta/map/MapRendererData.java

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -101,9 +101,10 @@ public void addPixel(@Nonnull final MapColoredPixel mapColoredPixel) {
101101
* @param x The x-coordinate of the text.
102102
* @param y The y-coordinate of the text.
103103
* @param text The text to display.
104+
* @return returns the newly created text overlay, so you could set some of the options after.
104105
*/
105-
public void addText(final int x, int y, final String text) {
106-
this.addText(x, y, text, null, null);
106+
public TextOverlay addText(final int x, int y, final String text) {
107+
return this.addText(x, y, text, null, null);
107108
}
108109

109110
/**
@@ -114,9 +115,10 @@ public void addText(final int x, int y, final String text) {
114115
* @param y The y-coordinate of the text.
115116
* @param text The text to display.
116117
* @param font The font for the character.
118+
* @return returns the newly created text overlay, so you could set some of the options after.
117119
*/
118-
public void addText(final int x, int y, final String text, @Nullable final Font font) {
119-
this.addText(x, y, text, null, font);
120+
public TextOverlay addText(final int x, int y, final String text, @Nullable final Font font) {
121+
return this.addText(x, y, text, null, font);
120122
}
121123

122124
/**
@@ -127,8 +129,9 @@ public void addText(final int x, int y, final String text, @Nullable final Font
127129
* @param text The text to display.
128130
* @param fontChars Set the characters you want to replace in your text with the font.
129131
* @param font The font for the character
132+
* @return returns the newly created text overlay, so you could set some of the options after.
130133
*/
131-
public void addText(final int x, int y, @Nonnull final String text, @Nullable final char[] fontChars, @Nullable final Font font) {
134+
public TextOverlay addText(final int x, int y, @Nonnull final String text, @Nullable final char[] fontChars, @Nullable final Font font) {
132135
TextOverlay textOverlay = new TextOverlay(x, y, text);
133136
if (font != null) {
134137
if (fontChars != null && fontChars.length > 0) {
@@ -137,6 +140,7 @@ public void addText(final int x, int y, @Nonnull final String text, @Nullable fi
137140
textOverlay.setMapFont(this.fontChars, font);
138141
}
139142
this.addText(textOverlay);
143+
return textOverlay;
140144
}
141145

142146
/**

Item Creator/src/main/java/org/broken/arrow/library/itemcreator/meta/map/pixel/TextOverlay.java

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -69,15 +69,14 @@ public void setMapFont(final char[] chars, @Nonnull final Font font) {
6969
}
7070

7171
/**
72-
* Sets the {@link ColorParser} used for interpreting color and style codes
73-
* in the text.
72+
* Sets the {@link ColorParser} used to interpret color and style codes
73+
* in this text instance.
7474
* <p>
75-
* The parser is responsible for detecting formatting sequences and updating
76-
* the {@link RenderState} accordingly. By default, the API uses
77-
* {@link AmpersandHexColorParser}, but this method allows you to replace it
78-
* with a custom implementation, including lambda-based parsers.
75+
* By default, the API uses the global parser from {@link MapFontWrapper} (typically
76+
* {@link AmpersandHexColorParser}). This method allows overriding it for this
77+
* specific text, including using lambda-based or custom parser implementations.
7978
*
80-
* @param colorParser the color parser to use
79+
* @param colorParser the color parser to use for this text
8180
*/
8281
public void setColorParser(@Nonnull final ColorParser colorParser) {
8382
mapFontWrapper.setColorParser(colorParser);

0 commit comments

Comments
 (0)