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
|
--- ../work/decompile-8eb82bde//net/minecraft/server/PropertyManager.java 2014-11-28 17:43:43.345707429 +0000
+++ src/main/java/net/minecraft/server/PropertyManager.java 2014-11-28 17:38:20.000000000 +0000
@@ -8,6 +8,8 @@
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
+import joptsimple.OptionSet; // CraftBukkit
+
public class PropertyManager {
private static final Logger a = LogManager.getLogger();
@@ -39,8 +41,25 @@
PropertyManager.a.warn(file + " does not exist");
this.a();
}
+ }
+
+ // CraftBukkit start
+ private OptionSet options = null;
+
+ public PropertyManager(final OptionSet options) {
+ this((File) options.valueOf("config"));
+
+ this.options = options;
+ }
+
+ private <T> T getOverride(String name, T value) {
+ if ((this.options != null) && (this.options.has(name))) {
+ return (T) this.options.valueOf(name);
+ }
+ return value;
}
+ // CraftBukkit end
public void a() {
PropertyManager.a.info("Generating new properties file");
@@ -51,6 +70,12 @@
FileOutputStream fileoutputstream = null;
try {
+ // CraftBukkit start - Don't attempt writing to file if it's read only
+ if (this.file.exists() && !this.file.canWrite()) {
+ return;
+ }
+ // CraftBukkit end
+
fileoutputstream = new FileOutputStream(this.file);
this.properties.store(fileoutputstream, "Minecraft server properties");
} catch (Exception exception) {
@@ -80,36 +105,36 @@
this.savePropertiesFile();
}
- return this.properties.getProperty(s, s1);
+ return getOverride(s, this.properties.getProperty(s, s1)); // CraftBukkit
}
public int getInt(String s, int i) {
try {
- return Integer.parseInt(this.getString(s, "" + i));
+ return getOverride(s, Integer.parseInt(this.getString(s, "" + i))); // CraftBukkit
} catch (Exception exception) {
this.properties.setProperty(s, "" + i);
this.savePropertiesFile();
- return i;
+ return getOverride(s, i); // CraftBukkit
}
}
public long getLong(String s, long i) {
try {
- return Long.parseLong(this.getString(s, "" + i));
+ return getOverride(s, Long.parseLong(this.getString(s, "" + i))); // CraftBukkit
} catch (Exception exception) {
this.properties.setProperty(s, "" + i);
this.savePropertiesFile();
- return i;
+ return getOverride(s ,i); // CraftBukkit
}
}
public boolean getBoolean(String s, boolean flag) {
try {
- return Boolean.parseBoolean(this.getString(s, "" + flag));
+ return getOverride(s, Boolean.parseBoolean(this.getString(s, "" + flag))); // CraftBukkit
} catch (Exception exception) {
this.properties.setProperty(s, "" + flag);
this.savePropertiesFile();
- return flag;
+ return getOverride(s, flag); // CraftBukkit
}
}
|