Skip to content

Commit

Permalink
feat: prevent dismounting & entering vehicles when it puts you outsid…
Browse files Browse the repository at this point in the history
…e of the map
  • Loading branch information
Boy0000 committed Jan 26, 2024
1 parent 537069f commit c327068
Showing 1 changed file with 12 additions and 11 deletions.
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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
}
}

0 comments on commit c327068

Please sign in to comment.