From 0b84e739a027ea7e5cc5bd728625839928f95283 Mon Sep 17 00:00:00 2001 From: Trumeet Date: Thu, 14 Jul 2022 10:26:28 -0700 Subject: Refactor: Move WorldKey, Vec2f and Vec3d to the common package Signed-off-by: Trumeet --- src/main/java/moe/ymc/acron/c2s/ReqSetConfig.java | 52 ++--------------------- 1 file changed, 4 insertions(+), 48 deletions(-) (limited to 'src/main/java/moe/ymc/acron/c2s') diff --git a/src/main/java/moe/ymc/acron/c2s/ReqSetConfig.java b/src/main/java/moe/ymc/acron/c2s/ReqSetConfig.java index 0abe42a..8959403 100644 --- a/src/main/java/moe/ymc/acron/c2s/ReqSetConfig.java +++ b/src/main/java/moe/ymc/acron/c2s/ReqSetConfig.java @@ -2,6 +2,9 @@ package moe.ymc.acron.c2s; import com.google.gson.*; import com.google.gson.annotations.SerializedName; +import moe.ymc.acron.common.Vec2f; +import moe.ymc.acron.common.Vec3d; +import moe.ymc.acron.common.WorldKey; import org.jetbrains.annotations.Nullable; import java.lang.reflect.Type; @@ -50,51 +53,4 @@ public record ReqSetConfig(@SerializedName("id") int id, } } - public enum WorldKey { - OVERWORLD, - NETHER, - END - } - - public record Vec3d(@SerializedName("x") double x, - @SerializedName("y") double y, - @SerializedName("z") double z) { - public static class Vec3dDeserializer implements JsonDeserializer { - @Override - public Vec3d deserialize(JsonElement json, - Type typeOfT, - JsonDeserializationContext context) throws JsonParseException { - final JsonObject object = json.getAsJsonObject(); - final double x = object.has("x") ? - object.get("x").getAsDouble() : - 0.0; - final double y = object.has("y") ? - object.get("y").getAsDouble() : - 0.0; - final double z = object.has("z") ? - object.get("z").getAsDouble() : - 0.0; - return new Vec3d(x, y, z); - } - } - } - - public record Vec2f(@SerializedName("x") float x, - @SerializedName("y") float y) { - public static class Vec2fDeserializer implements JsonDeserializer { - @Override - public Vec2f deserialize(JsonElement json, - Type typeOfT, - JsonDeserializationContext context) throws JsonParseException { - final JsonObject object = json.getAsJsonObject(); - final float x = object.has("x") ? - object.get("x").getAsFloat() : - 0.0f; - final float y = object.has("y") ? - object.get("y").getAsFloat() : - 0.0f; - return new Vec2f(x, y); - } - } - } -} +} \ No newline at end of file -- cgit v1.2.3