Search in sources :

Example 1 with CircleEffect

use of com.ebicep.warlords.effects.circle.CircleEffect in project Warlords by ebicep.

the class HammerOfLight method onActivate.

@Override
public boolean onActivate(WarlordsPlayer wp, Player player) {
    if (player.getTargetBlock((Set<Material>) null, 25).getType() == Material.AIR)
        return false;
    Location location = player.getTargetBlock((Set<Material>) null, 25).getLocation().add(1, 0, 1).clone();
    ArmorStand hammer = spawnHammer(location, wp);
    wp.subtractEnergy(energyCost);
    wp.getSpec().getOrange().setCurrentCooldown((float) (cooldown * wp.getCooldownModifier()));
    HammerOfLight tempHammerOfLight = new HammerOfLight();
    wp.getCooldownManager().addRegularCooldown(name, "HAMMER", HammerOfLight.class, tempHammerOfLight, wp, CooldownTypes.ABILITY, cooldownManager -> {
    }, duration * 20);
    Utils.playGlobalSound(player.getLocation(), "paladin.hammeroflight.impact", 2, 0.85f);
    CircleEffect circleEffect = new CircleEffect(wp.getGame(), wp.getTeam(), location, radius, new CircumferenceEffect(ParticleEffect.VILLAGER_HAPPY, ParticleEffect.REDSTONE), new LineEffect(location.clone().add(0, 2.3, 0), ParticleEffect.SPELL));
    BukkitTask task = wp.getGame().registerGameTask(circleEffect::playEffects, 0, 1);
    location.add(0, 1, 0);
    final int[] timeLeftHammer = { duration };
    new GameRunnable(wp.getGame()) {

        int counter = 0;

        @Override
        public void run() {
            if (counter % 20 == 0) {
                timeLeftHammer[0]--;
                for (WarlordsPlayer warlordsPlayer : PlayerFilter.entitiesAround(location, radius, radius, radius).isAlive()) {
                    if (wp.isTeammateAlive(warlordsPlayer)) {
                        warlordsPlayer.addHealingInstance(wp, name, minDamageHeal, maxDamageHeal, critChance, critMultiplier, false, false);
                    } else {
                        warlordsPlayer.addDamageInstance(wp, name, 178, 244, critChance, critMultiplier, false);
                    }
                }
            }
            if (timeLeftHammer[0] <= 0) {
                hammer.remove();
                this.cancel();
                task.cancel();
            }
            counter++;
        }
    }.runTaskTimer(0, 0);
    new GameRunnable(wp.getGame()) {

        boolean wasSneaking = false;

        @Override
        public void run() {
            if (wp.isAlive() && wp.isSneaking() && !wasSneaking) {
                tempHammerOfLight.setCrownOfLight(true);
                new CooldownFilter<>(wp, RegularCooldown.class).filterCooldownObject(tempHammerOfLight).findAny().ifPresent(regularCooldown -> {
                    regularCooldown.setNameAbbreviation("CROWN");
                });
                Utils.playGlobalSound(wp.getLocation(), "warrior.revenant.orbsoflife", 2, 0.15f);
                Utils.playGlobalSound(wp.getLocation(), "mage.firebreath.activation", 2, 0.25f);
                BukkitTask particles = new GameRunnable(wp.getGame()) {

                    @Override
                    public void run() {
                        double angle = 0;
                        for (int i = 0; i < 9; i++) {
                            double x = .4 * Math.cos(angle);
                            double z = .4 * Math.sin(angle);
                            angle += 40;
                            Vector v = new Vector(x, 2, z);
                            Location loc = wp.getLocation().clone().add(v);
                            ParticleEffect.SPELL.display(0, 0, 0, 0f, 1, loc, 500);
                        }
                        CircleEffect circle = new CircleEffect(wp.getGame(), wp.getTeam(), wp.getLocation().add(0, 0.75f, 0), radius / 2f);
                        circle.addEffect(new CircumferenceEffect(ParticleEffect.SPELL).particlesPerCircumference(0.5f));
                        circle.playEffects();
                    }
                }.runTaskTimer(0, 6);
                new GameRunnable(wp.getGame()) {

                    int timeLeft = timeLeftHammer[0];

                    @Override
                    public void run() {
                        PlayerFilter.entitiesAround(wp.getLocation(), radius, radius, radius).aliveTeammatesOf(wp).forEach(teammate -> teammate.addHealingInstance(wp, "Crown of Light", minDamageHeal * 1.5f, maxDamageHeal * 1.5f, critChance, critMultiplier, false, false));
                        timeLeft--;
                        if (timeLeft <= 0 || wp.isDead()) {
                            this.cancel();
                            particles.cancel();
                        }
                    }
                }.runTaskTimer(2, 20);
                this.cancel();
                timeLeftHammer[0] = 0;
            }
            wasSneaking = wp.isSneaking();
            if (wp.isDead() || timeLeftHammer[0] <= 0) {
                this.cancel();
            }
        }
    }.runTaskTimer(0, 0);
    return true;
}
Also used : Utils(com.ebicep.warlords.util.warlords.Utils) Player(org.bukkit.entity.Player) FixedMetadataValue(org.bukkit.metadata.FixedMetadataValue) ArrayList(java.util.ArrayList) Location(org.bukkit.Location) CircleEffect(com.ebicep.warlords.effects.circle.CircleEffect) AbstractAbility(com.ebicep.warlords.classes.AbstractAbility) ParticleEffect(com.ebicep.warlords.effects.ParticleEffect) Material(org.bukkit.Material) GameRunnable(com.ebicep.warlords.util.warlords.GameRunnable) Entity(org.bukkit.entity.Entity) CircumferenceEffect(com.ebicep.warlords.effects.circle.CircumferenceEffect) Set(java.util.Set) Warlords(com.ebicep.warlords.Warlords) CooldownTypes(com.ebicep.warlords.player.cooldowns.CooldownTypes) LineEffect(com.ebicep.warlords.effects.circle.LineEffect) EntityType(org.bukkit.entity.EntityType) PlayerFilter(com.ebicep.warlords.util.warlords.PlayerFilter) ItemStack(org.bukkit.inventory.ItemStack) Vector(org.bukkit.util.Vector) List(java.util.List) RegularCooldown(com.ebicep.warlords.player.cooldowns.cooldowns.RegularCooldown) EulerAngle(org.bukkit.util.EulerAngle) WarlordsPlayer(com.ebicep.warlords.player.WarlordsPlayer) ArmorStand(org.bukkit.entity.ArmorStand) BukkitTask(org.bukkit.scheduler.BukkitTask) CooldownFilter(com.ebicep.warlords.player.cooldowns.CooldownFilter) Protector(com.ebicep.warlords.classes.paladin.specs.Protector) CooldownFilter(com.ebicep.warlords.player.cooldowns.CooldownFilter) Set(java.util.Set) LineEffect(com.ebicep.warlords.effects.circle.LineEffect) WarlordsPlayer(com.ebicep.warlords.player.WarlordsPlayer) BukkitTask(org.bukkit.scheduler.BukkitTask) Material(org.bukkit.Material) CircumferenceEffect(com.ebicep.warlords.effects.circle.CircumferenceEffect) ArmorStand(org.bukkit.entity.ArmorStand) GameRunnable(com.ebicep.warlords.util.warlords.GameRunnable) CircleEffect(com.ebicep.warlords.effects.circle.CircleEffect) Vector(org.bukkit.util.Vector) Location(org.bukkit.Location)

