Added BadIPDetection
This commit is contained in:
@@ -0,0 +1,11 @@
|
||||
package net.axay.kspigot.languageextensions.kotlinextensions
|
||||
|
||||
import java.io.File
|
||||
|
||||
internal fun File.createIfNotExists(): Boolean {
|
||||
return if (!exists()) {
|
||||
if (!parentFile.exists())
|
||||
parentFile.mkdirs()
|
||||
createNewFile()
|
||||
} else true
|
||||
}
|
@@ -0,0 +1,7 @@
|
||||
package net.axay.kspigot.languageextensions.kotlinextensions
|
||||
|
||||
internal fun <T> T.applyIfNotNull(block: (T.() -> Unit)?): T {
|
||||
if (block != null)
|
||||
apply(block)
|
||||
return this
|
||||
}
|
@@ -0,0 +1,7 @@
|
||||
package net.axay.kspigot.languageextensions.kotlinextensions
|
||||
|
||||
internal inline fun <T, R> Lazy<T>.ifInitialized(block: (T) -> R) = if (isInitialized()) block(value) else null
|
||||
|
||||
internal val <T> Lazy<T>.valueIfInitialized get() = ifInitialized { value }
|
||||
|
||||
internal fun Lazy<AutoCloseable>.closeIfInitialized() = ifInitialized { value.close() }
|
@@ -0,0 +1,18 @@
|
||||
@file:Suppress("MemberVisibilityCanBePrivate")
|
||||
|
||||
package net.axay.kspigot.languageextensions.kotlinextensions
|
||||
|
||||
internal class MinMaxPair<T : Comparable<T>>(a: T, b: T) {
|
||||
|
||||
val min: T;
|
||||
val max: T
|
||||
|
||||
init {
|
||||
if (a >= b) {
|
||||
min = b; max = a
|
||||
} else {
|
||||
min = a; max = b
|
||||
}
|
||||
}
|
||||
|
||||
}
|
Reference in New Issue
Block a user