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;
}
}
}引用的其他类
-
- 引用位置:
参数
- 引用位置:
-
- 引用位置:
参数
- 引用位置:
-
- 引用位置:
返回值
- 引用位置:
-
- 引用位置:
方法调用 - 关联成员:
Identifier.tryParse()
- 引用位置:
-
- 引用位置:
方法调用 - 关联成员:
ResourceKey.create()
- 引用位置:
-
- 引用位置:
字段/方法调用/构造调用/返回值 - 关联成员:
MinecraftServer.ServerResourcePackInfo(), ServerResourcePackInfo()
- 引用位置:
-
- 引用位置:
字段/继承
- 引用位置:
-
- 引用位置:
方法调用 - 关联成员:
SecurityConfig.generateSecretKey()
- 引用位置:
-
- 引用位置:
参数/字段/方法调用/返回值 - 关联成员:
LevelBasedPermissionSet.forLevel()
- 引用位置:
-
- 引用位置:
方法调用 - 关联成员:
PermissionLevel.byId()
- 引用位置:
-
- 引用位置:
方法调用 - 关联成员:
GsonHelper.parse()
- 引用位置:
-
- 引用位置:
方法调用 - 关联成员:
Mth.clamp()
- 引用位置:
-
- 引用位置:
方法调用 - 关联成员:
StrictJsonParser.parse()
- 引用位置:
-
- 引用位置:
字段
- 引用位置:
-
- 引用位置:
字段/方法调用 - 关联成员:
Pattern.compile()
- 引用位置:
-
- 引用位置:
字段/构造调用/返回值 - 关联成员:
DataPackConfig()
- 引用位置:
-
- 引用位置:
字段
- 引用位置:
-
- 引用位置:
构造调用 - 关联成员:
FlatLevelSource()
- 引用位置:
-
- 引用位置:
返回值
- 引用位置:
-
- 引用位置:
字段/方法调用/构造调用 - 关联成员:
WorldOptions(), WorldOptions.parseSeed(), WorldOptions.randomSeed()
- 引用位置: