Refactor ServerUtilsConfig#set to delete existing objects at path

This commit is contained in:
Frank van der Heijden 2021-08-04 16:25:30 +02:00
parent 90b248f321
commit d2928b4a04
No known key found for this signature in database
GPG key ID: B808721C2DD5B5B8
5 changed files with 67 additions and 21 deletions

View file

@ -33,7 +33,13 @@ public class BungeeYamlConfig implements ServerUtilsConfig {
@Override
public Object get(String path) {
Object obj = config.get(path);
Object obj;
try {
obj = config.get(path);
} catch (ClassCastException ignored) {
return null;
}
if (obj instanceof Configuration) {
return new BungeeYamlConfig((Configuration) obj);
}
@ -61,10 +67,15 @@ public class BungeeYamlConfig implements ServerUtilsConfig {
}
@Override
public void set(String path, Object value) {
public void setUnsafe(String path, Object value) {
config.set(path, value);
}
@Override
public void remove(String path) {
config.set(path, null);
}
@Override
public String getString(String path) {
return config.getString(path);