Applied kotlin style conventions

This commit is contained in:
bluefireoly
2020-10-18 18:36:49 +02:00
parent e1d4e8bbfc
commit da848728d2
39 changed files with 509 additions and 385 deletions

View File

@@ -15,13 +15,12 @@ interface SpigotSerialzableCompanion<T>
/**
* @return A json string.
*/
fun SpigotSerializable<*>.serialize(pretty: Boolean = true): String
= ValueHolder.getGson(pretty).toJson(this)
fun SpigotSerializable<*>.serialize(pretty: Boolean = true): String = ValueHolder.getGson(pretty).toJson(this)
/**
* Deserializes the given json string and
* returns the deserialized object.
*/
@Suppress("unused")
inline fun <reified T> SpigotSerialzableCompanion<T>.deserialize(json: String): T
= ValueHolder.getGson(false).fromJson(json, T::class.java)
inline fun <reified T> SpigotSerialzableCompanion<T>.deserialize(json: String): T =
ValueHolder.getGson(false).fromJson(json, T::class.java)

View File

@@ -19,8 +19,7 @@ class SerializableLocation(
constructor(loc: Location) : this(loc.world?.name, loc.x, loc.y, loc.z, SerializableVector(loc.direction))
override fun toSpigot()
= Location(world?.let { Bukkit.getWorld(world) }, x, y, z)
.apply { direction = this@SerializableLocation.direction.toSpigot() }
override fun toSpigot() = Location(world?.let { Bukkit.getWorld(world) }, x, y, z)
.apply { direction = this@SerializableLocation.direction.toSpigot() }
}