use of org.spongepowered.test.myhomes.data.home.HomeData in project SpongeCommon by SpongePowered.
the class HomeDataBuilder method buildContent.
@Override
protected Optional<HomeData> buildContent(DataView container) throws InvalidDataException {
if (!container.contains(MyHomes.HOMES))
return Optional.empty();
HomeData data = new HomeDataImpl();
container.getView(MyHomes.HOMES.getQuery()).get().getKeys(false).forEach(name -> data.homes().put(name.toString(), container.getSerializable(name, Home.class).orElseThrow(InvalidDataException::new)));
container.getSerializable(MyHomes.DEFAULT_HOME.getQuery(), Home.class).ifPresent(home -> {
data.set(MyHomes.DEFAULT_HOME, home);
});
return Optional.of(data);
}
use of org.spongepowered.test.myhomes.data.home.HomeData in project SpongeCommon by SpongePowered.
the class HomeDataImpl method fill.
// Only required on mutable implementations
@Override
public Optional<HomeData> fill(DataHolder dataHolder, MergeFunction overlap) {
HomeData merged = overlap.merge(this, dataHolder.get(HomeData.class).orElse(null));
this.defaultHome = merged.defaultHome().get();
this.homes = merged.homes().get();
return Optional.of(this);
}
Aggregations