Skip to content

Commit

Permalink
refactor: pass initial argument in withGeary block
Browse files Browse the repository at this point in the history
  • Loading branch information
Boy0000 committed Oct 27, 2024
1 parent 25668ec commit 43a8bc9
Showing 1 changed file with 5 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,13 @@ import com.mineinabyss.geary.prefabs.PrefabKey
import com.mineinabyss.geary.prefabs.entityOfOrNull
import com.mineinabyss.idofront.typealiases.BukkitEntity
import org.bukkit.block.Block
import org.bukkit.block.TileState

context(Geary)
fun PrefabKey.toEntityOrNull() = entityOfOrNull(this)

inline fun <T> BukkitEntity.withGeary(run: Geary.() -> T) = with(world.toGeary()) { run() }
inline fun <T, R : BukkitEntity> R.withGeary(run: Geary.(R) -> T) = with(world.toGeary()) { run(this@withGeary) }

inline fun <T> Block.withGeary(run: Geary.() -> T) = with(world.toGeary()) { run() }
inline fun <T, R : TileState> R.withGeary(run: Geary.(R) -> T) = with(world.toGeary()) { run(this@withGeary) }

inline fun <T, R : Block> R.withGeary(run: Geary.(R) -> T) = with(world.toGeary()) { run(this@withGeary) }

0 comments on commit 43a8bc9

Please sign in to comment.