Example 2 with CircleEffect

use of com.ebicep.warlords.effects.circle.CircleEffect in project Warlords by ebicep.

the class PrismGuard method onActivate.

@Override
public boolean onActivate(@Nonnull WarlordsPlayer wp, @Nonnull Player player) {
    wp.subtractEnergy(energyCost);
    PrismGuard tempWideGuard = new PrismGuard();
    Set<WarlordsPlayer> isInsideBubble = new HashSet<>();
    wp.getCooldownManager().addCooldown(new RegularCooldown<PrismGuard>("Prism Guard", "GUARD", PrismGuard.class, tempWideGuard, wp, CooldownTypes.ABILITY, cooldownManager -> {
    }, duration * 20) {

        @Override
        public float modifyDamageAfterInterveneFromSelf(WarlordsDamageHealingEvent event, float currentDamageValue) {
            String ability = event.getAbility();
            if (ability.equals("Fireball") || ability.equals("Frostbolt") || ability.equals("Water Bolt") || ability.equals("Lightning Bolt") || ability.equals("Flame Burst") || ability.equals("Fallen Souls")) {
                if (isInsideBubble.contains(event.getAttacker())) {
                    return currentDamageValue;
                } else {
                    return currentDamageValue * .4f;
                }
            } else {
                return currentDamageValue * .75f;
            }
        }
    });
    Utils.playGlobalSound(wp.getLocation(), "mage.timewarp.teleport", 2, 2);
    Utils.playGlobalSound(player.getLocation(), "warrior.intervene.impact", 2, 0.1f);
    // First Particle Sphere
    playSphereAnimation(wp.getLocation(), bubbleRadius + 2.5, 68, 176, 176);
    // Second Particle Sphere
    new GameRunnable(wp.getGame()) {

        @Override
        public void run() {
            playSphereAnimation(wp.getLocation(), bubbleRadius + 1, 65, 185, 185);
            Utils.playGlobalSound(wp.getLocation(), "warrior.intervene.impact", 2, 0.2f);
        }
    }.runTaskLater(3);
    HashMap<WarlordsPlayer, Integer> timeInBubble = new HashMap<>();
    // Third Particle Sphere
    new GameRunnable(wp.getGame()) {

        @Override
        public void run() {
            if (wp.getCooldownManager().hasCooldown(tempWideGuard)) {
                playSphereAnimation(wp.getLocation(), bubbleRadius, 190, 190, 190);
                Utils.playGlobalSound(wp.getLocation(), Sound.CREEPER_DEATH, 2, 2);
                timeInBubble.compute(wp, (k, v) -> v == null ? 1 : v + 1);
                isInsideBubble.clear();
                for (WarlordsPlayer enemyInsideBubble : PlayerFilter.entitiesAround(wp, bubbleRadius, bubbleRadius, bubbleRadius).aliveEnemiesOf(wp)) {
                    isInsideBubble.add(enemyInsideBubble);
                }
                for (WarlordsPlayer bubblePlayer : PlayerFilter.entitiesAround(wp, bubbleRadius, bubbleRadius, bubbleRadius).aliveTeammatesOfExcludingSelf(wp)) {
                    bubblePlayer.getCooldownManager().removeCooldown(PrismGuard.class);
                    bubblePlayer.getCooldownManager().addCooldown(new RegularCooldown<PrismGuard>("Prism Guard", "GUARD", PrismGuard.class, tempWideGuard, wp, CooldownTypes.ABILITY, cooldownManager -> {
                    }, 20) {

                        @Override
                        public float modifyDamageAfterInterveneFromSelf(WarlordsDamageHealingEvent event, float currentDamageValue) {
                            String ability = event.getAbility();
                            if (ability.equals("Fireball") || ability.equals("Frostbolt") || ability.equals("Water Bolt") || ability.equals("Lightning Bolt") || ability.equals("Flame Burst") || ability.equals("Fallen Souls")) {
                                if (isInsideBubble.contains(event.getAttacker())) {
                                    return currentDamageValue;
                                } else {
                                    return currentDamageValue * .4f;
                                }
                            } else {
                                return currentDamageValue * .75f;
                            }
                        }
                    });
                    timeInBubble.compute(bubblePlayer, (k, v) -> v == null ? 1 : v + 1);
                }
            } else {
                this.cancel();
                Utils.playGlobalSound(wp.getLocation(), "paladin.holyradiance.activation", 2, 1.4f);
                Utils.playGlobalSound(wp.getLocation(), Sound.AMBIENCE_THUNDER, 2, 1.5f);
                for (Map.Entry<WarlordsPlayer, Integer> entry : timeInBubble.entrySet()) {
                    // 5% missing health * 4
                    float healingValue = 150 + (entry.getKey().getMaxHealth() - entry.getKey().getHealth()) * 0.05f;
                    int timeInSeconds = entry.getValue() * 4 / 20;
                    float totalHealing = (timeInSeconds * healingValue);
                    entry.getKey().addHealingInstance(wp, name, totalHealing, totalHealing, -1, 100, false, false);
                }
                CircleEffect circle = new CircleEffect(wp.getGame(), wp.getTeam(), wp.getLocation(), bubbleRadius);
                circle.addEffect(new CircumferenceEffect(ParticleEffect.SPELL).particlesPerCircumference(2));
                circle.playEffects();
            }
        }
    }.runTaskTimer(5, 4);
    return true;
}
Also used : Utils(com.ebicep.warlords.util.warlords.Utils) GameRunnable(com.ebicep.warlords.util.warlords.GameRunnable) EffectUtils.playSphereAnimation(com.ebicep.warlords.effects.EffectUtils.playSphereAnimation) CircumferenceEffect(com.ebicep.warlords.effects.circle.CircumferenceEffect) Set(java.util.Set) CooldownTypes(com.ebicep.warlords.player.cooldowns.CooldownTypes) HashMap(java.util.HashMap) Sound(org.bukkit.Sound) Player(org.bukkit.entity.Player) PlayerFilter(com.ebicep.warlords.util.warlords.PlayerFilter) HashSet(java.util.HashSet) RegularCooldown(com.ebicep.warlords.player.cooldowns.cooldowns.RegularCooldown) WarlordsPlayer(com.ebicep.warlords.player.WarlordsPlayer) Map(java.util.Map) CircleEffect(com.ebicep.warlords.effects.circle.CircleEffect) AbstractAbility(com.ebicep.warlords.classes.AbstractAbility) WarlordsDamageHealingEvent(com.ebicep.warlords.events.WarlordsDamageHealingEvent) Nonnull(javax.annotation.Nonnull) ParticleEffect(com.ebicep.warlords.effects.ParticleEffect) RegularCooldown(com.ebicep.warlords.player.cooldowns.cooldowns.RegularCooldown) WarlordsPlayer(com.ebicep.warlords.player.WarlordsPlayer) HashMap(java.util.HashMap) CircumferenceEffect(com.ebicep.warlords.effects.circle.CircumferenceEffect) GameRunnable(com.ebicep.warlords.util.warlords.GameRunnable) CircleEffect(com.ebicep.warlords.effects.circle.CircleEffect) WarlordsDamageHealingEvent(com.ebicep.warlords.events.WarlordsDamageHealingEvent) HashSet(java.util.HashSet)

