Search in sources :

Example 1 with LanternScoreCriterion

use of org.lanternpowered.server.advancement.criteria.LanternScoreCriterion 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()][]));
}
Also used : AdvancementCriterion(org.spongepowered.api.advancement.criteria.AdvancementCriterion) ArrayList(java.util.ArrayList) LanternScoreCriterion(org.lanternpowered.server.advancement.criteria.LanternScoreCriterion) AndCriterion(org.spongepowered.api.advancement.criteria.AndCriterion) Tuple(org.spongepowered.api.util.Tuple)

Aggregations

ArrayList (java.util.ArrayList)1 LanternScoreCriterion (org.lanternpowered.server.advancement.criteria.LanternScoreCriterion)1 AdvancementCriterion (org.spongepowered.api.advancement.criteria.AdvancementCriterion)1 AndCriterion (org.spongepowered.api.advancement.criteria.AndCriterion)1 Tuple (org.spongepowered.api.util.Tuple)1