Search in sources :

Example 1 with Overheal

use of com.ebicep.warlords.abilties.internal.Overheal in project Warlords by ebicep.

the class Warlords method startMainLoop.

private void startMainLoop() {
    new BukkitRunnable() {

        int counter = 0;

        @Override
        public void run() {
            // Every 1 tick - 0.05 seconds.
            {
                for (WarlordsPlayer wp : players.values()) {
                    Player player = wp.getEntity() instanceof Player ? (Player) wp.getEntity() : null;
                    if (player != null) {
                        // ACTION BAR
                        if (player.getInventory().getHeldItemSlot() != 8) {
                            wp.displayActionBar();
                        } else {
                            wp.displayFlagActionBar(player);
                        }
                    }
                    // Checks whether the game is paused.
                    if (wp.getGame().isFrozen()) {
                        continue;
                    }
                    // Updating all player speed.
                    wp.getSpeed().updateSpeed();
                    // will add more efficient system later
                    if (wp.getSpec() instanceof Apothecary) {
                        wp.getSpeed().addSpeedModifier("Base Speed", 23, 1, "BASE");
                    }
                    CooldownManager cooldownManager = wp.getCooldownManager();
                    // Setting the flag tracking compass.
                    if (player != null && wp.getCompassTarget() != null) {
                        player.setCompassTarget(wp.getCompassTarget().getLocation());
                    }
                    // Checks whether the player has cooldowns disabled.
                    if (wp.isDisableCooldowns()) {
                        wp.getSpec().getRed().setCurrentCooldown(0);
                        wp.getSpec().getPurple().setCurrentCooldown(0);
                        wp.getSpec().getBlue().setCurrentCooldown(0);
                        wp.getSpec().getOrange().setCurrentCooldown(0);
                        wp.setHorseCooldown(0);
                        wp.updateRedItem();
                        wp.updatePurpleItem();
                        wp.updateBlueItem();
                        wp.updateOrangeItem();
                        wp.updateHorseItem();
                    }
                    // Decrementing red skill's cooldown.
                    if (wp.getSpec().getRed().getCurrentCooldown() > 0) {
                        wp.getSpec().getRed().subtractCooldown(.05f);
                        if (player != null) {
                            wp.updateRedItem(player);
                        }
                    }
                    // Decrementing purple skill's cooldown.
                    if (wp.getSpec().getPurple().getCurrentCooldown() > 0) {
                        wp.getSpec().getPurple().subtractCooldown(.05f);
                        if (player != null) {
                            wp.updatePurpleItem(player);
                        }
                    }
                    // Decrementing blue skill's cooldown.
                    if (wp.getSpec().getBlue().getCurrentCooldown() > 0) {
                        wp.getSpec().getBlue().subtractCooldown(.05f);
                        if (player != null) {
                            wp.updateBlueItem(player);
                        }
                    }
                    // Decrementing orange skill's cooldown.
                    if (wp.getSpec().getOrange().getCurrentCooldown() > 0) {
                        wp.getSpec().getOrange().subtractCooldown(.05f);
                        if (player != null) {
                            wp.updateOrangeItem(player);
                        }
                    }
                    // Decrementing mount cooldown.
                    if (wp.getHorseCooldown() > 0 && !wp.getEntity().isInsideVehicle()) {
                        wp.setHorseCooldown(wp.getHorseCooldown() - .05f);
                        if (player != null) {
                            wp.updateHorseItem(player);
                        }
                    }
                    wp.getCooldownManager().reduceCooldowns();
                    // Checks whether the player has overheal active and is full health or not.
                    boolean hasOverhealCooldown = wp.getCooldownManager().hasCooldown(Overheal.OVERHEAL_MARKER);
                    boolean hasTooMuchHealth = wp.getHealth() > wp.getMaxHealth();
                    if (hasOverhealCooldown && !hasTooMuchHealth) {
                        wp.getCooldownManager().removeCooldown(Overheal.OVERHEAL_MARKER);
                    }
                    if (!hasOverhealCooldown && hasTooMuchHealth) {
                        wp.setHealth(wp.getMaxHealth());
                    }
                    // Checks whether the player has Vindicate active.
                    if (wp.getCooldownManager().hasCooldownFromName("Vindicate Debuff Immunity")) {
                        wp.getSpeed().removeSlownessModifiers();
                        wp.getCooldownManager().removeDebuffCooldowns();
                        wp.getEntity().removePotionEffect(PotionEffectType.BLINDNESS);
                    }
                    // Checks whether the displayed health can be above or under 40 health total. (20 hearts.)
                    float newHealth = (float) wp.getHealth() / wp.getMaxHealth() * 40;
                    if (newHealth < 0) {
                        newHealth = 0;
                    } else if (newHealth > 40) {
                        newHealth = 40;
                    }
                    // Checks whether the player has any remaining active Undying Army instances active.
                    if (wp.getCooldownManager().checkUndyingArmy(false) && newHealth <= 0) {
                        for (RegularCooldown undyingArmyCooldown : new CooldownFilter<>(wp, RegularCooldown.class).filterCooldownClass(UndyingArmy.class).stream().collect(Collectors.toList())) {
                            UndyingArmy undyingArmy = (UndyingArmy) undyingArmyCooldown.getCooldownObject();
                            if (!undyingArmy.isArmyDead(wp)) {
                                undyingArmy.pop(wp);
                                // Drops the flag when popped.
                                FlagHolder.dropFlagForPlayer(wp);
                                // Sending the message + check if getFrom is self
                                if (undyingArmyCooldown.getFrom() == wp) {
                                    wp.sendMessage("§a\u00BB§7 " + ChatColor.LIGHT_PURPLE + "Your Undying Army revived you with temporary health. Fight until your death! Your health will decay by " + ChatColor.RED + (wp.getMaxHealth() / 10) + ChatColor.LIGHT_PURPLE + " every second.");
                                } else {
                                    wp.sendMessage("§a\u00BB§7 " + ChatColor.LIGHT_PURPLE + undyingArmyCooldown.getFrom().getName() + "'s Undying Army revived you with temporary health. Fight until your death! Your health will decay by " + ChatColor.RED + (wp.getMaxHealth() / 10) + ChatColor.LIGHT_PURPLE + " every second.");
                                }
                                FireWorkEffectPlayer.playFirework(wp.getLocation(), FireworkEffect.builder().withColor(Color.LIME).with(FireworkEffect.Type.BALL).build());
                                wp.heal();
                                if (player != null) {
                                    player.getWorld().spigot().strikeLightningEffect(wp.getLocation(), false);
                                    player.getInventory().setItem(5, UndyingArmy.BONE);
                                }
                                newHealth = 40;
                                // gives 50% of max energy if player is less than half
                                if (wp.getEnergy() < wp.getMaxEnergy() / 2) {
                                    wp.setEnergy(wp.getMaxEnergy() / 2);
                                }
                                new GameRunnable(wp.getGame()) {

                                    @Override
                                    public void run() {
                                        if (wp.getRespawnTimer() >= 0 || wp.isDead()) {
                                            this.cancel();
                                        } else {
                                            // UNDYING ARMY - dmg 10% of max health each popped army
                                            wp.addDamageInstance(wp, "", wp.getMaxHealth() / 10f, wp.getMaxHealth() / 10f, -1, 100, false);
                                        }
                                    }
                                }.runTaskTimer(0, 20);
                                break;
                            }
                        }
                    }
                    if (player != null) {
                        // precaution
                        if (newHealth > 0 && newHealth <= 40) {
                            player.setHealth(newHealth);
                        }
                    }
                    // Respawn fix for when a player is stuck or leaves the game.
                    if (player != null) {
                        if (wp.getHealth() <= 0 && player.getGameMode() == GameMode.SPECTATOR) {
                            wp.heal();
                        }
                    }
                    if (wp.getEnergy() < wp.getMaxEnergy()) {
                        // Standard energy value per second.
                        float energyGainPerTick = wp.getSpec().getEnergyPerSec() / 20f;
                        // Checks whether the player has Avenger's Wrath active.
                        for (RegularCooldown regularCooldown : new CooldownFilter<>(cooldownManager, RegularCooldown.class).filterCooldownClass(AvengersWrath.class).stream().collect(Collectors.toList())) {
                            energyGainPerTick += 1;
                        }
                        // Checks whether the player has Inspiring Presence active.
                        for (RegularCooldown regularCooldown : new CooldownFilter<>(cooldownManager, RegularCooldown.class).filterCooldownClass(InspiringPresence.class).stream().collect(Collectors.toList())) {
                            energyGainPerTick += .5;
                        }
                        // Checks whether the player has been marked by an Avenger.
                        for (RegularCooldown regularCooldown : new CooldownFilter<>(cooldownManager, RegularCooldown.class).filterCooldownClass(HolyRadianceAvenger.class).stream().collect(Collectors.toList())) {
                            energyGainPerTick -= .4;
                        }
                        // Checks whether the player has been marked by a Crusader.
                        for (RegularCooldown regularCooldown : new CooldownFilter<>(cooldownManager, RegularCooldown.class).filterCooldownClass(HolyRadianceCrusader.class).stream().collect(Collectors.toList())) {
                            energyGainPerTick += .3;
                        }
                        // Checks whether the player has Acupressure active.
                        for (RegularCooldown regularCooldown : new CooldownFilter<>(cooldownManager, RegularCooldown.class).filterCooldownClass(VitalityLiquor.class).stream().collect(Collectors.toList())) {
                            energyGainPerTick += .75;
                        }
                        // Checks whether the player has the Energy Powerup active.
                        if (cooldownManager.hasCooldown(EnergyPowerup.class)) {
                            energyGainPerTick *= 1.4;
                        }
                        // Setting energy gain to the value after all ability instance multipliers have been applied.
                        float newEnergy = wp.getEnergy() + energyGainPerTick;
                        if (newEnergy > wp.getMaxEnergy()) {
                            newEnergy = wp.getMaxEnergy();
                        }
                        wp.setEnergy(newEnergy);
                    }
                    // Checks whether the player has under 0 energy to avoid infinite energy bugs.
                    if (player != null) {
                        if (wp.getEnergy() < 0) {
                            wp.setEnergy(1);
                        }
                        player.setLevel((int) wp.getEnergy());
                        player.setExp(wp.getEnergy() / wp.getMaxEnergy());
                    }
                    // Melee Cooldown
                    if (wp.getHitCooldown() > 0) {
                        wp.setHitCooldown(wp.getHitCooldown() - 1);
                    }
                    // Orbs of Life
                    Location playerPosition = wp.getLocation();
                    List<OrbsOfLife.Orb> orbs = new ArrayList<>();
                    PlayerFilter.playingGame(wp.getGame()).teammatesOf(wp).forEach(p -> {
                        new CooldownFilter<>(p, PersistentCooldown.class).filterCooldownClassAndMapToObjectsOfClass(OrbsOfLife.class).forEachOrdered(orbsOfLife -> orbs.addAll(orbsOfLife.getSpawnedOrbs()));
                    });
                    Iterator<OrbsOfLife.Orb> itr = orbs.iterator();
                    while (itr.hasNext()) {
                        OrbsOfLife.Orb orb = itr.next();
                        Location orbPosition = orb.getArmorStand().getLocation();
                        if ((orb.getPlayerToMoveTowards() == null || (orb.getPlayerToMoveTowards() != null && orb.getPlayerToMoveTowards() == wp)) && orbPosition.distanceSquared(playerPosition) < 1.35 * 1.35 && !wp.isDeath()) {
                            orb.remove();
                            itr.remove();
                            float orbHeal = OrbsOfLife.ORB_HEALING;
                            if (Warlords.getPlayerSettings(orb.getOwner().getUuid()).getSkillBoostForClass() == ClassesSkillBoosts.ORBS_OF_LIFE) {
                                orbHeal *= 1.2;
                            }
                            // 225 *= 1.4 = 315
                            if (orb.getPlayerToMoveTowards() == null) {
                                orbHeal *= 1 + orb.getTicksLived() / 325f;
                            }
                            wp.addHealingInstance(orb.getOwner(), "Orbs of Life", orbHeal, orbHeal, -1, 100, false, false);
                            if (player != null) {
                                Utils.playGlobalSound(player.getLocation(), Sound.ORB_PICKUP, 0.2f, 1);
                            }
                            for (WarlordsPlayer nearPlayer : PlayerFilter.entitiesAround(wp, 6, 6, 6).aliveTeammatesOfExcludingSelf(wp).limit(2)) {
                                nearPlayer.addHealingInstance(orb.getOwner(), "Orbs of Life", orbHeal, orbHeal, -1, 100, false, false);
                                if (player != null) {
                                    Utils.playGlobalSound(player.getLocation(), Sound.ORB_PICKUP, 0.2f, 1);
                                }
                            }
                        }
                        // Checks whether the Orb of Life has lived for 8 seconds.
                        if (orb.getBukkitEntity().getTicksLived() > 160 || (orb.getPlayerToMoveTowards() != null && orb.getPlayerToMoveTowards().isDeath())) {
                            orb.remove();
                            itr.remove();
                        }
                    }
                    // Saves the amount of blocks travelled per player.
                    if (player != null) {
                        wp.setBlocksTravelledCM(Utils.getPlayerMovementStatistics(player));
                    }
                }
                // Loops every 10 ticks - .5 second.
                if (counter % 10 == 0) {
                    for (WarlordsPlayer wps : players.values()) {
                        // Soulbinding Weapon - decrementing time left on the ability.
                        new CooldownFilter<>(wps, PersistentCooldown.class).filterCooldownClassAndMapToObjectsOfClass(Soulbinding.class).forEachOrdered(soulbinding -> soulbinding.getSoulBindedPlayers().forEach(Soulbinding.SoulBoundPlayer::decrementTimeLeft));
                        // Soulbinding Weapon - Removing bound players.
                        new CooldownFilter<>(wps, PersistentCooldown.class).filterCooldownClassAndMapToObjectsOfClass(Soulbinding.class).forEachOrdered(soulbinding -> soulbinding.getSoulBindedPlayers().removeIf(boundPlayer -> boundPlayer.getTimeLeft() == 0 || (boundPlayer.isHitWithSoul() && boundPlayer.isHitWithLink())));
                    }
                }
                // Loops every 20 ticks - 1 second.
                if (counter % 20 == 0) {
                    // Removes leftover horses if there are any.
                    RemoveEntities.removeHorsesInGame();
                    for (WarlordsPlayer wps : players.values()) {
                        // Checks whether the game is paused.
                        if (wps.getGame().isFrozen()) {
                            continue;
                        }
                        wps.runEverySecond();
                        Player player = wps.getEntity() instanceof Player ? (Player) wps.getEntity() : null;
                        // Natural Regen
                        if (wps.getRegenTimer() != 0) {
                            wps.setRegenTimer(wps.getRegenTimer() - 1);
                            if (wps.getRegenTimer() == 0) {
                                wps.getHitBy().clear();
                            }
                        } else {
                            int healthToAdd = (int) (wps.getMaxHealth() / 55.3);
                            wps.setHealth(Math.max(wps.getHealth(), Math.min(wps.getHealth() + healthToAdd, wps.getMaxHealth())));
                        }
                        // Checks whether the player has a flag cooldown.
                        if (wps.getFlagCooldown() > 0) {
                            wps.setFlagCooldown(wps.getFlagCooldown() - 1);
                        }
                        // Checks whether the player has the healing powerup active.
                        if (wps.getCooldownManager().hasCooldown(HealingPowerup.class)) {
                            int heal = (int) (wps.getMaxHealth() * .08);
                            if (wps.getHealth() + heal > wps.getMaxHealth()) {
                                heal = wps.getMaxHealth() - wps.getHealth();
                            }
                            if (heal != 0) {
                                wps.setHealth(wps.getHealth() + heal);
                                wps.sendMessage(WarlordsPlayer.RECEIVE_ARROW + " §7Healed §a" + heal + " §7health.");
                            }
                        }
                        // Combat Timer - Logs combat time after 4 seconds.
                        if (wps.getRegenTimer() > 6) {
                            wps.getMinuteStats().addTimeInCombat();
                        }
                        // Assists - 10 seconds timer.
                        wps.getHitBy().replaceAll((wp, integer) -> integer - 1);
                        wps.getHealedBy().replaceAll((wp, integer) -> integer - 1);
                        wps.getHitBy().entrySet().removeIf(p -> p.getValue() <= 0);
                        wps.getHealedBy().entrySet().removeIf(p -> p.getValue() <= 0);
                    }
                    WarlordsEvents.entityList.removeIf(e -> !e.isValid());
                }
                // Loops every 50 ticks - 2.5 seconds.
                if (counter % 50 == 0) {
                    for (WarlordsPlayer warlordsPlayer : players.values()) {
                        if (warlordsPlayer.getGame().isFrozen()) {
                            continue;
                        }
                        LivingEntity player = warlordsPlayer.getEntity();
                        List<Location> locations = warlordsPlayer.getLocations();
                        if (warlordsPlayer.isDeath() && !locations.isEmpty()) {
                            locations.add(locations.get(locations.size() - 1));
                        } else {
                            locations.add(player.getLocation());
                        }
                    }
                }
                // Loops every 100 ticks - 5 seconds.
                if (counter % 100 == 0) {
                    BotManager.sendStatusMessage(false);
                }
            }
            counter++;
        }
    }.runTaskTimer(this, 0, 0);
}
Also used : LoginException(javax.security.auth.login.LoginException) com.ebicep.warlords.game(com.ebicep.warlords.game) PersistentCooldown(com.ebicep.warlords.player.cooldowns.cooldowns.PersistentCooldown) BukkitTaskChainFactory(co.aikar.taskchain.BukkitTaskChainFactory) LoggerFactory(org.slf4j.LoggerFactory) com.ebicep.warlords.commands.debugcommands(com.ebicep.warlords.commands.debugcommands) DatabaseManager(com.ebicep.warlords.database.DatabaseManager) Player(org.bukkit.entity.Player) SkullMeta(org.bukkit.inventory.meta.SkullMeta) org.bukkit(org.bukkit) StreamCommand(com.ebicep.warlords.party.StreamCommand) HolographicDisplaysAPI(me.filoghost.holographicdisplays.api.beta.HolographicDisplaysAPI) TaskChainFactory(co.aikar.taskchain.TaskChainFactory) RemoveEntities(com.ebicep.warlords.util.bukkit.RemoveEntities) LocationFactory(com.ebicep.warlords.util.bukkit.LocationFactory) CraftItemStack(org.bukkit.craftbukkit.v1_8_R3.inventory.CraftItemStack) QueueCommand(com.ebicep.warlords.queuesystem.QueueCommand) BotManager(com.ebicep.jda.BotManager) HealingPowerup(com.ebicep.warlords.abilties.internal.HealingPowerup) Overheal(com.ebicep.warlords.abilties.internal.Overheal) GameRunnable(com.ebicep.warlords.util.warlords.GameRunnable) Entity(org.bukkit.entity.Entity) TaskChain(co.aikar.taskchain.TaskChain) com.ebicep.warlords.commands.miscellaneouscommands(com.ebicep.warlords.commands.miscellaneouscommands) Hologram(me.filoghost.holographicdisplays.api.beta.hologram.Hologram) ListenerPriority(com.comphenix.protocol.events.ListenerPriority) FlagHolder(com.ebicep.warlords.game.option.marker.FlagHolder) PacketType(com.comphenix.protocol.PacketType) FireWorkEffectPlayer(com.ebicep.warlords.effects.FireWorkEffectPlayer) LivingEntity(org.bukkit.entity.LivingEntity) PartyListener(com.ebicep.warlords.party.PartyListener) Collectors(java.util.stream.Collectors) CraftServer(org.bukkit.craftbukkit.v1_8_R3.CraftServer) PlayerFilter(com.ebicep.warlords.util.warlords.PlayerFilter) ItemStack(org.bukkit.inventory.ItemStack) JavaPlugin(org.bukkit.plugin.java.JavaPlugin) MetadataValue(org.bukkit.metadata.MetadataValue) RegularCooldown(com.ebicep.warlords.player.cooldowns.cooldowns.RegularCooldown) NPCManager(com.ebicep.customentities.npc.NPCManager) LocationBuilder(com.ebicep.warlords.util.bukkit.LocationBuilder) LeaderboardCommand(com.ebicep.warlords.database.leaderboards.LeaderboardCommand) CooldownFilter(com.ebicep.warlords.player.cooldowns.CooldownFilter) ProtocolManager(com.comphenix.protocol.ProtocolManager) PotionEffectType(org.bukkit.potion.PotionEffectType) BotCommands(com.ebicep.jda.BotCommands) ConfigurationSerialization(org.bukkit.configuration.serialization.ConfigurationSerialization) Utils(com.ebicep.warlords.util.warlords.Utils) java.util(java.util) ApplicationConfiguration(com.ebicep.warlords.database.configuration.ApplicationConfiguration) ProtocolLibrary(com.comphenix.protocol.ProtocolLibrary) PacketUtils(com.ebicep.warlords.util.bukkit.PacketUtils) CooldownManager(com.ebicep.warlords.player.cooldowns.CooldownManager) FutureMessageManager(com.ebicep.warlords.database.FutureMessageManager) PacketPlayInSteerVehicle(net.minecraft.server.v1_8_R3.PacketPlayInSteerVehicle) GameMode(org.bukkit.GameMode) PollCommand(com.ebicep.warlords.poll.PollCommand) PacketAdapter(com.comphenix.protocol.events.PacketAdapter) Apothecary(com.ebicep.warlords.classes.rogue.specs.Apothecary) BotListener(com.ebicep.jda.BotListener) MenuEventListener(com.ebicep.warlords.menu.MenuEventListener) Utils.iterable(com.ebicep.warlords.util.warlords.Utils.iterable) Nonnull(javax.annotation.Nonnull) com.ebicep.warlords.abilties(com.ebicep.warlords.abilties) Nullable(javax.annotation.Nullable) PacketEvent(com.comphenix.protocol.events.PacketEvent) BukkitRunnable(org.bukkit.scheduler.BukkitRunnable) Field(java.lang.reflect.Field) File(java.io.File) PartyCommand(com.ebicep.warlords.party.PartyCommand) com.ebicep.warlords.player(com.ebicep.warlords.player) PartyManager(com.ebicep.warlords.party.PartyManager) ChatChannels(com.ebicep.warlords.util.chat.ChatChannels) YamlConfiguration(org.bukkit.configuration.file.YamlConfiguration) EnergyPowerup(com.ebicep.warlords.abilties.internal.EnergyPowerup) WarlordsEvents(com.ebicep.warlords.events.WarlordsEvents) RegularCooldown(com.ebicep.warlords.player.cooldowns.cooldowns.RegularCooldown) LivingEntity(org.bukkit.entity.LivingEntity) Apothecary(com.ebicep.warlords.classes.rogue.specs.Apothecary) Player(org.bukkit.entity.Player) FireWorkEffectPlayer(com.ebicep.warlords.effects.FireWorkEffectPlayer) CooldownFilter(com.ebicep.warlords.player.cooldowns.CooldownFilter) BukkitRunnable(org.bukkit.scheduler.BukkitRunnable) GameRunnable(com.ebicep.warlords.util.warlords.GameRunnable) CooldownManager(com.ebicep.warlords.player.cooldowns.CooldownManager)

