mirror of
https://github.com/Winds-Studio/Leaf.git
synced 2025-12-19 15:09:25 +00:00
252 lines
15 KiB
Diff
252 lines
15 KiB
Diff
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
From: Martijn Muijsers <martijnmuijsers@live.nl>
|
|
Date: Sat, 24 Dec 2022 17:56:41 +0100
|
|
Subject: [PATCH] Include server.properties in timings
|
|
|
|
Removed since 1.21
|
|
|
|
License: GPL-3.0 (https://www.gnu.org/licenses/gpl-3.0.html)
|
|
Gale - https://galemc.org
|
|
|
|
diff --git a/src/main/java/co/aikar/timings/TimingsExport.java b/src/main/java/co/aikar/timings/TimingsExport.java
|
|
index 29796a404e210f7864f4b33b3367e02531bca2a0..73e503d0590964ac7f9ea15ac7ee7783f0801b2e 100644
|
|
--- a/src/main/java/co/aikar/timings/TimingsExport.java
|
|
+++ b/src/main/java/co/aikar/timings/TimingsExport.java
|
|
@@ -35,6 +35,7 @@ import org.bukkit.Material;
|
|
import org.bukkit.configuration.ConfigurationSection;
|
|
import org.bukkit.configuration.MemorySection;
|
|
import org.bukkit.entity.EntityType;
|
|
+import org.galemc.gale.configuration.timingsexport.VanillaServerPropertiesTimingsExport;
|
|
import org.json.simple.JSONObject;
|
|
import org.json.simple.JSONValue;
|
|
import oshi.SystemInfo;
|
|
@@ -238,6 +239,7 @@ public class TimingsExport extends Thread {
|
|
// Information on the users Config
|
|
|
|
parent.put("config", createObject(
|
|
+ pair("server.properties", VanillaServerPropertiesTimingsExport.get()), // Gale - include server.properties in timings
|
|
pair("spigot", mapAsJSON(Bukkit.spigot().getSpigotConfig(), null)),
|
|
pair("bukkit", mapAsJSON(Bukkit.spigot().getBukkitConfig(), null)),
|
|
// Gale start - Gale configuration - include in timings
|
|
diff --git a/src/main/java/net/minecraft/server/dedicated/DedicatedServerProperties.java b/src/main/java/net/minecraft/server/dedicated/DedicatedServerProperties.java
|
|
index d6431376184e5650b370cbab204e28bc31f4dac6..bfe9be2e329c2ea2c8c44458e88d22bc75520ed4 100644
|
|
--- a/src/main/java/net/minecraft/server/dedicated/DedicatedServerProperties.java
|
|
+++ b/src/main/java/net/minecraft/server/dedicated/DedicatedServerProperties.java
|
|
@@ -67,6 +67,7 @@ public class DedicatedServerProperties extends Settings<DedicatedServerPropertie
|
|
public final Difficulty difficulty;
|
|
public final GameType gamemode;
|
|
public final String levelName;
|
|
+ public final String levelSeed; // Gale - include server.properties in timings
|
|
public final int serverPort;
|
|
@Nullable
|
|
public final Boolean announcePlayerAchievements;
|
|
@@ -100,13 +101,14 @@ public class DedicatedServerProperties extends Settings<DedicatedServerPropertie
|
|
public final boolean hideOnlinePlayers;
|
|
public final int entityBroadcastRangePercentage;
|
|
public final String textFilteringConfig;
|
|
+ public final String resourcePackPrompt; // Gale - include server.properties in timings
|
|
public final Optional<MinecraftServer.ServerResourcePackInfo> serverResourcePackInfo;
|
|
public final DataPackConfig initialDataPackConfiguration;
|
|
public final Settings<DedicatedServerProperties>.MutableValue<Integer> playerIdleTimeout;
|
|
public final Settings<DedicatedServerProperties>.MutableValue<Boolean> whiteList;
|
|
public final boolean enforceSecureProfile;
|
|
public final boolean logIPs;
|
|
- private final DedicatedServerProperties.WorldDimensionData worldDimensionData;
|
|
+ public final DedicatedServerProperties.WorldDimensionData worldDimensionData; // Gale - include server.properties in timings - private -> public
|
|
public final WorldOptions worldOptions;
|
|
public boolean acceptsTransfers;
|
|
|
|
@@ -161,6 +163,7 @@ public class DedicatedServerProperties extends Settings<DedicatedServerPropertie
|
|
this.logIPs = this.get("log-ips", true);
|
|
this.acceptsTransfers = this.get("accepts-transfers", false);
|
|
String s = this.get("level-seed", "");
|
|
+ this.levelSeed = s; // Gale - include server.properties in timings
|
|
boolean flag = this.get("generate-structures", true);
|
|
long i = WorldOptions.parseSeed(s).orElse(WorldOptions.randomSeed());
|
|
|
|
@@ -170,7 +173,10 @@ public class DedicatedServerProperties extends Settings<DedicatedServerPropertie
|
|
}, new JsonObject()), (String) this.get("level-type", (s1) -> {
|
|
return s1.toLowerCase(Locale.ROOT);
|
|
}, WorldPresets.NORMAL.location().toString()));
|
|
- this.serverResourcePackInfo = DedicatedServerProperties.getServerPackInfo(this.get("resource-pack-id", ""), this.get("resource-pack", ""), this.get("resource-pack-sha1", ""), this.getLegacyString("resource-pack-hash"), this.get("require-resource-pack", false), this.get("resource-pack-prompt", ""));
|
|
+ // Gale start - include server.properties in timings
|
|
+ this.resourcePackPrompt = this.get("resource-pack-prompt", "");
|
|
+ this.serverResourcePackInfo = DedicatedServerProperties.getServerPackInfo(this.get("resource-pack-id", ""), this.get("resource-pack", ""), this.get("resource-pack-sha1", ""), this.getLegacyString("resource-pack-hash"), this.get("require-resource-pack", false), this.resourcePackPrompt);
|
|
+ // Gale end - include server.properties in timings
|
|
this.initialDataPackConfiguration = DedicatedServerProperties.getDatapackConfig(this.get("initial-enabled-packs", String.join(",", WorldDataConfiguration.DEFAULT.dataPacks().getEnabled())), this.get("initial-disabled-packs", String.join(",", WorldDataConfiguration.DEFAULT.dataPacks().getDisabled())));
|
|
// Paper start - Configurable rcon ip
|
|
final String rconIp = this.getStringRaw("rcon.ip");
|
|
diff --git a/src/main/java/org/galemc/gale/configuration/GaleGlobalConfiguration.java b/src/main/java/org/galemc/gale/configuration/GaleGlobalConfiguration.java
|
|
index 8f8fd98f96cd390ba43033521982a13044df91cf..dbb0f523608a9208e8c656898b18ce1b9505a1e0 100644
|
|
--- a/src/main/java/org/galemc/gale/configuration/GaleGlobalConfiguration.java
|
|
+++ b/src/main/java/org/galemc/gale/configuration/GaleGlobalConfiguration.java
|
|
@@ -27,4 +27,33 @@ public class GaleGlobalConfiguration extends ConfigurationPart {
|
|
|
|
}
|
|
|
|
+ public Misc misc;
|
|
+ public class Misc extends ConfigurationPart {
|
|
+
|
|
+ public IncludeInTimingsReport includeInTimingsReport;
|
|
+ public class IncludeInTimingsReport extends ConfigurationPart {
|
|
+
|
|
+ // Gale start - include server.properties in timings
|
|
+ public ServerProperties serverProperties;
|
|
+ public class ServerProperties extends ConfigurationPart {
|
|
+ public boolean dataPacks = true;
|
|
+ public boolean enableRcon = false;
|
|
+ public boolean generatorSettings = true;
|
|
+ public boolean levelName = false;
|
|
+ public boolean motd = false;
|
|
+ public boolean queryPort = false;
|
|
+ public boolean rconPort = false;
|
|
+ public boolean resourcePackPrompt = false;
|
|
+ @Setting("resource-pack-and-resource-pack-sha1")
|
|
+ public boolean resourcePackAndResourcePackSha1 = false;
|
|
+ public boolean serverIp = false;
|
|
+ public boolean serverPort = false;
|
|
+ public boolean textFilteringConfig = false;
|
|
+ }
|
|
+ // Gale end - include server.properties in timings
|
|
+
|
|
+ }
|
|
+
|
|
+ }
|
|
+
|
|
}
|
|
diff --git a/src/main/java/org/galemc/gale/configuration/timingsexport/VanillaServerPropertiesTimingsExport.java b/src/main/java/org/galemc/gale/configuration/timingsexport/VanillaServerPropertiesTimingsExport.java
|
|
new file mode 100644
|
|
index 0000000000000000000000000000000000000000..139d946346594d2a59a8b2930c4eae794c880dbc
|
|
--- /dev/null
|
|
+++ b/src/main/java/org/galemc/gale/configuration/timingsexport/VanillaServerPropertiesTimingsExport.java
|
|
@@ -0,0 +1,129 @@
|
|
+// Gale - include server.properties in timings
|
|
+
|
|
+package org.galemc.gale.configuration.timingsexport;
|
|
+
|
|
+import co.aikar.timings.TimingsExport;
|
|
+import net.minecraft.server.MinecraftServer;
|
|
+import net.minecraft.server.dedicated.DedicatedServer;
|
|
+import org.galemc.gale.configuration.GaleGlobalConfiguration;
|
|
+import org.jetbrains.annotations.NotNull;
|
|
+import org.json.simple.JSONObject;
|
|
+
|
|
+import java.util.Optional;
|
|
+
|
|
+/**
|
|
+ * Exports the vanilla server.properties to a JSON object, to be included in a timings report.
|
|
+ *
|
|
+ * @see TimingsExport
|
|
+ *
|
|
+ * @author Martijn Muijsers under GPL-3.0
|
|
+ */
|
|
+public final class VanillaServerPropertiesTimingsExport {
|
|
+
|
|
+ private VanillaServerPropertiesTimingsExport() {}
|
|
+
|
|
+ @SuppressWarnings("unchecked")
|
|
+ public static @NotNull JSONObject get() {
|
|
+
|
|
+ var json = new JSONObject();
|
|
+ var properties = ((DedicatedServer) MinecraftServer.getServer()).getProperties();
|
|
+ var includeConfig = GaleGlobalConfiguration.get().misc.includeInTimingsReport.serverProperties;
|
|
+
|
|
+ json.put("allow-flight", String.valueOf(properties.allowFlight));
|
|
+ json.put("allow-nether", String.valueOf(properties.allowNether));
|
|
+ json.put("broadcast-console-to-ops", String.valueOf(properties.broadcastConsoleToOps));
|
|
+ json.put("broadcast-rcon-to-ops", String.valueOf(properties.broadcastRconToOps));
|
|
+ json.put("debug", String.valueOf(properties.debug));
|
|
+ json.put("difficulty", String.valueOf(properties.difficulty));
|
|
+ json.put("enable-command-block", String.valueOf(properties.enableCommandBlock));
|
|
+ json.put("enable-jmx-monitoring", String.valueOf(properties.enableJmxMonitoring));
|
|
+ json.put("enable-query", String.valueOf(properties.enableQuery));
|
|
+ if (includeConfig.enableRcon) {
|
|
+ json.put("enable-rcon", String.valueOf(properties.enableRcon));
|
|
+ }
|
|
+ json.put("enable-status", String.valueOf(properties.enableStatus));
|
|
+ json.put("enforce-secure-profile", String.valueOf(properties.enforceSecureProfile));
|
|
+ json.put("enforce-whitelist", String.valueOf(properties.enforceWhitelist));
|
|
+ json.put("entity-broadcast-range-percentage", String.valueOf(properties.entityBroadcastRangePercentage));
|
|
+ json.put("force-gamemode", String.valueOf(properties.forceGameMode));
|
|
+ json.put("function-permission-level", String.valueOf(properties.functionPermissionLevel));
|
|
+ json.put("gamemode", String.valueOf(properties.gamemode));
|
|
+ Optional.ofNullable(properties.worldOptions).ifPresent(worldOptions -> json.put("generate-structures", String.valueOf(worldOptions.generateStructures())));
|
|
+ if (includeConfig.generatorSettings) {
|
|
+ Optional.ofNullable(properties.worldDimensionData).ifPresent(worldDimensionData -> json.put("generator-settings", String.valueOf(worldDimensionData.generatorSettings())));
|
|
+ }
|
|
+ json.put("hardcore", String.valueOf(properties.hardcore));
|
|
+ json.put("hide-online-players", String.valueOf(properties.hideOnlinePlayers));
|
|
+ if (includeConfig.dataPacks) {
|
|
+ Optional.ofNullable(properties.initialDataPackConfiguration).ifPresent(initialDataPackConfiguration -> {
|
|
+ json.put("initial-enabled-packs", String.valueOf(initialDataPackConfiguration.getEnabled()));
|
|
+ json.put("initial-disabled-packs", String.valueOf(initialDataPackConfiguration.getDisabled()));
|
|
+ });
|
|
+ }
|
|
+ if (includeConfig.levelName) {
|
|
+ json.put("level-name", String.valueOf(properties.levelName));
|
|
+ }
|
|
+ // Note: level-seed is never included to prevent it being leaked
|
|
+// if (includeConfig.levelSeed) {
|
|
+// json.put("level-seed", String.valueOf(properties.levelSeed));
|
|
+// }
|
|
+ Optional.ofNullable(properties.worldDimensionData).ifPresent(worldDimensionData -> json.put("level-type", String.valueOf(worldDimensionData.levelType())));
|
|
+ json.put("log-ips", String.valueOf(properties.logIPs));
|
|
+ json.put("max-chained-neighbor-updates", String.valueOf(properties.maxChainedNeighborUpdates));
|
|
+ json.put("max-players", String.valueOf(properties.maxPlayers));
|
|
+ json.put("max-tick-time", String.valueOf(properties.maxTickTime));
|
|
+ json.put("max-world-size", String.valueOf(properties.maxWorldSize));
|
|
+ if (includeConfig.motd) {
|
|
+ json.put("motd", String.valueOf(properties.motd));
|
|
+ }
|
|
+ json.put("network-compression-threshold", String.valueOf(properties.networkCompressionThreshold));
|
|
+ json.put("online-mode", String.valueOf(properties.onlineMode));
|
|
+ json.put("op-permission-level", String.valueOf(properties.opPermissionLevel));
|
|
+ Optional.ofNullable(properties.playerIdleTimeout).ifPresent(playerIdleTimeout -> json.put("player-idle-timeout", String.valueOf(playerIdleTimeout.get())));
|
|
+ json.put("prevent-proxy-connections", String.valueOf(properties.preventProxyConnections));
|
|
+ json.put("pvp", String.valueOf(properties.pvp));
|
|
+ if (includeConfig.queryPort) {
|
|
+ json.put("query-port", String.valueOf(properties.queryPort));
|
|
+ }
|
|
+ json.put("rate-limit", String.valueOf(properties.rateLimitPacketsPerSecond));
|
|
+ // Note: rcon-password is never included to prevent it being leaked
|
|
+// if (includeConfig.rconPassword) {
|
|
+// json.put("rcon-password", String.valueOf(properties.rconPassword));
|
|
+// }
|
|
+ if (includeConfig.rconPort) {
|
|
+ json.put("rcon-port", String.valueOf(properties.queryPort));
|
|
+ }
|
|
+ properties.serverResourcePackInfo.ifPresent(serverResourcePackInfo -> {
|
|
+ json.put("require-resource-pack", String.valueOf(serverResourcePackInfo.isRequired()));
|
|
+ if (includeConfig.resourcePackAndResourcePackSha1) {
|
|
+ json.put("resource-pack", String.valueOf(serverResourcePackInfo.url()));
|
|
+ json.put("resource-pack-sha1", String.valueOf(serverResourcePackInfo.hash()));
|
|
+ }
|
|
+ });
|
|
+ if (includeConfig.resourcePackPrompt) {
|
|
+ json.put("resource-pack-prompt", String.valueOf(properties.resourcePackPrompt));
|
|
+ }
|
|
+ if (includeConfig.serverIp) {
|
|
+ json.put("server-ip", String.valueOf(properties.serverIp));
|
|
+ }
|
|
+ if (includeConfig.serverPort) {
|
|
+ json.put("server-port", String.valueOf(properties.serverPort));
|
|
+ }
|
|
+ json.put("simulation-distance", String.valueOf(properties.simulationDistance));
|
|
+ json.put("spawn-animals", String.valueOf(properties.spawnAnimals));
|
|
+ json.put("spawn-monsters", String.valueOf(properties.spawnMonsters));
|
|
+ json.put("spawn-npcs", String.valueOf(properties.spawnNpcs));
|
|
+ json.put("spawn-protection", String.valueOf(properties.spawnProtection));
|
|
+ json.put("sync-chunk-writes", String.valueOf(properties.syncChunkWrites));
|
|
+ if (includeConfig.textFilteringConfig) {
|
|
+ json.put("text-filtering-config", String.valueOf(properties.textFilteringConfig));
|
|
+ }
|
|
+ json.put("use-native-transport", String.valueOf(properties.useNativeTransport));
|
|
+ json.put("view-distance", String.valueOf(properties.viewDistance));
|
|
+ Optional.ofNullable(properties.whiteList).ifPresent(whiteList -> json.put("white-list", String.valueOf(whiteList.get())));
|
|
+
|
|
+ return json;
|
|
+
|
|
+ }
|
|
+
|
|
+}
|