Create KSpigotParticles.kt
This commit is contained in:
@@ -0,0 +1,53 @@
|
|||||||
|
package net.axay.kspigot.particles
|
||||||
|
|
||||||
|
import org.bukkit.Location
|
||||||
|
import org.bukkit.Particle
|
||||||
|
import org.bukkit.entity.Player
|
||||||
|
import org.bukkit.util.Vector
|
||||||
|
|
||||||
|
data class KSpigotParticle(
|
||||||
|
val particle: Particle,
|
||||||
|
var amount: Int = 1,
|
||||||
|
var offset: Vector? = null,
|
||||||
|
var extra: Number = 1.0,
|
||||||
|
var data: Any? = null,
|
||||||
|
var force: Boolean = false
|
||||||
|
) {
|
||||||
|
|
||||||
|
fun spawnAt(loc: Location) {
|
||||||
|
loc.world?.spawnParticle(
|
||||||
|
particle,
|
||||||
|
loc,
|
||||||
|
amount,
|
||||||
|
offset?.x ?: 0.0,
|
||||||
|
offset?.y ?: 0.0,
|
||||||
|
offset?.z ?: 0.0,
|
||||||
|
extra.toDouble(),
|
||||||
|
data,
|
||||||
|
force
|
||||||
|
) ?: throw IllegalArgumentException("The world of the given location is null!")
|
||||||
|
}
|
||||||
|
|
||||||
|
fun spawnFor(player: Player) {
|
||||||
|
player.spawnParticle(
|
||||||
|
particle,
|
||||||
|
player.location,
|
||||||
|
amount,
|
||||||
|
offset?.x ?: 0.0,
|
||||||
|
offset?.y ?: 0.0,
|
||||||
|
offset?.z ?: 0.0,
|
||||||
|
extra.toDouble(),
|
||||||
|
data
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
fun particle(particle: Particle, builder: KSpigotParticle.() -> Unit)
|
||||||
|
= KSpigotParticle(particle).apply(builder)
|
||||||
|
|
||||||
|
fun Player.particle(particle: Particle, builder: KSpigotParticle.() -> Unit)
|
||||||
|
= KSpigotParticle(particle).apply(builder).spawnFor(this)
|
||||||
|
|
||||||
|
fun Location.particle(particle: Particle, builder: KSpigotParticle.() -> Unit)
|
||||||
|
= KSpigotParticle(particle).apply(builder).spawnAt(this)
|
Reference in New Issue
Block a user