Skip to content

Commit c65afbd

Browse files
committed
feature: add Component?.orElse
1 parent 3321049 commit c65afbd

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
package dev.fruxz.stacked.extension
2+
3+
import net.kyori.adventure.text.Component
4+
5+
/**
6+
* This extension function allows you to return the current [Component] if it is not null,
7+
* otherwise it returns the provided [default] [Component].
8+
* @param default The default [Component] to return if the current one is null.
9+
* @return The current [Component] or the provided default one.
10+
* @see Component
11+
* @author Fruxz
12+
* @since 2025.5
13+
*/
14+
fun Component?.orElse(default: Component) = this ?: default

0 commit comments

Comments
 (0)