DedicatedServerProperties.java

net.minecraft.server.dedicated.DedicatedServerProperties

信息

  • 全限定名:net.minecraft.server.dedicated.DedicatedServerProperties
  • 类型:public class
  • 包:net.minecraft.server.dedicated
  • 源码路径:src/main/java/net/minecraft/server/dedicated/DedicatedServerProperties.java
  • 起始行号:L49
  • 继承:Settings
  • 职责:

    TODO

字段/常量

  • LOGGER

    • 类型: Logger
    • 修饰符: private static final
    • 源码定位: L50
    • 说明:

      TODO

  • SHA1

    • 类型: Pattern
    • 修饰符: private static final
    • 源码定位: L51
    • 说明:

      TODO

  • COMMA_SPLITTER

    • 类型: Splitter
    • 修饰符: private static final
    • 源码定位: L52
    • 说明:

      TODO

  • MANAGEMENT_SERVER_TLS_ENABLED_KEY

    • 类型: String
    • 修饰符: public static final
    • 源码定位: L53
    • 说明:

      TODO

  • MANAGEMENT_SERVER_TLS_KEYSTORE_KEY

    • 类型: String
    • 修饰符: public static final
    • 源码定位: L54
    • 说明:

      TODO

  • MANAGEMENT_SERVER_TLS_KEYSTORE_PASSWORD_KEY

    • 类型: String
    • 修饰符: public static final
    • 源码定位: L55
    • 说明:

      TODO

  • onlineMode

    • 类型: boolean
    • 修饰符: public final
    • 源码定位: L56
    • 说明:

      TODO

  • preventProxyConnections

    • 类型: boolean
    • 修饰符: public final
    • 源码定位: L57
    • 说明:

      TODO

  • serverIp

    • 类型: String
    • 修饰符: public final
    • 源码定位: L58
    • 说明:

      TODO

  • allowFlight

    • 类型: Settings<DedicatedServerProperties>.MutableValue<Boolean>
    • 修饰符: public final
    • 源码定位: L59
    • 说明:

      TODO

  • motd

    • 类型: Settings<DedicatedServerProperties>.MutableValue<String>
    • 修饰符: public final
    • 源码定位: L60
    • 说明:

      TODO

  • codeOfConduct

    • 类型: boolean
    • 修饰符: public final
    • 源码定位: L61
    • 说明:

      TODO

  • bugReportLink

    • 类型: String
    • 修饰符: public final
    • 源码定位: L62
    • 说明:

      TODO

  • forceGameMode

    • 类型: Settings<DedicatedServerProperties>.MutableValue<Boolean>
    • 修饰符: public final
    • 源码定位: L63
    • 说明:

      TODO

  • enforceWhitelist

    • 类型: Settings<DedicatedServerProperties>.MutableValue<Boolean>
    • 修饰符: public final
    • 源码定位: L64
    • 说明:

      TODO

  • difficulty

    • 类型: Settings<DedicatedServerProperties>.MutableValue<Difficulty>
    • 修饰符: public final
    • 源码定位: L65
    • 说明:

      TODO

  • gameMode

    • 类型: Settings<DedicatedServerProperties>.MutableValue<GameType>
    • 修饰符: public final
    • 源码定位: L68
    • 说明:

      TODO

  • levelName

    • 类型: String
    • 修饰符: public final
    • 源码定位: L71
    • 说明:

      TODO

  • serverPort

    • 类型: int
    • 修饰符: public final
    • 源码定位: L72
    • 说明:

      TODO

  • managementServerEnabled

    • 类型: boolean
    • 修饰符: public final
    • 源码定位: L73
    • 说明:

      TODO

  • managementServerHost

    • 类型: String
    • 修饰符: public final
    • 源码定位: L74
    • 说明:

      TODO

  • managementServerPort

    • 类型: int
    • 修饰符: public final
    • 源码定位: L75
    • 说明:

      TODO

  • managementServerSecret

    • 类型: String
    • 修饰符: public final
    • 源码定位: L76
    • 说明:

      TODO

  • managementServerTlsEnabled

    • 类型: boolean
    • 修饰符: public final
    • 源码定位: L77
    • 说明:

      TODO

  • managementServerTlsKeystore

    • 类型: String
    • 修饰符: public final
    • 源码定位: L78
    • 说明:

      TODO

  • managementServerTlsKeystorePassword

    • 类型: String
    • 修饰符: public final
    • 源码定位: L79
    • 说明:

      TODO

  • managementServerAllowedOrigins

    • 类型: String
    • 修饰符: public final
    • 源码定位: L80
    • 说明:

      TODO

  • announcePlayerAchievements

    • 类型: Boolean
    • 修饰符: public final
    • 源码定位: L81
    • 说明:

      TODO

  • enableQuery

    • 类型: boolean
    • 修饰符: public final
    • 源码定位: L82
    • 说明:

      TODO

  • queryPort

    • 类型: int
    • 修饰符: public final
    • 源码定位: L83
    • 说明:

      TODO

  • enableRcon

    • 类型: boolean
    • 修饰符: public final
    • 源码定位: L84
    • 说明:

      TODO

  • rconPort

    • 类型: int
    • 修饰符: public final
    • 源码定位: L85
    • 说明:

      TODO

  • rconPassword

    • 类型: String
    • 修饰符: public final
    • 源码定位: L86
    • 说明:

      TODO

  • hardcore

    • 类型: boolean
    • 修饰符: public final
    • 源码定位: L87
    • 说明:

      TODO

  • useNativeTransport

    • 类型: boolean
    • 修饰符: public final
    • 源码定位: L88
    • 说明:

      TODO

  • spawnProtection

    • 类型: Settings<DedicatedServerProperties>.MutableValue<Integer>
    • 修饰符: public final
    • 源码定位: L89
    • 说明:

      TODO

  • opPermissions

    • 类型: Settings<DedicatedServerProperties>.MutableValue<LevelBasedPermissionSet>
    • 修饰符: public final
    • 源码定位: L90
    • 说明:

      TODO

  • functionPermissions

    • 类型: LevelBasedPermissionSet
    • 修饰符: public final
    • 源码定位: L93
    • 说明:

      TODO

  • maxTickTime

    • 类型: long
    • 修饰符: public final
    • 源码定位: L99
    • 说明:

      TODO

  • maxChainedNeighborUpdates

    • 类型: int
    • 修饰符: public final
    • 源码定位: L100
    • 说明:

      TODO

  • rateLimitPacketsPerSecond

    • 类型: int
    • 修饰符: public final
    • 源码定位: L101
    • 说明:

      TODO

  • viewDistance

    • 类型: Settings<DedicatedServerProperties>.MutableValue<Integer>
    • 修饰符: public final
    • 源码定位: L102
    • 说明:

      TODO

  • simulationDistance

    • 类型: Settings<DedicatedServerProperties>.MutableValue<Integer>
    • 修饰符: public final
    • 源码定位: L103
    • 说明:

      TODO

  • maxPlayers

    • 类型: Settings<DedicatedServerProperties>.MutableValue<Integer>
    • 修饰符: public final
    • 源码定位: L104
    • 说明:

      TODO

  • networkCompressionThreshold

    • 类型: int
    • 修饰符: public final
    • 源码定位: L105
    • 说明:

      TODO

  • broadcastRconToOps

    • 类型: boolean
    • 修饰符: public final
    • 源码定位: L106
    • 说明:

      TODO

  • broadcastConsoleToOps

    • 类型: boolean
    • 修饰符: public final
    • 源码定位: L107
    • 说明:

      TODO

  • maxWorldSize

    • 类型: int
    • 修饰符: public final
    • 源码定位: L108
    • 说明:

      TODO

  • syncChunkWrites

    • 类型: boolean
    • 修饰符: public final
    • 源码定位: L109
    • 说明:

      TODO

  • regionFileComression

    • 类型: String
    • 修饰符: public final
    • 源码定位: L110
    • 说明:

      TODO

  • enableJmxMonitoring

    • 类型: boolean
    • 修饰符: public final
    • 源码定位: L111
    • 说明:

      TODO

  • enableStatus

    • 类型: Settings<DedicatedServerProperties>.MutableValue<Boolean>
    • 修饰符: public final
    • 源码定位: L112
    • 说明:

      TODO

  • hideOnlinePlayers

    • 类型: Settings<DedicatedServerProperties>.MutableValue<Boolean>
    • 修饰符: public final
    • 源码定位: L113
    • 说明:

      TODO

  • entityBroadcastRangePercentage

    • 类型: Settings<DedicatedServerProperties>.MutableValue<Integer>
    • 修饰符: public final
    • 源码定位: L114
    • 说明:

      TODO

  • textFilteringConfig

    • 类型: String
    • 修饰符: public final
    • 源码定位: L117
    • 说明:

      TODO

  • textFilteringVersion

    • 类型: int
    • 修饰符: public final
    • 源码定位: L118
    • 说明:

      TODO

  • serverResourcePackInfo

    • 类型: Optional<MinecraftServer.ServerResourcePackInfo>
    • 修饰符: public final
    • 源码定位: L119
    • 说明:

      TODO

  • initialDataPackConfiguration

    • 类型: DataPackConfig
    • 修饰符: public final
    • 源码定位: L120
    • 说明:

      TODO

  • playerIdleTimeout

    • 类型: Settings<DedicatedServerProperties>.MutableValue<Integer>
    • 修饰符: public final
    • 源码定位: L121
    • 说明:

      TODO

  • statusHeartbeatInterval

    • 类型: Settings<DedicatedServerProperties>.MutableValue<Integer>
    • 修饰符: public final
    • 源码定位: L122
    • 说明:

      TODO

  • whiteList

    • 类型: Settings<DedicatedServerProperties>.MutableValue<Boolean>
    • 修饰符: public final
    • 源码定位: L123
    • 说明:

      TODO

  • enforceSecureProfile

    • 类型: boolean
    • 修饰符: public final
    • 源码定位: L124
    • 说明:

      TODO

  • logIPs

    • 类型: boolean
    • 修饰符: public final
    • 源码定位: L125
    • 说明:

      TODO

  • pauseWhenEmptySeconds

    • 类型: Settings<DedicatedServerProperties>.MutableValue<Integer>
    • 修饰符: public final
    • 源码定位: L126
    • 说明:

      TODO

  • worldDimensionData

    • 类型: DedicatedServerProperties.WorldDimensionData
    • 修饰符: private final
    • 源码定位: L127
    • 说明:

      TODO

  • worldOptions

    • 类型: WorldOptions
    • 修饰符: public final
    • 源码定位: L128
    • 说明:

      TODO

  • acceptsTransfers

    • 类型: Settings<DedicatedServerProperties>.MutableValue<Boolean>
    • 修饰符: public final
    • 源码定位: L129
    • 说明:

      TODO

