refactoring

This commit is contained in:
NetRiceCake
2025-11-29 20:52:35 +09:00
parent f9d7254538
commit 0558360bed
24 changed files with 190 additions and 157 deletions

View File

@@ -0,0 +1,28 @@
package com.github.netricecake.loco.packet;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
public class InboundPacket {
public String getStringOrNull(JsonObject jsonObject, String key) {
JsonElement jsonElement = jsonObject.get(key);
return jsonElement == null ? null : jsonElement.getAsString();
}
public int getIntOrNull(JsonObject jsonObject, String key) {
JsonElement jsonElement = jsonObject.get(key);
return jsonElement == null ? 0 : jsonElement.getAsInt();
}
public boolean getBoolOrNull(JsonObject jsonObject, String key) {
JsonElement jsonElement = jsonObject.get(key);
return jsonElement == null || jsonElement.getAsBoolean();
}
public long getLongOrNull(JsonObject jsonObject, String key) {
JsonElement jsonElement = jsonObject.get(key);
return jsonElement == null ? 0L : jsonElement.getAsLong();
}
}