@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();
 }
Ejemplo n.º 2
0
 @SuppressWarnings("unchecked")
 private static void translateMapOrList(ConfigurationNode node, DataView container) {
   Object value = node.getValue();
   if (value instanceof Map) {
     for (Map.Entry<Object, Object> entry : ((Map<Object, Object>) value).entrySet()) {
       container.set(of('.', entry.getKey().toString()), entry.getValue());
     }
   } else if (value != null) {
     container.set(of(node.getKey().toString()), value);
   }
 }
 @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();
 }
Ejemplo n.º 4
0
 private static void populateNode(ConfigurationNode node, DataView container) {
   checkNotNull(node, "node");
   checkNotNull(container, "container");
   node.setValue(container.getMap(of()).get());
 }