From 6b1df76f3669c87415ebb471ecd6ef4e8361738c Mon Sep 17 00:00:00 2001 From: Roman Makeev Date: Sun, 12 May 2024 13:03:14 +0300 Subject: [PATCH] Fix sit on slab --- gradle.properties | 2 +- .../aspekt/event/sit/SitEvent.kt | 18 ++++++++++++------ 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/gradle.properties b/gradle.properties index d0fbe92..06bf145 100644 --- a/gradle.properties +++ b/gradle.properties @@ -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|makeevrserg@gmail.com makeevrserg.project.url=https://empireprojekt.ru diff --git a/plugin/src/main/kotlin/ru/astrainteractive/aspekt/event/sit/SitEvent.kt b/plugin/src/main/kotlin/ru/astrainteractive/aspekt/event/sit/SitEvent.kt index a1910de..4c75be6 100644 --- a/plugin/src/main/kotlin/ru/astrainteractive/aspekt/event/sit/SitEvent.kt +++ b/plugin/src/main/kotlin/ru/astrainteractive/aspekt/event/sit/SitEvent.kt @@ -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(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(eventListener, plugin) { e ->