'on server started' should only work during the first check

This commit is contained in:
Tim203 2021-06-08 13:21:22 +02:00
parent acc3a8222a
commit f0b8870a47
No known key found for this signature in database
GPG Key ID: 064EE9F5BF7C3EE8
2 changed files with 5 additions and 11 deletions

View File

@ -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<String> 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;

View File

@ -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;
}