Update to ConfigMe 1.2.0

This commit is contained in:
ljacqu
2020-09-07 21:33:00 +02:00
parent e92721e597
commit ac5868787a
7 changed files with 41 additions and 19 deletions
@@ -2,6 +2,7 @@ package fr.xephi.authme.message.updater;
import ch.jalu.configme.configurationdata.ConfigurationDataImpl;
import ch.jalu.configme.properties.Property;
import ch.jalu.configme.properties.convertresult.PropertyValue;
import ch.jalu.configme.resource.PropertyReader;
import fr.xephi.authme.message.MessageKey;
@@ -23,9 +24,18 @@ public class MessageKeyConfigurationData extends ConfigurationDataImpl {
@Override
public void initializeValues(PropertyReader reader) {
getAllMessageProperties().stream()
.filter(prop -> prop.isPresent(reader))
.forEach(prop -> setValue(prop, prop.determineValue(reader)));
for (Property<String> property : getAllMessageProperties()) {
PropertyValue<String> value = property.determineValue(reader);
if (value.isValidInResource()) {
setValue(property, value.getValue());
}
}
}
@Override
public <T> T getValue(Property<T> property) {
// Override to silently return null if property is unknown
return (T) getValues().get(property.getPath());
}
@SuppressWarnings("unchecked")
@@ -59,6 +59,11 @@ final class MessageMigraterPropertyReader implements PropertyReader {
throw new UnsupportedOperationException();
}
@Override
public Set<String> getChildKeys(String s) {
throw new UnsupportedOperationException();
}
@Override
public Object getObject(String path) {
if (path.isEmpty()) {
@@ -4,6 +4,7 @@ import ch.jalu.configme.configurationdata.ConfigurationData;
import ch.jalu.configme.configurationdata.PropertyListBuilder;
import ch.jalu.configme.properties.Property;
import ch.jalu.configme.properties.StringProperty;
import ch.jalu.configme.properties.convertresult.ConvertErrorRecorder;
import ch.jalu.configme.resource.PropertyReader;
import ch.jalu.configme.resource.PropertyResource;
import com.google.common.collect.ImmutableMap;
@@ -177,7 +178,7 @@ public class MessageUpdater {
}
@Override
protected String getFromReader(PropertyReader reader) {
protected String getFromReader(PropertyReader reader, ConvertErrorRecorder errorRecorder) {
return reader.getString(getPath());
}
}