mirror of
https://github.com/PaperMC/Paper.git
synced 2024-11-27 13:06:02 +01:00
99 lines
3.3 KiB
Diff
99 lines
3.3 KiB
Diff
--- /home/matt/mc-dev-private//net/minecraft/server/PropertyManager.java 2015-02-26 22:40:23.035608135 +0000
|
|
+++ src/main/java/net/minecraft/server/PropertyManager.java 2015-02-26 22:40:23.039608134 +0000
|
|
@@ -8,10 +8,12 @@
|
|
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();
|
|
- private final Properties properties = new Properties();
|
|
+ public final Properties properties = new Properties(); // CraftBukkit - public
|
|
private final File file;
|
|
|
|
public PropertyManager(File file) {
|
|
@@ -42,6 +44,24 @@
|
|
|
|
}
|
|
|
|
+ // 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");
|
|
this.savePropertiesFile();
|
|
@@ -51,6 +71,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 +106,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
|
|
}
|
|
}
|
|
|