Example 3 with CircleEffect

use of com.ebicep.warlords.effects.circle.CircleEffect in project Warlords by ebicep.

the class Vindicate method onActivate.

@Override
public boolean onActivate(@Nonnull WarlordsPlayer wp, @Nonnull Player player) {
    wp.subtractEnergy(energyCost);
    Utils.playGlobalSound(player.getLocation(), "rogue.vindicate.activation", 2, 0.7f);
    Utils.playGlobalSound(player.getLocation(), "shaman.capacitortotem.pulse", 2, 0.7f);
    Vindicate tempVindicate = new Vindicate();
    for (WarlordsPlayer vindicateTarget : PlayerFilter.entitiesAround(wp, radius, radius, radius).aliveTeammatesOfExcludingSelf(wp).closestFirst(wp)) {
        wp.sendMessage(WarlordsPlayer.RECEIVE_ARROW + ChatColor.GRAY + " Your Vindicate is now protecting " + ChatColor.YELLOW + vindicateTarget.getName() + ChatColor.GRAY + "!");
        vindicateTarget.sendMessage(WarlordsPlayer.RECEIVE_ARROW + " " + ChatColor.GRAY + wp.getName() + "'s" + ChatColor.YELLOW + " Vindicate" + ChatColor.GRAY + " is now protecting you from de-buffs for " + ChatColor.GOLD + vindicateDuration + ChatColor.GRAY + " seconds!");
        // Vindicate Immunity
        vindicateTarget.getSpeed().removeSlownessModifiers();
        vindicateTarget.getCooldownManager().removeDebuffCooldowns();
        vindicateTarget.getCooldownManager().removeCooldownByName("Vindicate Debuff Immunity");
        vindicateTarget.getCooldownManager().addRegularCooldown("Vindicate Debuff Immunity", "VIND", Vindicate.class, tempVindicate, wp, CooldownTypes.BUFF, cooldownManager -> {
        }, vindicateDuration * 20);
    }
    wp.getCooldownManager().addCooldown(new RegularCooldown<Vindicate>("Vindicate Resistance", "VIND RES", Vindicate.class, tempVindicate, wp, CooldownTypes.BUFF, cooldownManager -> {
    }, vindicateSelfDuration * 20) {

        @Override
        public float modifyDamageAfterInterveneFromSelf(WarlordsDamageHealingEvent event, float currentDamageValue) {
            return currentDamageValue * getVindicateDamageReduction();
        }
    });
    CircleEffect circle = new CircleEffect(wp.getGame(), wp.getTeam(), player.getLocation(), radius);
    circle.addEffect(new CircumferenceEffect(ParticleEffect.SPELL, ParticleEffect.REDSTONE).particlesPerCircumference(2));
    circle.playEffects();
    EffectUtils.playHelixAnimation(player, radius, 230, 130, 5);
    return true;
}
Also used : EffectUtils(com.ebicep.warlords.effects.EffectUtils) Utils(com.ebicep.warlords.util.warlords.Utils) CircumferenceEffect(com.ebicep.warlords.effects.circle.CircumferenceEffect) CooldownTypes(com.ebicep.warlords.player.cooldowns.CooldownTypes) Player(org.bukkit.entity.Player) PlayerFilter(com.ebicep.warlords.util.warlords.PlayerFilter) RegularCooldown(com.ebicep.warlords.player.cooldowns.cooldowns.RegularCooldown) WarlordsPlayer(com.ebicep.warlords.player.WarlordsPlayer) ChatColor(org.bukkit.ChatColor) CircleEffect(com.ebicep.warlords.effects.circle.CircleEffect) AbstractAbility(com.ebicep.warlords.classes.AbstractAbility) WarlordsDamageHealingEvent(com.ebicep.warlords.events.WarlordsDamageHealingEvent) Nonnull(javax.annotation.Nonnull) ParticleEffect(com.ebicep.warlords.effects.ParticleEffect) WarlordsPlayer(com.ebicep.warlords.player.WarlordsPlayer) CircleEffect(com.ebicep.warlords.effects.circle.CircleEffect) CircumferenceEffect(com.ebicep.warlords.effects.circle.CircumferenceEffect) WarlordsDamageHealingEvent(com.ebicep.warlords.events.WarlordsDamageHealingEvent)

