We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
package name.name import com.beust.klaxon.Converter import com.beust.klaxon.JsonValue import net.darkdevelopers.darkbedrock.darkness.spigot.functions.toBukkitWorld import org.bukkit.Location object LocationConverter : Converter { override fun canConvert(cls: Class<*>): Boolean = cls == Location::class.java override fun fromJson(jv: JsonValue): Location? { val obj = jv.obj ?: return null val world = obj["world"].toString().toBukkitWorld() ?: return null val x = obj["x"].toString().toDoubleOrNull() ?: 0.0 val y = obj["y"].toString().toDoubleOrNull() ?: 0.0 val z = obj["z"].toString().toDoubleOrNull() ?: 0.0 val yaw = obj["yaw"].toString().toFloatOrNull() ?: 0f val pitch = obj["pitch"].toString().toFloatOrNull() ?: 0f return Location(world, x, y, z, yaw, pitch) } override fun toJson(value: Any): String { value as Location return """{"world": "${value.world?.name}", "x": ${value.x}, "y": ${value.y}, "z": ${value.z}, "yaw": ${value.yaw}, "pitch": ${value.pitch}}""" } }
The text was updated successfully, but these errors were encountered:
No branches or pull requests
The text was updated successfully, but these errors were encountered: