--- a/net/minecraft/server/dedicated/DedicatedServerProperties.java +++ b/net/minecraft/server/dedicated/DedicatedServerProperties.java @@ -41,10 +44,15 @@ import net.minecraft.world.level.levelgen.presets.WorldPresets; import org.slf4j.Logger; +// CraftBukkit start +import joptsimple.OptionSet; +// CraftBukkit end + public class DedicatedServerProperties extends Settings { static final Logger LOGGER = LogUtils.getLogger(); private static final Pattern SHA1 = Pattern.compile("^[a-fA-F0-9]{40}$"); private static final Splitter COMMA_SPLITTER = Splitter.on(',').trimResults(); + public final boolean debug = this.get("debug", false); // CraftBukkit public final boolean onlineMode = this.get("online-mode", true); public final boolean preventProxyConnections = this.get("prevent-proxy-connections", false); public final String serverIp = this.get("server-ip", ""); @@ -101,9 +108,53 @@ private final DedicatedServerProperties.WorldDimensionData worldDimensionData; public final WorldOptions worldOptions; - public DedicatedServerProperties(Properties properties) { - super(properties); - String string = this.get("level-seed", ""); + // CraftBukkit start + public DedicatedServerProperties(Properties properties, OptionSet optionset) { + super(properties, optionset); + // CraftBukkit end + this.difficulty = (Difficulty) this.get("difficulty", dispatchNumberOrString(Difficulty::byId, Difficulty::byName), Difficulty::getKey, Difficulty.EASY); + this.gamemode = (GameType) this.get("gamemode", dispatchNumberOrString(GameType::byId, GameType::byName), GameType::getName, GameType.SURVIVAL); + this.levelName = this.get("level-name", "world"); + this.serverPort = this.get("server-port", 25565); + this.announcePlayerAchievements = this.getLegacyBoolean("announce-player-achievements"); + this.enableQuery = this.get("enable-query", false); + this.queryPort = this.get("query.port", 25565); + this.enableRcon = this.get("enable-rcon", false); + this.rconPort = this.get("rcon.port", 25575); + this.rconPassword = this.get("rcon.password", ""); + this.hardcore = this.get("hardcore", false); + this.allowNether = this.get("allow-nether", true); + this.spawnMonsters = this.get("spawn-monsters", true); + this.useNativeTransport = this.get("use-native-transport", true); + this.enableCommandBlock = this.get("enable-command-block", false); + this.spawnProtection = this.get("spawn-protection", 16); + this.opPermissionLevel = this.get("op-permission-level", 4); + this.functionPermissionLevel = this.get("function-permission-level", 2); + this.maxTickTime = this.get("max-tick-time", TimeUnit.MINUTES.toMillis(1L)); + this.maxChainedNeighborUpdates = this.get("max-chained-neighbor-updates", 1000000); + this.rateLimitPacketsPerSecond = this.get("rate-limit", 0); + this.viewDistance = this.get("view-distance", 10); + this.simulationDistance = this.get("simulation-distance", 10); + this.maxPlayers = this.get("max-players", 20); + this.networkCompressionThreshold = this.get("network-compression-threshold", 256); + this.broadcastRconToOps = this.get("broadcast-rcon-to-ops", true); + this.broadcastConsoleToOps = this.get("broadcast-console-to-ops", true); + this.maxWorldSize = this.get("max-world-size", (integer) -> { + return Mth.clamp(integer, 1, 29999984); + }, 29999984); + this.syncChunkWrites = this.get("sync-chunk-writes", true); + this.enableJmxMonitoring = this.get("enable-jmx-monitoring", false); + this.enableStatus = this.get("enable-status", true); + this.hideOnlinePlayers = this.get("hide-online-players", false); + this.entityBroadcastRangePercentage = this.get("entity-broadcast-range-percentage", (integer) -> { + return Mth.clamp(integer, 10, 1000); + }, 100); + this.textFilteringConfig = this.get("text-filtering-config", ""); + this.playerIdleTimeout = this.getMutable("player-idle-timeout", 0); + this.whiteList = this.getMutable("white-list", false); + this.enforceSecureProfile = this.get("enforce-secure-profile", true); + this.logIPs = this.get("log-ips", true); + String s = this.get("level-seed", ""); boolean flag = this.get("generate-structures", true); long l = WorldOptions.parseSeed(string).orElse(WorldOptions.randomSeed()); this.worldOptions = new WorldOptions(l, flag, false); @@ -125,13 +168,15 @@ ); } - public static DedicatedServerProperties fromFile(Path path) { - return new DedicatedServerProperties(loadFromFile(path)); + // CraftBukkit start + public static DedicatedServerProperties fromFile(Path path, OptionSet optionset) { + return new DedicatedServerProperties(loadFromFile(path), optionset); } @Override - protected DedicatedServerProperties reload(RegistryAccess registryAccess, Properties properties) { - return new DedicatedServerProperties(properties); + protected DedicatedServerProperties reload(RegistryAccess iregistrycustom, Properties properties, OptionSet optionset) { + return new DedicatedServerProperties(properties, optionset); + // CraftBukkit end } @Nullable