内部类/嵌套类型

  • net.minecraft.server.dedicated.DedicatedServerProperties.WorldDimensionData
    • 类型: record
    • 修饰符: private
    • 源码定位: L247
    • 说明:

      TODO

构造器

public DedicatedServerProperties(Properties settings) @ L131

  • 构造器名:DedicatedServerProperties
  • 源码定位:L131
  • 修饰符:public

参数:

  • settings: Properties

说明:

TODO

方法

下面的方法块按源码顺序生成。

public static DedicatedServerProperties fromFile(Path file) @ L155

  • 方法名:fromFile
  • 源码定位:L155
  • 返回类型:DedicatedServerProperties
  • 修饰符:public static

参数:

  • file: Path

说明:

TODO

protected DedicatedServerProperties reload(RegistryAccess registryAccess, Properties properties) @ L159

  • 方法名:reload
  • 源码定位:L159
  • 返回类型:DedicatedServerProperties
  • 修饰符:protected

参数:

  • registryAccess: RegistryAccess
  • properties: Properties

说明:

TODO

private static Component parseResourcePackPrompt(String prompt) @ L163

  • 方法名:parseResourcePackPrompt
  • 源码定位:L163
  • 返回类型:Component
  • 修饰符:private static

参数:

  • prompt: String

说明:

