Mirror von
https://github.com/GeyserMC/Geyser.git
synchronisiert 2024-12-25 15:50:14 +01:00
Updated to global api v2
Dieser Commit ist enthalten in:
Ursprung
0b35449fb7
Commit
c18404cb52
@ -10,6 +10,12 @@
|
||||
</parent>
|
||||
<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>
|
||||
<dependency>
|
||||
<groupId>org.geysermc.cumulus</groupId>
|
||||
|
@ -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<NewsItemAction> actions;
|
||||
private final String url;
|
||||
|
||||
private NewsItem(int id, String project, boolean active, NewsType type, ItemData data,
|
||||
boolean priority, String message, Set<NewsItemAction> actions, String url) {
|
||||
private NewsItem(
|
||||
int id, boolean active, NewsType type, ItemData data,
|
||||
String message, Set<NewsItemAction> 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;
|
||||
}
|
||||
|
@ -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/";
|
||||
|
@ -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)) {
|
||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren