aboutsummaryrefslogtreecommitdiffhomepage
path: root/patch-remap/mache-spigotflower/net/minecraft/server/dedicated/DedicatedServerProperties.java.patch
blob: dc1a1829957accf845f8152d25e41fb045918cae (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
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()));
                 }
             }