public static Direction deserialize(JsonElement element) {
        Preconditions.checkArgument(element.isJsonObject());
        JsonObject object = element.getAsJsonObject();

        Preconditions.checkArgument(object.has("yaw"));
        Preconditions.checkArgument(object.has("pitch"));

        float yaw = object.get("yaw").getAsFloat();
        float pitch = object.get("pitch").getAsFloat();

        return of(yaw, pitch);
    }
An immutable and serializable direction object
helper/src/main/java/me/lucko/helper/serialize/Direction.java