diff --git a/src/main/kotlin/net/axay/kspigot/extensions/bukkit/GeoExtensions.kt b/src/main/kotlin/net/axay/kspigot/extensions/bukkit/GeoExtensions.kt new file mode 100644 index 00000000..9bba4418 --- /dev/null +++ b/src/main/kotlin/net/axay/kspigot/extensions/bukkit/GeoExtensions.kt @@ -0,0 +1,26 @@ +package net.axay.kspigot.extensions.bukkit + +import org.bukkit.Chunk +import org.bukkit.Location +import org.bukkit.World +import org.bukkit.block.Block + +/** + * Assumes that this Location has world data. + * If not, an exception will be thrown. + */ +val Location.worldOrException: World + get() = world + ?: throw NullPointerException("The world of the location is null!") + +/** + * @return All blocks in this chunk. + */ +val Chunk.allBlocks + get() = LinkedHashSet().apply { + for (y in 0 until 256) { + for (x in 0 until 16) + for (z in 0 until 16) + add(getBlock(x, y, z)) + } + } \ No newline at end of file diff --git a/src/main/kotlin/net/axay/kspigot/extensions/bukkit/LocationExtensions.kt b/src/main/kotlin/net/axay/kspigot/extensions/bukkit/LocationExtensions.kt deleted file mode 100644 index fe1ee5e7..00000000 --- a/src/main/kotlin/net/axay/kspigot/extensions/bukkit/LocationExtensions.kt +++ /dev/null @@ -1,12 +0,0 @@ -package net.axay.kspigot.extensions.bukkit - -import org.bukkit.Location -import org.bukkit.World - -/** - * Assumes that this Location has world data. - * If not, an exception will be thrown. - */ -val Location.worldOrException: World - get() = world - ?: throw NullPointerException("The world of the location is null!") \ No newline at end of file