aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/moe/ymc/acron/c2s/ReqSetConfig.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/moe/ymc/acron/c2s/ReqSetConfig.java')
-rw-r--r--src/main/java/moe/ymc/acron/c2s/ReqSetConfig.java63
1 files changed, 0 insertions, 63 deletions
diff --git a/src/main/java/moe/ymc/acron/c2s/ReqSetConfig.java b/src/main/java/moe/ymc/acron/c2s/ReqSetConfig.java
deleted file mode 100644
index fcddf35..0000000
--- a/src/main/java/moe/ymc/acron/c2s/ReqSetConfig.java
+++ /dev/null
@@ -1,63 +0,0 @@
-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;
-
-public record ReqSetConfig(@SerializedName("id") int id,
- @SerializedName("world") @Nullable WorldKey world,
- @SerializedName("pos") @Nullable Vec3d pos,
- @SerializedName("rot") @Nullable Vec2f rot,
- @SerializedName("name") @Nullable String name)
- implements Request {
- @Override
- public void validate() {
- }
-
- @Override
- public int getId() {
- return id;
- }
-
- public static class ReqSetConfigDeserializer implements JsonDeserializer<ReqSetConfig> {
- @Override
- public ReqSetConfig deserialize(JsonElement json,
- Type typeOfT,
- JsonDeserializationContext context) throws JsonParseException {
- final JsonObject object = json.getAsJsonObject();
- final int id = object.has("id") ?
- object.get("id").getAsInt() :
- -1;
- final WorldKey world;
- if (object.has("world")) {
- world = context.deserialize(object.get("world"), WorldKey.class);
- // https://stackoverflow.com/a/49574019
- if (world == null) {
- throw new JsonParseException("Invalid world");
- }
- } else {
- world = null;
- }
- final Vec3d pos = object.has("pos") ?
- context.deserialize(object.get("pos"), Vec3d.class) :
- null;
- final Vec2f rot = object.has("rot") ?
- context.deserialize(object.get("rot"), Vec2f.class) :
- null;
- final String name = object.has("name") ?
- object.get("name").getAsString() :
- null;
- return new ReqSetConfig(id,
- world,
- pos,
- rot,
- name);
- }
- }
-
-} \ No newline at end of file