Search in sources :

Example 16 with GameRunnable

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

the class SoulShackle method onActivate.

@Override
public boolean onActivate(@Nonnull WarlordsPlayer wp, @Nonnull Player player) {
    SoulShackle tempSoulShackle = new SoulShackle();
    for (WarlordsPlayer shackleTarget : PlayerFilter.entitiesAround(wp, shackleRange, shackleRange, shackleRange).aliveEnemiesOf(wp).requireLineOfSight(wp).limit(maxShackleTargets)) {
        wp.getSpeed().addSpeedModifier("Shacke Speed", 40, 30, "BASE");
        wp.subtractEnergy(energyCost);
        wp.sendMessage(WarlordsPlayer.RECEIVE_ARROW + ChatColor.GRAY + " You shackled " + ChatColor.YELLOW + shackleTarget.getName() + ChatColor.GRAY + "!");
        int silenceDuration = minSilenceDurationInTicks + (int) (shacklePool / 1000) * 20;
        if (silenceDuration > maxSilenceDurationInTicks) {
            silenceDuration = maxSilenceDurationInTicks;
        }
        System.out.println(minSilenceDurationInTicks);
        System.out.println(maxSilenceDurationInTicks);
        System.out.println(silenceDuration);
        shackleTarget.addDamageInstance(wp, name, minDamageHeal, maxDamageHeal, critChance, critMultiplier, false);
        shackleTarget.getCooldownManager().removeCooldown(SoulShackle.class);
        shackleTarget.getCooldownManager().addRegularCooldown("Shackle Silence", "SILENCE", SoulShackle.class, tempSoulShackle, wp, CooldownTypes.DEBUFF, cooldownManager -> {
        }, silenceDuration);
        shacklePool = 0;
        Utils.playGlobalSound(player.getLocation(), "warrior.intervene.impact", 1.5f, 0.45f);
        Utils.playGlobalSound(player.getLocation(), "mage.fireball.activation", 1.5f, 0.3f);
        EffectUtils.playChainAnimation(wp, shackleTarget, new ItemStack(Material.PUMPKIN), 20);
        new GameRunnable(wp.getGame()) {

            @Override
            public void run() {
                if (shackleTarget.getCooldownManager().hasCooldown(tempSoulShackle)) {
                    Location playerLoc = shackleTarget.getLocation();
                    Location particleLoc = playerLoc.clone();
                    for (int i = 0; i < 10; i++) {
                        for (int j = 0; j < 10; j++) {
                            double angle = j / 10D * Math.PI * 2;
                            double width = 1.075;
                            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(25, 25, 25), particleLoc, 500);
                        }
                    }
                    Utils.playGlobalSound(shackleTarget.getLocation(), Sound.DIG_SAND, 2, 2);
                } else {
                    this.cancel();
                }
            }
        }.runTaskTimer(0, 10);
        return true;
    }
    return false;
}
Also used : WarlordsPlayer(com.ebicep.warlords.player.WarlordsPlayer) GameRunnable(com.ebicep.warlords.util.warlords.GameRunnable) ItemStack(org.bukkit.inventory.ItemStack) Location(org.bukkit.Location)

Example 17 with GameRunnable

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

the class Soulbinding method onActivate.

