11package org.xodium.illyriaplus.guis
22
3- // import org.xodium.illyriaplus.pdcs.PlayerPDC.kingdom
3+ import io.papermc.paper.datacomponent.DataComponentTypes
44import org.bukkit.Material
55import org.bukkit.entity.Player
66import org.bukkit.inventory.ItemStack
77import org.xodium.illyriaplus.data.KingdomData
8- import org.xodium.illyriaplus.interfaces.GuiInterface
98import org.xodium.illyriaplus.utils.Utils.MM
109import xyz.xenondevs.invui.gui.Gui
1110import xyz.xenondevs.invui.item.Item
@@ -14,8 +13,9 @@ import xyz.xenondevs.invui.window.Window
1413import kotlin.uuid.ExperimentalUuidApi
1514
1615/* * A demo GUI showing a basic InvUI setup with a clickable dragon breath item. */
16+ @Suppress(" UnstableApiUsage" )
1717@OptIn(ExperimentalUuidApi ::class )
18- internal object MainGui : GuiInterface {
18+ internal object MainGui {
1919 /* * The clickable item displayed in the GUI that prints "TEST" when clicked. */
2020 private val FILLER_ITEM =
2121 Item
@@ -24,11 +24,14 @@ internal object MainGui : GuiInterface {
2424 .build()
2525
2626 /* * The item that triggers rename functionality when clicked in the GUI. */
27- private fun createRenameItem (kingdom : KingdomData ) =
27+ private fun renameItem (kingdom : KingdomData ) =
2828 Item
2929 .builder()
30- .setItemProvider(ItemStack .of(Material .NAME_TAG ))
31- .addClickHandler { _, click ->
30+ .setItemProvider(
31+ ItemStack .of(Material .NAME_TAG ).apply {
32+ setData(DataComponentTypes .ITEM_NAME , MM .deserialize(" Rename Kingdom" ))
33+ },
34+ ).addClickHandler { _, click ->
3235 AnvilWindow
3336 .builder()
3437 .setTitle(MM .deserialize(" Enter New Kingdom Name" ))
@@ -37,16 +40,8 @@ internal object MainGui : GuiInterface {
3740 .open(click.player)
3841 }.build()
3942
40- /* * Placeholder GUI - actual GUI is built dynamically in window(). */
41- override val gui: Gui =
42- Gui
43- .builder()
44- .setStructure(" # # # # # # # # #" )
45- .addIngredient(' #' , FILLER_ITEM )
46- .build()
47-
4843 /* * Creates a window for the given player with their kingdom name as the title. */
49- override fun window (
44+ fun window (
5045 player : Player ,
5146 kingdom : KingdomData ,
5247 ): Window {
@@ -55,7 +50,7 @@ internal object MainGui : GuiInterface {
5550 .builder()
5651 .setStructure(" # # # # # # R # #" )
5752 .addIngredient(' #' , FILLER_ITEM )
58- .addIngredient(' R' , createRenameItem (kingdom))
53+ .addIngredient(' R' , renameItem (kingdom))
5954 .build()
6055
6156 return Window
0 commit comments