3
0
Mirror von https://github.com/GeyserMC/Geyser.git synchronisiert 2024-12-26 00:00:41 +01:00

Merge branch 'feature/1.17' of https://github.com/GeyserMC/Geyser into feature/1.17

Dieser Commit ist enthalten in:
Camotoy 2021-06-08 08:57:50 -04:00
Commit b2ef059aed
Es konnte kein GPG-Schlüssel zu dieser Signatur gefunden werden
GPG-Schlüssel-ID: 7EEFB66FE798081F
8 geänderte Dateien mit 54 neuen und 51 gelöschten Zeilen

Datei anzeigen

@ -100,6 +100,10 @@ public final class NewsItem {
return project; return project;
} }
public boolean isGlobal() {
return "all".equals(getProject());
}
public boolean isActive() { public boolean isActive() {
return active; return active;
} }

Datei anzeigen

@ -1,35 +0,0 @@
/*
* Copyright (c) 2019-2021 GeyserMC. http://geysermc.org
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*
* @author GeyserMC
* @link https://github.com/GeyserMC/Geyser
*/
package org.geysermc.floodgate.util;
import lombok.Getter;
import lombok.Setter;
public final class FloodgateConfigHolder {
@Getter
@Setter
private static Object config;
}

Datei anzeigen

@ -27,9 +27,13 @@ package org.geysermc.floodgate.util;
import lombok.Getter; import lombok.Getter;
import lombok.Setter; import lombok.Setter;
import java.util.Properties; import java.util.Properties;
public class FloodgateGitPropertiesHolder { public final class FloodgateInfoHolder {
@Getter
@Setter
private static Object config;
@Getter @Getter
@Setter @Setter
private static Properties gitProperties; private static Properties gitProperties;

Datei anzeigen

@ -81,6 +81,8 @@ import java.util.concurrent.CompletableFuture;
import java.util.concurrent.Executors; import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService; import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
@Getter @Getter
public class GeyserConnector { public class GeyserConnector {
@ -330,6 +332,40 @@ public class GeyserConnector {
return versionMap; return versionMap;
})); }));
} }
// The following code can be attributed to the PaperMC project
// https://github.com/PaperMC/Paper/blob/master/Spigot-Server-Patches/0005-Paper-Metrics.patch#L614
metrics.addCustomChart(new Metrics.DrilldownPie("javaVersion", () -> {
Map<String, Map<String, Integer>> map = new HashMap<>();
String javaVersion = System.getProperty("java.version");
Map<String, Integer> entry = new HashMap<>();
entry.put(javaVersion, 1);
// http://openjdk.java.net/jeps/223
// Java decided to change their versioning scheme and in doing so modified the
// java.version system property to return $major[.$minor][.$security][-ea], as opposed to
// 1.$major.0_$identifier we can handle pre-9 by checking if the "major" is equal to "1",
// otherwise, 9+
String majorVersion = javaVersion.split("\\.")[0];
String release;
int indexOf = javaVersion.lastIndexOf('.');
if (majorVersion.equals("1")) {
release = "Java " + javaVersion.substring(0, indexOf);
} else {
// of course, it really wouldn't be all that simple if they didn't add a quirk, now
// would it valid strings for the major may potentially include values such as -ea to
// denote a pre release
Matcher versionMatcher = Pattern.compile("\\d+").matcher(majorVersion);
if (versionMatcher.find()) {
majorVersion = versionMatcher.group(0);
}
release = "Java " + majorVersion;
}
map.put(release, entry);
return map;
}));
} }
boolean isGui = false; boolean isGui = false;

Datei anzeigen

@ -42,8 +42,7 @@ import org.geysermc.connector.network.session.GeyserSession;
import org.geysermc.connector.utils.DockerCheck; import org.geysermc.connector.utils.DockerCheck;
import org.geysermc.connector.utils.FileUtils; import org.geysermc.connector.utils.FileUtils;
import org.geysermc.floodgate.util.DeviceOs; import org.geysermc.floodgate.util.DeviceOs;
import org.geysermc.floodgate.util.FloodgateConfigHolder; import org.geysermc.floodgate.util.FloodgateInfoHolder;
import org.geysermc.floodgate.util.FloodgateGitPropertiesHolder;
import java.io.File; import java.io.File;
import java.io.IOException; import java.io.IOException;
@ -184,8 +183,8 @@ public class DumpInfo {
private final Object config; private final Object config;
Floodgate() { Floodgate() {
this.gitInfo = FloodgateGitPropertiesHolder.getGitProperties(); this.gitInfo = FloodgateInfoHolder.getGitProperties();
this.config = FloodgateConfigHolder.getConfig(); this.config = FloodgateInfoHolder.getConfig();
} }
} }

Datei anzeigen

@ -152,20 +152,15 @@ public class Metrics {
*/ */
private ObjectNode getServerData() { private ObjectNode getServerData() {
// OS specific data // OS specific data
int playerAmount = connector.getPlayers().size();
String osName = System.getProperty("os.name"); String osName = System.getProperty("os.name");
String osArch = System.getProperty("os.arch"); String osArch = System.getProperty("os.arch");
String osVersion = System.getProperty("os.version"); String osVersion = System.getProperty("os.version");
String javaVersion = System.getProperty("java.version");
int coreCount = Runtime.getRuntime().availableProcessors(); int coreCount = Runtime.getRuntime().availableProcessors();
ObjectNode data = mapper.createObjectNode(); ObjectNode data = mapper.createObjectNode();
data.put("serverUUID", serverUUID); data.put("serverUUID", serverUUID);
data.put("playerAmount", playerAmount);
data.put("javaVersion", javaVersion);
data.put("osName", osName); data.put("osName", osName);
data.put("osArch", osArch); data.put("osArch", osArch);
data.put("osVersion", osVersion); data.put("osVersion", osVersion);

Datei anzeigen

@ -27,18 +27,14 @@ package org.geysermc.connector.utils;
import java.net.URI; import java.net.URI;
import java.net.URISyntaxException; import java.net.URISyntaxException;
import java.util.Arrays;
import java.util.Collections; import java.util.Collections;
import java.util.HashSet;
import java.util.Set; 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.unmodifiableSet( public static final Set<String> NEWS_PROJECT_LIST = Collections.singleton("geyser");
new HashSet<>(Arrays.asList("geyser", "floodgate"))
);
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";

Datei anzeigen

@ -142,7 +142,11 @@ public class NewsHandler {
return; return;
} }
if (!Constants.NEWS_PROJECT_LIST.contains(item.getProject())) { if (!item.isActive()) {
return;
}
if (!item.isGlobal() && !Constants.NEWS_PROJECT_LIST.contains(item.getProject())) {
return; return;
} }