diff --git a/src/main/java/app/entities/a2s/external/ExternalValveClient.java b/src/main/java/app/entities/a2s/external/ExternalValveClient.java index e762989..e0e1c05 100644 --- a/src/main/java/app/entities/a2s/external/ExternalValveClient.java +++ b/src/main/java/app/entities/a2s/external/ExternalValveClient.java @@ -9,9 +9,7 @@ import jakarta.annotation.PostConstruct; import org.springframework.beans.factory.annotation.Value; import org.springframework.web.client.RestTemplate; -import java.util.HashMap; -import java.util.List; -import java.util.Map; +import java.util.*; public abstract class ExternalValveClient { @JsonIgnore @@ -59,16 +57,16 @@ public abstract class ExternalValveClient { } } - public List GetRCONPlayers(RCONRequest request){ + public ArrayList GetRCONPlayers(RCONRequest request){ if(!enabled) { System.out.printf("External client not enabled, cannot get rcon players on %s\n", gateway); return null; } try { - return restTemplate.postForEntity("%s/api/players".formatted(gateway), request, List.class).getBody(); + return new ArrayList<>(Arrays.asList(restTemplate.postForEntity("%s/api/players".formatted(gateway), request, RCONPlayer[].class).getBody())); } catch (Exception err) { err.printStackTrace(); - return List.of(); + return new ArrayList<>(); } } } diff --git a/src/main/java/app/entities/server/players/DefaultPlayer.java b/src/main/java/app/entities/server/players/DefaultPlayer.java index 5fa64f5..d9222e6 100644 --- a/src/main/java/app/entities/server/players/DefaultPlayer.java +++ b/src/main/java/app/entities/server/players/DefaultPlayer.java @@ -8,4 +8,5 @@ public class DefaultPlayer { String name; int score; int id = 0; + public DefaultPlayer() {} } diff --git a/src/main/java/app/entities/server/players/RCONPlayer.java b/src/main/java/app/entities/server/players/RCONPlayer.java index 1ae6a64..2041244 100644 --- a/src/main/java/app/entities/server/players/RCONPlayer.java +++ b/src/main/java/app/entities/server/players/RCONPlayer.java @@ -3,10 +3,7 @@ package app.entities.server.players; import app.entities.other.SteamID; import app.entities.server.players.DefaultPlayer; import app.utils.SteamIDConverter; -import com.fasterxml.jackson.annotation.JsonGetter; -import com.fasterxml.jackson.annotation.JsonIgnore; -import com.fasterxml.jackson.annotation.JsonSetter; -import com.fasterxml.jackson.annotation.JsonValue; +import com.fasterxml.jackson.annotation.*; import com.fasterxml.jackson.databind.annotation.JsonSerialize; import lombok.Data; import lombok.Getter; @@ -17,7 +14,7 @@ import java.util.List; public class RCONPlayer extends DefaultPlayer { String duration; int id; - @JsonIgnore + @JsonProperty(access = JsonProperty.Access.WRITE_ONLY) String ip; int loss; int ping; @@ -31,6 +28,8 @@ public class RCONPlayer extends DefaultPlayer { return steam; } + public RCONPlayer(){} + public RCONPlayer(List status_line) { id = Integer.parseInt(status_line.get(1)); ip = status_line.get(status_line.size() - 1);