Browse Source

fix list

ты тупой не забывай что есть [] вместо LIST.CLASS ПОНЯЛЛЛ??
master
gsd 2 years ago
parent
commit
615c5f0ae2
  1. 10
      src/main/java/app/entities/a2s/external/ExternalValveClient.java
  2. 1
      src/main/java/app/entities/server/players/DefaultPlayer.java
  3. 9
      src/main/java/app/entities/server/players/RCONPlayer.java

10
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<RCONPlayer> GetRCONPlayers(RCONRequest request){
public ArrayList<RCONPlayer> 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<>();
}
}
}

1
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() {}
}

9
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<String> status_line) {
id = Integer.parseInt(status_line.get(1));
ip = status_line.get(status_line.size() - 1);

Loading…
Cancel
Save