Example 2 with Overheal

use of com.ebicep.warlords.abilties.internal.Overheal in project Warlords by ebicep.

the class HealingRain 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().clone();
    wp.subtractEnergy(energyCost);
    wp.getCooldownManager().addRegularCooldown(name, "RAIN", HealingRain.class, new HealingRain(), wp, CooldownTypes.ABILITY, cooldownManager -> {
    }, duration * 20);
    wp.getSpec().getOrange().setCurrentCooldown((float) (cooldown * wp.getCooldownModifier()));
    Utils.playGlobalSound(location, "mage.healingrain.impact", 2, 1);
    CircleEffect circleEffect = new CircleEffect(wp.getGame(), wp.getTeam(), location, radius, new CircumferenceEffect(ParticleEffect.VILLAGER_HAPPY, ParticleEffect.REDSTONE), new AreaEffect(5, ParticleEffect.CLOUD).particlesPerSurface(0.025), new AreaEffect(5, ParticleEffect.DRIP_WATER).particlesPerSurface(0.025));
    BukkitTask task = wp.getGame().registerGameTask(circleEffect::playEffects, 0, 1);
    location.add(0, 1, 0);
    BukkitTask rainSneakAbility = new GameRunnable(wp.getGame()) {

        boolean wasSneaking = false;

        @Override
        public void run() {
            if (wp.isAlive() && wp.isSneaking() && !wasSneaking) {
                wp.playSound(wp.getLocation(), "mage.timewarp.teleport", 2, 1.35f);
                wp.sendMessage(WarlordsPlayer.RECEIVE_ARROW + " §7You moved your §aHealing Rain §7to your current location.");
                location.setX(wp.getLocation().getX());
                location.setY(wp.getLocation().getY());
                location.setZ(wp.getLocation().getZ());
            }
            wasSneaking = wp.isSneaking();
        }
    }.runTaskTimer(0, 0);
    new GameRunnable(wp.getGame()) {

        int counter = 0;

        int timeLeft = duration;

        @Override
        public void run() {
            if (counter % 10 == 0) {
                for (WarlordsPlayer teammateInRain : PlayerFilter.entitiesAround(location, radius, radius, radius).aliveTeammatesOf(wp)) {
                    teammateInRain.addHealingInstance(wp, name, minDamageHeal, maxDamageHeal, critChance, critMultiplier, false, false);
                    if (teammateInRain != wp) {
                        teammateInRain.getCooldownManager().removeCooldown(Overheal.OVERHEAL_MARKER);
                        teammateInRain.getCooldownManager().addRegularCooldown("Overheal", "OVERHEAL", Overheal.class, Overheal.OVERHEAL_MARKER, wp, CooldownTypes.BUFF, cooldownManager -> {
                        }, Overheal.OVERHEAL_DURATION * 20);
                    }
                }
                if (timeLeft < 0) {
                    this.cancel();
                    task.cancel();
                    rainSneakAbility.cancel();
                }
            }
            if (counter % 20 == 0) {
                timeLeft--;
            }
            counter--;
        }
    }.runTaskTimer(0, 0);
    return true;
}
Also used : Overheal(com.ebicep.warlords.abilties.internal.Overheal) Utils(com.ebicep.warlords.util.warlords.Utils) GameRunnable(com.ebicep.warlords.util.warlords.GameRunnable) CircumferenceEffect(com.ebicep.warlords.effects.circle.CircumferenceEffect) Set(java.util.Set) CooldownTypes(com.ebicep.warlords.player.cooldowns.CooldownTypes) Player(org.bukkit.entity.Player) PlayerFilter(com.ebicep.warlords.util.warlords.PlayerFilter) Location(org.bukkit.Location) WarlordsPlayer(com.ebicep.warlords.player.WarlordsPlayer) BukkitTask(org.bukkit.scheduler.BukkitTask) AreaEffect(com.ebicep.warlords.effects.circle.AreaEffect) CircleEffect(com.ebicep.warlords.effects.circle.CircleEffect) AbstractAbility(com.ebicep.warlords.classes.AbstractAbility) ParticleEffect(com.ebicep.warlords.effects.ParticleEffect) Material(org.bukkit.Material) AreaEffect(com.ebicep.warlords.effects.circle.AreaEffect) WarlordsPlayer(com.ebicep.warlords.player.WarlordsPlayer) BukkitTask(org.bukkit.scheduler.BukkitTask) Material(org.bukkit.Material) CircumferenceEffect(com.ebicep.warlords.effects.circle.CircumferenceEffect) Overheal(com.ebicep.warlords.abilties.internal.Overheal) GameRunnable(com.ebicep.warlords.util.warlords.GameRunnable) CircleEffect(com.ebicep.warlords.effects.circle.CircleEffect) Location(org.bukkit.Location)

Aggregations

Overheal (com.ebicep.warlords.abilties.internal.Overheal)2 BukkitTaskChainFactory (co.aikar.taskchain.BukkitTaskChainFactory)1 TaskChain (co.aikar.taskchain.TaskChain)1 TaskChainFactory (co.aikar.taskchain.TaskChainFactory)1 PacketType (com.comphenix.protocol.PacketType)1 ProtocolLibrary (com.comphenix.protocol.ProtocolLibrary)1 ProtocolManager (com.comphenix.protocol.ProtocolManager)1 ListenerPriority (com.comphenix.protocol.events.ListenerPriority)1 PacketAdapter (com.comphenix.protocol.events.PacketAdapter)1 PacketEvent (com.comphenix.protocol.events.PacketEvent)1 NPCManager (com.ebicep.customentities.npc.NPCManager)1 BotCommands (com.ebicep.jda.BotCommands)1 BotListener (com.ebicep.jda.BotListener)1 BotManager (com.ebicep.jda.BotManager)1 com.ebicep.warlords.abilties (com.ebicep.warlords.abilties)1 EnergyPowerup (com.ebicep.warlords.abilties.internal.EnergyPowerup)1 HealingPowerup (com.ebicep.warlords.abilties.internal.HealingPowerup)1 AbstractAbility (com.ebicep.warlords.classes.AbstractAbility)1 Apothecary (com.ebicep.warlords.classes.rogue.specs.Apothecary)1 com.ebicep.warlords.commands.debugcommands (com.ebicep.warlords.commands.debugcommands)1