Example 4 with CircleEffect

use of com.ebicep.warlords.effects.circle.CircleEffect in project Warlords by ebicep.

the class SoothingPuddle method onActivate.

@Override
public boolean onActivate(WarlordsPlayer wp, Player player) {
    wp.subtractEnergy(energyCost);
    Location location = player.getLocation();
    Vector speed = player.getLocation().getDirection().multiply(SPEED);
    ArmorStand stand = (ArmorStand) location.getWorld().spawnEntity(location, EntityType.ARMOR_STAND);
    stand.setHelmet(new ItemStack(Material.STAINED_GLASS, 1, (short) 6));
    stand.setGravity(false);
    stand.setVisible(false);
    new GameRunnable(wp.getGame()) {

        int timer = 0;

        @Override
        public void run() {
            quarterStep(false);
            quarterStep(false);
            quarterStep(false);
            quarterStep(false);
            quarterStep(false);
            quarterStep(false);
            quarterStep(true);
        }

        private void quarterStep(boolean last) {
            if (!stand.isValid()) {
                this.cancel();
                return;
            }
            speed.add(new Vector(0, GRAVITY * SPEED, 0));
            Location newLoc = stand.getLocation();
            newLoc.add(speed);
            stand.teleport(newLoc);
            newLoc.add(0, 1.75, 0);
            stand.setHeadPose(new EulerAngle(-speed.getY() * 3, 0, 0));
            boolean shouldExplode;
            timer++;
            if (last) {
                Matrix4d center = new Matrix4d(newLoc);
                for (float i = 0; i < 6; i++) {
                    double angle = Math.toRadians(i * 90) + timer * 0.3;
                    double width = 0.4D;
                    ParticleEffect.VILLAGER_HAPPY.display(0, 0, 0, 0, 2, center.translateVector(newLoc.getWorld(), 0, Math.sin(angle) * width, Math.cos(angle) * width), 500);
                }
            }
            WarlordsPlayer directHit;
            if (!newLoc.getBlock().isEmpty() && newLoc.getBlock().getType() != Material.GRASS && newLoc.getBlock().getType() != Material.BARRIER && newLoc.getBlock().getType() != Material.VINE) {
                // Explode based on collision
                shouldExplode = true;
            } else {
                directHit = PlayerFilter.entitiesAroundRectangle(newLoc, 1, 2, 1).aliveTeammatesOfExcludingSelf(wp).findFirstOrNull();
                shouldExplode = directHit != null;
                newLoc.add(0, -1, 0);
            }
            newLoc.add(0, 1, 0);
            if (shouldExplode) {
                stand.remove();
                Utils.playGlobalSound(newLoc, "rogue.healingremedy.impact", 1.5f, 0.2f);
                Utils.playGlobalSound(newLoc, Sound.GLASS, 1.5f, 0.7f);
                Utils.playGlobalSound(newLoc, "mage.waterbolt.impact", 1.5f, 0.3f);
                FireWorkEffectPlayer.playFirework(newLoc, FireworkEffect.builder().withColor(Color.WHITE).with(FireworkEffect.Type.BURST).build());
                for (WarlordsPlayer nearEntity : PlayerFilter.entitiesAround(newLoc, HITBOX, HITBOX, HITBOX).aliveTeammatesOf(wp)) {
                    nearEntity.addHealingInstance(wp, name, minDamageHeal, maxDamageHeal, critChance, critMultiplier, false, false);
                }
                CircleEffect circleEffect = new CircleEffect(wp.getGame(), wp.getTeam(), newLoc, HITBOX, new CircumferenceEffect(ParticleEffect.VILLAGER_HAPPY, ParticleEffect.REDSTONE), new AreaEffect(1, ParticleEffect.DRIP_WATER).particlesPerSurface(0.025));
                BukkitTask task = Bukkit.getScheduler().runTaskTimer(Warlords.getInstance(), circleEffect::playEffects, 0, 1);
                wp.getGame().registerGameTask(task);
                new GameRunnable(wp.getGame()) {

                    int timeLeft = 4;

                    @Override
                    public void run() {
                        PlayerFilter.entitiesAround(newLoc, HITBOX, HITBOX, HITBOX).aliveTeammatesOf(wp).forEach((ally) -> ally.addHealingInstance(wp, name, puddleMinHealing, puddleMaxHealing, critChance, critMultiplier, false, false));
                        timeLeft--;
                        if (timeLeft < 0) {
                            this.cancel();
                            task.cancel();
                        }
                    }
                }.runTaskTimer(20, 20);
                this.cancel();
            }
        }
    }.runTaskTimer(0, 1);
    Utils.playGlobalSound(player.getLocation(), "mage.frostbolt.activation", 2, 0.7f);
    return true;
}
Also used : AreaEffect(com.ebicep.warlords.effects.circle.AreaEffect) WarlordsPlayer(com.ebicep.warlords.player.WarlordsPlayer) BukkitTask(org.bukkit.scheduler.BukkitTask) CircumferenceEffect(com.ebicep.warlords.effects.circle.CircumferenceEffect) Matrix4d(com.ebicep.warlords.util.bukkit.Matrix4d) ArmorStand(org.bukkit.entity.ArmorStand) GameRunnable(com.ebicep.warlords.util.warlords.GameRunnable) CircleEffect(com.ebicep.warlords.effects.circle.CircleEffect) ItemStack(org.bukkit.inventory.ItemStack) EulerAngle(org.bukkit.util.EulerAngle) Vector(org.bukkit.util.Vector)

