Simplified ConfigNode#moveChild

This commit is contained in:
Rsl1122 2019-01-06 13:43:02 +02:00
parent ed67e0763d
commit d0df3e3fcf
2 changed files with 5 additions and 5 deletions

View File

@ -160,14 +160,10 @@ public class ConfigNode {
}
ConfigNode moveFrom = found.get();
ConfigNode moveTo = addNode(newPath);
ConfigNode oldParent = moveFrom.parent;
ConfigNode newParent = moveTo.parent;
oldParent.removeChild(moveFrom);
moveTo.copyAll(moveFrom);
newParent.addChild(moveTo);
removeNode(oldPath);
return getNode(newPath).isPresent();
}

View File

@ -17,6 +17,7 @@
package com.djrapitops.plan.system.settings.paths.key;
import com.djrapitops.plan.system.settings.config.ConfigNode;
import com.djrapitops.plugin.utilities.Verify;
import java.util.concurrent.TimeUnit;
import java.util.function.Predicate;
@ -46,6 +47,9 @@ public class TimeSetting extends Setting<Long> {
}
String unitName = node.getString(path + ".Unit");
try {
Verify.nullCheck(unitName, () -> new IllegalStateException(
"Config value for " + path + ".Unit has a bad value: 'null'"
));
TimeUnit unit = TimeUnit.valueOf(unitName.toUpperCase());
return unit.toMillis(duration);
} catch (IllegalArgumentException e) {