-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Broke up the massive methods in the MovementListener.kt and allow for better abstraction.
- Loading branch information
Showing
12 changed files
with
433 additions
and
288 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
38 changes: 38 additions & 0 deletions
38
...java/com/derongan/minecraft/deeperworld/movement/BedrockBlockingInvalidTeleportHandler.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
package com.derongan.minecraft.deeperworld.movement | ||
|
||
import com.derongan.minecraft.deeperworld.deeperWorld | ||
import com.derongan.minecraft.deeperworld.listeners.MovementListener | ||
import com.mineinabyss.idofront.location.up | ||
import com.okkero.skedule.schedule | ||
import org.bukkit.Location | ||
import org.bukkit.Material | ||
import org.bukkit.entity.Player | ||
|
||
class BedrockBlockingInvalidTeleportHandler(player: Player, from: Location, to: Location) : | ||
InvalidTeleportHandler(player, from, to) { | ||
override fun handleInvalidTeleport() { | ||
from.block.type = Material.BEDROCK | ||
|
||
val spawnedBedrock = from.block | ||
MovementListener.temporaryBedrock.add(spawnedBedrock) | ||
|
||
// Keep bedrock spawned if there are players within a 1.5 radius (regular jump height). | ||
// If no players are in this radius, destroy the bedrock. | ||
deeperWorld.schedule { | ||
this.repeating(1) | ||
while (spawnedBedrock.location.up(1).getNearbyPlayers(1.5).isNotEmpty()) { | ||
yield() | ||
} | ||
spawnedBedrock.type = Material.AIR | ||
MovementListener.temporaryBedrock.remove(spawnedBedrock) | ||
} | ||
|
||
val oldFallDistance = player.fallDistance | ||
val oldVelocity = player.velocity | ||
|
||
player.teleport(from.up(1)) | ||
|
||
player.fallDistance = oldFallDistance | ||
player.velocity = oldVelocity | ||
} | ||
} |
Oops, something went wrong.