Example 5 with CircleEffect

use of com.ebicep.warlords.effects.circle.CircleEffect in project Warlords by ebicep.

the class UndyingArmy method onActivate.

@Override
public boolean onActivate(WarlordsPlayer wp, Player player) {
    wp.subtractEnergy(energyCost);
    UndyingArmy tempUndyingArmy = new UndyingArmy();
    int numberOfPlayersWithArmy = 0;
    for (WarlordsPlayer teammate : PlayerFilter.entitiesAround(wp, radius, radius, radius).aliveTeammatesOf(wp).closestFirst(wp)) {
        tempUndyingArmy.getPlayersPopped().put(teammate, false);
        if (teammate != wp) {
            wp.sendMessage(WarlordsPlayer.RECEIVE_ARROW + ChatColor.GRAY + " Your " + ChatColor.YELLOW + "Undying Army" + ChatColor.GRAY + " is now protecting " + teammate.getName() + ChatColor.GRAY + ".");
            teammate.sendMessage(WarlordsPlayer.RECEIVE_ARROW + ChatColor.GRAY + " " + ChatColor.GRAY + wp.getName() + "'s " + ChatColor.YELLOW + "Undying Army" + ChatColor.GRAY + " is now protecting you for " + ChatColor.GOLD + duration + ChatColor.GRAY + " seconds.");
        }
        teammate.getCooldownManager().addRegularCooldown(name, "ARMY", UndyingArmy.class, tempUndyingArmy, wp, CooldownTypes.ABILITY, cooldownManager -> {
        }, duration * 20);
        new GameRunnable(wp.getGame()) {

            @Override
            public void run() {
                Optional<UndyingArmy> optionalUndyingArmy = new CooldownFilter<>(teammate, RegularCooldown.class).findFirstObject(tempUndyingArmy, UndyingArmy.class);
                if (optionalUndyingArmy.isPresent()) {
                    if (!(optionalUndyingArmy.get()).isArmyDead(teammate)) {
                        float healAmount = 100 + (teammate.getMaxHealth() - teammate.getHealth()) * 0.035f;
                        teammate.addHealingInstance(wp, name, healAmount, healAmount, -1, 100, false, false);
                        teammate.playSound(teammate.getLocation(), "paladin.holyradiance.activation", 0.1f, 0.7f);
                        // particles
                        Location playerLoc = teammate.getLocation();
                        playerLoc.add(0, 2.1, 0);
                        Location particleLoc = playerLoc.clone();
                        for (int i = 0; i < 1; i++) {
                            for (int j = 0; j < 10; j++) {
                                double angle = j / 10D * Math.PI * 2;
                                double width = 0.5;
                                particleLoc.setX(playerLoc.getX() + Math.sin(angle) * width);
                                particleLoc.setY(playerLoc.getY() + i / 5D);
                                particleLoc.setZ(playerLoc.getZ() + Math.cos(angle) * width);
                                ParticleEffect.REDSTONE.display(new ParticleEffect.OrdinaryColor(255, 255, 255), particleLoc, 500);
                            }
                        }
                    } else {
                        this.cancel();
                    }
                } else {
                    this.cancel();
                }
            }
        }.runTaskTimer(0, 20);
        numberOfPlayersWithArmy++;
        if (numberOfPlayersWithArmy >= maxArmyAllies) {
            break;
        }
    }
    Utils.playGlobalSound(player.getLocation(), Sound.ZOMBIE_IDLE, 2, 0.3f);
    Utils.playGlobalSound(player.getLocation(), Sound.AMBIENCE_THUNDER, 2, 0.9f);
    // particles
    Location loc = player.getEyeLocation();
    loc.setPitch(0);
    loc.setYaw(0);
    Matrix4d matrix = new Matrix4d();
    for (int i = 0; i < 9; i++) {
        loc.setYaw(loc.getYaw() + 360F / 9F);
        matrix.updateFromLocation(loc);
        for (int c = 0; c < 30; c++) {
            double angle = c / 30D * Math.PI * 2;
            double width = 1.5;
            ParticleEffect.ENCHANTMENT_TABLE.display(0, 0.1f, 0, 0, 1, matrix.translateVector(player.getWorld(), radius, Math.sin(angle) * width, Math.cos(angle) * width), 500);
        }
        for (int c = 0; c < 15; c++) {
            double angle = c / 15D * Math.PI * 2;
            double width = 0.6;
            ParticleEffect.SPELL.display(0, 0, 0, 0, 1, matrix.translateVector(player.getWorld(), radius, Math.sin(angle) * width, Math.cos(angle) * width), 500);
        }
    }
    CircleEffect circle = new CircleEffect(wp.getGame(), wp.getTeam(), player.getLocation(), radius);
    circle.addEffect(new CircumferenceEffect(ParticleEffect.VILLAGER_HAPPY, ParticleEffect.REDSTONE).particlesPerCircumference(2));
    circle.playEffects();
    return true;
}
Also used : CooldownFilter(com.ebicep.warlords.player.cooldowns.CooldownFilter) WarlordsPlayer(com.ebicep.warlords.player.WarlordsPlayer) Optional(java.util.Optional) CircumferenceEffect(com.ebicep.warlords.effects.circle.CircumferenceEffect) Matrix4d(com.ebicep.warlords.util.bukkit.Matrix4d) GameRunnable(com.ebicep.warlords.util.warlords.GameRunnable) CircleEffect(com.ebicep.warlords.effects.circle.CircleEffect) Location(org.bukkit.Location)

