Search in sources :

Example 1 with LineEffect

use of com.ebicep.warlords.effects.circle.LineEffect 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)

Aggregations

Warlords (com.ebicep.warlords.Warlords)1 AbstractAbility (com.ebicep.warlords.classes.AbstractAbility)1 Protector (com.ebicep.warlords.classes.paladin.specs.Protector)1 ParticleEffect (com.ebicep.warlords.effects.ParticleEffect)1 CircleEffect (com.ebicep.warlords.effects.circle.CircleEffect)1 CircumferenceEffect (com.ebicep.warlords.effects.circle.CircumferenceEffect)1 LineEffect (com.ebicep.warlords.effects.circle.LineEffect)1 WarlordsPlayer (com.ebicep.warlords.player.WarlordsPlayer)1 CooldownFilter (com.ebicep.warlords.player.cooldowns.CooldownFilter)1 CooldownTypes (com.ebicep.warlords.player.cooldowns.CooldownTypes)1 RegularCooldown (com.ebicep.warlords.player.cooldowns.cooldowns.RegularCooldown)1 GameRunnable (com.ebicep.warlords.util.warlords.GameRunnable)1 PlayerFilter (com.ebicep.warlords.util.warlords.PlayerFilter)1 Utils (com.ebicep.warlords.util.warlords.Utils)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1 Set (java.util.Set)1 Location (org.bukkit.Location)1 Material (org.bukkit.Material)1 ArmorStand (org.bukkit.entity.ArmorStand)1