use of org.spongepowered.api.data.DataContainer in project SpongeCommon by SpongePowered.
the class MemoryDataTest method testTest.
@Test
public void testTest() {
DataContainer containertest = DataContainer.createNew();
DataContainer containertest2 = DataContainer.createNew();
containertest.set(DataQuery.of("test1", "test2", "test3"), containertest2);
}
use of org.spongepowered.api.data.DataContainer in project SpongeCommon by SpongePowered.
the class ConfigurateDataViewTest method testNodeToData.
@Test
public void testNodeToData() {
ConfigurationNode node = SimpleConfigurationNode.root();
node.getNode("foo", "int").setValue(1);
node.getNode("foo", "double").setValue(10.0D);
node.getNode("foo", "long").setValue(Long.MAX_VALUE);
List<String> stringList = Lists.newArrayList();
for (int i = 0; i < 100; i++) {
stringList.add("String" + i);
}
node.getNode("foo", "stringList").setValue(stringList);
List<SimpleData> dataList = Lists.newArrayList();
for (int i = 0; i < 100; i++) {
dataList.add(new SimpleData(i, 10.0 + i, "String" + i, Collections.<String>emptyList()));
}
node.getNode("foo", "nested", "Data").setValue(dataList);
DataContainer manual = DataContainer.createNew();
manual.set(DataQuery.of("foo", "int"), 1).set(DataQuery.of("foo", "double"), 10.0D).set(DataQuery.of("foo", "long"), Long.MAX_VALUE).set(DataQuery.of("foo", "stringList"), stringList).set(DataQuery.of("foo", "nested", "Data"), dataList);
DataView container = ConfigurateTranslator.instance().translate(node);
assertTrue(manual.equals(container));
ConfigurationNode translated = ConfigurateTranslator.instance().translate(container);
// assertTrue(node.equals(translated)); // TODO Pending Configurate equals implementation
}
use of org.spongepowered.api.data.DataContainer in project SpongeCommon by SpongePowered.
the class FakeSerializable method toContainer.
@Override
public DataContainer toContainer() {
DataContainer container = DataContainer.createNew();
container.set(Queries.CONTENT_VERSION, getContentVersion());
container.set(DataQuery.of("foo"), this.foo);
container.set(DataQuery.of("myInt"), this.myInt);
container.set(DataQuery.of("theDouble"), this.theDouble);
container.set(DataQuery.of("nested", "compound"), this.nestedCompound);
container.set(DataQuery.of("MyBoolean"), this.aBoolean);
return container;
}
use of org.spongepowered.api.data.DataContainer in project SpongeAPI by SpongePowered.
the class ColorTest method testToContainer.
// Ignored by dualspiral, 7th January 2018
//
// Ignored as Sponge.getDataManager() will fail. It is expected that
// this will move to impl in API 8, thus not too concerned about fixing
// this as of yet.
@Test
@Ignore
public void testToContainer() {
final Color colorGray = Color.GRAY;
final Color.Builder builder = new Color.Builder();
final DataContainer container = colorGray.toContainer();
final Color deserialized = builder.build(container).get();
assertTrue(colorGray.equals(deserialized));
}
use of org.spongepowered.api.data.DataContainer in project SpongeAPI by SpongePowered.
the class Location method toContainer.
@Override
public DataContainer toContainer() {
final DataContainer container = DataContainer.createNew();
container.set(Queries.CONTENT_VERSION, getContentVersion());
if (getExtent() instanceof World) {
container.set(Queries.WORLD_NAME, ((World) getExtent()).getName());
container.set(Queries.WORLD_ID, getExtent().getUniqueId().toString());
} else if (getExtent() instanceof Chunk) {
container.set(Queries.CHUNK_X, ((Chunk) getExtent()).getPosition().getX()).set(Queries.CHUNK_Y, ((Chunk) getExtent()).getPosition().getY()).set(Queries.CHUNK_Z, ((Chunk) getExtent()).getPosition().getZ()).set(Queries.WORLD_NAME, ((Chunk) getExtent()).getWorld().getName()).set(Queries.WORLD_ID, ((Chunk) getExtent()).getWorld().getUniqueId().toString());
}
container.set(Queries.BLOCK_TYPE, this.getExtent().getBlockType(getBlockPosition()).getId()).set(Queries.POSITION_X, this.getX()).set(Queries.POSITION_Y, this.getY()).set(Queries.POSITION_Z, this.getZ());
return container;
}
Aggregations