fix: Corrected an issue where elevators would not function if other blocks were present between the elevator blocks.

This commit is contained in:
Kariya 2025-12-07 14:31:48 +00:00
parent 1266ff75cd
commit 152bb5096d

View File

@ -29,12 +29,12 @@ class EventListener(private val plugin: App) : Listener {
val maxHeight = plugin.config.getInt("maxHeight", 64)
var distance = 0
while (!location.block.type.isSolid && !(location.block.type in oreBlock) && distance < maxHeight) {
while (!(location.block.type in oreBlock) && distance < maxHeight) {
location = location.add(0.0, 1.0, 0.0)
distance++
}
if (location.block.type.isSolid && location.block.type in oreBlock) {
if (location.block.type in oreBlock) {
player.teleport(location.add(0.5, 1.0, 0.5).addRotation(player.location.yaw, player.location.pitch))
}
}
@ -47,19 +47,19 @@ class EventListener(private val plugin: App) : Listener {
val player = event.player
val blockUnder = player.location.subtract(0.0, 1.0, 0.0).block
if (blockUnder.type.isSolid && blockUnder.type in oreBlock) {
if (blockUnder.type in oreBlock) {
var location = blockUnder.location
location = location.subtract(0.0, 1.0, 0.0)
val maxHeight = plugin.config.getInt("maxHeight", 64)
var distance = 0
while (!location.block.type.isSolid && !(location.block.type in oreBlock) && distance < maxHeight) {
while (!(location.block.type in oreBlock) && distance < maxHeight) {
location = location.subtract(0.0, 1.0, 0.0)
distance++
}
if (location.block.type.isSolid && location.block.type in oreBlock) {
if (location.block.type in oreBlock) {
player.teleport(location.add(0.5, 1.0, 0.5).addRotation(player.location.yaw, player.location.pitch))
}
}