From 67fc107a823914683fe2799130dada1929297546 Mon Sep 17 00:00:00 2001 From: gsd Date: Thu, 7 Dec 2023 15:40:19 +0300 Subject: [PATCH] preview fix --- src/main/java/app/entities/server/Server.java | 5 +++++ src/main/java/app/updates/PreviewUpdater.java | 14 +++++++------- 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/src/main/java/app/entities/server/Server.java b/src/main/java/app/entities/server/Server.java index 65229dc..18bbb1c 100644 --- a/src/main/java/app/entities/server/Server.java +++ b/src/main/java/app/entities/server/Server.java @@ -63,6 +63,11 @@ public class Server extends ExternalValveClient { } } + @JsonIgnore + public String getMapCleared() { + return map == null || map.isEmpty() ? "" : map.replace("workshop/","").split(".ugc")[0]; + } + @Override public String toString() { return "SERVER> %s | %s\nSTATS > %d/%d | %s\nCONFIG> grab limit: %d".formatted( diff --git a/src/main/java/app/updates/PreviewUpdater.java b/src/main/java/app/updates/PreviewUpdater.java index e7eeb86..02f1ad7 100644 --- a/src/main/java/app/updates/PreviewUpdater.java +++ b/src/main/java/app/updates/PreviewUpdater.java @@ -22,8 +22,8 @@ public class PreviewUpdater extends BaseUpdater{ private String domain = "tf2.pblr-nyk.pro"; private String preview = "https://%s/site_content/images/preview/%s.%s"; - @Value("${backend.updates.a2s}") - private boolean update = false; + //@Value("${backend.updates.a2s}") + private boolean update = true; private HashMap preview_cache; @Autowired @@ -53,16 +53,16 @@ public class PreviewUpdater extends BaseUpdater{ return; } - if (preview_cache.containsKey(server.getMap())) { - if (preview_cache.get(server.getMap()).equals(server.getPreview())) return; + if (preview_cache.containsKey(server.getMapCleared())) { + if (preview_cache.get(server.getMapCleared()).equals(server.getPreview())) return; } - String url = getPreview(server.getMap()); + String url = getPreview(server.getMapCleared()); if (url != null) { server.setPreview(url); - preview_cache.put(server.getMap(), server.getPreview()); + preview_cache.put(server.getMapCleared(), server.getPreview()); } else { - logger.warn("Not found preview for {}", server.getMap()); + logger.warn("Not found preview for {}", server.getMapCleared()); server.setPreview(not_found()); } }