All Downloads are FREE. Search and download functionalities are using the official Maven repository.

walkmc.shape.Line.kt Maven / Gradle / Ivy

There is a newer version: 2.4.0
Show newest version
@file:UseContextualSerialization(Location::class)

package walkmc.shape

import kotlinx.serialization.*
import org.bukkit.*
import walkmc.extensions.*

/**
 * Represents a line util class. This can be used to draw/display particles in a line.
 */
@Serializable
data class Line(
	var start: Location,
	var end: Location,
	var points: Int
) : Shape {
	
	/**
	 * Returns the path of this shape.
	 */
	@Transient
	override lateinit var path: List
	
	/**
	 * Generates the [path] and updates their property.
	 */
	override fun generatePath(): List {
		val path = start.generateLinePath(end, points)
		this.path = path
		return path
	}
}

/**
 * Creates a line representation with this location as center.
 */
fun Location.line(end: Location, points: Int) = Line(this, end, points)




© 2015 - 2025 Weber Informatics LLC | Privacy Policy