Skip to content

Commit

Permalink
fix: tooltip(TooltipChunk) & Lists -> Collections
Browse files Browse the repository at this point in the history
  • Loading branch information
andantet committed Nov 11, 2024
1 parent ec9a1c9 commit 8dd531e
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 8 deletions.
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,6 @@ kotlin_version=2.0.21
fabric_kotlin_version=1.12.3

# mod properties
mod_version=1.3.12
mod_version=1.3.13
maven_group=net.mcbrawls
mod_id=slate
14 changes: 11 additions & 3 deletions src/main/kotlin/net/mcbrawls/slate/tile/Tile.kt
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ abstract class Tile {
* Adds tooltips to this tile.
*/
@JvmName("tooltipText")
fun tooltip(tooltips: List<Text>) {
fun tooltip(tooltips: Collection<Text>) {
tooltip.addAll(tooltips)
}

Expand All @@ -53,7 +53,7 @@ abstract class Tile {
* Adds tooltips to this tile.
*/
@JvmName("tooltipString")
fun tooltip(tooltips: List<String>) {
fun tooltip(tooltips: Collection<String>) {
tooltip.addAll(tooltips.map(Text::literal))
}

Expand All @@ -67,7 +67,8 @@ abstract class Tile {
/**
* Adds tooltip chunks to this tile.
*/
fun tooltip(vararg chunks: TooltipChunk) {
@JvmName("tooltipTooltipChunk")
fun tooltip(chunks: List<TooltipChunk>) {
val lastIndex = chunks.lastIndex
chunks.forEachIndexed { index, chunk ->
// append chunk
Expand All @@ -82,6 +83,13 @@ abstract class Tile {
}
}

/**
* Adds tooltip chunks to this tile.
*/
fun tooltip(vararg tooltips: TooltipChunk) {
tooltip(tooltips.toList())
}

/**
* Adds a click callback for the given click type.
*/
Expand Down
8 changes: 4 additions & 4 deletions src/main/kotlin/net/mcbrawls/slate/tooltip/TooltipChunk.kt
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ class TooltipChunk(
* Builds a tooltip chunk.
*/
@JvmName("tooltipChunkText")
inline fun tooltipChunk(texts: List<Text>, builder: TooltipChunk.() -> Unit = {}): TooltipChunk {
return TooltipChunk(texts).apply(builder)
inline fun tooltipChunk(texts: Collection<Text>, builder: TooltipChunk.() -> Unit = {}): TooltipChunk {
return TooltipChunk(texts.toList()).apply(builder)
}

/**
Expand All @@ -44,8 +44,8 @@ class TooltipChunk(
* Builds a tooltip chunk.
*/
@JvmName("tooltipChunkString")
inline fun tooltipChunk(texts: List<String>, builder: TooltipChunk.() -> Unit = {}): TooltipChunk {
return TooltipChunk(texts.map(Text::literal)).apply(builder)
inline fun tooltipChunk(texts: Collection<String>, builder: TooltipChunk.() -> Unit = {}): TooltipChunk {
return tooltipChunk(texts.map(Text::literal), builder)
}

/**
Expand Down

0 comments on commit 8dd531e

Please sign in to comment.