@Override
public boolean onActivate(WarlordsPlayer wp, Player player) {
    wp.subtractEnergy(energyCost);
    Soulbinding tempSoulBinding = new Soulbinding();
    wp.getCooldownManager().addPersistentCooldown(name, "SOUL", Soulbinding.class, tempSoulBinding, wp, CooldownTypes.ABILITY, cooldownManager -> {
        if (new CooldownFilter<>(cooldownManager, PersistentCooldown.class).filterCooldownClass(Soulbinding.class).stream().count() == 1) {
            if (wp.getEntity() instanceof Player) {
                ((Player) wp.getEntity()).getInventory().getItem(0).removeEnchantment(Enchantment.OXYGEN);
            }
        }
    }, duration * 20, soulbinding -> soulbinding.getSoulBindedPlayers().isEmpty());
    ItemMeta newItemMeta = player.getInventory().getItem(0).getItemMeta();
    newItemMeta.addEnchant(Enchantment.OXYGEN, 1, true);
    player.getInventory().getItem(0).setItemMeta(newItemMeta);
    Utils.playGlobalSound(player.getLocation(), "paladin.consecrate.activation", 2, 2);
    new GameRunnable(wp.getGame()) {

        @Override
        public void run() {
            if (wp.getCooldownManager().hasCooldown(tempSoulBinding)) {
                Location location = wp.getLocation();
                location.add(0, 1.2, 0);
                ParticleEffect.SPELL_WITCH.display(0.2F, 0F, 0.2F, 0.1F, 1, location, 500);
            } else {
                this.cancel();
            }
        }
    }.runTaskTimer(0, 4);
    return true;
}
Also used : CooldownFilter(com.ebicep.warlords.player.cooldowns.CooldownFilter) Player(org.bukkit.entity.Player) WarlordsPlayer(com.ebicep.warlords.player.WarlordsPlayer) GameRunnable(com.ebicep.warlords.util.warlords.GameRunnable) ItemMeta(org.bukkit.inventory.meta.ItemMeta) Location(org.bukkit.Location)

Example 18 with GameRunnable

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

the class VitalityLiquor method onActivate.

@Override
public boolean onActivate(@Nonnull WarlordsPlayer wp, @Nonnull Player player) {
    VitalityLiquor tempVitalityLiquor = new VitalityLiquor();
    wp.subtractEnergy(energyCost);
    wp.addHealingInstance(wp, name, minDamageHeal, maxDamageHeal, critChance, critMultiplier, false, false);
    Utils.playGlobalSound(player.getLocation(), Sound.GLASS, 2, 0.1f);
    Utils.playGlobalSound(player.getLocation(), Sound.BLAZE_DEATH, 2, 0.7f);
    new FallingBlockWaveEffect(player.getLocation(), 7, 1, Material.SAPLING, (byte) 2).play();
    for (WarlordsPlayer acuTarget : PlayerFilter.entitiesAround(player, acuRange, acuRange, acuRange).aliveTeammatesOfExcludingSelf(wp)) {
        acuTarget.addHealingInstance(wp, name, minDamageHeal, maxDamageHeal, critChance, critMultiplier, false, false);
    }
    for (WarlordsPlayer enemyTarget : PlayerFilter.entitiesAround(player, acuRange, acuRange, acuRange).aliveEnemiesOf(wp)) {
        new CooldownFilter<>(enemyTarget, RegularCooldown.class).filterCooldownClass(ImpalingStrike.class).filterCooldownFrom(wp).findAny().ifPresent(regularCooldown -> {
            Utils.playGlobalSound(enemyTarget.getLocation(), Sound.GLASS, 2, 0.6f);
            new GameRunnable(wp.getGame()) {

                @Override
                public void run() {
                    for (WarlordsPlayer allyTarget : PlayerFilter.entitiesAround(player, 6, 6, 6).aliveTeammatesOf(wp).limit(2)) {
                        allyTarget.addHealingInstance(wp, name, minWaveHealing, maxWaveHealing, critChance, critMultiplier, false, false);
                        allyTarget.getCooldownManager().removeCooldown(VitalityLiquor.class);
                        allyTarget.getCooldownManager().addRegularCooldown("Vitality Liquor", "VITAL", VitalityLiquor.class, tempVitalityLiquor, wp, CooldownTypes.BUFF, cooldownManager -> {
                        }, duration * 20);
                    }
                }
            }.runTaskLater(5);
            FireWorkEffectPlayer.playFirework(enemyTarget.getLocation(), FireworkEffect.builder().withColor(Color.ORANGE).with(FireworkEffect.Type.STAR).build());
            new GameRunnable(wp.getGame()) {

                @Override
                public void run() {
                    if (wp.getCooldownManager().hasCooldown(tempVitalityLiquor)) {
                        EffectUtils.playParticleLinkAnimation(wp.getLocation(), enemyTarget.getLocation(), 255, 170, 0, 1);
                    } else {
                        this.cancel();
                    }
                }
            }.runTaskTimer(0, 5);
        });
    }
    return true;
}
Also used : EffectUtils(com.ebicep.warlords.effects.EffectUtils) Utils(com.ebicep.warlords.util.warlords.Utils) GameRunnable(com.ebicep.warlords.util.warlords.GameRunnable) FireworkEffect(org.bukkit.FireworkEffect) CooldownTypes(com.ebicep.warlords.player.cooldowns.CooldownTypes) Sound(org.bukkit.Sound) Player(org.bukkit.entity.Player) FireWorkEffectPlayer(com.ebicep.warlords.effects.FireWorkEffectPlayer) PlayerFilter(com.ebicep.warlords.util.warlords.PlayerFilter) RegularCooldown(com.ebicep.warlords.player.cooldowns.cooldowns.RegularCooldown) WarlordsPlayer(com.ebicep.warlords.player.WarlordsPlayer) CooldownFilter(com.ebicep.warlords.player.cooldowns.CooldownFilter) AbstractAbility(com.ebicep.warlords.classes.AbstractAbility) Color(org.bukkit.Color) Nonnull(javax.annotation.Nonnull) Material(org.bukkit.Material) FallingBlockWaveEffect(com.ebicep.warlords.effects.FallingBlockWaveEffect) CooldownFilter(com.ebicep.warlords.player.cooldowns.CooldownFilter) WarlordsPlayer(com.ebicep.warlords.player.WarlordsPlayer) GameRunnable(com.ebicep.warlords.util.warlords.GameRunnable) FallingBlockWaveEffect(com.ebicep.warlords.effects.FallingBlockWaveEffect)