TODO

private static Optional<MinecraftServer.ServerResourcePackInfo> getServerPackInfo(String id, String url, String resourcePackSha1, String resourcePackHash, boolean requireResourcePack, String resourcePackPrompt) @ L179

  • 方法名:getServerPackInfo
  • 源码定位:L179
  • 返回类型:Optional<MinecraftServer.ServerResourcePackInfo>
  • 修饰符:private static

参数:

  • id: String
  • url: String
  • resourcePackSha1: String
  • resourcePackHash: String
  • requireResourcePack: boolean
  • resourcePackPrompt: String

说明:

TODO

private static DataPackConfig getDatapackConfig(String enabledPacks, String disabledPacks) @ L224

  • 方法名:getDatapackConfig
  • 源码定位:L224
  • 返回类型:DataPackConfig
  • 修饰符:private static

参数:

  • enabledPacks: String
  • disabledPacks: String

说明:

TODO

public static LevelBasedPermissionSet deserializePermission(String value) @ L230

  • 方法名:deserializePermission
  • 源码定位:L230
  • 返回类型:LevelBasedPermissionSet
  • 修饰符:public static

参数:

  • value: String

说明:

TODO

public static String serializePermission(LevelBasedPermissionSet permission) @ L239

  • 方法名:serializePermission
  • 源码定位:L239
  • 返回类型:String
  • 修饰符:public static

