diff --git a/src/main/kotlin/com/mineinabyss/deeperworld/listeners/PlayerListener.kt b/src/main/kotlin/com/mineinabyss/deeperworld/listeners/PlayerListener.kt index 4353391..48619cb 100644 --- a/src/main/kotlin/com/mineinabyss/deeperworld/listeners/PlayerListener.kt +++ b/src/main/kotlin/com/mineinabyss/deeperworld/listeners/PlayerListener.kt @@ -1,21 +1,18 @@ package com.mineinabyss.deeperworld.listeners import com.mineinabyss.deeperworld.services.canMoveSections -import com.mineinabyss.deeperworld.world.section.correspondingSection -import com.mineinabyss.deeperworld.world.section.inSectionOverlap import com.mineinabyss.deeperworld.world.section.inSectionTransition import com.mineinabyss.deeperworld.world.section.section import com.mineinabyss.idofront.location.up -import com.mineinabyss.idofront.messaging.broadcastVal import com.mineinabyss.idofront.messaging.error import org.bukkit.GameMode.CREATIVE import org.bukkit.event.EventHandler import org.bukkit.event.Listener -import org.bukkit.event.entity.EntityDismountEvent import org.bukkit.event.player.PlayerTeleportEvent import org.bukkit.event.player.PlayerTeleportEvent.TeleportCause.CHORUS_FRUIT import org.bukkit.event.player.PlayerTeleportEvent.TeleportCause.ENDER_PEARL -import org.bukkit.event.vehicle.VehicleCreateEvent +import org.bukkit.event.vehicle.VehicleEnterEvent +import org.bukkit.event.vehicle.VehicleExitEvent object PlayerListener : Listener { @EventHandler @@ -34,12 +31,16 @@ object PlayerListener : Listener { } @EventHandler - fun EntityDismountEvent.onCreateVehicle() { - if (entity.location.up(1).section != null) return - entity.error("The Abyss prevents you from dismounting here...") + fun VehicleEnterEvent.onEnterVehicle() { + if (vehicle.location.up(1).section != null) return + entered.error("The Abyss prevents you from mounting here...") isCancelled = true } -} -//TODO move into idofront -private operator fun PlayerTeleportEvent.component4() = cause + @EventHandler + fun VehicleExitEvent.onExitVehicle() { + if (vehicle.location.up(1).section != null) return + exited.error("The Abyss prevents you from dismounting here...") + isCancelled = true + } +}