Skip to content

Commit a0d9bc1

Browse files
authored
Merge pull request #2 from MineInAbyss/chest_changes
Change string to component and add method for string
2 parents 480ae64 + ec60c8e commit a0d9bc1

File tree

1 file changed

+13
-1
lines changed
  • src/main/kotlin/com/mineinabyss/guiy/components/canvases

1 file changed

+13
-1
lines changed

src/main/kotlin/com/mineinabyss/guiy/components/canvases/Chest.kt

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import com.mineinabyss.guiy.modifiers.SizeModifier
1313
import com.mineinabyss.guiy.modifiers.sizeIn
1414
import com.mineinabyss.guiy.nodes.InventoryCloseScope
1515
import com.mineinabyss.guiy.nodes.StaticMeasurePolicy
16+
import com.mineinabyss.idofront.messaging.miniMsg
1617
import net.kyori.adventure.text.Component
1718
import org.bukkit.Bukkit
1819
import org.bukkit.entity.Player
@@ -31,6 +32,17 @@ fun GuiyOwner.Chest(
3132
modifier: Modifier = Modifier,
3233
onClose: (InventoryCloseScope.(player: Player) -> Unit) = {},
3334
content: @Composable () -> Unit,
35+
) {
36+
Chest(viewers, title.miniMsg(), modifier, onClose, content)
37+
}
38+
39+
@Composable
40+
fun GuiyOwner.Chest(
41+
viewers: Set<Player>,
42+
title: Component,
43+
modifier: Modifier = Modifier,
44+
onClose: (InventoryCloseScope.(player: Player) -> Unit) = {},
45+
content: @Composable () -> Unit,
3446
) {
3547
val constrainedModifier = modifier.sizeIn(CHEST_WIDTH, CHEST_WIDTH, MIN_CHEST_HEIGHT, MAX_CHEST_HEIGHT)
3648
//TODO a proper way of reading size (onSizeChange recomposes twice when both title and size change.)
@@ -62,7 +74,7 @@ fun GuiyOwner.Chest(
6274
// Create new inventory when any appropriate value changes
6375
val inventory: Inventory = remember(title, size) {
6476
if (size == Size()) return@remember null
65-
Bukkit.createInventory(holder, CHEST_WIDTH * size.height, Component.text(title)).also {
77+
Bukkit.createInventory(holder, CHEST_WIDTH * size.height, title).also {
6678
holder.activeInventory = it
6779
}
6880
} ?: run {

0 commit comments

Comments
 (0)