参数:

  • permission: LevelBasedPermissionSet

说明:

TODO

public WorldDimensions createDimensions(HolderLookup.Provider registries) @ L243

  • 方法名:createDimensions
  • 源码定位:L243
  • 返回类型:WorldDimensions
  • 修饰符:public

参数:

  • registries: HolderLookup.Provider

说明:

TODO

代码

public class DedicatedServerProperties extends Settings<DedicatedServerProperties> {
    private 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 static final String MANAGEMENT_SERVER_TLS_ENABLED_KEY = "management-server-tls-enabled";
    public static final String MANAGEMENT_SERVER_TLS_KEYSTORE_KEY = "management-server-tls-keystore";
    public static final String MANAGEMENT_SERVER_TLS_KEYSTORE_PASSWORD_KEY = "management-server-tls-keystore-password";
    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", "");
    public final Settings<DedicatedServerProperties>.MutableValue<Boolean> allowFlight = this.getMutable("allow-flight", false);
    public final Settings<DedicatedServerProperties>.MutableValue<String> motd = this.getMutable("motd", "A Minecraft Server");
    public final boolean codeOfConduct = this.get("enable-code-of-conduct", false);
    public final String bugReportLink = this.get("bug-report-link", "");
    public final Settings<DedicatedServerProperties>.MutableValue<Boolean> forceGameMode = this.getMutable("force-gamemode", false);
    public final Settings<DedicatedServerProperties>.MutableValue<Boolean> enforceWhitelist = this.getMutable("enforce-whitelist", false);
    public final Settings<DedicatedServerProperties>.MutableValue<Difficulty> difficulty = this.getMutable(
        "difficulty", dispatchNumberOrString(Difficulty::byId, Difficulty::byName), Difficulty::getSerializedName, Difficulty.EASY
    );
    public final Settings<DedicatedServerProperties>.MutableValue<GameType> gameMode = this.getMutable(
        "gamemode", dispatchNumberOrString(GameType::byId, GameType::byName), GameType::getName, GameType.SURVIVAL
    );
    public final String levelName = this.get("level-name", "world");
    public final int serverPort = this.get("server-port", 25565);
    public final boolean managementServerEnabled = this.get("management-server-enabled", false);
    public final String managementServerHost = this.get("management-server-host", "localhost");
    public final int managementServerPort = this.get("management-server-port", 0);
    public final String managementServerSecret = this.get("management-server-secret", SecurityConfig.generateSecretKey());
    public final boolean managementServerTlsEnabled = this.get("management-server-tls-enabled", true);
    public final String managementServerTlsKeystore = this.get("management-server-tls-keystore", "");
    public final String managementServerTlsKeystorePassword = this.get("management-server-tls-keystore-password", "");
    public final String managementServerAllowedOrigins = this.get("management-server-allowed-origins", "");
    public final @Nullable Boolean announcePlayerAchievements = this.getLegacyBoolean("announce-player-achievements");
    public final boolean enableQuery = this.get("enable-query", false);
    public final int queryPort = this.get("query.port", 25565);
    public final boolean enableRcon = this.get("enable-rcon", false);
    public final int rconPort = this.get("rcon.port", 25575);
    public final String rconPassword = this.get("rcon.password", "");
    public final boolean hardcore = this.get("hardcore", false);
    public final boolean useNativeTransport = this.get("use-native-transport", true);
    public final Settings<DedicatedServerProperties>.MutableValue<Integer> spawnProtection = this.getMutable("spawn-protection", 16);
    public final Settings<DedicatedServerProperties>.MutableValue<LevelBasedPermissionSet> opPermissions = this.getMutable(
        "op-permission-level", DedicatedServerProperties::deserializePermission, DedicatedServerProperties::serializePermission, LevelBasedPermissionSet.OWNER
    );
    public final LevelBasedPermissionSet functionPermissions = this.get(
        "function-permission-level",
        DedicatedServerProperties::deserializePermission,
        DedicatedServerProperties::serializePermission,
        LevelBasedPermissionSet.GAMEMASTER
    );
    public final long maxTickTime = this.get("max-tick-time", TimeUnit.MINUTES.toMillis(1L));
    public final int maxChainedNeighborUpdates = this.get("max-chained-neighbor-updates", 1000000);
    public final int rateLimitPacketsPerSecond = this.get("rate-limit", 0);
    public final Settings<DedicatedServerProperties>.MutableValue<Integer> viewDistance = this.getMutable("view-distance", 10);
    public final Settings<DedicatedServerProperties>.MutableValue<Integer> simulationDistance = this.getMutable("simulation-distance", 10);
    public final Settings<DedicatedServerProperties>.MutableValue<Integer> maxPlayers = this.getMutable("max-players", 20);
    public final int networkCompressionThreshold = this.get("network-compression-threshold", 256);
    public final boolean broadcastRconToOps = this.get("broadcast-rcon-to-ops", true);
    public final boolean broadcastConsoleToOps = this.get("broadcast-console-to-ops", true);
    public final int maxWorldSize = this.get("max-world-size", v -> Mth.clamp(v, 1, 29999984), 29999984);
    public final boolean syncChunkWrites = this.get("sync-chunk-writes", true);
    public final String regionFileComression = this.get("region-file-compression", "deflate");
    public final boolean enableJmxMonitoring = this.get("enable-jmx-monitoring", false);
    public final Settings<DedicatedServerProperties>.MutableValue<Boolean> enableStatus = this.getMutable("enable-status", true);
    public final Settings<DedicatedServerProperties>.MutableValue<Boolean> hideOnlinePlayers = this.getMutable("hide-online-players", false);
    public final Settings<DedicatedServerProperties>.MutableValue<Integer> entityBroadcastRangePercentage = this.getMutable(
        "entity-broadcast-range-percentage", v -> Mth.clamp(Integer.parseInt(v), 10, 1000), 100
    );
    public final String textFilteringConfig = this.get("text-filtering-config", "");
    public final int textFilteringVersion = this.get("text-filtering-version", 0);
    public final Optional<MinecraftServer.ServerResourcePackInfo> serverResourcePackInfo;
    public final DataPackConfig initialDataPackConfiguration;
    public final Settings<DedicatedServerProperties>.MutableValue<Integer> playerIdleTimeout = this.getMutable("player-idle-timeout", 0);
    public final Settings<DedicatedServerProperties>.MutableValue<Integer> statusHeartbeatInterval = this.getMutable("status-heartbeat-interval", 0);
    public final Settings<DedicatedServerProperties>.MutableValue<Boolean> whiteList = this.getMutable("white-list", false);
    public final boolean enforceSecureProfile = this.get("enforce-secure-profile", true);
    public final boolean logIPs = this.get("log-ips", true);
    public final Settings<DedicatedServerProperties>.MutableValue<Integer> pauseWhenEmptySeconds = this.getMutable("pause-when-empty-seconds", 60);
    private final DedicatedServerProperties.WorldDimensionData worldDimensionData;
    public final WorldOptions worldOptions;
    public final Settings<DedicatedServerProperties>.MutableValue<Boolean> acceptsTransfers = this.getMutable("accepts-transfers", false);
 
