use of ninja.leaping.configurate.SimpleConfigurationNode in project AtherysCore by Atherys-Horizons.
the class PluginConfig method save.
/**
* Save the contents of the object mapper to the config file. This will override config values already-present in the file.
*/
public void save() {
try {
SimpleConfigurationNode out = SimpleConfigurationNode.root();
this.configMapper.serialize(out);
this.loader.save(out);
} catch (ObjectMappingException | IOException e) {
e.printStackTrace();
}
}
use of ninja.leaping.configurate.SimpleConfigurationNode in project SpongeCommon by SpongePowered.
the class ConfigurateTranslator method translate.
@Override
public ConfigurationNode translate(DataView view) throws InvalidDataException {
final SimpleConfigurationNode node = SimpleConfigurationNode.root();
populateNode(node, view);
return node;
}
use of ninja.leaping.configurate.SimpleConfigurationNode in project LanternServer by LanternPowered.
the class MultimapTypeSerializer method serialize.
@Override
public void serialize(TypeToken<?> type, Multimap obj, ConfigurationNode node) throws ObjectMappingException {
TypeToken<?> key = type.resolveType(Multimap.class.getTypeParameters()[0]);
TypeToken<?> value = type.resolveType(Multimap.class.getTypeParameters()[1]);
TypeSerializer keySerial = node.getOptions().getSerializers().get(key);
TypeSerializer valueSerial = node.getOptions().getSerializers().get(value);
if (keySerial == null) {
throw new ObjectMappingException("No type serializer available for type " + key);
}
if (valueSerial == null) {
throw new ObjectMappingException("No type serializer available for type " + value);
}
node.setValue(ImmutableMap.of());
for (Object k : obj.keySet()) {
for (Object v : obj.get(k)) {
SimpleConfigurationNode keyNode = SimpleConfigurationNode.root();
keySerial.serialize(key, k, keyNode);
valueSerial.serialize(value, v, node.getNode(keyNode.getValue()));
}
}
}
Aggregations