mirror of
https://github.com/GeyserMC/Geyser.git
synced 2024-12-28 23:38:32 +01:00
Updated to global api v2
This commit is contained in:
parent
0b35449fb7
commit
c18404cb52
4 changed files with 12 additions and 26 deletions
|
@ -10,6 +10,12 @@
|
||||||
</parent>
|
</parent>
|
||||||
<artifactId>common</artifactId>
|
<artifactId>common</artifactId>
|
||||||
|
|
||||||
|
<!-- Floodgate is still targeting Java 8 -->
|
||||||
|
<properties>
|
||||||
|
<maven.compiler.source>8</maven.compiler.source>
|
||||||
|
<maven.compiler.target>8</maven.compiler.target>
|
||||||
|
</properties>
|
||||||
|
|
||||||
<dependencies>
|
<dependencies>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.geysermc.cumulus</groupId>
|
<groupId>org.geysermc.cumulus</groupId>
|
||||||
|
|
|
@ -35,23 +35,21 @@ import java.util.Set;
|
||||||
|
|
||||||
public final class NewsItem {
|
public final class NewsItem {
|
||||||
private final int id;
|
private final int id;
|
||||||
private final String project;
|
|
||||||
private final boolean active;
|
private final boolean active;
|
||||||
private final NewsType type;
|
private final NewsType type;
|
||||||
private final ItemData data;
|
private final ItemData data;
|
||||||
private final boolean priority;
|
|
||||||
private final String message;
|
private final String message;
|
||||||
private final Set<NewsItemAction> actions;
|
private final Set<NewsItemAction> actions;
|
||||||
private final String url;
|
private final String url;
|
||||||
|
|
||||||
private NewsItem(int id, String project, boolean active, NewsType type, ItemData data,
|
private NewsItem(
|
||||||
boolean priority, String message, Set<NewsItemAction> actions, String url) {
|
int id, boolean active, NewsType type, ItemData data,
|
||||||
|
String message, Set<NewsItemAction> actions, String url) {
|
||||||
|
|
||||||
this.id = id;
|
this.id = id;
|
||||||
this.project = project;
|
|
||||||
this.active = active;
|
this.active = active;
|
||||||
this.type = type;
|
this.type = type;
|
||||||
this.data = data;
|
this.data = data;
|
||||||
this.priority = priority;
|
|
||||||
this.message = message;
|
this.message = message;
|
||||||
this.actions = Collections.unmodifiableSet(actions);
|
this.actions = Collections.unmodifiableSet(actions);
|
||||||
this.url = url;
|
this.url = url;
|
||||||
|
@ -81,11 +79,9 @@ public final class NewsItem {
|
||||||
|
|
||||||
return new NewsItem(
|
return new NewsItem(
|
||||||
newsItem.get("id").getAsInt(),
|
newsItem.get("id").getAsInt(),
|
||||||
newsItem.get("project").getAsString(),
|
|
||||||
newsItem.get("active").getAsBoolean(),
|
newsItem.get("active").getAsBoolean(),
|
||||||
newsType,
|
newsType,
|
||||||
newsType.read(newsItem.getAsJsonObject("data")),
|
newsType.read(newsItem.getAsJsonObject("data")),
|
||||||
newsItem.get("priority").getAsBoolean(),
|
|
||||||
message,
|
message,
|
||||||
actions,
|
actions,
|
||||||
newsItem.get("url").getAsString()
|
newsItem.get("url").getAsString()
|
||||||
|
@ -96,14 +92,6 @@ public final class NewsItem {
|
||||||
return id;
|
return id;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getProject() {
|
|
||||||
return project;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isGlobal() {
|
|
||||||
return "all".equals(getProject());
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isActive() {
|
public boolean isActive() {
|
||||||
return active;
|
return active;
|
||||||
}
|
}
|
||||||
|
@ -121,10 +109,6 @@ public final class NewsItem {
|
||||||
return (T) data;
|
return (T) data;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isPriority() {
|
|
||||||
return priority;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getRawMessage() {
|
public String getRawMessage() {
|
||||||
return message;
|
return message;
|
||||||
}
|
}
|
||||||
|
|
|
@ -32,7 +32,7 @@ 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 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 NEWS_PROJECT_NAME = "geyser";
|
||||||
|
|
||||||
public static final String FLOODGATE_DOWNLOAD_LOCATION = "https://ci.opencollab.dev/job/GeyserMC/job/Floodgate/job/master/";
|
public static final String FLOODGATE_DOWNLOAD_LOCATION = "https://ci.opencollab.dev/job/GeyserMC/job/Floodgate/job/master/";
|
||||||
|
|
|
@ -68,7 +68,7 @@ public class NewsHandler {
|
||||||
|
|
||||||
private void checkNews() {
|
private void checkNews() {
|
||||||
try {
|
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);
|
JsonArray array = gson.fromJson(body, JsonArray.class);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
@ -144,10 +144,6 @@ public class NewsHandler {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!item.isGlobal() && !Constants.NEWS_PROJECT_NAME.equals(item.getProject())) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
switch (item.getType()) {
|
switch (item.getType()) {
|
||||||
case ANNOUNCEMENT:
|
case ANNOUNCEMENT:
|
||||||
if (!item.getDataAs(AnnouncementData.class).isAffected(Constants.NEWS_PROJECT_NAME)) {
|
if (!item.getDataAs(AnnouncementData.class).isAffected(Constants.NEWS_PROJECT_NAME)) {
|
||||||
|
|
Loading…
Reference in a new issue