From 615c5f0ae2da51187fc1bcd1624bdcf54ffb7207 Mon Sep 17 00:00:00 2001 From: gsd Date: Tue, 28 Feb 2023 21:28:11 +0300 Subject: [PATCH] =?UTF-8?q?fix=20list=20=D1=82=D1=8B=20=D1=82=D1=83=D0=BF?= =?UTF-8?q?=D0=BE=D0=B9=20=D0=BD=D0=B5=20=D0=B7=D0=B0=D0=B1=D1=8B=D0=B2?= =?UTF-8?q?=D0=B0=D0=B9=20=D1=87=D1=82=D0=BE=20=D0=B5=D1=81=D1=82=D1=8C=20?= =?UTF-8?q?[]=20=D0=B2=D0=BC=D0=B5=D1=81=D1=82=D0=BE=20LIST.CLASS=20=D0=9F?= =?UTF-8?q?=D0=9E=D0=9D=D0=AF=D0=9B=D0=9B=D0=9B=3F=3F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../app/entities/a2s/external/ExternalValveClient.java | 10 ++++------ .../app/entities/server/players/DefaultPlayer.java | 1 + .../java/app/entities/server/players/RCONPlayer.java | 9 ++++----- 3 files changed, 9 insertions(+), 11 deletions(-) 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);