Search in sources :

Example 26 with FireworkEffect

use of org.bukkit.FireworkEffect in project Arcade2 by ShootGame.

the class FireworkEffectParser method parseTree.

@Override
protected ParserResult<FireworkEffect> parseTree(Node node, String name) throws ParserException {
    FireworkEffect.Builder builder = FireworkEffect.builder().with(this.typeParser.parse(node.property("type", "of")).orDefault(FireworkEffect.Type.BALL)).flicker(this.flickerParser.parse(node.property("flicker")).orDefault(false)).trail(this.trailParser.parse(node.property("trail")).orDefault(false));
    boolean colorsDefined = false;
    for (Node color : node.children("color")) {
        builder.withColor(this.colorParser.parse(color).orFail());
        colorsDefined = true;
    }
    if (!colorsDefined) {
        throw this.fail(node, name, null, "No colors defined");
    }
    for (Node fadeColor : node.children("fade-color", "fadecolor", "fade")) {
        builder.withFade(this.fadeColorParser.parse(fadeColor).orFail());
    }
    return ParserResult.fine(node, name, builder.build());
}
Also used : Node(pl.themolka.arcade.dom.Node) FireworkEffect(org.bukkit.FireworkEffect)

Aggregations

FireworkEffect (org.bukkit.FireworkEffect)26 Color (org.bukkit.Color)14 FireworkMeta (org.bukkit.inventory.meta.FireworkMeta)11 FireworkEffectMeta (org.bukkit.inventory.meta.FireworkEffectMeta)10 Firework (org.bukkit.entity.Firework)5 DyeColor (org.bukkit.DyeColor)4 Type (org.bukkit.FireworkEffect.Type)4 ItemStack (org.bukkit.inventory.ItemStack)4 ItemMeta (org.bukkit.inventory.meta.ItemMeta)4 Random (java.util.Random)3 ChatColor (org.bukkit.ChatColor)3 Enchantment (org.bukkit.enchantments.Enchantment)3 PotionEffect (org.bukkit.potion.PotionEffect)3 PotionEffectType (org.bukkit.potion.PotionEffectType)3 Vector (org.bukkit.util.Vector)3 ColorTag (com.denizenscript.denizen.objects.ColorTag)2 ElementTag (com.denizenscript.denizencore.objects.core.ElementTag)2 ListTag (com.denizenscript.denizencore.objects.core.ListTag)2 MapTag (com.denizenscript.denizencore.objects.core.MapTag)2 MetaItemStack (com.earth2me.essentials.MetaItemStack)2