From f0b8870a47b661cf84b51f127bf81272268616d7 Mon Sep 17 00:00:00 2001 From: Tim203 Date: Tue, 8 Jun 2021 13:21:22 +0200 Subject: [PATCH] 'on server started' should only work during the first check --- .../java/org/geysermc/connector/utils/Constants.java | 5 +---- .../org/geysermc/connector/utils/NewsHandler.java | 11 ++++------- 2 files changed, 5 insertions(+), 11 deletions(-) diff --git a/connector/src/main/java/org/geysermc/connector/utils/Constants.java b/connector/src/main/java/org/geysermc/connector/utils/Constants.java index 2a47a5bce..02f5c1ae4 100644 --- a/connector/src/main/java/org/geysermc/connector/utils/Constants.java +++ b/connector/src/main/java/org/geysermc/connector/utils/Constants.java @@ -27,16 +27,13 @@ package org.geysermc.connector.utils; import java.net.URI; import java.net.URISyntaxException; -import java.util.Collections; -import java.util.Set; public final class Constants { public static final URI GLOBAL_API_WS_URI; public static final String NTP_SERVER = "time.cloudflare.com"; - public static final Set NEWS_PROJECT_LIST = Collections.singleton("geyser"); - public static final String NEWS_OVERVIEW_URL = "https://api.geysermc.org/v1/news"; + public static final String NEWS_PROJECT_NAME = "geyser"; static { URI wsUri = null; diff --git a/connector/src/main/java/org/geysermc/connector/utils/NewsHandler.java b/connector/src/main/java/org/geysermc/connector/utils/NewsHandler.java index fb945edc6..c70255f52 100644 --- a/connector/src/main/java/org/geysermc/connector/utils/NewsHandler.java +++ b/connector/src/main/java/org/geysermc/connector/utils/NewsHandler.java @@ -52,7 +52,7 @@ public class NewsHandler { private final String branch; private final int build; - private boolean geyserStarted; + private boolean firstCheck = true; public NewsHandler(String branch, int build) { this.branch = branch; @@ -77,6 +77,7 @@ public class NewsHandler { addNews(newsItem); } } + firstCheck = false; } catch (Exception e) { if (logger.isDebug()) { logger.error("Error while reading news item", e); @@ -85,10 +86,6 @@ public class NewsHandler { } catch (JsonSyntaxException ignored) {} } - public void setGeyserStarted() { - geyserStarted = true; - } - public void handleNews(GeyserSession session, NewsItemAction action) { for (NewsItem news : getActiveNews(action)) { handleNewsItem(session, news, action); @@ -98,7 +95,7 @@ public class NewsHandler { private void handleNewsItem(GeyserSession session, NewsItem news, NewsItemAction action) { switch (action) { case ON_SERVER_STARTED: - if (!geyserStarted) { + if (!firstCheck) { return; } case BROADCAST_TO_CONSOLE: @@ -146,7 +143,7 @@ public class NewsHandler { return; } - if (!item.isGlobal() && !Constants.NEWS_PROJECT_LIST.contains(item.getProject())) { + if (!item.isGlobal() && !Constants.NEWS_PROJECT_NAME.equals(item.getProject())) { return; }