mirror of
https://github.com/PaperMC/Paper.git
synced 2025-01-06 00:07:56 +01:00
Configuration tweaks - enforce default + parent file nullcheck
By: Dinnerbone <dinnerbone@dinnerbone.com>
This commit is contained in:
parent
0373e53844
commit
7f8be3e195
@ -93,7 +93,10 @@ public class Configuration extends ConfigurationNode {
|
||||
public boolean save() {
|
||||
FileOutputStream stream = null;
|
||||
|
||||
file.getParentFile().mkdirs();
|
||||
File parent = file.getParentFile();
|
||||
if (parent != null) {
|
||||
parent.mkdirs();
|
||||
}
|
||||
|
||||
try {
|
||||
stream = new FileOutputStream(file);
|
||||
|
@ -126,6 +126,7 @@ public class ConfigurationNode {
|
||||
public String getString(String path, String def) {
|
||||
String o = getString(path);
|
||||
if (o == null) {
|
||||
setProperty(path, def);
|
||||
return def;
|
||||
}
|
||||
return o;
|
||||
@ -144,6 +145,7 @@ public class ConfigurationNode {
|
||||
public int getInt(String path, int def) {
|
||||
Integer o = castInt(getProperty(path));
|
||||
if (o == null) {
|
||||
setProperty(path, def);
|
||||
return def;
|
||||
} else {
|
||||
return o;
|
||||
@ -163,6 +165,7 @@ public class ConfigurationNode {
|
||||
public double getDouble(String path, double def) {
|
||||
Double o = castDouble(getProperty(path));
|
||||
if (o == null) {
|
||||
setProperty(path, def);
|
||||
return def;
|
||||
} else {
|
||||
return o;
|
||||
@ -181,6 +184,7 @@ public class ConfigurationNode {
|
||||
public boolean getBoolean(String path, boolean def) {
|
||||
Boolean o = castBoolean(getProperty(path));
|
||||
if (o == null) {
|
||||
setProperty(path, def);
|
||||
return def;
|
||||
} else {
|
||||
return o;
|
||||
|
Loading…
Reference in New Issue
Block a user