
walkmc.shape.Shape.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of walk-server Show documentation
Show all versions of walk-server Show documentation
A spigot fork to kotlin structure and news.
package walkmc.shape
import org.bukkit.*
import org.bukkit.block.*
import org.bukkit.entity.*
import walkmc.*
/**
* Represents a base shape.
*/
interface Shape {
/**
* Returns the path of this shape.
*/
var path: List
/**
* Generates the [path] and updates their property.
*/
fun generatePath(): List
}
/**
* Returns if this shape contains the specified location in their path.
*/
operator fun Shape.contains(location: Location): Boolean = location in path
/**
* Draws this shape to the specified [material]. This replaces any block by [material].
*/
fun Shape.draw(material: Materials) {
for (l in path)
l.block.material = material
}
/**
* Draws this shape to the specified [material]. A [predicate] is used to test if this shape
* can draw at the given block.
*/
inline fun Shape.draw(material: Materials, predicate: (Block) -> Boolean) {
for (l in path) {
val block = l.block
if (predicate(block))
block.material = material
}
}
/**
* Displays the specified [particle] in all single path of this shape.
*/
fun Shape.display(
particle: Particle,
amount: Int = 1,
speed: Float = 0f,
offsetX: Float = 0f,
offsetY: Float = 0f,
offsetZ: Float = 0f,
) {
for (l in path)
particle.play(l, amount, speed, offsetX, offsetY, offsetZ)
}
/**
* Displays the specified [particle] in all single path of this shape.
*/
fun Shape.display(
player: Player,
particle: Particle,
amount: Int = 1,
speed: Float = 0f,
offsetX: Float = 0f,
offsetY: Float = 0f,
offsetZ: Float = 0f,
) {
for (l in path)
particle.play(player, l, amount, speed, offsetX, offsetY, offsetZ)
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy