Search in sources :

Example 6 with Ref

use of pl.themolka.arcade.config.Ref in project Arcade2 by ShootGame.

the class ScoreGameParser method parseNode.

@Override
protected ParserResult<ScoreGame.Config> parseNode(Node node, String name, String value) throws ParserException {
    Set<Score.Config> scores = new LinkedHashSet<>();
    for (Node scoreNode : node.children("score")) {
        scores.add(this.scoreParser.parse(scoreNode).orFail());
    }
    if (ParserUtils.ensureNotEmpty(scores)) {
        throw this.fail(node, name, value, "No scores defined");
    }
    Set<ScoreBox.Config> scoreBoxes = new LinkedHashSet<>();
    for (Node scoreBoxNode : node.children("score-box", "scorebox")) {
        scoreBoxes.add(this.scoreBoxParser.parse(scoreBoxNode).orFail());
    }
    return ParserResult.fine(node, name, value, new ScoreGame.Config() {

        public Ref<Set<Score.Config>> scores() {
            return Ref.ofProvided(scores);
        }

        public Ref<Set<ScoreBox.Config>> scoreBoxes() {
            return Ref.ofProvided(scoreBoxes);
        }
    });
}
Also used : LinkedHashSet(java.util.LinkedHashSet) Ref(pl.themolka.arcade.config.Ref) Node(pl.themolka.arcade.dom.Node)

Example 7 with Ref

use of pl.themolka.arcade.config.Ref in project Arcade2 by ShootGame.

the class AutoRespawnGameParser method parseNode.

@Override
protected ParserResult<AutoRespawnGame.Config> parseNode(Node node, String name, String value) throws ParserException {
    Ref<Filter.Config<?>> filter = this.filterParser.parse(node.property("filter")).orDefault(Ref.empty());
    Time cooldown = this.cooldownParser.parse(node.property("cooldown", "after")).orDefault(PlayerDeathEvent.DEFAULT_AUTO_RESPAWN_COOLDOWN);
    return ParserResult.fine(node, name, value, new AutoRespawnGame.Config() {

        public Ref<Filter.Config<?>> filter() {
            return filter;
        }

        public Time cooldown() {
            return cooldown;
        }
    });
}
Also used : Ref(pl.themolka.arcade.config.Ref) Filter(pl.themolka.arcade.filter.Filter) Time(pl.themolka.arcade.time.Time)

Aggregations

Ref (pl.themolka.arcade.config.Ref)7 Filter (pl.themolka.arcade.filter.Filter)3 Node (pl.themolka.arcade.dom.Node)2 Time (pl.themolka.arcade.time.Time)2 HashSet (java.util.HashSet)1 LinkedHashSet (java.util.LinkedHashSet)1 Sound (org.bukkit.Sound)1 Kit (pl.themolka.arcade.kit.Kit)1 AbstractRegion (pl.themolka.arcade.region.AbstractRegion)1 SpawnApply (pl.themolka.arcade.spawn.SpawnApply)1 Team (pl.themolka.arcade.team.Team)1 Percentage (pl.themolka.arcade.util.Percentage)1