From 51fa10eb53333892d7e75fa07c1f715e5323b434 Mon Sep 17 00:00:00 2001 From: bluefireoly Date: Mon, 19 Oct 2020 17:50:59 +0200 Subject: [PATCH 1/4] Added khttp as a dependency --- build.gradle.kts | 3 +++ 1 file changed, 3 insertions(+) diff --git a/build.gradle.kts b/build.gradle.kts index 38743105..54a21c53 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -57,6 +57,9 @@ dependencies { compileOnly("org.spigotmc", "spigot", "1.16.3-R0.1-SNAPSHOT") testCompileOnly("org.spigotmc", "spigot", "1.16.3-R0.1-SNAPSHOT") + // KHTTP + implementation("khttp", "khttp", "1.0.0") + } /* From fd505cd902cc3acb3f6bc64a89af705e1087ad34 Mon Sep 17 00:00:00 2001 From: bluefireoly Date: Mon, 19 Oct 2020 17:51:21 +0200 Subject: [PATCH 2/4] Added BadIPDetection --- .../net/axay/kspigot/config/ConfigManager.kt | 4 +- .../kspigot/inventory/InventoryGUISlots.kt | 2 +- .../axay/kspigot/ipaddress/BadIPDetection.kt | 118 ++++++++++++++++++ .../axay/kspigot/ipaddress/IPAddressData.kt | 44 +++---- .../badipdetectionservices/GetIPIntel.kt | 23 ++++ .../ipaddress/badipdetectionservices/IPHub.kt | 21 ++++ .../badipdetectionservices/IPInfo.kt | 24 ++++ .../badipdetectionservices/VPNBlocker.kt | 24 ++++ .../kotlinextensions/GeneralExtensions.kt | 36 ------ .../languageextensions/GsonExtensions.kt | 20 +++ .../languageextensions/JSONExtensions.kt | 11 ++ .../kotlinextensions/FileExtensions.kt | 11 ++ .../kotlinextensions/GeneralExtensions.kt | 7 ++ .../kotlinextensions/LazyExtensions.kt | 7 ++ .../kotlinextensions/MinMaxPair.kt | 18 +++ .../kotlin/net/axay/kspigot/main/KSpigot.kt | 2 +- .../net/axay/kspigot/main/ValueHolder.kt | 2 +- .../kspigot/particles/KSpigotParticles.kt | 2 +- .../serialization/SpigotSerializable.kt | 2 +- .../net/axay/kspigot/sound/KSpigotSound.kt | 2 +- 20 files changed, 311 insertions(+), 69 deletions(-) create mode 100644 src/main/kotlin/net/axay/kspigot/ipaddress/BadIPDetection.kt create mode 100644 src/main/kotlin/net/axay/kspigot/ipaddress/badipdetectionservices/GetIPIntel.kt create mode 100644 src/main/kotlin/net/axay/kspigot/ipaddress/badipdetectionservices/IPHub.kt create mode 100644 src/main/kotlin/net/axay/kspigot/ipaddress/badipdetectionservices/IPInfo.kt create mode 100644 src/main/kotlin/net/axay/kspigot/ipaddress/badipdetectionservices/VPNBlocker.kt delete mode 100644 src/main/kotlin/net/axay/kspigot/kotlinextensions/GeneralExtensions.kt create mode 100644 src/main/kotlin/net/axay/kspigot/languageextensions/GsonExtensions.kt create mode 100644 src/main/kotlin/net/axay/kspigot/languageextensions/JSONExtensions.kt create mode 100644 src/main/kotlin/net/axay/kspigot/languageextensions/kotlinextensions/FileExtensions.kt create mode 100644 src/main/kotlin/net/axay/kspigot/languageextensions/kotlinextensions/GeneralExtensions.kt create mode 100644 src/main/kotlin/net/axay/kspigot/languageextensions/kotlinextensions/LazyExtensions.kt create mode 100644 src/main/kotlin/net/axay/kspigot/languageextensions/kotlinextensions/MinMaxPair.kt diff --git a/src/main/kotlin/net/axay/kspigot/config/ConfigManager.kt b/src/main/kotlin/net/axay/kspigot/config/ConfigManager.kt index d87bd4f5..33c78ab9 100644 --- a/src/main/kotlin/net/axay/kspigot/config/ConfigManager.kt +++ b/src/main/kotlin/net/axay/kspigot/config/ConfigManager.kt @@ -2,7 +2,7 @@ package net.axay.kspigot.config -import net.axay.kspigot.kotlinextensions.createIfNotExists +import net.axay.kspigot.languageextensions.createIfNotExists import net.axay.kspigot.main.ValueHolder.getGson import java.io.File import java.io.FileReader @@ -83,7 +83,7 @@ class ConfigDelegate( internal object GsonConfigManager { fun loadConfig(file: File, configClass: KClass): T = - FileReader(file).use { reader -> return getGson(false).fromJson(reader, configClass.java) } + FileReader(file).use { reader -> return getGson().fromJson(reader, configClass.java) } fun saveConfig(file: File, config: T, pretty: Boolean = true) { file.createIfNotExists() diff --git a/src/main/kotlin/net/axay/kspigot/inventory/InventoryGUISlots.kt b/src/main/kotlin/net/axay/kspigot/inventory/InventoryGUISlots.kt index 52bf65bd..c90e906e 100644 --- a/src/main/kotlin/net/axay/kspigot/inventory/InventoryGUISlots.kt +++ b/src/main/kotlin/net/axay/kspigot/inventory/InventoryGUISlots.kt @@ -2,7 +2,7 @@ package net.axay.kspigot.inventory -import net.axay.kspigot.kotlinextensions.MinMaxPair +import net.axay.kspigot.languageextensions.MinMaxPair // INVENTORY diff --git a/src/main/kotlin/net/axay/kspigot/ipaddress/BadIPDetection.kt b/src/main/kotlin/net/axay/kspigot/ipaddress/BadIPDetection.kt new file mode 100644 index 00000000..dfd2648e --- /dev/null +++ b/src/main/kotlin/net/axay/kspigot/ipaddress/BadIPDetection.kt @@ -0,0 +1,118 @@ +package net.axay.kspigot.ipaddress + +import net.axay.kspigot.ipaddress.badipdetectionservices.GetIPIntel +import net.axay.kspigot.ipaddress.badipdetectionservices.IPHub +import org.bukkit.entity.Player +import org.json.JSONException +import org.json.JSONObject + +/** + * Checks if the IP address of the player is not a + * normal residential address. + * + * This function returns true if just one of all + * available detection services detects a bad IP address. + * + * @param detector The compound of detection services. + */ +fun Player.hasBadIP(detector: BadIPDetector = BadIPDetector.DEFAULT) = + checkIP(detector).filterValues { it.isBad }.isNotEmpty() + +/** + * Checks if the IP address of the player is not a + * normal residential address. + * + * This function returns the result of each + * detection service given by the [detector]. + * + * @param detector The compound of detection services. + */ +fun Player.checkIP( + detector: BadIPDetector = BadIPDetector.DEFAULT, + breakOnHit: Boolean = true +): Map { + val ip = address?.hostString ?: return emptyMap() + return detector.checkIP(ip, breakOnHit) +} + +/** + * @param services A list of [BadIPDetectionService]s. + * The order matters! + */ +class BadIPDetector( + val services: List +) { + + constructor(vararg services: BadIPDetectionService) : this(services.toList()) + + companion object { + val DEFAULT = BadIPDetector( + listOf( + GetIPIntel(), + IPHub() + ) + ) + } + + fun checkIP(ip: String, breakOnHit: Boolean = true) = + HashMap().apply { + for (it in services) { + + val curResult = it.isBad(ip) + this[it] = curResult + + if (curResult.isBad && breakOnHit) break + + } + } + +} + +enum class BadIPDetectionResult( + val isBad: Boolean, + val typeName: String +) { + + GENERAL_BAD(true, "bad ip"), + + VPN(true, "vpn"), + PROXY(true, "proxy"), + TOR(true, "tor network"), + HOSTING(true, "hosting"), + + GOOD(false, "valid ip"), + ERROR(false, "error"), + LIMIT(false, "limit"); + +} + +abstract class BadIPDetectionService( + val name: String +) { + + protected abstract fun requestString(ip: String): String + + protected abstract fun interpreteResult(result: JSONObject): BadIPDetectionResult + + fun isBad(ip: String): BadIPDetectionResult { + val response = khttp.get(requestString(ip)) + if (response.statusCode == 429) + return BadIPDetectionResult.LIMIT + else { + + val result = try { + response.jsonObject + } catch (exc: JSONException) { + null + } ?: return BadIPDetectionResult.ERROR + + return try { + interpreteResult(result) + } catch (exc: Exception) { + return BadIPDetectionResult.ERROR + } + + } + } + +} \ No newline at end of file diff --git a/src/main/kotlin/net/axay/kspigot/ipaddress/IPAddressData.kt b/src/main/kotlin/net/axay/kspigot/ipaddress/IPAddressData.kt index daac87dc..affbf3af 100644 --- a/src/main/kotlin/net/axay/kspigot/ipaddress/IPAddressData.kt +++ b/src/main/kotlin/net/axay/kspigot/ipaddress/IPAddressData.kt @@ -3,9 +3,10 @@ package net.axay.kspigot.ipaddress import com.google.gson.JsonObject +import net.axay.kspigot.languageextensions.fromUrlJson +import net.axay.kspigot.languageextensions.getStringOrNull import net.axay.kspigot.main.ValueHolder import org.bukkit.entity.Player -import java.net.URL private const val IP_API = "http://ip-api.com/json/" private const val IP_API_FIELDS = @@ -27,9 +28,8 @@ fun Player.ipAddressData(language: IPAddressDataLanguage = IPAddressDataLanguage val hostString = address?.hostString ?: return null - val jsonObject = ValueHolder.getGson(false).fromJson( - URL("$IP_API${hostString}?fields=${IP_API_FIELDS}?lang=${language.code}").readText(), - JsonObject::class.java + val jsonObject = ValueHolder.getGson().fromUrlJson( + "$IP_API${hostString}?fields=${IP_API_FIELDS}?lang=${language.code}" ) ?: return null if (jsonObject["status"].toString() == "fail") return null @@ -55,32 +55,26 @@ enum class IPAddressDataLanguage(val code: String) { class IPAddressData(private val json: JsonObject) { - val ip get() = json.getString("query") + val ip get() = json.getStringOrNull("query") // region - val continent get() = json.getString("continent") - val continentCode get() = json.getString("continentCode") - val country get() = json.getString("country") - val countryCode get() = json.getString("countryCode") - val region get() = json.getString("regionName") - val regionCode get() = json.getString("region") - val city get() = json.getString("city") - val district get() = json.getString("district") - val postalCode get() = json.getString("zip") - val timezone get() = json.getString("timezone") + val continent get() = json.getStringOrNull("continent") + val continentCode get() = json.getStringOrNull("continentCode") + val country get() = json.getStringOrNull("country") + val countryCode get() = json.getStringOrNull("countryCode") + val region get() = json.getStringOrNull("regionName") + val regionCode get() = json.getStringOrNull("region") + val city get() = json.getStringOrNull("city") + val district get() = json.getStringOrNull("district") + val postalCode get() = json.getStringOrNull("zip") + val timezone get() = json.getStringOrNull("timezone") // position - val latitude get() = json.getString("lat") - val longitude get() = json.getString("lon") + val latitude get() = json.getStringOrNull("lat") + val longitude get() = json.getStringOrNull("lon") // information - val internetServiceProvider get() = json.getString("isp") - val organisation get() = json.getString("org") + val internetServiceProvider get() = json.getStringOrNull("isp") + val organisation get() = json.getStringOrNull("org") -} - -private fun JsonObject.getString(key: String) = try { - this[key].toString() -} catch (exc: Exception) { - null } \ No newline at end of file diff --git a/src/main/kotlin/net/axay/kspigot/ipaddress/badipdetectionservices/GetIPIntel.kt b/src/main/kotlin/net/axay/kspigot/ipaddress/badipdetectionservices/GetIPIntel.kt new file mode 100644 index 00000000..00027a2d --- /dev/null +++ b/src/main/kotlin/net/axay/kspigot/ipaddress/badipdetectionservices/GetIPIntel.kt @@ -0,0 +1,23 @@ +@file:Suppress("MemberVisibilityCanBePrivate") + +package net.axay.kspigot.ipaddress.badipdetectionservices + +import net.axay.kspigot.ipaddress.BadIPDetectionResult +import net.axay.kspigot.ipaddress.BadIPDetectionService +import net.axay.kspigot.languageextensions.getStringOrNull +import org.json.JSONObject + +class GetIPIntel( + private val intensity: Float = 0.99f, + private val contactEmail: String = "foo@bar.com" +) : BadIPDetectionService("getipintel.net") { + + override fun requestString(ip: String) = "http://check.getipintel.net/check.php?ip=$ip&contact=$contactEmail" + + override fun interpreteResult(result: JSONObject): BadIPDetectionResult { + val probability = result.getStringOrNull("result")?.toFloatOrNull() + ?: return BadIPDetectionResult.ERROR + return if (probability >= intensity) BadIPDetectionResult.GENERAL_BAD else BadIPDetectionResult.GOOD + } + +} \ No newline at end of file diff --git a/src/main/kotlin/net/axay/kspigot/ipaddress/badipdetectionservices/IPHub.kt b/src/main/kotlin/net/axay/kspigot/ipaddress/badipdetectionservices/IPHub.kt new file mode 100644 index 00000000..3a551909 --- /dev/null +++ b/src/main/kotlin/net/axay/kspigot/ipaddress/badipdetectionservices/IPHub.kt @@ -0,0 +1,21 @@ +@file:Suppress("MemberVisibilityCanBePrivate") + +package net.axay.kspigot.ipaddress.badipdetectionservices + +import net.axay.kspigot.ipaddress.BadIPDetectionResult +import net.axay.kspigot.ipaddress.BadIPDetectionService +import net.axay.kspigot.languageextensions.getStringOrNull +import org.json.JSONObject + +class IPHub( + private val ifStrict: Boolean = false +) : BadIPDetectionService("iphub.info") { + + override fun requestString(ip: String) = "http://v2.api.iphub.info/ip/$ip" + + override fun interpreteResult(result: JSONObject): BadIPDetectionResult { + val ifBlock = result.getStringOrNull("block")?.toInt() ?: return BadIPDetectionResult.ERROR + return if (ifBlock == 1 || (ifStrict && ifBlock == 2)) BadIPDetectionResult.GENERAL_BAD else BadIPDetectionResult.GOOD + } + +} \ No newline at end of file diff --git a/src/main/kotlin/net/axay/kspigot/ipaddress/badipdetectionservices/IPInfo.kt b/src/main/kotlin/net/axay/kspigot/ipaddress/badipdetectionservices/IPInfo.kt new file mode 100644 index 00000000..91a64380 --- /dev/null +++ b/src/main/kotlin/net/axay/kspigot/ipaddress/badipdetectionservices/IPInfo.kt @@ -0,0 +1,24 @@ +package net.axay.kspigot.ipaddress.badipdetectionservices + +import net.axay.kspigot.ipaddress.BadIPDetectionResult +import net.axay.kspigot.ipaddress.BadIPDetectionService +import net.axay.kspigot.languageextensions.getStringOrNull +import org.json.JSONObject + +class IPInfo( + private val token: String +) : BadIPDetectionService("ipinfo.io") { + + override fun requestString(ip: String) = "https://ipinfo.io/$ip/privacy?token=$token" + + override fun interpreteResult(result: JSONObject): BadIPDetectionResult { + return when { + result.getStringOrNull("vpn").toBoolean() -> BadIPDetectionResult.VPN + result.getStringOrNull("proxy").toBoolean() -> BadIPDetectionResult.PROXY + result.getStringOrNull("tor").toBoolean() -> BadIPDetectionResult.TOR + result.getStringOrNull("hosting").toBoolean() -> BadIPDetectionResult.HOSTING + else -> BadIPDetectionResult.GOOD + } + } + +} \ No newline at end of file diff --git a/src/main/kotlin/net/axay/kspigot/ipaddress/badipdetectionservices/VPNBlocker.kt b/src/main/kotlin/net/axay/kspigot/ipaddress/badipdetectionservices/VPNBlocker.kt new file mode 100644 index 00000000..25b32e48 --- /dev/null +++ b/src/main/kotlin/net/axay/kspigot/ipaddress/badipdetectionservices/VPNBlocker.kt @@ -0,0 +1,24 @@ +package net.axay.kspigot.ipaddress.badipdetectionservices + +import net.axay.kspigot.ipaddress.BadIPDetectionResult +import net.axay.kspigot.ipaddress.BadIPDetectionService +import net.axay.kspigot.languageextensions.getStringOrNull +import org.json.JSONObject + +class VPNBlocker : BadIPDetectionService("vpnblocker.net") { + + override fun requestString(ip: String) = "http://api.vpnblocker.net/v2/json/$ip" + + override fun interpreteResult(result: JSONObject): BadIPDetectionResult { + val isBad = result.getStringOrNull("host-ip") + return when { + isBad != null -> if (isBad.toBoolean()) BadIPDetectionResult.GENERAL_BAD else BadIPDetectionResult.GOOD + else -> { + val remaining = result.getStringOrNull("remaining_requests")?.toIntOrNull() + ?: return BadIPDetectionResult.ERROR + if (remaining <= 0) BadIPDetectionResult.LIMIT else BadIPDetectionResult.ERROR + } + } + } + +} \ No newline at end of file diff --git a/src/main/kotlin/net/axay/kspigot/kotlinextensions/GeneralExtensions.kt b/src/main/kotlin/net/axay/kspigot/kotlinextensions/GeneralExtensions.kt deleted file mode 100644 index 9d0ea7ae..00000000 --- a/src/main/kotlin/net/axay/kspigot/kotlinextensions/GeneralExtensions.kt +++ /dev/null @@ -1,36 +0,0 @@ -package net.axay.kspigot.kotlinextensions - -import java.io.File - -internal inline fun Lazy.ifInitialized(block: (T) -> R) = if (isInitialized()) block(value) else null - -internal val Lazy.valueIfInitialized get() = ifInitialized { value } - -internal fun Lazy.closeIfInitialized() = ifInitialized { value.close() } - -internal class MinMaxPair>(a: T, b: T) { - val min: T; - val max: T - - init { - if (a >= b) { - min = b; max = a - } else { - min = a; max = b - } - } -} - -internal fun T.applyIfNotNull(block: (T.() -> Unit)?): T { - if (block != null) - apply(block) - return this -} - -internal fun File.createIfNotExists(): Boolean { - return if (!exists()) { - if (!parentFile.exists()) - parentFile.mkdirs() - createNewFile() - } else true -} diff --git a/src/main/kotlin/net/axay/kspigot/languageextensions/GsonExtensions.kt b/src/main/kotlin/net/axay/kspigot/languageextensions/GsonExtensions.kt new file mode 100644 index 00000000..b08d66de --- /dev/null +++ b/src/main/kotlin/net/axay/kspigot/languageextensions/GsonExtensions.kt @@ -0,0 +1,20 @@ +package net.axay.kspigot.languageextensions + +import com.google.gson.Gson +import com.google.gson.JsonObject +import java.net.URL + +internal fun JsonObject.getStringOrNull(key: String): String? { + return try { + this[key].toString() + } catch (exc: Exception) { + null + } +} + +internal fun Gson.fromUrlJson(url: String): JsonObject? { + return fromJson( + URL(url).readText(), + JsonObject::class.java + ) ?: return null +} \ No newline at end of file diff --git a/src/main/kotlin/net/axay/kspigot/languageextensions/JSONExtensions.kt b/src/main/kotlin/net/axay/kspigot/languageextensions/JSONExtensions.kt new file mode 100644 index 00000000..009335fb --- /dev/null +++ b/src/main/kotlin/net/axay/kspigot/languageextensions/JSONExtensions.kt @@ -0,0 +1,11 @@ +package net.axay.kspigot.languageextensions + +import org.json.JSONObject + +internal fun JSONObject.getStringOrNull(key: String): String? { + return try { + this[key].toString() + } catch (exc: Exception) { + null + } +} \ No newline at end of file diff --git a/src/main/kotlin/net/axay/kspigot/languageextensions/kotlinextensions/FileExtensions.kt b/src/main/kotlin/net/axay/kspigot/languageextensions/kotlinextensions/FileExtensions.kt new file mode 100644 index 00000000..e61859fc --- /dev/null +++ b/src/main/kotlin/net/axay/kspigot/languageextensions/kotlinextensions/FileExtensions.kt @@ -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 +} diff --git a/src/main/kotlin/net/axay/kspigot/languageextensions/kotlinextensions/GeneralExtensions.kt b/src/main/kotlin/net/axay/kspigot/languageextensions/kotlinextensions/GeneralExtensions.kt new file mode 100644 index 00000000..ad44dd30 --- /dev/null +++ b/src/main/kotlin/net/axay/kspigot/languageextensions/kotlinextensions/GeneralExtensions.kt @@ -0,0 +1,7 @@ +package net.axay.kspigot.languageextensions.kotlinextensions + +internal fun T.applyIfNotNull(block: (T.() -> Unit)?): T { + if (block != null) + apply(block) + return this +} \ No newline at end of file diff --git a/src/main/kotlin/net/axay/kspigot/languageextensions/kotlinextensions/LazyExtensions.kt b/src/main/kotlin/net/axay/kspigot/languageextensions/kotlinextensions/LazyExtensions.kt new file mode 100644 index 00000000..3f4d7050 --- /dev/null +++ b/src/main/kotlin/net/axay/kspigot/languageextensions/kotlinextensions/LazyExtensions.kt @@ -0,0 +1,7 @@ +package net.axay.kspigot.languageextensions.kotlinextensions + +internal inline fun Lazy.ifInitialized(block: (T) -> R) = if (isInitialized()) block(value) else null + +internal val Lazy.valueIfInitialized get() = ifInitialized { value } + +internal fun Lazy.closeIfInitialized() = ifInitialized { value.close() } \ No newline at end of file diff --git a/src/main/kotlin/net/axay/kspigot/languageextensions/kotlinextensions/MinMaxPair.kt b/src/main/kotlin/net/axay/kspigot/languageextensions/kotlinextensions/MinMaxPair.kt new file mode 100644 index 00000000..00a1c160 --- /dev/null +++ b/src/main/kotlin/net/axay/kspigot/languageextensions/kotlinextensions/MinMaxPair.kt @@ -0,0 +1,18 @@ +@file:Suppress("MemberVisibilityCanBePrivate") + +package net.axay.kspigot.languageextensions.kotlinextensions + +internal class MinMaxPair>(a: T, b: T) { + + val min: T; + val max: T + + init { + if (a >= b) { + min = b; max = a + } else { + min = a; max = b + } + } + +} \ No newline at end of file diff --git a/src/main/kotlin/net/axay/kspigot/main/KSpigot.kt b/src/main/kotlin/net/axay/kspigot/main/KSpigot.kt index 71428ca9..3ee09216 100644 --- a/src/main/kotlin/net/axay/kspigot/main/KSpigot.kt +++ b/src/main/kotlin/net/axay/kspigot/main/KSpigot.kt @@ -1,7 +1,7 @@ package net.axay.kspigot.main import net.axay.kspigot.inventory.InventoryGUIHolder -import net.axay.kspigot.kotlinextensions.closeIfInitialized +import net.axay.kspigot.languageextensions.closeIfInitialized import net.axay.kspigot.runnables.KRunnableHolder import org.bukkit.plugin.java.JavaPlugin diff --git a/src/main/kotlin/net/axay/kspigot/main/ValueHolder.kt b/src/main/kotlin/net/axay/kspigot/main/ValueHolder.kt index 8367c0a3..58b90fd5 100644 --- a/src/main/kotlin/net/axay/kspigot/main/ValueHolder.kt +++ b/src/main/kotlin/net/axay/kspigot/main/ValueHolder.kt @@ -12,6 +12,6 @@ object ValueHolder { private val gson: Gson by lazy { gsonBuilder.create() } private val gsonPretty: Gson by lazy { gsonBuilder.setPrettyPrinting().create() } - fun getGson(pretty: Boolean) = if (pretty) gsonPretty else gson + fun getGson(pretty: Boolean = false) = if (pretty) gsonPretty else gson } \ No newline at end of file diff --git a/src/main/kotlin/net/axay/kspigot/particles/KSpigotParticles.kt b/src/main/kotlin/net/axay/kspigot/particles/KSpigotParticles.kt index 467214da..68e3d2d0 100644 --- a/src/main/kotlin/net/axay/kspigot/particles/KSpigotParticles.kt +++ b/src/main/kotlin/net/axay/kspigot/particles/KSpigotParticles.kt @@ -1,7 +1,7 @@ package net.axay.kspigot.particles import net.axay.kspigot.extensions.bukkit.worldOrException -import net.axay.kspigot.kotlinextensions.applyIfNotNull +import net.axay.kspigot.languageextensions.applyIfNotNull import org.bukkit.Location import org.bukkit.Particle import org.bukkit.entity.Player diff --git a/src/main/kotlin/net/axay/kspigot/serialization/SpigotSerializable.kt b/src/main/kotlin/net/axay/kspigot/serialization/SpigotSerializable.kt index 781688b4..d643b369 100644 --- a/src/main/kotlin/net/axay/kspigot/serialization/SpigotSerializable.kt +++ b/src/main/kotlin/net/axay/kspigot/serialization/SpigotSerializable.kt @@ -23,4 +23,4 @@ fun SpigotSerializable<*>.serialize(pretty: Boolean = true): String = ValueHolde */ @Suppress("unused") inline fun SpigotSerialzableCompanion.deserialize(json: String): T = - ValueHolder.getGson(false).fromJson(json, T::class.java) \ No newline at end of file + ValueHolder.getGson().fromJson(json, T::class.java) \ No newline at end of file diff --git a/src/main/kotlin/net/axay/kspigot/sound/KSpigotSound.kt b/src/main/kotlin/net/axay/kspigot/sound/KSpigotSound.kt index 4fce09d6..fd5351a3 100644 --- a/src/main/kotlin/net/axay/kspigot/sound/KSpigotSound.kt +++ b/src/main/kotlin/net/axay/kspigot/sound/KSpigotSound.kt @@ -1,7 +1,7 @@ package net.axay.kspigot.sound import net.axay.kspigot.extensions.bukkit.worldOrException -import net.axay.kspigot.kotlinextensions.applyIfNotNull +import net.axay.kspigot.languageextensions.applyIfNotNull import org.bukkit.Location import org.bukkit.Sound import org.bukkit.SoundCategory From 8b087d78e1903e71c3437e00edddc997e48dd464 Mon Sep 17 00:00:00 2001 From: bluefireoly Date: Mon, 19 Oct 2020 17:56:35 +0200 Subject: [PATCH 3/4] Update build.gradle.kts --- build.gradle.kts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.gradle.kts b/build.gradle.kts index 54a21c53..8b1894a4 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -17,7 +17,7 @@ val JVM_VERSION_STRING = JVM_VERSION.versionString */ group = "net.axay" -version = "1.16.3_R13" +version = "1.16.3_R14" description = "A Kotlin API for the Minecraft Server Software \"Spigot\"." From 0f62db615527d668f306ba43cee531be260a99fb Mon Sep 17 00:00:00 2001 From: bluefireoly Date: Mon, 19 Oct 2020 18:00:34 +0200 Subject: [PATCH 4/4] Added a list of available services to the documentation --- .../kotlin/net/axay/kspigot/ipaddress/BadIPDetection.kt | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/main/kotlin/net/axay/kspigot/ipaddress/BadIPDetection.kt b/src/main/kotlin/net/axay/kspigot/ipaddress/BadIPDetection.kt index dfd2648e..5613f116 100644 --- a/src/main/kotlin/net/axay/kspigot/ipaddress/BadIPDetection.kt +++ b/src/main/kotlin/net/axay/kspigot/ipaddress/BadIPDetection.kt @@ -38,6 +38,12 @@ fun Player.checkIP( /** * @param services A list of [BadIPDetectionService]s. * The order matters! + * + * Available services: + * - [net.axay.kspigot.ipaddress.badipdetectionservices.IPInfo] (recommended, but requires login) + * - [net.axay.kspigot.ipaddress.badipdetectionservices.GetIPIntel] + * - [net.axay.kspigot.ipaddress.badipdetectionservices.IPHub] + * - [net.axay.kspigot.ipaddress.badipdetectionservices.VPNBlocker] */ class BadIPDetector( val services: List