use of com.ebicep.warlords.util.bukkit.LocationBuilder in project Warlords by ebicep.
the class ChainLightning method lookingAtTotem.
private boolean lookingAtTotem(@Nonnull LivingEntity player) {
Location eye = new LocationBuilder(player.getEyeLocation()).addY(.5).backward(1).get();
// eye.setY(eye.getY() + .5);
for (Entity entity : player.getNearbyEntities(20, 17, 20)) {
if (entity instanceof ArmorStand && entity.hasMetadata("capacitor-totem-" + player.getName().toLowerCase())) {
Vector toEntity = ((ArmorStand) entity).getEyeLocation().add(0, 1, 0).toVector().subtract(eye.toVector());
float dot = (float) toEntity.normalize().dot(eye.getDirection());
return dot > .93f;
}
}
return false;
}
use of com.ebicep.warlords.util.bukkit.LocationBuilder in project Warlords by ebicep.
the class OrbsOfLife method onActivate.
@Override
public boolean onActivate(WarlordsPlayer wp, Player player) {
wp.subtractEnergy(energyCost);
OrbsOfLife tempOrbsOfLight = new OrbsOfLife();
wp.getCooldownManager().addCooldown(new PersistentCooldown<OrbsOfLife>(name, "ORBS", OrbsOfLife.class, tempOrbsOfLight, wp, CooldownTypes.ABILITY, cooldownManager -> {
}, duration * 20, orbsOfLife -> orbsOfLife.getSpawnedOrbs().isEmpty()) {
@Override
public void onInterveneFromAttacker(WarlordsDamageHealingEvent event, float currentDamageValue) {
spawnOrbs(event.getPlayer(), event.getAbility(), this);
if (event.getAbility().equals("Crippling Strike")) {
spawnOrbs(event.getPlayer(), event.getAbility(), this);
}
}
@Override
public void onShieldFromAttacker(WarlordsDamageHealingEvent event, float currentDamageValue, boolean isCrit) {
spawnOrbs(event.getPlayer(), event.getAbility(), this);
if (event.getAbility().equals("Crippling Strike")) {
spawnOrbs(event.getPlayer(), event.getAbility(), this);
}
}
@Override
public void onDamageFromAttacker(WarlordsDamageHealingEvent event, float currentDamageValue, boolean isCrit) {
spawnOrbs(event.getPlayer(), event.getAbility(), this);
if (event.getAbility().equals("Crippling Strike")) {
spawnOrbs(event.getPlayer(), event.getAbility(), this);
}
}
});
tempOrbsOfLight.getSpawnedOrbs().add(new Orb(((CraftWorld) player.getLocation().getWorld()).getHandle(), generateSpawnLocation(player.getLocation()), wp));
tempOrbsOfLight.getSpawnedOrbs().add(new Orb(((CraftWorld) player.getLocation().getWorld()).getHandle(), generateSpawnLocation(player.getLocation()), wp));
Utils.playGlobalSound(player.getLocation(), "warrior.revenant.orbsoflife", 2, 1);
new GameRunnable(wp.getGame()) {
int counter = 0;
boolean wasSneaking = false;
@Override
public void run() {
counter++;
if (wp.isAlive() && wp.isSneaking() && !wasSneaking) {
// setting target player to move towards (includes self)
tempOrbsOfLight.getSpawnedOrbs().forEach(orb -> orb.setPlayerToMoveTowards(PlayerFilter.entitiesAround(orb.armorStand.getLocation(), floatingOrbRadius, floatingOrbRadius, floatingOrbRadius).aliveTeammatesOf(wp).closestFirst(orb.getArmorStand().getLocation()).findFirstOrNull()));
// moving orb
new GameRunnable(wp.getGame()) {
@Override
public void run() {
tempOrbsOfLight.getSpawnedOrbs().stream().filter(orb -> orb.getPlayerToMoveTowards() != null).forEach(targetOrb -> {
WarlordsPlayer target = targetOrb.getPlayerToMoveTowards();
ArmorStand orbArmorStand = targetOrb.getArmorStand();
Location orbLocation = orbArmorStand.getLocation();
Entity orb = orbArmorStand.getPassenger();
// must eject passenger then reassign it before teleporting bc ???
orbArmorStand.eject();
orbArmorStand.teleport(new LocationBuilder(orbLocation.clone()).add(target.getLocation().toVector().subtract(orbLocation.toVector()).normalize().multiply(1)).get());
orbArmorStand.setPassenger(orb);
ParticleEffect.VILLAGER_HAPPY.display(0, 0, 0, 0, 1, orbArmorStand.getLocation().add(0, 1.65, 0), 500);
});
if (tempOrbsOfLight.getSpawnedOrbs().stream().noneMatch(orb -> orb.getPlayerToMoveTowards() != null)) {
this.cancel();
}
}
}.runTaskTimer(0, 1);
wp.sendMessage(WarlordsPlayer.RECEIVE_ARROW + ChatColor.GRAY + " Your current " + ChatColor.GREEN + name + ChatColor.GRAY + " will now levitate towards you or a teammate!");
Utils.playGlobalSound(wp.getLocation(), Sound.LEVEL_UP, 0.08f, 0.7f);
ParticleEffect.ENCHANTMENT_TABLE.display(0.8f, 0, 0.8f, 0.2f, 10, wp.getLocation().add(0, 1.5, 0), 500);
}
wasSneaking = player.isSneaking();
if (counter >= 20 * duration || wp.isDead()) {
this.cancel();
}
}
}.runTaskTimer(0, 0);
return true;
}
Aggregations