Update the return json of /mojang/status in the API
All checks were successful
Deploy API / docker (17, 3.8.5) (push) Successful in 2m14s
All checks were successful
Deploy API / docker (17, 3.8.5) (push) Successful in 2m14s
This commit is contained in:
parent
979018b508
commit
fd16430307
@ -39,14 +39,19 @@ import java.net.UnknownHostException;
|
||||
*/
|
||||
@AllArgsConstructor @Getter @ToString
|
||||
public enum MojangServer {
|
||||
SESSION("https://sessionserver.mojang.com"),
|
||||
API("https://api.mojang.com"),
|
||||
TEXTURES("https://textures.minecraft.net"),
|
||||
ASSETS("https://assets.mojang.com"),
|
||||
LIBRARIES("https://libraries.minecraft.net");
|
||||
SESSION("Session Server", "https://sessionserver.mojang.com"),
|
||||
API("Mojang API", "https://api.mojang.com"),
|
||||
TEXTURES("Textures Server", "https://textures.minecraft.net"),
|
||||
ASSETS("Assets Server", "https://assets.mojang.com"),
|
||||
LIBRARIES("Libraries Server", "https://libraries.minecraft.net");
|
||||
|
||||
private static final int STATUS_TIMEOUT = 7000;
|
||||
|
||||
/**
|
||||
* The name of this server.
|
||||
*/
|
||||
@NonNull private final String name;
|
||||
|
||||
/**
|
||||
* The endpoint of this service.
|
||||
*/
|
||||
|
@ -37,7 +37,9 @@ import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.ResponseBody;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
@ -68,11 +70,17 @@ public final class MojangController {
|
||||
*/
|
||||
@GetMapping("/status")
|
||||
@ResponseBody
|
||||
public ResponseEntity<Map<String, String>> getStatus() throws BadRequestException {
|
||||
Map<String, String> response = new HashMap<>();
|
||||
public ResponseEntity<Map<String, List<Map<String, Object>>>> getStatus() throws BadRequestException {
|
||||
List<Map<String, Object>> servers = new ArrayList<>();
|
||||
for (Map.Entry<MojangServer, MojangServer.Status> entry : mojangService.getMojangServerStatuses().entrySet()) {
|
||||
response.put(entry.getKey().getEndpoint(), entry.getValue().name());
|
||||
MojangServer server = entry.getKey();
|
||||
|
||||
Map<String, Object> serverStatus = new HashMap<>();
|
||||
serverStatus.put("name", server.getName());
|
||||
serverStatus.put("endpoint", server.getEndpoint());
|
||||
serverStatus.put("status", entry.getValue().name());
|
||||
servers.add(serverStatus);
|
||||
}
|
||||
return ResponseEntity.ok(response);
|
||||
return ResponseEntity.ok(Map.of("servers", servers));
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user