use of org.spongepowered.api.data.persistence.DataContainer in project SpongeCommon by SpongePowered.
the class ConfigurateDataViewTest method testEmptyNodeToData.
@Test
void testEmptyNodeToData() {
final ConfigurationNode source = BasicConfigurationNode.root();
final DataContainer container = ConfigurateTranslator.instance().translate(source);
assertTrue(container.isEmpty());
}
use of org.spongepowered.api.data.persistence.DataContainer in project SpongeCommon by SpongePowered.
the class ConfigurateDataViewTest method testRespawnLocationData.
@Test
void testRespawnLocationData() throws IOException {
final Map<ResourceKey, RespawnLocation> m = new HashMap<>();
for (int i = 0; i < 5; i++) {
final ResourceKey key = ResourceKey.sponge("overworld" + i);
final RespawnLocation loc = RespawnLocation.builder().world(key).position(Vector3d.ZERO).build();
m.put(key, loc);
}
final DataContainer container = DataContainer.createNew().set(DataQuery.of("respawn_locations"), m);
final ConfigurationNode node = ConfigurateTranslator.instance().translate(container);
final DataContainer dc = ConfigurateTranslator.instance().translate(node);
assertEquals(container, dc);
}
use of org.spongepowered.api.data.persistence.DataContainer in project SpongeCommon by SpongePowered.
the class SimpleData method toContainer.
@Override
public DataContainer toContainer() {
final DataContainer container = DataContainer.createNew();
container.set(DataQuery.of("myInt"), this.testInt);
container.set(DataQuery.of("myDouble"), this.testDouble);
container.set(DataQuery.of("myString"), this.testString);
container.set(DataQuery.of("myStringList"), Arrays.asList(this.testList));
return container;
}
Aggregations