mirror of
https://github.com/funkemunky/AntiVPN.git
synced 2026-06-01 17:52:16 +00:00
Completed new antivpn plugin
This commit is contained in:
@@ -4,14 +4,17 @@ import dev.brighten.antivpn.utils.json.JSONException;
|
||||
import dev.brighten.antivpn.utils.json.JSONObject;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.Setter;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@AllArgsConstructor
|
||||
@RequiredArgsConstructor
|
||||
public class VPNResponse {
|
||||
private String asn, ip, countryName, countryCode, city, timeZone, method, isp;
|
||||
private boolean proxy, cached, success;
|
||||
private boolean proxy, cached;
|
||||
private final boolean success;
|
||||
private double latitude, longitude;
|
||||
private long lastAccess;
|
||||
private long queriesLeft;
|
||||
@@ -47,4 +50,19 @@ public class VPNResponse {
|
||||
jsonObject.getDouble("latitude"), jsonObject.getDouble("longitude"),
|
||||
jsonObject.getLong("lastAccess"), jsonObject.getInt("queriesLeft"));
|
||||
}
|
||||
|
||||
public static VPNResponse fromJson(JSONObject jsonObject) throws JSONException {
|
||||
if(jsonObject.getBoolean("success")) {
|
||||
return new VPNResponse(jsonObject.getString("asn"), jsonObject.getString("ip"),
|
||||
jsonObject.getString("countryName"), jsonObject.getString("countryCode"),
|
||||
jsonObject.getString("city"), jsonObject.getString("timeZone"),
|
||||
jsonObject.has("method") ? jsonObject.getString("method") : "N/A",
|
||||
jsonObject.getString("isp"), jsonObject.getBoolean("proxy"),
|
||||
jsonObject.getBoolean("cached"), jsonObject.getBoolean("success"),
|
||||
jsonObject.getDouble("latitude"), jsonObject.getDouble("longitude"),
|
||||
jsonObject.getLong("lastAccess"), jsonObject.getInt("queriesLeft"));
|
||||
}
|
||||
|
||||
return new VPNResponse(false);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user