Update KSpigotLocations.kt
This commit is contained in:
@@ -1,5 +1,8 @@
|
||||
@file:Suppress("unused")
|
||||
|
||||
package net.axay.kspigot.extensions.geometry
|
||||
|
||||
import org.bukkit.Chunk
|
||||
import org.bukkit.Location
|
||||
import org.bukkit.World
|
||||
|
||||
@@ -14,9 +17,14 @@ data class SimpleLocation3D(val x: Double, val y: Double, val z: Double) {
|
||||
|
||||
data class SimpleChunkLocation(val x: Int, val z: Int)
|
||||
|
||||
// EXTENSIONS
|
||||
// CONVERTER
|
||||
|
||||
fun Location.toSimple() = SimpleLocation3D(x, y, z)
|
||||
fun Chunk.toSimple() = SimpleChunkLocation(x, z)
|
||||
|
||||
fun SimpleLocation3D.withWorld(world: World) = Location(world, x, y, z)
|
||||
fun SimpleChunkLocation.withWorld(world: World) = world.getChunkAt(x, z)
|
||||
|
||||
// EXTENSIONS
|
||||
|
||||
val Location.worldOrException: World get() = world ?: throw NullPointerException("The world of the location is null!")
|
Reference in New Issue
Block a user