Aggregations

CircleEffect (com.ebicep.warlords.effects.circle.CircleEffect)10 CircumferenceEffect (com.ebicep.warlords.effects.circle.CircumferenceEffect)10 WarlordsPlayer (com.ebicep.warlords.player.WarlordsPlayer)9 GameRunnable (com.ebicep.warlords.util.warlords.GameRunnable)8 ParticleEffect (com.ebicep.warlords.effects.ParticleEffect)7 PlayerFilter (com.ebicep.warlords.util.warlords.PlayerFilter)7 Utils (com.ebicep.warlords.util.warlords.Utils)7 Location (org.bukkit.Location)7 Player (org.bukkit.entity.Player)7 CooldownTypes (com.ebicep.warlords.player.cooldowns.CooldownTypes)6 AbstractAbility (com.ebicep.warlords.classes.AbstractAbility)5 RegularCooldown (com.ebicep.warlords.player.cooldowns.cooldowns.RegularCooldown)5 ArmorStand (org.bukkit.entity.ArmorStand)5 ItemStack (org.bukkit.inventory.ItemStack)5 BukkitTask (org.bukkit.scheduler.BukkitTask)5 Warlords (com.ebicep.warlords.Warlords)4 WarlordsDamageHealingEvent (com.ebicep.warlords.events.WarlordsDamageHealingEvent)4 Material (org.bukkit.Material)4 CooldownFilter (com.ebicep.warlords.player.cooldowns.CooldownFilter)3 Set (java.util.Set)3