Skip to content

Commit

Permalink
'on server started' should only work during the first check
Browse files Browse the repository at this point in the history
  • Loading branch information
Tim203 committed Jun 8, 2021
1 parent acc3a82 commit f0b8870
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,16 +27,13 @@

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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -77,6 +77,7 @@ private void checkNews() {
addNews(newsItem);
}
}
firstCheck = false;
} catch (Exception e) {
if (logger.isDebug()) {
logger.error("Error while reading news item", e);
Expand All @@ -85,10 +86,6 @@ private void checkNews() {
} catch (JsonSyntaxException ignored) {}
}

public void setGeyserStarted() {
geyserStarted = true;
}

public void handleNews(GeyserSession session, NewsItemAction action) {
for (NewsItem news : getActiveNews(action)) {
handleNewsItem(session, news, action);
Expand All @@ -98,7 +95,7 @@ public void handleNews(GeyserSession session, NewsItemAction action) {
private void handleNewsItem(GeyserSession session, NewsItem news, NewsItemAction action) {
switch (action) {
case ON_SERVER_STARTED:
if (!geyserStarted) {
if (!firstCheck) {
return;
}
case BROADCAST_TO_CONSOLE:
Expand Down Expand Up @@ -146,7 +143,7 @@ public void addNews(NewsItem item) {
return;
}

if (!item.isGlobal() && !Constants.NEWS_PROJECT_LIST.contains(item.getProject())) {
if (!item.isGlobal() && !Constants.NEWS_PROJECT_NAME.equals(item.getProject())) {
return;
}

Expand Down

0 comments on commit f0b8870

Please sign in to comment.