Skip to content

Commit

Permalink
Merge pull request #32 from Astra-Interactive/fix/slab-sit
Browse files Browse the repository at this point in the history
Fix sit on slab
  • Loading branch information
makeevrserg committed May 12, 2024
2 parents dab32b5 + 6b1df76 commit 9d187f5
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 7 deletions.
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ makeevrserg.java.ktarget=17
# Project
makeevrserg.project.name=AspeKt
makeevrserg.project.group=ru.astrainteractive.aspekt
makeevrserg.project.version.string=2.19.7
makeevrserg.project.version.string=2.19.8
makeevrserg.project.description=Essentials plugin for EmpireProjekt
makeevrserg.project.developers=makeevrserg|Makeev Roman|[email protected]
makeevrserg.project.url=https://empireprojekt.ru
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,18 +23,24 @@ class SitEvent(
sitController.stopSitPlayer(e.player)
}

private fun canSit(type: Material): Boolean {
if (type.name.contains(other = "stairs", ignoreCase = true)) return true
if (type.name.contains(other = "slab", ignoreCase = true)) return true
return false
}

val playerInteractEvent = DSLEvent<PlayerInteractEvent>(eventListener, plugin) { e ->
if (!configuration.sit) return@DSLEvent
if (e.hand != EquipmentSlot.HAND) return@DSLEvent
if (e.player.isSneaking) return@DSLEvent
if (e.action != Action.RIGHT_CLICK_BLOCK) return@DSLEvent
if (e.player.inventory.itemInMainHand.type != Material.AIR) return@DSLEvent
if (e.clickedBlock?.type?.name?.contains("stairs", ignoreCase = true) == true) {
sitController.toggleSitPlayer(
e.player,
e.clickedBlock?.location?.clone()?.add(0.5, 0.5, 0.5) ?: return@DSLEvent
)
}
val material = e.clickedBlock?.type ?: return@DSLEvent
if (!canSit(material)) return@DSLEvent
sitController.toggleSitPlayer(
e.player,
e.clickedBlock?.location?.clone()?.add(0.5, 0.5, 0.5) ?: return@DSLEvent
)
}

val onDisconnect = DSLEvent<PlayerQuitEvent>(eventListener, plugin) { e ->
Expand Down

0 comments on commit 9d187f5

Please sign in to comment.