    public DedicatedServerProperties(Properties settings) {
        super(settings);
        String levelSeed = this.get("level-seed", "");
        boolean generateStructures = this.get("generate-structures", true);
        long seed = WorldOptions.parseSeed(levelSeed).orElse(WorldOptions.randomSeed());
        this.worldOptions = new WorldOptions(seed, generateStructures, false);
        this.worldDimensionData = new DedicatedServerProperties.WorldDimensionData(
            this.get("generator-settings", s -> GsonHelper.parse(!s.isEmpty() ? s : "{}"), new JsonObject()),
            this.get("level-type", v -> v.toLowerCase(Locale.ROOT), WorldPresets.NORMAL.identifier().toString())
        );
        this.serverResourcePackInfo = 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", "")
        );
        this.initialDataPackConfiguration = getDatapackConfig(
            this.get("initial-enabled-packs", String.join(",", WorldDataConfiguration.DEFAULT.dataPacks().getEnabled())),
            this.get("initial-disabled-packs", String.join(",", WorldDataConfiguration.DEFAULT.dataPacks().getDisabled()))
        );
    }
 
    public static DedicatedServerProperties fromFile(Path file) {
        return new DedicatedServerProperties(loadFromFile(file));
    }
 
    protected DedicatedServerProperties reload(RegistryAccess registryAccess, Properties properties) {
        return new DedicatedServerProperties(properties);
    }
 
    private static @Nullable Component parseResourcePackPrompt(String prompt) {
        if (!Strings.isNullOrEmpty(prompt)) {
            try {
                JsonElement element = StrictJsonParser.parse(prompt);
                return ComponentSerialization.CODEC
                    .parse(RegistryAccess.EMPTY.createSerializationContext(JsonOps.INSTANCE), element)
                    .resultOrPartial(msg -> LOGGER.warn("Failed to parse resource pack prompt '{}': {}", prompt, msg))
                    .orElse(null);
            } catch (Exception var2) {
                LOGGER.warn("Failed to parse resource pack prompt '{}'", prompt, var2);
            }
        }
 
        return null;
    }
 
    private static Optional<MinecraftServer.ServerResourcePackInfo> getServerPackInfo(
        String id, String url, String resourcePackSha1, @Nullable String resourcePackHash, boolean requireResourcePack, String resourcePackPrompt
    ) {
        if (url.isEmpty()) {
            return Optional.empty();
        } else {
            String hash;
            if (!resourcePackSha1.isEmpty()) {
                hash = resourcePackSha1;
                if (!Strings.isNullOrEmpty(resourcePackHash)) {
                    LOGGER.warn("resource-pack-hash is deprecated and found along side resource-pack-sha1. resource-pack-hash will be ignored.");
                }
            } else if (!Strings.isNullOrEmpty(resourcePackHash)) {
                LOGGER.warn("resource-pack-hash is deprecated. Please use resource-pack-sha1 instead.");
                hash = resourcePackHash;
            } else {
                hash = "";
            }
 
            if (hash.isEmpty()) {
                LOGGER.warn(
                    "You specified a resource pack without providing a sha1 hash. Pack will be updated on the client only if you change the name of the pack."
                );
            } else if (!SHA1.matcher(hash).matches()) {
                LOGGER.warn("Invalid sha1 for resource-pack-sha1");
            }
 
            Component prompt = parseResourcePackPrompt(resourcePackPrompt);
            UUID parsedId;
            if (id.isEmpty()) {
                parsedId = UUID.nameUUIDFromBytes(url.getBytes(StandardCharsets.UTF_8));
                LOGGER.warn("resource-pack-id missing, using default of {}", parsedId);
            } else {
                try {
                    parsedId = UUID.fromString(id);
                } catch (IllegalArgumentException var10) {
                    LOGGER.warn("Failed to parse '{}' into UUID", id);
                    return Optional.empty();
                }
            }
 
            return Optional.of(new MinecraftServer.ServerResourcePackInfo(parsedId, url, hash, requireResourcePack, prompt));
        }
    }
 
    private static DataPackConfig getDatapackConfig(String enabledPacks, String disabledPacks) {
        List<String> enabledPacksIds = COMMA_SPLITTER.splitToList(enabledPacks);
        List<String> disabledPacksIds = COMMA_SPLITTER.splitToList(disabledPacks);
        return new DataPackConfig(enabledPacksIds, disabledPacksIds);
    }
 
    public static @Nullable LevelBasedPermissionSet deserializePermission(String value) {
        try {
            PermissionLevel permissionLevel = PermissionLevel.byId(Integer.parseInt(value));
            return LevelBasedPermissionSet.forLevel(permissionLevel);
        } catch (NumberFormatException var2) {
            return null;
        }
    }
 
    public static String serializePermission(LevelBasedPermissionSet permission) {
        return Integer.toString(permission.level().id());
    }
 
    public WorldDimensions createDimensions(HolderLookup.Provider registries) {
        return this.worldDimensionData.create(registries);
    }
 
    private record WorldDimensionData(JsonObject generatorSettings, String levelType) {
        private static final Map<String, ResourceKey<WorldPreset>> LEGACY_PRESET_NAMES = Map.of(
            "default", WorldPresets.NORMAL, "largebiomes", WorldPresets.LARGE_BIOMES
        );
 
        public WorldDimensions create(HolderLookup.Provider registries) {
            HolderLookup<WorldPreset> worldPresets = registries.lookupOrThrow(Registries.WORLD_PRESET);
            Holder.Reference<WorldPreset> defaultHolder = worldPresets.get(WorldPresets.NORMAL)
                .or(() -> worldPresets.listElements().findAny())
                .orElseThrow(() -> new IllegalStateException("Invalid datapack contents: can't find default preset"));
            Holder<WorldPreset> worldPreset = Optional.ofNullable(Identifier.tryParse(this.levelType))
                .map(id -> ResourceKey.create(Registries.WORLD_PRESET, id))
                .or(() -> Optional.ofNullable(LEGACY_PRESET_NAMES.get(this.levelType)))
                .flatMap(worldPresets::get)
                .orElseGet(() -> {
                    DedicatedServerProperties.LOGGER.warn("Failed to parse level-type {}, defaulting to {}", this.levelType, defaultHolder.key().identifier());
                    return defaultHolder;
                });
            WorldDimensions worldDimensions = worldPreset.value().createWorldDimensions();
            if (worldPreset.is(WorldPresets.FLAT)) {
                RegistryOps<JsonElement> ops = registries.createSerializationContext(JsonOps.INSTANCE);
                Optional<FlatLevelGeneratorSettings> parsedSettings = FlatLevelGeneratorSettings.CODEC
                    .parse(new Dynamic<>(ops, this.generatorSettings()))
                    .resultOrPartial(DedicatedServerProperties.LOGGER::error);
                if (parsedSettings.isPresent()) {
                    return worldDimensions.replaceOverworldGenerator(registries, new FlatLevelSource(parsedSettings.get()));
                }
            }
 
            return worldDimensions;
        }
    }
}

