Fixed StackOverflowError
This commit is contained in:
@@ -16,7 +16,7 @@ internal class MinMaxPair<T : Comparable<T>>(a: T, b: T) {
|
||||
}
|
||||
}
|
||||
|
||||
internal fun <T> T.apply(block: (T.() -> Unit)?): T {
|
||||
internal fun <T> T.applyIfNotNull(block: (T.() -> Unit)?): T {
|
||||
if (block != null)
|
||||
apply(block)
|
||||
return this
|
||||
|
@@ -1,7 +1,7 @@
|
||||
package net.axay.kspigot.particles
|
||||
|
||||
import net.axay.kspigot.extensions.bukkit.worldOrException
|
||||
import net.axay.kspigot.kotlinextensions.apply
|
||||
import net.axay.kspigot.kotlinextensions.applyIfNotNull
|
||||
import org.bukkit.Location
|
||||
import org.bukkit.Particle
|
||||
import org.bukkit.entity.Player
|
||||
@@ -74,7 +74,7 @@ fun particle(particle: Particle, builder: KSpigotParticle.() -> Unit)
|
||||
* @see KSpigotParticle
|
||||
*/
|
||||
fun Location.particle(particle: Particle, builder: (KSpigotParticle.() -> Unit)? = null)
|
||||
= KSpigotParticle(particle).apply(builder).spawnAt(this)
|
||||
= KSpigotParticle(particle).applyIfNotNull(builder).spawnAt(this)
|
||||
|
||||
/**
|
||||
* Accesses the particle builder and then immediately
|
||||
@@ -82,4 +82,4 @@ fun Location.particle(particle: Particle, builder: (KSpigotParticle.() -> Unit)?
|
||||
* @see KSpigotParticle
|
||||
*/
|
||||
fun Player.particle(particle: Particle, builder: (KSpigotParticle.() -> Unit)? = null)
|
||||
= KSpigotParticle(particle).apply(builder).spawnFor(this)
|
||||
= KSpigotParticle(particle).applyIfNotNull(builder).spawnFor(this)
|
@@ -1,7 +1,7 @@
|
||||
package net.axay.kspigot.sound
|
||||
|
||||
import net.axay.kspigot.extensions.bukkit.worldOrException
|
||||
import net.axay.kspigot.kotlinextensions.apply
|
||||
import net.axay.kspigot.kotlinextensions.applyIfNotNull
|
||||
import org.bukkit.Location
|
||||
import org.bukkit.Sound
|
||||
import org.bukkit.SoundCategory
|
||||
@@ -53,7 +53,7 @@ fun sound(sound: Sound, builder: KSpigotSound.() -> Unit)
|
||||
* @see KSpigotSound
|
||||
*/
|
||||
fun Location.sound(sound: Sound, builder: (KSpigotSound.() -> Unit)? = null)
|
||||
= KSpigotSound(sound).apply(builder).playAt(this)
|
||||
= KSpigotSound(sound).applyIfNotNull(builder).playAt(this)
|
||||
|
||||
/**
|
||||
* Accesses the sound builder and then immediately
|
||||
@@ -61,4 +61,4 @@ fun Location.sound(sound: Sound, builder: (KSpigotSound.() -> Unit)? = null)
|
||||
* @see KSpigotSound
|
||||
*/
|
||||
fun Player.sound(sound: Sound, builder: (KSpigotSound.() -> Unit)? = null)
|
||||
= KSpigotSound(sound).apply(builder).playFor(this)
|
||||
= KSpigotSound(sound).applyIfNotNull(builder).playFor(this)
|
||||
|
Reference in New Issue
Block a user