From f70a7b68de51bd70d1be9b25d04358a3a87fe79b Mon Sep 17 00:00:00 2001 From: md_5 Date: Tue, 22 Aug 2023 20:51:34 +1000 Subject: [PATCH] SPIGOT-7465, MC-264979: Fresh installations print NoSuchFileException for server.properties --- .../server/dedicated/PropertyManager.patch | 27 ++++++++++++------- 1 file changed, 18 insertions(+), 9 deletions(-) diff --git a/nms-patches/net/minecraft/server/dedicated/PropertyManager.patch b/nms-patches/net/minecraft/server/dedicated/PropertyManager.patch index 0c844635f..3baccfc5e 100644 --- a/nms-patches/net/minecraft/server/dedicated/PropertyManager.patch +++ b/nms-patches/net/minecraft/server/dedicated/PropertyManager.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/server/dedicated/PropertyManager.java +++ b/net/minecraft/server/dedicated/PropertyManager.java -@@ -23,13 +23,28 @@ +@@ -23,17 +23,37 @@ import net.minecraft.core.IRegistryCustom; import org.slf4j.Logger; @@ -30,7 +30,16 @@ } public static Properties loadFromFile(Path path) { -@@ -97,6 +112,11 @@ + try { ++ // CraftBukkit start - SPIGOT-7465, MC-264979: Don't load if file doesn't exist ++ if (!path.toFile().exists()) { ++ return new Properties(); ++ } ++ // CraftBukkit end + Properties properties; + Properties properties1; + +@@ -97,6 +117,11 @@ public void store(Path path) { try { @@ -42,7 +51,7 @@ BufferedWriter bufferedwriter = Files.newBufferedWriter(path, StandardCharsets.UTF_8); try { -@@ -125,7 +145,7 @@ +@@ -125,7 +150,7 @@ private static Function wrapNumberDeserializer(Function function) { return (s) -> { try { @@ -51,7 +60,7 @@ } catch (NumberFormatException numberformatexception) { return null; } -@@ -144,7 +164,7 @@ +@@ -144,7 +169,7 @@ @Nullable private String getStringRaw(String s) { @@ -60,7 +69,7 @@ } @Nullable -@@ -160,6 +180,16 @@ +@@ -160,6 +185,16 @@ } protected V get(String s, Function function, Function function1, V v0) { @@ -77,7 +86,7 @@ String s1 = this.getStringRaw(s); V v1 = MoreObjects.firstNonNull(s1 != null ? function.apply(s1) : null, v0); -@@ -172,7 +202,7 @@ +@@ -172,7 +207,7 @@ V v1 = MoreObjects.firstNonNull(s1 != null ? function.apply(s1) : null, v0); this.properties.put(s, function1.apply(v1)); @@ -86,7 +95,7 @@ } protected V get(String s, Function function, UnaryOperator unaryoperator, Function function1, V v0) { -@@ -236,7 +266,7 @@ +@@ -236,7 +271,7 @@ return properties; } @@ -95,7 +104,7 @@ public class EditableProperty implements Supplier { -@@ -244,7 +274,7 @@ +@@ -244,7 +279,7 @@ private final V value; private final Function serializer; @@ -104,7 +113,7 @@ this.key = s; this.value = object; this.serializer = function; -@@ -258,7 +288,7 @@ +@@ -258,7 +293,7 @@ Properties properties = PropertyManager.this.cloneProperties(); properties.put(this.key, this.serializer.apply(v0));