引用的其他类

  • HolderLookup

    • 引用位置: 参数
  • RegistryAccess

    • 引用位置: 参数
  • Component

    • 引用位置: 返回值
  • Identifier

    • 引用位置: 方法调用
    • 关联成员: Identifier.tryParse()
  • ResourceKey

    • 引用位置: 方法调用
    • 关联成员: ResourceKey.create()
  • MinecraftServer

    • 引用位置: 字段/方法调用/构造调用/返回值
    • 关联成员: MinecraftServer.ServerResourcePackInfo(), ServerResourcePackInfo()
  • Settings

    • 引用位置: 字段/继承
  • SecurityConfig

    • 引用位置: 方法调用
    • 关联成员: SecurityConfig.generateSecretKey()
  • LevelBasedPermissionSet

    • 引用位置: 参数/字段/方法调用/返回值
    • 关联成员: LevelBasedPermissionSet.forLevel()
  • PermissionLevel

    • 引用位置: 方法调用
    • 关联成员: PermissionLevel.byId()
  • GsonHelper

    • 引用位置: 方法调用
    • 关联成员: GsonHelper.parse()
  • Mth

    • 引用位置: 方法调用
    • 关联成员: Mth.clamp()
  • StrictJsonParser

    • 引用位置: 方法调用
    • 关联成员: StrictJsonParser.parse()
  • Difficulty

    • 引用位置: 字段
  • TropicalFish

    • 引用位置: 字段/方法调用
    • 关联成员: Pattern.compile()
  • DataPackConfig

    • 引用位置: 字段/构造调用/返回值
    • 关联成员: DataPackConfig()
  • GameType

    • 引用位置: 字段
  • FlatLevelSource

    • 引用位置: 构造调用
    • 关联成员: FlatLevelSource()
  • WorldDimensions

    • 引用位置: 返回值
  • WorldOptions

    • 引用位置: 字段/方法调用/构造调用
    • 关联成员: WorldOptions(), WorldOptions.parseSeed(), WorldOptions.randomSeed()