use of org.spongepowered.api.advancement.criteria.AndCriterion in project SpongeCommon by SpongePowered.
the class MixinAdvancementProgress method processProgressMap.
private void processProgressMap(AdvancementCriterion criterion, Map<AdvancementCriterion, ICriterionProgress> progressMap) {
if (criterion instanceof OperatorCriterion) {
((OperatorCriterion) criterion).getCriteria().forEach(child -> processProgressMap(child, progressMap));
if (criterion instanceof AndCriterion) {
progressMap.put(criterion, new SpongeAndCriterionProgress(this, (SpongeAndCriterion) criterion));
} else if (criterion instanceof OrCriterion) {
progressMap.put(criterion, new SpongeOrCriterionProgress(this, (SpongeOrCriterion) criterion));
}
} else if (criterion instanceof SpongeScoreCriterion) {
final SpongeScoreCriterion scoreCriterion = (SpongeScoreCriterion) criterion;
for (AdvancementCriterion internalCriterion : scoreCriterion.internalCriteria) {
final IMixinCriterionProgress progress = (IMixinCriterionProgress) this.criteria.get(internalCriterion.getName());
progress.setCriterion(internalCriterion);
progressMap.put(internalCriterion, (ICriterionProgress) progress);
}
progressMap.put(scoreCriterion, new SpongeScoreCriterionProgress(this, scoreCriterion));
} else if (criterion != SpongeEmptyCriterion.INSTANCE) {
final IMixinCriterionProgress progress = (IMixinCriterionProgress) this.criteria.get(criterion.getName());
progress.setCriterion(criterion);
progressMap.put(criterion, (ICriterionProgress) progress);
}
}
use of org.spongepowered.api.advancement.criteria.AndCriterion in project LanternServer by LanternPowered.
the class LanternPlayerAdvancements method createCriteria.
static Tuple<List<AdvancementCriterion>, String[][]> createCriteria(AdvancementCriterion criterion) {
final List<AdvancementCriterion> criteria = new ArrayList<>();
final List<String[]> names = new ArrayList<>();
if (criterion instanceof AndCriterion) {
for (AdvancementCriterion child : ((AndCriterion) criterion).getCriteria()) {
if (child instanceof LanternScoreCriterion) {
for (String id : ((LanternScoreCriterion) child).getIds()) {
names.add(new String[] { id });
}
} else {
names.add(new String[] { child.getName() });
}
criteria.add(child);
}
} else {
if (criterion instanceof LanternScoreCriterion) {
for (String id : ((LanternScoreCriterion) criterion).getIds()) {
names.add(new String[] { id });
}
} else {
names.add(new String[] { criterion.getName() });
}
criteria.add(criterion);
}
return new Tuple<>(criteria, names.toArray(new String[names.size()][]));
}
Aggregations