11package dev.slne.surf.surfapi.core.api.messages.builder
22
3- import dev.slne.surf.surfapi.core.api.messages.Colors.Companion.DARK_SPACER
4- import dev.slne.surf.surfapi.core.api.messages.Colors.Companion.ERROR
5- import dev.slne.surf.surfapi.core.api.messages.Colors.Companion.INFO
63import dev.slne.surf.surfapi.core.api.messages.Colors.Companion.NOTE
74import dev.slne.surf.surfapi.core.api.messages.Colors.Companion.PREFIX
8- import dev.slne.surf.surfapi.core.api.messages.Colors.Companion.PRIMARY
9- import dev.slne.surf.surfapi.core.api.messages.Colors.Companion.SECONDARY
105import dev.slne.surf.surfapi.core.api.messages.Colors.Companion.SPACER
11- import dev.slne.surf.surfapi.core.api.messages.Colors.Companion.SUCCESS
12- import dev.slne.surf.surfapi.core.api.messages.Colors.Companion.VARIABLE_KEY
136import dev.slne.surf.surfapi.core.api.messages.Colors.Companion.VARIABLE_VALUE
14- import dev.slne.surf.surfapi.core.api.messages.Colors.Companion.WARNING
157import dev.slne.surf.surfapi.core.api.messages.CommonComponents
168import dev.slne.surf.surfapi.core.api.messages.CommonComponents.DISCONNECT_HEADER
179import dev.slne.surf.surfapi.core.api.messages.CommonComponents.DISCORD_LINK
@@ -34,7 +26,7 @@ import java.util.function.Function
3426import kotlin.time.Duration
3527
3628@ApiStatus.NonExtendable
37- interface SurfComponentBuilder : TextComponent .Builder {
29+ interface SurfComponentBuilder : TextComponent .Builder , ComponentBuilderColors {
3830 companion object {
3931 @JvmStatic
4032 fun builder (): SurfComponentBuilder = SurfComponentBuilderImpl (Component .text())
@@ -44,7 +36,10 @@ interface SurfComponentBuilder : TextComponent.Builder {
4436 builder().apply (block).build()
4537 }
4638
39+ @Deprecated(" Use TYPE specific functions" )
4740 fun appendPrefix () = append(PREFIX )
41+
42+ @Deprecated(" Use TYPE specific functions" )
4843 fun appendNewPrefixedLine () = appendNewline().appendPrefix()
4944
5045 fun append (block : SurfComponentBuilder .() -> Unit ): SurfComponentBuilder =
@@ -74,169 +69,18 @@ interface SurfComponentBuilder : TextComponent.Builder {
7469 fun text (char : Char , color : TextColor ? = null, vararg decoration : TextDecoration ) =
7570 append(Component .text(char, color, * decoration))
7671
77- fun text (double : Double , color : TextColor ? = null, vararg decoration : TextDecoration ) =
78- append(Component .text(double, color, * decoration))
79-
80- fun text (float : Float , color : TextColor ? = null, vararg decoration : TextDecoration ) =
81- append(Component .text(float, color, * decoration))
82-
83- fun text (int : Int , color : TextColor ? = null, vararg decoration : TextDecoration ) =
84- append(Component .text(int, color, * decoration))
85-
86- fun text (long : Long , color : TextColor ? = null, vararg decoration : TextDecoration ) =
87- append(Component .text(long, color, * decoration))
88-
89- fun primary (text : String , vararg decoration : TextDecoration ) = text(text, PRIMARY , * decoration)
90- fun primary (boolean : Boolean , vararg decoration : TextDecoration ) =
91- text(boolean, PRIMARY , * decoration)
92-
93- fun primary (char : Char , vararg decoration : TextDecoration ) = text(char, PRIMARY , * decoration)
94- fun primary (double : Double , vararg decoration : TextDecoration ) =
95- text(double, PRIMARY , * decoration)
96-
97- fun primary (float : Float , vararg decoration : TextDecoration ) = text(float, PRIMARY , * decoration)
98- fun primary (int : Int , vararg decoration : TextDecoration ) = text(int, PRIMARY , * decoration)
99- fun primary (long : Long , vararg decoration : TextDecoration ) = text(long, PRIMARY , * decoration)
100-
101- fun secondary (text : String , vararg decoration : TextDecoration ) =
102- text(text, SECONDARY , * decoration)
103-
104- fun secondary (boolean : Boolean , vararg decoration : TextDecoration ) =
105- text(boolean, SECONDARY , * decoration)
106-
107- fun secondary (char : Char , vararg decoration : TextDecoration ) =
108- text(char, SECONDARY , * decoration)
109-
110- fun secondary (double : Double , vararg decoration : TextDecoration ) =
111- text(double, SECONDARY , * decoration)
112-
113- fun secondary (float : Float , vararg decoration : TextDecoration ) =
114- text(float, SECONDARY , * decoration)
115-
116- fun secondary (int : Int , vararg decoration : TextDecoration ) = text(int, SECONDARY , * decoration)
117- fun secondary (long : Long , vararg decoration : TextDecoration ) =
118- text(long, SECONDARY , * decoration)
119-
120- fun info (text : String , vararg decoration : TextDecoration ) = text(text, INFO , * decoration)
121- fun info (boolean : Boolean , vararg decoration : TextDecoration ) = text(boolean, INFO , * decoration)
122- fun info (char : Char , vararg decoration : TextDecoration ) = text(char, INFO , * decoration)
123- fun info (double : Double , vararg decoration : TextDecoration ) = text(double, INFO , * decoration)
124- fun info (float : Float , vararg decoration : TextDecoration ) = text(float, INFO , * decoration)
125- fun info (int : Int , vararg decoration : TextDecoration ) = text(int, INFO , * decoration)
126- fun info (long : Long , vararg decoration : TextDecoration ) = text(long, INFO , * decoration)
72+ fun text (number : Number , color : TextColor ? = null, vararg decoration : TextDecoration ) = append(
73+ when (number) {
74+ is Double -> Component .text(number, color, * decoration)
75+ is Float -> Component .text(number, color, * decoration)
76+ is Int -> Component .text(number, color, * decoration)
77+ is Long -> Component .text(number, color, * decoration)
78+ else -> Component .text(number.toString(), color, * decoration)
79+ }
80+ )
12781
12882 fun note (any : Any , vararg decoration : TextDecoration ) = text(any.toString(), NOTE , * decoration)
12983
130- fun success (text : String , vararg decoration : TextDecoration ) = text(text, SUCCESS , * decoration)
131- fun success (boolean : Boolean , vararg decoration : TextDecoration ) =
132- text(boolean, SUCCESS , * decoration)
133-
134- fun success (char : Char , vararg decoration : TextDecoration ) = text(char, SUCCESS , * decoration)
135- fun success (double : Double , vararg decoration : TextDecoration ) =
136- text(double, SUCCESS , * decoration)
137-
138- fun success (float : Float , vararg decoration : TextDecoration ) = text(float, SUCCESS , * decoration)
139- fun success (int : Int , vararg decoration : TextDecoration ) = text(int, SUCCESS , * decoration)
140- fun success (long : Long , vararg decoration : TextDecoration ) = text(long, SUCCESS , * decoration)
141-
142- fun warning (text : String , vararg decoration : TextDecoration ) = text(text, WARNING , * decoration)
143- fun warning (boolean : Boolean , vararg decoration : TextDecoration ) =
144- text(boolean, WARNING , * decoration)
145-
146- fun warning (char : Char , vararg decoration : TextDecoration ) = text(char, WARNING , * decoration)
147- fun warning (double : Double , vararg decoration : TextDecoration ) =
148- text(double, WARNING , * decoration)
149-
150- fun warning (float : Float , vararg decoration : TextDecoration ) = text(float, WARNING , * decoration)
151- fun warning (int : Int , vararg decoration : TextDecoration ) = text(int, WARNING , * decoration)
152- fun warning (long : Long , vararg decoration : TextDecoration ) = text(long, WARNING , * decoration)
153-
154-
155- fun error (text : String , vararg decoration : TextDecoration ) = text(text, ERROR , * decoration)
156- fun error (boolean : Boolean , vararg decoration : TextDecoration ) =
157- text(boolean, ERROR , * decoration)
158-
159- fun error (char : Char , vararg decoration : TextDecoration ) = text(char, ERROR , * decoration)
160- fun error (double : Double , vararg decoration : TextDecoration ) = text(double, ERROR , * decoration)
161- fun error (float : Float , vararg decoration : TextDecoration ) = text(float, ERROR , * decoration)
162- fun error (int : Int , vararg decoration : TextDecoration ) = text(int, ERROR , * decoration)
163- fun error (long : Long , vararg decoration : TextDecoration ) = text(long, ERROR , * decoration)
164-
165- fun variableKey (text : String , vararg decoration : TextDecoration ) =
166- text(text, VARIABLE_KEY , * decoration)
167-
168- fun variableKey (boolean : Boolean , vararg decoration : TextDecoration ) =
169- text(boolean, VARIABLE_KEY , * decoration)
170-
171- fun variableKey (char : Char , vararg decoration : TextDecoration ) =
172- text(char, VARIABLE_KEY , * decoration)
173-
174- fun variableKey (double : Double , vararg decoration : TextDecoration ) =
175- text(double, VARIABLE_KEY , * decoration)
176-
177- fun variableKey (float : Float , vararg decoration : TextDecoration ) =
178- text(float, VARIABLE_KEY , * decoration)
179-
180- fun variableKey (int : Int , vararg decoration : TextDecoration ) =
181- text(int, VARIABLE_KEY , * decoration)
182-
183- fun variableKey (long : Long , vararg decoration : TextDecoration ) =
184- text(long, VARIABLE_KEY , * decoration)
185-
186- fun variableValue (text : String , vararg decoration : TextDecoration ) =
187- text(text, VARIABLE_VALUE , * decoration)
188-
189- fun variableValue (boolean : Boolean , vararg decoration : TextDecoration ) =
190- text(boolean, VARIABLE_VALUE , * decoration)
191-
192- fun variableValue (char : Char , vararg decoration : TextDecoration ) =
193- text(char, VARIABLE_VALUE , * decoration)
194-
195- fun variableValue (double : Double , vararg decoration : TextDecoration ) =
196- text(double, VARIABLE_VALUE , * decoration)
197-
198- fun variableValue (float : Float , vararg decoration : TextDecoration ) =
199- text(float, VARIABLE_VALUE , * decoration)
200-
201- fun variableValue (int : Int , vararg decoration : TextDecoration ) =
202- text(int, VARIABLE_VALUE , * decoration)
203-
204- fun variableValue (long : Long , vararg decoration : TextDecoration ) =
205- text(long, VARIABLE_VALUE , * decoration)
206-
207- fun spacer (text : String , vararg decoration : TextDecoration ) = text(text, SPACER , * decoration)
208- fun spacer (boolean : Boolean , vararg decoration : TextDecoration ) =
209- text(boolean, SPACER , * decoration)
210-
211- fun spacer (char : Char , vararg decoration : TextDecoration ) = text(char, SPACER , * decoration)
212- fun spacer (double : Double , vararg decoration : TextDecoration ) =
213- text(double, SPACER , * decoration)
214-
215- fun spacer (float : Float , vararg decoration : TextDecoration ) = text(float, SPACER , * decoration)
216- fun spacer (int : Int , vararg decoration : TextDecoration ) = text(int, SPACER , * decoration)
217- fun spacer (long : Long , vararg decoration : TextDecoration ) = text(long, SPACER , * decoration)
218-
219- fun darkSpacer (text : String , vararg decoration : TextDecoration ) =
220- text(text, DARK_SPACER , * decoration)
221-
222- fun darkSpacer (boolean : Boolean , vararg decoration : TextDecoration ) =
223- text(boolean, DARK_SPACER , * decoration)
224-
225- fun darkSpacer (char : Char , vararg decoration : TextDecoration ) =
226- text(char, DARK_SPACER , * decoration)
227-
228- fun darkSpacer (double : Double , vararg decoration : TextDecoration ) =
229- text(double, DARK_SPACER , * decoration)
230-
231- fun darkSpacer (float : Float , vararg decoration : TextDecoration ) =
232- text(float, DARK_SPACER , * decoration)
233-
234- fun darkSpacer (int : Int , vararg decoration : TextDecoration ) =
235- text(int, DARK_SPACER , * decoration)
236-
237- fun darkSpacer (long : Long , vararg decoration : TextDecoration ) =
238- text(long, DARK_SPACER , * decoration)
239-
24084 fun ellipsis (color : TextColor ? = SPACER ) = append(CommonComponents .ELLIPSIS .color(color))
24185
24286 fun appendDiscordLink () = append(DISCORD_LINK )
0 commit comments