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;
}
Aggregations