use of org.spongepowered.common.advancement.criterion.SpongeEmptyCriterion in project SpongeCommon by SpongePowered.
the class AdvancementProgressMixin method impl$processProgressMap.
private void impl$processProgressMap(AdvancementCriterion criterion, Map<String, ImplementationBackedCriterionProgress> progressMap) {
if (criterion instanceof OperatorCriterion) {
((OperatorCriterion) criterion).criteria().forEach(child -> this.impl$processProgressMap(child, progressMap));
if (criterion instanceof AndCriterion) {
progressMap.put(criterion.name(), new SpongeAndCriterionProgress((org.spongepowered.api.advancement.AdvancementProgress) this, (SpongeAndCriterion) criterion));
} else if (criterion instanceof OrCriterion) {
progressMap.put(criterion.name(), new SpongeOrCriterionProgress((org.spongepowered.api.advancement.AdvancementProgress) this, (SpongeOrCriterion) criterion));
}
} else if (criterion instanceof SpongeScoreCriterion) {
final SpongeScoreCriterion scoreCriterion = (SpongeScoreCriterion) criterion;
for (final AdvancementCriterion internalCriterion : scoreCriterion.internalCriteria) {
final CriterionProgressBridge progress = (CriterionProgressBridge) this.criteria.get(internalCriterion.name());
progress.bridge$setCriterion(internalCriterion);
progress.bridge$setAdvancementProgress((org.spongepowered.api.advancement.AdvancementProgress) this);
progressMap.put(internalCriterion.name(), (ImplementationBackedCriterionProgress) progress);
}
progressMap.put(scoreCriterion.name(), new SpongeScoreCriterionProgress((org.spongepowered.api.advancement.AdvancementProgress) this, scoreCriterion));
} else if (!(criterion instanceof SpongeEmptyCriterion)) {
final CriterionProgressBridge progress = (CriterionProgressBridge) this.criteria.get(criterion.name());
progress.bridge$setCriterion(criterion);
progress.bridge$setAdvancementProgress((org.spongepowered.api.advancement.AdvancementProgress) this);
progressMap.put(criterion.name(), (ImplementationBackedCriterionProgress) progress);
}
}
use of org.spongepowered.common.advancement.criterion.SpongeEmptyCriterion in project SpongeCommon by SpongePowered.
the class SpongeCriterionUtil method build.
public static AdvancementCriterion build(final Class<? extends OperatorCriterion> type, final Function<Set<AdvancementCriterion>, AdvancementCriterion> function, final AdvancementCriterion criterion, final Iterable<AdvancementCriterion> criteria) {
checkNotNull(criteria, "criteria");
final List<AdvancementCriterion> builder = new ArrayList<>();
SpongeCriterionUtil.build(type, criterion, builder);
for (final AdvancementCriterion criterion1 : criteria) {
SpongeCriterionUtil.build(type, criterion1, builder);
}
return builder.isEmpty() ? new SpongeEmptyCriterion() : builder.size() == 1 ? builder.get(0) : function.apply(ImmutableSet.copyOf(builder));
}
Aggregations