Mirror von
https://github.com/GeyserMC/Geyser.git
synchronisiert 2024-11-03 14:50:19 +01:00
'on server started' should only work during the first check
Dieser Commit ist enthalten in:
Ursprung
acc3a8222a
Commit
f0b8870a47
@ -27,16 +27,13 @@ package org.geysermc.connector.utils;
|
|||||||
|
|
||||||
import java.net.URI;
|
import java.net.URI;
|
||||||
import java.net.URISyntaxException;
|
import java.net.URISyntaxException;
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.Set;
|
|
||||||
|
|
||||||
public final class Constants {
|
public final class Constants {
|
||||||
public static final URI GLOBAL_API_WS_URI;
|
public static final URI GLOBAL_API_WS_URI;
|
||||||
public static final String NTP_SERVER = "time.cloudflare.com";
|
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_OVERVIEW_URL = "https://api.geysermc.org/v1/news";
|
||||||
|
public static final String NEWS_PROJECT_NAME = "geyser";
|
||||||
|
|
||||||
static {
|
static {
|
||||||
URI wsUri = null;
|
URI wsUri = null;
|
||||||
|
@ -52,7 +52,7 @@ public class NewsHandler {
|
|||||||
private final String branch;
|
private final String branch;
|
||||||
private final int build;
|
private final int build;
|
||||||
|
|
||||||
private boolean geyserStarted;
|
private boolean firstCheck = true;
|
||||||
|
|
||||||
public NewsHandler(String branch, int build) {
|
public NewsHandler(String branch, int build) {
|
||||||
this.branch = branch;
|
this.branch = branch;
|
||||||
@ -77,6 +77,7 @@ public class NewsHandler {
|
|||||||
addNews(newsItem);
|
addNews(newsItem);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
firstCheck = false;
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
if (logger.isDebug()) {
|
if (logger.isDebug()) {
|
||||||
logger.error("Error while reading news item", e);
|
logger.error("Error while reading news item", e);
|
||||||
@ -85,10 +86,6 @@ public class NewsHandler {
|
|||||||
} catch (JsonSyntaxException ignored) {}
|
} catch (JsonSyntaxException ignored) {}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setGeyserStarted() {
|
|
||||||
geyserStarted = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void handleNews(GeyserSession session, NewsItemAction action) {
|
public void handleNews(GeyserSession session, NewsItemAction action) {
|
||||||
for (NewsItem news : getActiveNews(action)) {
|
for (NewsItem news : getActiveNews(action)) {
|
||||||
handleNewsItem(session, news, action);
|
handleNewsItem(session, news, action);
|
||||||
@ -98,7 +95,7 @@ public class NewsHandler {
|
|||||||
private void handleNewsItem(GeyserSession session, NewsItem news, NewsItemAction action) {
|
private void handleNewsItem(GeyserSession session, NewsItem news, NewsItemAction action) {
|
||||||
switch (action) {
|
switch (action) {
|
||||||
case ON_SERVER_STARTED:
|
case ON_SERVER_STARTED:
|
||||||
if (!geyserStarted) {
|
if (!firstCheck) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
case BROADCAST_TO_CONSOLE:
|
case BROADCAST_TO_CONSOLE:
|
||||||
@ -146,7 +143,7 @@ public class NewsHandler {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!item.isGlobal() && !Constants.NEWS_PROJECT_LIST.contains(item.getProject())) {
|
if (!item.isGlobal() && !Constants.NEWS_PROJECT_NAME.equals(item.getProject())) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren