diff --git a/build.gradle.kts b/build.gradle.kts index e0c30763..046417c1 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -8,7 +8,7 @@ plugins { alias(idofrontLibs.plugins.mia.copyjar) alias(idofrontLibs.plugins.mia.publication) alias(idofrontLibs.plugins.mia.autoversion) - alias(idofrontLibs.plugins.compose) + alias(idofrontLibs.plugins.compose.compiler) id("net.minecrell.plugin-yml.paper") version "0.6.0" } diff --git a/gradle.properties b/gradle.properties index e63001d2..e14b3ee3 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,3 +1,3 @@ group=com.mineinabyss version=0.9 -idofrontVersion=0.24.0-dev.8 +idofrontVersion=0.24.0 diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 69352319..08ea3e44 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -1,10 +1,10 @@ [versions] -gearyPaper = "0.30.1-dev.16" -guiy="0.9.4" +gearyPaper = "0.30.1" +guiy="0.10.0" [libraries] geary-papermc = { module = "com.mineinabyss:geary-papermc", version.ref = "gearyPaper" } guiy = { module = "com.mineinabyss:guiy-compose", version.ref = "guiy" } minecraft-plugin-customblockdata = "com.jeff-media:custom-block-data:2.2.2" -minecraft-plugin-protectionlib = "io.th0rgal:protectionlib:1.5.7" +minecraft-plugin-protectionlib = "io.th0rgal:protectionlib:1.5.8" diff --git a/src/main/kotlin/com/mineinabyss/blocky/helpers/composables/Button.kt b/src/main/kotlin/com/mineinabyss/blocky/helpers/composables/Button.kt index e829b303..50a30e36 100644 --- a/src/main/kotlin/com/mineinabyss/blocky/helpers/composables/Button.kt +++ b/src/main/kotlin/com/mineinabyss/blocky/helpers/composables/Button.kt @@ -4,7 +4,7 @@ import androidx.compose.runtime.Composable import com.mineinabyss.guiy.components.canvases.LocalInventory import com.mineinabyss.guiy.layout.Row import com.mineinabyss.guiy.modifiers.Modifier -import com.mineinabyss.guiy.modifiers.clickable +import com.mineinabyss.guiy.modifiers.click.clickable import org.bukkit.Sound import org.bukkit.entity.Player @@ -17,12 +17,9 @@ inline fun Button( crossinline content: @Composable (enabled: Boolean) -> Unit, ) { val inv = LocalInventory.current - Row(modifier.clickable { //TODO clickable should pass player - val viewers = inv.viewers.filterIsInstance() - if (playSound) { - if (enabled) viewers.forEach { it.playSound(it.location, Sound.ITEM_ARMOR_EQUIP_GENERIC, 1f, 1f) } - else viewers.forEach { it.playSound(it.location, Sound.BLOCK_LEVER_CLICK, 1f, 1f) } - } + Row(modifier.clickable { + val player = whoClicked as? Player ?: return@clickable + if (playSound) player.playSound(player.location, if (enabled) Sound.ITEM_ARMOR_EQUIP_GENERIC else Sound.BLOCK_LEVER_CLICK, 1f, 1f) if (enabled) onClick() }) { content(enabled) diff --git a/src/main/kotlin/com/mineinabyss/blocky/menus/BlockyMenu.kt b/src/main/kotlin/com/mineinabyss/blocky/menus/BlockyMenu.kt index 963d1351..2cafcc46 100644 --- a/src/main/kotlin/com/mineinabyss/blocky/menus/BlockyMenu.kt +++ b/src/main/kotlin/com/mineinabyss/blocky/menus/BlockyMenu.kt @@ -8,7 +8,7 @@ import com.mineinabyss.geary.prefabs.PrefabKey import com.mineinabyss.guiy.components.Item import com.mineinabyss.guiy.modifiers.Modifier import com.mineinabyss.guiy.modifiers.at -import com.mineinabyss.guiy.modifiers.clickable +import com.mineinabyss.guiy.modifiers.click.clickable import org.bukkit.entity.Player import org.bukkit.event.inventory.ClickType @@ -34,18 +34,18 @@ fun HandleMenuClicks(key: PrefabKey, player: Player) { val block = gearyItems.createItem(key) Item(block, Modifier.clickable { when (clickType) { - ClickType.LEFT -> { - if (cursor == null) cursor = block - else if (player.gearyInventory?.itemOnCursor == key.toEntity()) cursor?.add(1) - else cursor = block?.asQuantity(1) + ClickType.LEFT -> when { + cursor == null -> whoClicked.setItemOnCursor(block) + player.gearyInventory?.itemOnCursor?.prefabs?.first()?.get() == key -> cursor?.add(1) + else -> whoClicked.setItemOnCursor(block?.asQuantity(1)) } - ClickType.RIGHT -> { - if (cursor == null) cursor = block?.asQuantity(1) - else cursor?.subtract(1) + ClickType.RIGHT -> when (cursor) { + null -> whoClicked.setItemOnCursor(block?.asQuantity(1)) + else -> cursor?.subtract(1) } - ClickType.MIDDLE -> cursor = block?.asQuantity(block.maxStackSize) - ClickType.SHIFT_LEFT -> cursor = block?.asQuantity(block.maxStackSize) - ClickType.SHIFT_RIGHT -> cursor = block?.asQuantity(block.maxStackSize) + ClickType.MIDDLE -> whoClicked.setItemOnCursor(block?.asQuantity(block.maxStackSize)) + ClickType.SHIFT_LEFT -> whoClicked.setItemOnCursor(block?.asQuantity(block.maxStackSize)) + ClickType.SHIFT_RIGHT -> whoClicked.setItemOnCursor(block?.asQuantity(block.maxStackSize)) ClickType.DROP -> block?.let { player.world.dropItemNaturally(player.location, it) } ClickType.CONTROL_DROP -> block?.asQuantity(block.maxStackSize)?.let { player.world.dropItemNaturally(player.location, it) } else -> return@clickable diff --git a/src/main/kotlin/com/mineinabyss/blocky/menus/BlockyNavigation.kt b/src/main/kotlin/com/mineinabyss/blocky/menus/BlockyNavigation.kt index 5cf977f0..9c95b6a2 100644 --- a/src/main/kotlin/com/mineinabyss/blocky/menus/BlockyNavigation.kt +++ b/src/main/kotlin/com/mineinabyss/blocky/menus/BlockyNavigation.kt @@ -6,6 +6,7 @@ import com.mineinabyss.blocky.helpers.composables.Button import com.mineinabyss.guiy.components.Item import com.mineinabyss.guiy.components.canvases.Chest import com.mineinabyss.guiy.inventory.GuiyOwner +import com.mineinabyss.guiy.inventory.LocalGuiyOwner import com.mineinabyss.guiy.modifiers.Modifier import com.mineinabyss.guiy.modifiers.height import com.mineinabyss.guiy.navigation.Navigator @@ -30,9 +31,10 @@ class BlockyUIScope(val player: Player) { } @Composable -fun GuiyOwner.BlockyMainMenu(player: Player) { +fun BlockyMainMenu(player: Player) { + val owner = LocalGuiyOwner.current BlockyUIScope(player).apply { - nav.withScreen(setOf(player), onEmpty = ::exit) { screen -> + nav.withScreen(setOf(player), onEmpty = owner::exit) { screen -> Chest(setOf(player), screen.title, Modifier.height(screen.height), onClose = { player.closeInventory() }) {