From c18404cb52b3c4ab9abf14d0303aba2539a4c936 Mon Sep 17 00:00:00 2001 From: Tim203 Date: Sun, 7 Nov 2021 15:41:08 +0100 Subject: [PATCH] Updated to global api v2 --- common/pom.xml | 6 +++++ .../org/geysermc/floodgate/news/NewsItem.java | 24 ++++--------------- .../geysermc/connector/utils/Constants.java | 2 +- .../geysermc/connector/utils/NewsHandler.java | 6 +---- 4 files changed, 12 insertions(+), 26 deletions(-) diff --git a/common/pom.xml b/common/pom.xml index a3e86ff9b..a76ded3cf 100644 --- a/common/pom.xml +++ b/common/pom.xml @@ -10,6 +10,12 @@ common + + + 8 + 8 + + org.geysermc.cumulus diff --git a/common/src/main/java/org/geysermc/floodgate/news/NewsItem.java b/common/src/main/java/org/geysermc/floodgate/news/NewsItem.java index be0634a6d..5d9cd9d27 100644 --- a/common/src/main/java/org/geysermc/floodgate/news/NewsItem.java +++ b/common/src/main/java/org/geysermc/floodgate/news/NewsItem.java @@ -35,23 +35,21 @@ import java.util.Set; public final class NewsItem { private final int id; - private final String project; private final boolean active; private final NewsType type; private final ItemData data; - private final boolean priority; private final String message; private final Set actions; private final String url; - private NewsItem(int id, String project, boolean active, NewsType type, ItemData data, - boolean priority, String message, Set actions, String url) { + private NewsItem( + int id, boolean active, NewsType type, ItemData data, + String message, Set actions, String url) { + this.id = id; - this.project = project; this.active = active; this.type = type; this.data = data; - this.priority = priority; this.message = message; this.actions = Collections.unmodifiableSet(actions); this.url = url; @@ -81,11 +79,9 @@ public final class NewsItem { return new NewsItem( newsItem.get("id").getAsInt(), - newsItem.get("project").getAsString(), newsItem.get("active").getAsBoolean(), newsType, newsType.read(newsItem.getAsJsonObject("data")), - newsItem.get("priority").getAsBoolean(), message, actions, newsItem.get("url").getAsString() @@ -96,14 +92,6 @@ public final class NewsItem { return id; } - public String getProject() { - return project; - } - - public boolean isGlobal() { - return "all".equals(getProject()); - } - public boolean isActive() { return active; } @@ -121,10 +109,6 @@ public final class NewsItem { return (T) data; } - public boolean isPriority() { - return priority; - } - public String getRawMessage() { return message; } 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 0a6062a3b..58125d909 100644 --- a/connector/src/main/java/org/geysermc/connector/utils/Constants.java +++ b/connector/src/main/java/org/geysermc/connector/utils/Constants.java @@ -32,7 +32,7 @@ public final class Constants { public static final URI GLOBAL_API_WS_URI; public static final String NTP_SERVER = "time.cloudflare.com"; - public static final String NEWS_OVERVIEW_URL = "https://api.geysermc.org/v1/news"; + public static final String NEWS_OVERVIEW_URL = "https://api.geysermc.org/v2/news/"; public static final String NEWS_PROJECT_NAME = "geyser"; public static final String FLOODGATE_DOWNLOAD_LOCATION = "https://ci.opencollab.dev/job/GeyserMC/job/Floodgate/job/master/"; 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 6c5168dd2..8272fb0b2 100644 --- a/connector/src/main/java/org/geysermc/connector/utils/NewsHandler.java +++ b/connector/src/main/java/org/geysermc/connector/utils/NewsHandler.java @@ -68,7 +68,7 @@ public class NewsHandler { private void checkNews() { try { - String body = WebUtils.getBody(Constants.NEWS_OVERVIEW_URL); + String body = WebUtils.getBody(Constants.NEWS_OVERVIEW_URL + Constants.NEWS_PROJECT_NAME); JsonArray array = gson.fromJson(body, JsonArray.class); try { @@ -144,10 +144,6 @@ public class NewsHandler { return; } - if (!item.isGlobal() && !Constants.NEWS_PROJECT_NAME.equals(item.getProject())) { - return; - } - switch (item.getType()) { case ANNOUNCEMENT: if (!item.getDataAs(AnnouncementData.class).isAffected(Constants.NEWS_PROJECT_NAME)) {