diff options
Diffstat (limited to 'patch-remap/mache-spigotflower/net/minecraft/server/dedicated/DedicatedServerProperties.java.patch')
-rw-r--r-- | patch-remap/mache-spigotflower/net/minecraft/server/dedicated/DedicatedServerProperties.java.patch | 152 |
1 files changed, 152 insertions, 0 deletions
diff --git a/patch-remap/mache-spigotflower/net/minecraft/server/dedicated/DedicatedServerProperties.java.patch b/patch-remap/mache-spigotflower/net/minecraft/server/dedicated/DedicatedServerProperties.java.patch new file mode 100644 index 0000000000..dc1a182995 --- /dev/null +++ b/patch-remap/mache-spigotflower/net/minecraft/server/dedicated/DedicatedServerProperties.java.patch @@ -0,0 +1,152 @@ +--- a/net/minecraft/server/dedicated/DedicatedServerProperties.java ++++ b/net/minecraft/server/dedicated/DedicatedServerProperties.java +@@ -44,11 +44,16 @@ + import net.minecraft.world.level.levelgen.presets.WorldPresets; + import org.slf4j.Logger; + ++// CraftBukkit start ++import joptsimple.OptionSet; ++// CraftBukkit end ++ + public class DedicatedServerProperties extends Settings<DedicatedServerProperties> { + + 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", ""); +@@ -103,8 +108,10 @@ + private final DedicatedServerProperties.WorldDimensionData worldDimensionData; + public final WorldOptions worldOptions; + +- public DedicatedServerProperties(Properties properties) { +- super(properties); ++ // 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"); +@@ -161,23 +168,24 @@ + 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 path) { +- return new DedicatedServerProperties(loadFromFile(path)); ++ // CraftBukkit start ++ public static DedicatedServerProperties fromFile(Path path, OptionSet optionset) { ++ return new DedicatedServerProperties(loadFromFile(path), optionset); + } + + @Override +- @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 +- private static Component parseResourcePackPrompt(String s) { +- if (!Strings.isNullOrEmpty(s)) { ++ private static Component parseResourcePackPrompt(String json) { ++ if (!Strings.isNullOrEmpty(json)) { + try { +- return Component.Serializer.fromJson(s); ++ return Component.Serializer.fromJson(json); + } catch (Exception exception) { +- DedicatedServerProperties.LOGGER.warn("Failed to parse resource pack prompt '{}'", s, exception); ++ DedicatedServerProperties.LOGGER.warn("Failed to parse resource pack prompt '{}'", json, exception); + } + } + +@@ -208,7 +216,7 @@ + DedicatedServerProperties.LOGGER.warn("Invalid sha1 for resource-pack-sha1"); + } + +- Component component = parseResourcePackPrompt(s4); ++ Component ichatbasecomponent = parseResourcePackPrompt(s4); + UUID uuid; + + if (s.isEmpty()) { +@@ -223,55 +231,55 @@ + } + } + +- return Optional.of(new MinecraftServer.ServerResourcePackInfo(uuid, s1, s5, flag, component)); ++ return Optional.of(new MinecraftServer.ServerResourcePackInfo(uuid, s1, s5, flag, ichatbasecomponent)); + } + } + +- private static DataPackConfig getDatapackConfig(String s, String s1) { +- List<String> list = DedicatedServerProperties.COMMA_SPLITTER.splitToList(s); +- List<String> list1 = DedicatedServerProperties.COMMA_SPLITTER.splitToList(s1); ++ private static DataPackConfig getDatapackConfig(String initalEnabledPacks, String initialDisabledPacks) { ++ List<String> list = DedicatedServerProperties.COMMA_SPLITTER.splitToList(initalEnabledPacks); ++ List<String> list1 = DedicatedServerProperties.COMMA_SPLITTER.splitToList(initialDisabledPacks); + + return new DataPackConfig(list, list1); + } + +- public WorldDimensions createDimensions(RegistryAccess registryaccess) { +- return this.worldDimensionData.create(registryaccess); ++ public WorldDimensions createDimensions(RegistryAccess registryAccess) { ++ return this.worldDimensionData.create(registryAccess); + } + +- private static record WorldDimensionData(JsonObject generatorSettings, String levelType) { ++ public static 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(RegistryAccess registryaccess) { +- Registry<WorldPreset> registry = registryaccess.registryOrThrow(Registries.WORLD_PRESET); +- Holder.Reference<WorldPreset> holder_reference = (Holder.Reference) registry.getHolder(WorldPresets.NORMAL).or(() -> { +- return registry.holders().findAny(); ++ public WorldDimensions create(RegistryAccess registryAccess) { ++ Registry<WorldPreset> iregistry = registryAccess.registryOrThrow(Registries.WORLD_PRESET); ++ Holder.Reference<WorldPreset> holder_c = (Holder.Reference) iregistry.getHolder(WorldPresets.NORMAL).or(() -> { ++ return iregistry.holders().findAny(); + }).orElseThrow(() -> { + return new IllegalStateException("Invalid datapack contents: can't find default preset"); + }); +- Optional optional = Optional.ofNullable(ResourceLocation.tryParse(this.levelType)).map((resourcelocation) -> { +- return ResourceKey.create(Registries.WORLD_PRESET, resourcelocation); ++ Optional<ResourceKey<WorldPreset>> optional = Optional.ofNullable(ResourceLocation.tryParse(this.levelType)).map((minecraftkey) -> { // CraftBukkit - decompile error ++ return ResourceKey.create(Registries.WORLD_PRESET, minecraftkey); + }).or(() -> { +- return Optional.ofNullable((ResourceKey) DedicatedServerProperties.WorldDimensionData.LEGACY_PRESET_NAMES.get(this.levelType)); ++ return Optional.ofNullable(DedicatedServerProperties.WorldDimensionData.LEGACY_PRESET_NAMES.get(this.levelType)); // CraftBukkit - decompile error + }); + +- Objects.requireNonNull(registry); +- Holder<WorldPreset> holder = (Holder) optional.flatMap(registry::getHolder).orElseGet(() -> { +- DedicatedServerProperties.LOGGER.warn("Failed to parse level-type {}, defaulting to {}", this.levelType, holder_reference.key().location()); +- return holder_reference; ++ Objects.requireNonNull(iregistry); ++ Holder<WorldPreset> holder = (Holder) optional.flatMap(iregistry::getHolder).orElseGet(() -> { ++ DedicatedServerProperties.LOGGER.warn("Failed to parse level-type {}, defaulting to {}", this.levelType, holder_c.key().location()); ++ return holder_c; + }); + WorldDimensions worlddimensions = ((WorldPreset) holder.value()).createWorldDimensions(); + + if (holder.is(WorldPresets.FLAT)) { +- RegistryOps<JsonElement> registryops = RegistryOps.create(JsonOps.INSTANCE, (HolderLookup.Provider) registryaccess); +- DataResult dataresult = FlatLevelGeneratorSettings.CODEC.parse(new Dynamic(registryops, this.generatorSettings())); ++ RegistryOps<JsonElement> registryops = RegistryOps.create(JsonOps.INSTANCE, (HolderLookup.Provider) registryAccess); ++ DataResult<FlatLevelGeneratorSettings> dataresult = FlatLevelGeneratorSettings.CODEC.parse(new Dynamic(registryops, this.generatorSettings())); // CraftBukkit - decompile error + Logger logger = DedicatedServerProperties.LOGGER; + + Objects.requireNonNull(logger); + Optional<FlatLevelGeneratorSettings> optional1 = dataresult.resultOrPartial(logger::error); + + if (optional1.isPresent()) { +- return worlddimensions.replaceOverworldGenerator(registryaccess, new FlatLevelSource((FlatLevelGeneratorSettings) optional1.get())); ++ return worlddimensions.replaceOverworldGenerator(registryAccess, new FlatLevelSource((FlatLevelGeneratorSettings) optional1.get())); + } + } + |