Skip to content

Commit

Permalink
chore: bump idofront, geary & guiy
Browse files Browse the repository at this point in the history
  • Loading branch information
Boy0000 committed May 31, 2024
1 parent 03f96c2 commit 5c2bf67
Show file tree
Hide file tree
Showing 13 changed files with 30 additions and 31 deletions.
2 changes: 1 addition & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}

Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
group=com.mineinabyss
version=0.9
idofrontVersion=0.24.0-dev.8
idofrontVersion=0.24.2
6 changes: 3 additions & 3 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
@@ -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"
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,6 @@ val Block.persistentDataContainer get() = customBlockData as PersistentDataConta
val Block.customBlockData get() = CustomBlockData(this, blocky.plugin)
fun Block.toBlockPos() = BlockPos(this.x, this.y, this.z)

internal infix fun <A, B, C> Pair<A, B>.to(that: C): Triple<A, B, C> = Triple(this.first, this.second, that)
internal inline fun <reified T> ItemStack.decode(): T? = this.itemMeta?.persistentDataContainer?.decode()
internal val Player.gearyInventory get() = inventory.toGeary()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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<Player>()
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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import com.mineinabyss.blocky.helpers.CaveVineHelpers
import com.mineinabyss.blocky.helpers.GenericHelpers.isInteractable
import com.mineinabyss.blocky.helpers.gearyInventory
import com.mineinabyss.blocky.helpers.placeBlockyBlock
import com.mineinabyss.blocky.helpers.to
import com.mineinabyss.geary.papermc.tracking.blocks.components.SetBlock
import com.mineinabyss.idofront.util.to
import io.papermc.paper.event.block.BlockBreakBlockEvent
import org.bukkit.Material
import org.bukkit.block.BlockFace
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@ import com.mineinabyss.blocky.helpers.GenericHelpers.isInteractable
import com.mineinabyss.geary.papermc.datastore.encode
import com.mineinabyss.geary.papermc.tracking.blocks.components.SetBlock
import com.mineinabyss.idofront.events.call
import com.mineinabyss.idofront.messaging.broadcast
import com.mineinabyss.idofront.messaging.broadcastVal
import com.mineinabyss.idofront.util.to
import io.th0rgal.protectionlib.ProtectionLib
import org.bukkit.Material
import org.bukkit.block.Block
Expand All @@ -25,7 +24,6 @@ import org.bukkit.event.EventPriority
import org.bukkit.event.Listener
import org.bukkit.event.block.Action
import org.bukkit.event.block.BlockBreakEvent
import org.bukkit.event.block.BlockDropItemEvent
import org.bukkit.event.block.BlockFormEvent
import org.bukkit.event.player.PlayerInteractEvent
import org.bukkit.inventory.EquipmentSlot
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package com.mineinabyss.blocky.listeners
import com.destroystokyo.paper.event.entity.EntityRemoveFromWorldEvent
import com.destroystokyo.paper.event.player.PlayerUseUnknownEntityEvent
import com.github.shynixn.mccoroutine.bukkit.launch
import com.mineinabyss.idofront.util.to
import com.github.shynixn.mccoroutine.bukkit.minecraftDispatcher
import com.mineinabyss.blocky.api.BlockyFurnitures
import com.mineinabyss.blocky.api.BlockyFurnitures.isBlockyFurniture
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import com.mineinabyss.blocky.components.features.mining.PlayerMiningAttribute
import com.mineinabyss.blocky.components.features.mining.miningAttribute
import com.mineinabyss.blocky.helpers.*
import com.mineinabyss.blocky.helpers.gearyInventory
import com.mineinabyss.blocky.helpers.to
import com.mineinabyss.idofront.util.to
import com.mineinabyss.geary.papermc.tracking.blocks.components.SetBlock
import com.mineinabyss.geary.papermc.tracking.blocks.helpers.toGearyOrNull
import com.mineinabyss.geary.papermc.tracking.entities.toGearyOrNull
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package com.mineinabyss.blocky.listeners

import com.jeff_media.customblockdata.CustomBlockData
import com.mineinabyss.blocky.api.BlockyBlocks.isBlockyBlock
import com.mineinabyss.idofront.util.to
import com.mineinabyss.blocky.api.events.block.BlockyBlockInteractEvent
import com.mineinabyss.blocky.blocky
import com.mineinabyss.blocky.components.core.VanillaNoteBlock
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import com.mineinabyss.blocky.api.BlockyBlocks.isBlockyBlock
import com.mineinabyss.blocky.api.events.block.BlockyBlockPlaceEvent
import com.mineinabyss.blocky.components.features.wire.BlockyTallWire
import com.mineinabyss.blocky.helpers.*
import com.mineinabyss.idofront.util.to
import com.mineinabyss.blocky.helpers.GenericHelpers.isInteractable
import com.mineinabyss.geary.papermc.datastore.decode
import com.mineinabyss.geary.papermc.datastore.encode
Expand Down
22 changes: 11 additions & 11 deletions src/main/kotlin/com/mineinabyss/blocky/menus/BlockyMenu.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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<PrefabKey>() == 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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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() }) {
Expand Down

0 comments on commit 5c2bf67

Please sign in to comment.