Refactor ServerUtilsConfig#set to delete existing objects at path
This commit is contained in:
parent
90b248f321
commit
d2928b4a04
5 changed files with 67 additions and 21 deletions
|
|
@ -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);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue