Search in sources :

Example 46 with GameRunnable

use of com.ebicep.warlords.util.warlords.GameRunnable in project Warlords by ebicep.

the class HolyRadianceProtector method chain.

@Override
public void chain(WarlordsPlayer wp, Player player) {
    for (WarlordsPlayer markTarget : PlayerFilter.entitiesAround(player, markRadius, markRadius, markRadius).aliveTeammatesOfExcludingSelf(wp).lookingAtFirst(wp).limit(1)) {
        if (Utils.isLookingAtMark(player, markTarget.getEntity()) && Utils.hasLineOfSight(player, markTarget.getEntity())) {
            wp.subtractEnergy(energyCost);
            for (WarlordsPlayer healTarget : PlayerFilter.playingGame(wp.getGame()).excluding(getPlayersHit()).aliveTeammatesOf(wp)) {
                markTarget.addHealingInstance(wp, name, minDamageHeal, maxDamageHeal, critChance, critMultiplier, false, false);
            }
            Utils.playGlobalSound(player.getLocation(), "paladin.consecrate.activation", 2, 0.65f);
            PacketPlayOutAnimation playOutAnimation = new PacketPlayOutAnimation(((CraftPlayer) player).getHandle(), 0);
            ((CraftPlayer) player).getHandle().playerConnection.sendPacket(playOutAnimation);
            // chain particles
            EffectUtils.playParticleLinkAnimation(player.getLocation(), markTarget.getLocation(), 0, 255, 70, 1);
            EffectUtils.playChainAnimation(wp.getLocation(), markTarget.getLocation(), new ItemStack(Material.RED_ROSE), 8);
            HolyRadianceProtector tempMark = new HolyRadianceProtector(minDamageHeal, maxDamageHeal, cooldown, energyCost, critChance, critMultiplier);
            markTarget.getCooldownManager().addRegularCooldown(name, "PROT MARK", HolyRadianceProtector.class, tempMark, wp, CooldownTypes.BUFF, cooldownManager -> {
                ParticleEffect.SPELL.display(1, 1, 1, 0.06F, 12, markTarget.getLocation(), 500);
                Utils.playGlobalSound(markTarget.getLocation(), "paladin.holyradiance.activation", 2, 0.95f);
                for (WarlordsPlayer waveTarget : PlayerFilter.entitiesAround(markTarget, 6, 6, 6).aliveTeammatesOf(markTarget)) {
                    wp.getGame().registerGameTask(new FlyingArmorStand(markTarget.getLocation(), waveTarget, wp, 1.1, minDamageHeal * 0.5f, maxDamageHeal * 0.5f).runTaskTimer(Warlords.getInstance(), 1, 1));
                }
            }, markDuration * 20);
            player.sendMessage(WarlordsPlayer.RECEIVE_ARROW + ChatColor.GRAY + " You have marked " + ChatColor.GREEN + markTarget.getName() + ChatColor.GRAY + "!");
            markTarget.sendMessage(WarlordsPlayer.RECEIVE_ARROW + ChatColor.GRAY + " You have been granted " + ChatColor.GREEN + "Protector's Mark" + ChatColor.GRAY + " by " + wp.getName() + "!");
            new GameRunnable(wp.getGame()) {

                @Override
                public void run() {
                    if (markTarget.getCooldownManager().hasCooldown(tempMark)) {
                        Location playerLoc = markTarget.getLocation();
                        Location particleLoc = playerLoc.clone();
                        for (int i = 0; i < 4; i++) {
                            for (int j = 0; j < 10; j++) {
                                double angle = j / 9D * Math.PI * 2;
                                double width = 1;
                                particleLoc.setX(playerLoc.getX() + Math.sin(angle) * width);
                                particleLoc.setY(playerLoc.getY() + i / 6D);
                                particleLoc.setZ(playerLoc.getZ() + Math.cos(angle) * width);
                                ParticleEffect.REDSTONE.display(new ParticleEffect.OrdinaryColor(0, 255, 70), particleLoc, 500);
                            }
                        }
                    } else {
                        this.cancel();
                    }
                }
            }.runTaskTimer(0, 10);
        } else {
            player.sendMessage("§cYour mark was out of range or you did not target a player!");
        }
    }
}
Also used : WarlordsPlayer(com.ebicep.warlords.player.WarlordsPlayer) GameRunnable(com.ebicep.warlords.util.warlords.GameRunnable) CraftPlayer(org.bukkit.craftbukkit.v1_8_R3.entity.CraftPlayer) ItemStack(org.bukkit.inventory.ItemStack) PacketPlayOutAnimation(net.minecraft.server.v1_8_R3.PacketPlayOutAnimation) Location(org.bukkit.Location)

Example 47 with GameRunnable

use of com.ebicep.warlords.util.warlords.GameRunnable in project Warlords by ebicep.

the class IceBarrier method onActivate.

@Override
public boolean onActivate(WarlordsPlayer wp, Player player) {
    IceBarrier tempIceBarrier = new IceBarrier(damageReductionPercent);
    wp.getCooldownManager().addCooldown(new RegularCooldown<IceBarrier>(name, "ICE", IceBarrier.class, tempIceBarrier, wp, CooldownTypes.ABILITY, cooldownManager -> {
    }, duration * 20) {

        @Override
        public float modifyDamageAfterInterveneFromSelf(WarlordsDamageHealingEvent event, float currentDamageValue) {
            float newDamageValue = currentDamageValue * getDamageReduction();
            event.getPlayer().addAbsorbed(Math.abs(currentDamageValue - newDamageValue));
            return newDamageValue;
        }
    });
    Utils.playGlobalSound(player.getLocation(), "mage.icebarrier.activation", 2, 1);
    new GameRunnable(wp.getGame()) {

        @Override
        public void run() {
            if (wp.getCooldownManager().hasCooldown(tempIceBarrier)) {
                Location location = wp.getLocation();
                location.add(0, 1.5, 0);
                ParticleEffect.CLOUD.display(0.2F, 0.2F, 0.2F, 0.001F, 1, location, 500);
                ParticleEffect.FIREWORKS_SPARK.display(0.3F, 0.2F, 0.3F, 0.0001F, 1, location, 500);
            } else {
                this.cancel();
            }
        }
    }.runTaskTimer(0, 5);
    return true;
}
Also used : Utils(com.ebicep.warlords.util.warlords.Utils) GameRunnable(com.ebicep.warlords.util.warlords.GameRunnable) RegularCooldown(com.ebicep.warlords.player.cooldowns.cooldowns.RegularCooldown) Location(org.bukkit.Location) WarlordsPlayer(com.ebicep.warlords.player.WarlordsPlayer) CooldownTypes(com.ebicep.warlords.player.cooldowns.CooldownTypes) Player(org.bukkit.entity.Player) AbstractAbility(com.ebicep.warlords.classes.AbstractAbility) WarlordsDamageHealingEvent(com.ebicep.warlords.events.WarlordsDamageHealingEvent) ParticleEffect(com.ebicep.warlords.effects.ParticleEffect) GameRunnable(com.ebicep.warlords.util.warlords.GameRunnable) WarlordsDamageHealingEvent(com.ebicep.warlords.events.WarlordsDamageHealingEvent) Location(org.bukkit.Location)

Example 48 with GameRunnable

use of com.ebicep.warlords.util.warlords.GameRunnable in project Warlords by ebicep.

the class Intervene method onActivate.

@Override
public boolean onActivate(@Nonnull WarlordsPlayer wp, @Nonnull Player player) {
    setDamagePrevented(0);
    for (WarlordsPlayer vt : PlayerFilter.entitiesAround(wp, radius, radius, radius).aliveTeammatesOfExcludingSelf(wp).requireLineOfSightIntervene(wp).lookingAtFirst(wp).limit(1)) {
        // Green line / Sound
        EffectUtils.playParticleLinkAnimation(wp.getLocation(), vt.getLocation(), ParticleEffect.VILLAGER_HAPPY);
        Utils.playGlobalSound(wp.getLocation(), "warrior.intervene.impact", 1, 1);
        // New cooldown, both players have the same instance of intervene.
        Intervene tempIntervene = new Intervene();
        // Removing all other intervenes
        wp.getCooldownManager().getCooldowns().removeIf(cd -> cd.getCooldownClass() == Intervene.class && vt.getCooldownManager().hasCooldown(cd.getCooldownObject()));
        vt.getCooldownManager().getCooldowns().removeIf(cd -> {
            if (cd.getCooldownClass() == Intervene.class) {
                cd.getFrom().sendMessage(WarlordsPlayer.GIVE_ARROW + " " + cd.getFrom().getName() + "'s " + ChatColor.YELLOW + "Intervene " + ChatColor.GRAY + "has expired!");
                vt.sendMessage(WarlordsPlayer.GIVE_ARROW + " " + cd.getFrom().getName() + "'s " + ChatColor.YELLOW + "Intervene " + ChatColor.GRAY + "has expired!");
                return true;
            } else {
                return false;
            }
        });
        wp.sendMessage(WarlordsPlayer.RECEIVE_ARROW + "§7 You are now protecting " + vt.getName() + " with your §eIntervene!");
        wp.getCooldownManager().addRegularCooldown(name, "VENE", Intervene.class, tempIntervene, wp, CooldownTypes.ABILITY, cooldownManager -> {
        }, duration * 20);
        vt.sendMessage(WarlordsPlayer.RECEIVE_ARROW + "§7 " + wp.getName() + " is shielding you with their " + ChatColor.YELLOW + "Intervene" + ChatColor.GRAY + "!");
        vt.getCooldownManager().addRegularCooldown(name, "VENE", Intervene.class, tempIntervene, wp, CooldownTypes.ABILITY, cooldownManager -> {
        }, duration * 20);
        wp.getSpec().getBlue().setCurrentCooldown((float) (cooldown * wp.getCooldownModifier()));
        wp.updateBlueItem();
        wp.subtractEnergy(energyCost);
        new GameRunnable(wp.getGame()) {

            @Override
            public void run() {
                Optional<RegularCooldown> optionalRegularCooldown = new CooldownFilter<>(vt, RegularCooldown.class).filterCooldownObject(tempIntervene).findFirst();
                if (optionalRegularCooldown.isPresent()) {
                    RegularCooldown interveneRegularCooldown = optionalRegularCooldown.get();
                    if (interveneRegularCooldown.getTicksLeft() <= 20)
                        vt.sendMessage(WarlordsPlayer.RECEIVE_ARROW + " " + ChatColor.GRAY + wp.getName() + "'s §eIntervene §7will expire in §6" + (int) (interveneRegularCooldown.getTicksLeft() / 20 + .5) + "§7 second!");
                    else
                        vt.sendMessage(WarlordsPlayer.RECEIVE_ARROW + " " + ChatColor.GRAY + wp.getName() + "'s §eIntervene §7will expire in §6" + (int) (interveneRegularCooldown.getTicksLeft() / 20 + .5) + "§7 seconds!");
                } else {
                    this.cancel();
                }
            }
        }.runTaskTimer(0, 20);
        new GameRunnable(wp.getGame()) {

            @Override
            public void run() {
                Optional<RegularCooldown> optionalRegularCooldown = new CooldownFilter<>(vt, RegularCooldown.class).filterCooldownObject(tempIntervene).findFirst();
                if (wp.isDead() || tempIntervene.damagePrevented >= (maxDamagePrevented / 2) || !optionalRegularCooldown.isPresent() || vt.getLocation().distanceSquared(optionalRegularCooldown.get().getFrom().getEntity().getLocation()) > breakRadius * breakRadius) {
                    wp.sendMessage(WarlordsPlayer.GIVE_ARROW + " " + ChatColor.GRAY + wp.getName() + "'s " + ChatColor.YELLOW + "Intervene " + ChatColor.GRAY + "has expired!");
                    wp.getCooldownManager().removeCooldown(tempIntervene);
                    vt.sendMessage(WarlordsPlayer.GIVE_ARROW + " " + ChatColor.GRAY + wp.getName() + "'s " + ChatColor.YELLOW + "Intervene " + ChatColor.GRAY + "has expired!");
                    vt.getCooldownManager().removeCooldown(tempIntervene);
                    this.cancel();
                }
            }
        }.runTaskTimer(0, 0);
        return true;
    }
    return false;
}
Also used : RegularCooldown(com.ebicep.warlords.player.cooldowns.cooldowns.RegularCooldown) WarlordsPlayer(com.ebicep.warlords.player.WarlordsPlayer) GameRunnable(com.ebicep.warlords.util.warlords.GameRunnable) Optional(java.util.Optional)

Example 49 with GameRunnable

use of com.ebicep.warlords.util.warlords.GameRunnable in project Warlords by ebicep.

the class LightInfusion method onActivate.

@Override
public boolean onActivate(WarlordsPlayer wp, Player player) {
    wp.subtractEnergy(energyCost);
    Runnable cancelSpeed = wp.getSpeed().addSpeedModifier("Infusion", speedBuff, duration * 20, "BASE");
    LightInfusion tempLightInfusion = new LightInfusion(cooldown, energyCost);
    wp.getCooldownManager().addRegularCooldown(name, "INF", LightInfusion.class, tempLightInfusion, wp, CooldownTypes.ABILITY, cooldownManager -> {
    }, duration * 20);
    Utils.playGlobalSound(player.getLocation(), "paladin.infusionoflight.activation", 2, 1);
    for (int i = 0; i < 10; i++) {
        Location particleLoc = player.getLocation().add(0, 1.5, 0);
        ParticleEffect.SPELL.display(1, 0F, 1, 0.3F, 3, particleLoc, 500);
    }
    new GameRunnable(wp.getGame()) {

        @Override
        public void run() {
            if (wp.getCooldownManager().hasCooldown(tempLightInfusion)) {
                Location location = wp.getLocation();
                location.add(0, 1.2, 0);
                ParticleEffect.SPELL.display(0.3F, 0.1F, 0.3F, 0.2F, 2, location, 500);
            } else {
                cancelSpeed.run();
                this.cancel();
            }
        }
    }.runTaskTimer(0, 4);
    return true;
}
Also used : GameRunnable(com.ebicep.warlords.util.warlords.GameRunnable) GameRunnable(com.ebicep.warlords.util.warlords.GameRunnable) Location(org.bukkit.Location)

Example 50 with GameRunnable

use of com.ebicep.warlords.util.warlords.GameRunnable in project Warlords by ebicep.

the class InterchangeModeOption method start.

@Override
public void start(@Nonnull Game game) {
    // saving player info as it will be modified during the game
    game.getPlayers().forEach((uuid, team) -> {
        PlayerSettings playerSettings = Warlords.getPlayerSettings(uuid);
        previousSelectedClasses.put(uuid, playerSettings.getSelectedClass());
        previousSelectedSkillBoosts.put(uuid, playerSettings.getClassesSkillBoosts());
        previousSelectedWeaponSkins.put(uuid, playerSettings.getWeaponSkins());
        previousSelectedHelmets.put(uuid, ArmorManager.Helmets.getSelected(uuid));
        previousSelectedArmorSets.put(uuid, ArmorManager.ArmorSets.getSelected(uuid));
    });
    generateNextSwapTime();
    new GameRunnable(game) {

        int secondsPast = 0;

        @Override
        public void run() {
            if (game.getState() instanceof EndState) {
                return;
            }
            if (secondsPast >= secondsUntilNextSwap) {
                swap(game);
                generateNextSwapTime();
                secondsPast = 0;
            }
            secondsPast++;
        }
    }.runTaskTimer(GameRunnable.SECOND, GameRunnable.SECOND);
}
Also used : GameRunnable(com.ebicep.warlords.util.warlords.GameRunnable) EndState(com.ebicep.warlords.game.state.EndState)

Aggregations

GameRunnable (com.ebicep.warlords.util.warlords.GameRunnable)53 WarlordsPlayer (com.ebicep.warlords.player.WarlordsPlayer)39 Location (org.bukkit.Location)34 Player (org.bukkit.entity.Player)23 Utils (com.ebicep.warlords.util.warlords.Utils)21 CooldownTypes (com.ebicep.warlords.player.cooldowns.CooldownTypes)17 AbstractAbility (com.ebicep.warlords.classes.AbstractAbility)16 ParticleEffect (com.ebicep.warlords.effects.ParticleEffect)16 RegularCooldown (com.ebicep.warlords.player.cooldowns.cooldowns.RegularCooldown)16 PlayerFilter (com.ebicep.warlords.util.warlords.PlayerFilter)16 WarlordsDamageHealingEvent (com.ebicep.warlords.events.WarlordsDamageHealingEvent)13 ItemStack (org.bukkit.inventory.ItemStack)13 ArmorStand (org.bukkit.entity.ArmorStand)12 Vector (org.bukkit.util.Vector)11 ChatColor (org.bukkit.ChatColor)10 Material (org.bukkit.Material)10 Warlords (com.ebicep.warlords.Warlords)9 ArrayList (java.util.ArrayList)9 List (java.util.List)9 Nonnull (javax.annotation.Nonnull)9