mirror of
https://github.com/PaperMC/Paper.git
synced 2025-01-20 23:46:57 +01:00
SPIGOT-7465, MC-264979: Fresh installations print NoSuchFileException for server.properties
By: md_5 <git@md-5.net>
This commit is contained in:
parent
41756b5eb0
commit
764b9df72a
1 changed files with 18 additions and 9 deletions
|
@ -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 <V extends Number> Function<String, V> wrapNumberDeserializer(Function<String, V> 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> V get(String s, Function<String, V> function, Function<V, String> 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> V get(String s, Function<String, V> function, UnaryOperator<V> unaryoperator, Function<V, String> function1, V v0) {
|
||||
@@ -236,7 +266,7 @@
|
||||
@@ -236,7 +271,7 @@
|
||||
return properties;
|
||||
}
|
||||
|
||||
|
@ -95,7 +104,7 @@
|
|||
|
||||
public class EditableProperty<V> implements Supplier<V> {
|
||||
|
||||
@@ -244,7 +274,7 @@
|
||||
@@ -244,7 +279,7 @@
|
||||
private final V value;
|
||||
private final Function<V, String> 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));
|
||||
|
|
Loading…
Reference in a new issue