From 3887fbc3067e81d2fe504f6a1d305cf417d8e810 Mon Sep 17 00:00:00 2001 From: fanta Date: Sat, 21 Oct 2023 20:57:51 +0200 Subject: [PATCH] more --- src/main/java/de/fanta/stats/Config.java | 4 +++- src/main/java/de/fanta/stats/client/GUI.java | 17 +++++++++++------ 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/src/main/java/de/fanta/stats/Config.java b/src/main/java/de/fanta/stats/Config.java index 02009f7..a1efd43 100644 --- a/src/main/java/de/fanta/stats/Config.java +++ b/src/main/java/de/fanta/stats/Config.java @@ -37,7 +37,9 @@ static void serialize() { } catch (IOException e) { StatsClient.LOGGER.warn("Failed to write config!"); } - GUI.updateStats(); + if (GUI.updater != null && GUI.updater.isAlive()) { + GUI.updateStats(); + } } public static void deserialize() { diff --git a/src/main/java/de/fanta/stats/client/GUI.java b/src/main/java/de/fanta/stats/client/GUI.java index bdb3cc1..9cba9c6 100644 --- a/src/main/java/de/fanta/stats/client/GUI.java +++ b/src/main/java/de/fanta/stats/client/GUI.java @@ -33,6 +33,7 @@ public class GUI { private static final HashMap otherStatsEntries = new HashMap<>(); private static final HashMap positionStatsEntries = new HashMap<>(); private static final HashMap skullList = new HashMap<>(); + private static String description = ""; public static Thread updater; public GUI() { @@ -78,8 +79,7 @@ private void renderStats(DrawContext drawContext) { int distance = 14; if (Config.headline) { - PlayerStatsProvider provider = StatsClient.getStatsKey(Config.statsKeyID); - drawContext.drawText(this.fontRenderer, "§l" + "----- " + (provider != null ? provider.getTitle() : Config.statsKeyID) + " -----", 5, (30 + result.height + 9 / 2), Color.white.getRGB(), true); + drawContext.drawText(this.fontRenderer, "§l" + "----- " + description + " -----", 5, (30 + result.height + 9 / 2), Color.white.getRGB(), true); result.height += distance; } @@ -178,11 +178,14 @@ public static void updateStats() { return; } + PlayerStatsProvider provider = StatsClient.getStatsKey(Config.statsKeyID); + description = provider != null ? provider.getTitle() : Config.statsKeyID; + // - Get PositionScores - Collection newPositionStatsEntries = new ArrayList<>(StatsClient.getCubesideStats().getStatsFromPositionRange(Config.statsKeyID, 0, Config.places)); + Collection newPositionStatsEntries = new ArrayList<>(StatsClient.getCubesideStats().getStatsFromPositionRange(Config.statsKeyID, 0, 30)); synchronized (skullList) { for (PlayerStatsEntry statsPlayer : newPositionStatsEntries) { - if (!skullList.containsKey(statsPlayer.getName())) { + if (!skullList.containsKey(statsPlayer.getName()) && statsPlayer.getPosition() <= Config.places) { skullList.put(statsPlayer.getName(), getCustomHead(statsPlayer.getName())); } } @@ -191,8 +194,10 @@ public static void updateStats() { synchronized (positionStatsEntries) { positionStatsEntries.clear(); for (PlayerStatsEntry entry : newPositionStatsEntries) { - System.out.println(entry.getPosition() + "(" + entry.getDisplayPosition() + ") ." + entry.getName()); - positionStatsEntries.put(entry.getName(), entry); + if (entry.getPosition() <= Config.places) { + System.out.println(entry.getPosition() + ": " + entry.getName()); + positionStatsEntries.put(entry.getName(), entry); + } } }