@Override public Optional<ScreamingData> build(DataView container) throws InvalidDataException { if (container.contains(Keys.IS_SCREAMING.getQuery())) { Optional<Boolean> isScreaming = container.getBoolean(Keys.IS_SCREAMING.getQuery()); if (isScreaming.isPresent()) { return Optional.of(new SpongeScreamingData(isScreaming.get())); } } return Optional.empty(); }
@Override protected Optional<FireworkEffect> buildContent(DataView container) throws InvalidDataException { if (container.contains( DataQueries.FIREWORK_SHAPE, DataQueries.FIREWORK_COLORS, DataQueries.FIREWORK_FADE_COLORS, DataQueries.FIREWORK_FLICKERS, DataQueries.FIREWORK_TRAILS)) { final String fireworkShapeId = DataUtil.getData(container, DataQueries.FIREWORK_SHAPE, String.class); final Optional<FireworkShape> shapeOptional = Sponge.getRegistry().getType(FireworkShape.class, fireworkShapeId); if (!shapeOptional.isPresent()) { throw new InvalidDataException( "Could not find the FireworkShape for the provided id: " + fireworkShapeId); } final FireworkShape shape = shapeOptional.get(); final boolean trails = DataUtil.getData(container, DataQueries.FIREWORK_TRAILS, Boolean.class); final boolean flickers = DataUtil.getData(container, DataQueries.FIREWORK_FLICKERS, Boolean.class); final List<Color> colors = container.getSerializableList(DataQueries.FIREWORK_COLORS, Color.class).get(); final List<Color> fadeColors = container.getSerializableList(DataQueries.FIREWORK_FADE_COLORS, Color.class).get(); return Optional.of( FireworkEffect.builder() .colors(colors) .flicker(flickers) .fades(fadeColors) .trail(trails) .shape(shape) .build()); } return Optional.empty(); }