Example 19 with GameRunnable

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

the class Game method start.

public void start() {
    if (state != null) {
        throw new IllegalStateException("Game already started");
    }
    for (GameAddon addon : addons) {
        addon.modifyGame(this);
    }
    this.options = Collections.unmodifiableList(options);
    state = this.map.initialState(this);
    for (Option option : options) {
        option.register(this);
    }
    for (Team team : TeamMarker.getTeams(this)) {
        this.points.put(team, 0);
    }
    state.begin();
    for (GameAddon addon : addons) {
        addon.stateHasChanged(this, null, state);
    }
    new GameRunnable(this) {

        @Override
        public void run() {
            Game.this.run();
        }
    }.runTaskTimer(0, 1);
// this.printDebuggingInformation();
}
Also used : GameRunnable(com.ebicep.warlords.util.warlords.GameRunnable) Option(com.ebicep.warlords.game.option.Option)

Example 20 with GameRunnable

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

the class BasicScoreboardOption method getDateScoreboard.

private static SimpleScoreboardHandler getDateScoreboard(Game game) {
    SimpleDateFormat format = new SimpleDateFormat("MM/dd/yyyy - kk:mm");
    format.setTimeZone(TimeZone.getTimeZone("EST"));
    SimpleScoreboardHandler simpleScoreboardHandler = new SimpleScoreboardHandler(0, "date") {

        @Nonnull
        @Override
        public List<String> computeLines(@Nullable WarlordsPlayer player) {
            return Collections.singletonList(ChatColor.GRAY + format.format(new Date()));
        }
    };
    new GameRunnable(game) {

        @Override
        public void run() {
            simpleScoreboardHandler.markChanged();
        }
    }.runTaskTimer(GameRunnable.SECOND, GameRunnable.SECOND);
    return simpleScoreboardHandler;
}
Also used : WarlordsPlayer(com.ebicep.warlords.player.WarlordsPlayer) GameRunnable(com.ebicep.warlords.util.warlords.GameRunnable) SimpleScoreboardHandler(com.ebicep.warlords.game.option.marker.scoreboard.SimpleScoreboardHandler) SimpleDateFormat(java.text.SimpleDateFormat) Nullable(javax.annotation.Nullable) Date(java.util.Date)

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