private boolean moveEarth() { progress++; Block affectedblock = location.clone().add(direction).getBlock(); location = location.add(direction); if (GeneralMethods.isRegionProtectedFromBuild(player, "IceSpike", location)) return false; for (Entity en : GeneralMethods.getEntitiesAroundPoint(location, 1.4)) { if (en instanceof LivingEntity && en != player && !damaged.contains(((LivingEntity) en))) { LivingEntity le = (LivingEntity) en; affect(le); // le.setVelocity(thrown); // le.damage(damage); // damaged.add(le); // Methods.verbose(damage + " Hp:" + le.getHealth()); } } affectedblock.setType(Material.ICE); WaterMethods.playIcebendingSound(block.getLocation()); loadAffectedBlocks(); if (location.distance(origin) >= height) { return false; } return true; }
public void manageAirVectors() { for (int i = 0; i < tasks.size(); i++) { if (((FireComboStream) tasks.get(i)).isCancelled()) { tasks.remove(i); i--; } } if (tasks.size() == 0) { remove(); return; } for (int i = 0; i < tasks.size(); i++) { FireComboStream fstream = (FireComboStream) tasks.get(i); Location loc = fstream.getLocation(); if (GeneralMethods.isRegionProtectedFromBuild(this, loc)) { fstream.remove(); return; } if (!isTransparent(loc.getBlock())) { if (!isTransparent(loc.clone().add(0, 0.2, 0).getBlock())) { fstream.remove(); return; } } if (i % 3 == 0) { for (Entity entity : GeneralMethods.getEntitiesAroundPoint(loc, 2.5)) { if (GeneralMethods.isRegionProtectedFromBuild(this, entity.getLocation())) { remove(); return; } if (!entity.equals(player) && !affectedEntities.contains(entity)) { affectedEntities.add(entity); if (knockback != 0) { Vector force = fstream.getDirection(); entity.setVelocity(force.multiply(knockback)); } if (damage != 0) { if (entity instanceof LivingEntity) { if (fstream.getAbility().equalsIgnoreCase("AirSweep")) { DamageHandler.damageEntity(entity, damage, this); } else { DamageHandler.damageEntity(entity, damage, this); } } } } } if (GeneralMethods.blockAbilities(player, FireCombo.getBlockableAbilities(), loc, 1)) { fstream.remove(); } else AirAbility.removeAirSpouts(loc, player); WaterAbility.removeWaterSpouts(loc, player); EarthAbility.removeSandSpouts(loc, player); } } }
public IceSpike(Player player) { BendingPlayer bPlayer = GeneralMethods.getBendingPlayer(player.getName()); if (bPlayer.isOnCooldown("IceSpike")) return; try { this.player = player; double lowestdistance = range + 1; Entity closestentity = null; for (Entity entity : GeneralMethods.getEntitiesAroundPoint(player.getLocation(), range)) { if (GeneralMethods.getDistanceFromLine( player.getLocation().getDirection(), player.getLocation(), entity.getLocation()) <= 2 && (entity instanceof LivingEntity) && (entity.getEntityId() != player.getEntityId())) { double distance = player.getLocation().distance(entity.getLocation()); if (distance < lowestdistance) { closestentity = entity; lowestdistance = distance; } } } if (closestentity != null) { Block temptestingblock = closestentity.getLocation().getBlock().getRelative(BlockFace.DOWN, 1); // if (temptestingblock.getType() == Material.ICE){ this.block = temptestingblock; // } } else { this.block = player.getTargetBlock((HashSet<Material>) null, (int) range); } for (IceSpike2 icespike : IceSpike2.instances.values()) { if (icespike.getBlock().equals(block)) { return; } } origin = block.getLocation(); location = origin.clone(); } catch (IllegalStateException e) { return; } loadAffectedBlocks(); if (height != 0) { if (canInstantiate()) { id = ID; instances.put(id, this); if (ID >= Integer.MAX_VALUE) { ID = Integer.MIN_VALUE; } ID++; time = System.currentTimeMillis() - interval; bPlayer.addCooldown("IceSpike", cooldown); } } }
private void affectPeople(Location location, Vector direction) { WaterMethods.removeWaterSpouts(location, player); AirMethods.removeAirSpouts(location, player); final List<Entity> entities = GeneralMethods.getEntitiesAroundPoint(location, affectingradius); final List<Entity> surroundingEntities = GeneralMethods.getEntitiesAroundPoint(location, 4); final Vector fDirection = direction; for (int i = 0; i < entities.size(); i++) { final Entity entity = entities.get(i); new BukkitRunnable() { public void run() { if (GeneralMethods.isRegionProtectedFromBuild(player, "AirSwipe", entity.getLocation())) return; if (entity.getEntityId() != player.getEntityId()) { if (entity instanceof Player) { if (Commands.invincible.contains(((Player) entity).getName())) return; } if (surroundingEntities.size() < MAX_AFFECTABLE_ENTITIES) { if (AvatarState.isAvatarState(player)) { GeneralMethods.setVelocity( entity, fDirection.multiply(AvatarState.getValue(pushfactor))); } else { GeneralMethods.setVelocity(entity, fDirection.multiply(pushfactor)); } } if (entity instanceof LivingEntity && !affectedentities.contains(entity)) { if (damage != 0) GeneralMethods.damageEntity(player, entity, damage, "AirSwipe"); affectedentities.add(entity); } if (entity instanceof Player) { new Flight((Player) entity, player); } AirMethods.breakBreathbendingHold(entity); if (elements.containsKey(fDirection)) { elements.remove(fDirection); } } } }.runTaskLater(ProjectKorra.plugin, i / MAX_AFFECTABLE_ENTITIES); } }
public Suffocate(Player player) { this.player = player; bplayer = GeneralMethods.getBendingPlayer(player.getName()); targets = new ArrayList<LivingEntity>(); tasks = new ArrayList<BukkitRunnable>(); time = System.currentTimeMillis(); // reloadVariables(); reqConstantAim = REQUIRE_CONSTANT_AIM; canSuffUndead = CAN_SUFFOCATE_UNDEAD; chargeTime = CHARGE_TIME; cooldown = COOLDOWN; particleScale = ANIM_PARTICLE_AMOUNT; range = RANGE; radius = ANIM_RADIUS; speedFactor = ANIM_SPEED; aimRadius = AIM_RADIUS; damage = DAMAGE; damageDelay = DAMAGE_INITIAL_DELAY; damageRepeat = DAMAGE_INTERVAL; slow = SLOW; slowRepeat = SLOW_INTERVAL; slowDelay = SLOW_DELAY; blind = BLIND; blindDelay = BLIND_DELAY; blindRepeat = BLIND_INTERVAL; if (instances.containsKey(player)) { return; } if (AvatarState.isAvatarState(player)) { cooldown = 0; chargeTime = 0; reqConstantAim = false; damage = AvatarState.getValue(damage); range *= 2; slow = AvatarState.getValue(slow); slowRepeat = AvatarState.getValue(slowRepeat); blind = AvatarState.getValue(blind); blindRepeat = AvatarState.getValue(blindRepeat); } if (particleScale < 1) particleScale = 1; else if (particleScale > 2) particleScale = 2; if (AvatarState.isAvatarState(player)) { for (Entity ent : GeneralMethods.getEntitiesAroundPoint(player.getLocation(), range)) if (ent instanceof LivingEntity && !ent.equals(player)) targets.add((LivingEntity) ent); } else { // Entity ent = GeneralMethods.getTargetedEntity(player, range, new ArrayList<Entity>()); List<Entity> entities = new ArrayList<Entity>(); for (int i = 0; i < 6; i++) { Location location = GeneralMethods.getTargetedLocation(player, i, transparent); entities = GeneralMethods.getEntitiesAroundPoint(location, 1.7); if (entities.contains(player)) entities.remove(player); if (entities != null && !entities.isEmpty() && !entities.contains(player)) { break; } } if (entities == null || entities.isEmpty()) { return; } Entity target = entities.get(0); if (target != null && target instanceof LivingEntity) targets.add((LivingEntity) target); } if (!canSuffUndead) { for (int i = 0; i < targets.size(); i++) { LivingEntity target = targets.get(i); if (GeneralMethods.isUndead(target)) { targets.remove(i); i--; } } } if (targets.size() == 0) return; else if (bplayer.isOnCooldown("suffocate")) return; bplayer.addCooldown("suffocate", cooldown); instances.put(player, this); }
/** * Progresses this instance of Suffocate by 1 tick. * * @return true If progress does not stop, progresses succesfully */ public boolean progress() { if (targets.size() == 0) { remove(); return false; } if (player.isDead() || !player.isOnline()) { remove(); return false; } String ability = GeneralMethods.getBoundAbility(player); if (ability == null || !ability.equalsIgnoreCase("Suffocate") || !GeneralMethods.canBend(player.getName(), "Suffocate")) { remove(); return false; } for (int i = 0; i < targets.size(); i++) { LivingEntity target = targets.get(i); if (target.isDead() || !target.getWorld().equals(player.getWorld()) || target.getLocation().distance(player.getEyeLocation()) > range) { breakSuffocateLocal(target); i--; } else if (target instanceof Player) { Player targPlayer = (Player) target; if (!targPlayer.isOnline()) { breakSuffocateLocal(target); i--; } } } if (targets.size() == 0) { remove(); return false; } if (reqConstantAim) { double dist = player.getEyeLocation().distance(targets.get(0).getEyeLocation()); Location targetLoc = player .getEyeLocation() .clone() .add(player.getEyeLocation().getDirection().normalize().multiply(dist)); List<Entity> ents = GeneralMethods.getEntitiesAroundPoint(targetLoc, aimRadius); for (int i = 0; i < targets.size(); i++) { LivingEntity target = targets.get(i); if (!ents.contains(target)) { breakSuffocateLocal(target); i--; } } if (targets.size() == 0) { remove(); return false; } } if (System.currentTimeMillis() - time < chargeTime) { return false; } else if (!started) { started = true; final Player fplayer = player; for (LivingEntity targ : targets) { final LivingEntity target = targ; BukkitRunnable br1 = new BukkitRunnable() { @Override public void run() { GeneralMethods.damageEntity(fplayer, target, damage, "Suffocate"); } }; BukkitRunnable br2 = new BukkitRunnable() { @Override public void run() { target.addPotionEffect( new PotionEffect(PotionEffectType.SLOW, (int) (slowRepeat * 20), (int) slow)); } }; BukkitRunnable br3 = new BukkitRunnable() { @Override public void run() { target.addPotionEffect( new PotionEffect( PotionEffectType.BLINDNESS, (int) (blindRepeat * 20), (int) blind)); } }; tasks.add(br1); tasks.add(br2); tasks.add(br3); br1.runTaskTimer( ProjectKorra.plugin, (long) (damageDelay * 20), (long) (damageRepeat * 20)); br2.runTaskTimer( ProjectKorra.plugin, (long) (slowDelay * 20), (long) (slowRepeat * 20 / 0.25)); br3.runTaskTimer(ProjectKorra.plugin, (long) (blindDelay * 20), (long) (blindRepeat * 20)); } } animate(); if (!player.isSneaking()) { remove(); return false; } return true; }
private void progress() { BendingPlayer bPlayer = GeneralMethods.getBendingPlayer(player.getName()); if (player.isDead() || !player.isOnline() || !GeneralMethods.canBend(player.getName(), "IceBlast") || bPlayer.isOnCooldown("IceBlast")) { cancel(); return; } if (!player.getWorld().equals(location.getWorld())) { cancel(); return; } if (player.getEyeLocation().distance(location) >= range) { if (progressing) { breakParticles(20); cancel(); returnWater(); } else { breakParticles(20); cancel(); } return; } if ((GeneralMethods.getBoundAbility(player) == null || !GeneralMethods.getBoundAbility(player).equalsIgnoreCase("IceBlast")) && prepared) { cancel(); return; } if (System.currentTimeMillis() < time + interval) return; time = System.currentTimeMillis(); if (progressing) { Vector direction; if (location.getBlockY() == firstdestination.getBlockY()) settingup = false; if (location.distance(destination) <= 2) { cancel(); returnWater(); return; } if (settingup) { direction = GeneralMethods.getDirection(location, firstdestination).normalize(); } else { direction = GeneralMethods.getDirection(location, destination).normalize(); } location.add(direction); Block block = location.getBlock(); if (block.equals(sourceblock)) return; source.revertBlock(); source = null; if (EarthMethods.isTransparentToEarthbending(player, block) && !block.isLiquid()) { GeneralMethods.breakBlock(block); } else if (!WaterMethods.isWater(block)) { breakParticles(20); cancel(); returnWater(); return; } if (GeneralMethods.isRegionProtectedFromBuild(player, "IceBlast", location)) { cancel(); returnWater(); return; } for (Entity entity : GeneralMethods.getEntitiesAroundPoint(location, affectingradius)) { if (entity.getEntityId() != player.getEntityId() && entity instanceof LivingEntity) { affect((LivingEntity) entity); progressing = false; returnWater(); } } if (!progressing) { cancel(); return; } sourceblock = block; source = new TempBlock(sourceblock, Material.PACKED_ICE, data); for (int x = 0; x < 10; x++) { ParticleEffect.ITEM_CRACK.display( new ParticleEffect.ItemData(Material.ICE, (byte) 0), new Vector( ((Math.random() - 0.5) * .5), ((Math.random() - 0.5) * .5), ((Math.random() - 0.5) * .5)), .5f, location, 257.0D); ParticleEffect.SNOW_SHOVEL.display( location, (float) (Math.random() - 0.5), (float) (Math.random() - 0.5), (float) (Math.random() - 0.5), 0, 5); } if (GeneralMethods.rand.nextInt(4) == 0) { WaterMethods.playIcebendingSound(location); } location = location.add(direction.clone()); } else if (prepared) { WaterMethods.playFocusWaterEffect(sourceblock); } }
public void manage(final Server server) { for (final Player player : server.getOnlinePlayers()) { if (TouchOfEvil.instances.containsKey(player)) { final BendingPlayer bPlayer = GeneralMethods.getBendingPlayer(player.getName()); if (bPlayer.effects != null) { for (final Effect e : bPlayer.effects.keySet()) { if (bPlayer.effects.get(e) == "Helix") { // this.effect = (HelixEffect) e; break; } } } else { this.effect = new HelixEffect(MegaBending.getEM()); this.start = true; bPlayer.addCooldown("EvilAura", 9000); } if (!GeneralMethods.canBend(player.getName(), "TouchOfEvil") || (GeneralMethods.getBendingPlayer(player.getName()).eviltouch == false)) { // instances.get(player); TouchOfEvil.instances.remove(player); if (this.effect != null) { bPlayer.effects.remove(this.effect); this.effect.cancel(); } } else { TouchOfEvil.instances.get(player).set(); this.effect.setDynamicOrigin(new DynamicLocation(player.getEyeLocation().add(0, -1, 0))); // effect.setTargetEntity(player); this.effect.radius = 6; this.effect.particle = ParticleEffect.PORTAL; this.effect.iterations = 40; // effect.infinite(); // effect.infinite(); if (this.start == true) { this.effect.start(); this.start = false; } for (final Entity e : GeneralMethods.getEntitiesAroundPoint(player.getLocation(), 5)) { if (e instanceof LivingEntity) { if (e instanceof Player) { if ((Player) e == player) { continue; } } if (!((LivingEntity) e).hasPotionEffect(PotionEffectType.POISON)) { new TempPotionEffect((LivingEntity) e, TouchOfEvil.poison); } if (!((LivingEntity) e).hasPotionEffect(PotionEffectType.WEAKNESS)) { new TempPotionEffect((LivingEntity) e, TouchOfEvil.weak); } } } } } } for (final Player player : TouchOfEvil.instances.keySet()) { if (!player.isOnline() || player.isDead() || !GeneralMethods.getBendingPlayer(player.getName()).isOnCooldown("EvilAura")) { // instances.get(player).revert(); final BendingPlayer bPlayer = GeneralMethods.getBendingPlayer(player.getName()); if (bPlayer.effects != null) { for (final Effect e : bPlayer.effects.keySet()) { if (bPlayer.effects.get(e) == "Helix") { bPlayer.eviltouch = false; this.effect = (HelixEffect) e; bPlayer.effects.remove(this.effect); player.sendMessage(ChatColor.DARK_GRAY + "The dark spirit returns to your body."); break; } } } TouchOfEvil.instances.remove(player); this.effect.cancel(); } } }
@Override public void progress() { progressCounter++; if (player.isDead() || !player.isOnline()) { remove(); return; } else if (currentLoc != null && GeneralMethods.isRegionProtectedFromBuild(this, currentLoc)) { remove(); return; } if (abilityName.equalsIgnoreCase("Twister")) { if (destination == null) { state = AbilityState.TWISTER_MOVING; direction = player.getEyeLocation().getDirection().clone().normalize(); direction.setY(0); origin = player.getLocation().add(direction.clone().multiply(2)); destination = player.getLocation().add(direction.clone().multiply(range)); currentLoc = origin.clone(); } if (origin.distanceSquared(currentLoc) < origin.distanceSquared(destination) && state == AbilityState.TWISTER_MOVING) { currentLoc.add(direction.clone().multiply(speed)); } else if (state == AbilityState.TWISTER_MOVING) { state = AbilityState.TWISTER_STATIONARY; time = System.currentTimeMillis(); } else if (System.currentTimeMillis() - time >= twisterRemoveDelay) { remove(); return; } else if (GeneralMethods.isRegionProtectedFromBuild(this, currentLoc)) { remove(); return; } Block topBlock = GeneralMethods.getTopBlock(currentLoc, 3, -3); if (topBlock == null) { remove(); return; } currentLoc.setY(topBlock.getLocation().getY()); double height = twisterHeight; double radius = twisterRadius; for (double y = 0; y < height; y += twisterHeightParticles) { double animRadius = ((radius / height) * y); for (double i = -180; i <= 180; i += twisterDegreeParticles) { Vector animDir = GeneralMethods.rotateXZ(new Vector(1, 0, 1), i); Location animLoc = currentLoc.clone().add(animDir.multiply(animRadius)); animLoc.add(0, y, 0); playAirbendingParticles(animLoc, 1, 0, 0, 0); } } playAirbendingSound(currentLoc); for (int i = 0; i < height; i += 3) { for (Entity entity : GeneralMethods.getEntitiesAroundPoint(currentLoc.clone().add(0, i, 0), radius * 0.75)) { if (!affectedEntities.contains(entity) && !entity.equals(player)) { affectedEntities.add(entity); } } } for (Entity entity : affectedEntities) { Vector forceDir = GeneralMethods.getDirection(entity.getLocation(), currentLoc.clone().add(0, height, 0)); if (entity instanceof Player) { if (Commands.invincible.contains(((Player) entity).getName())) { break; } } entity.setVelocity(forceDir.clone().normalize().multiply(0.3)); } } else if (abilityName.equalsIgnoreCase("AirStream")) { if (destination == null) { origin = player.getEyeLocation(); currentLoc = origin.clone(); } Entity target = GeneralMethods.getTargetedEntity(player, range); if (target instanceof Player) { if (Commands.invincible.contains(((Player) target).getName())) { return; } } if (target != null && target.getLocation().distanceSquared(currentLoc) > 49) { destination = target.getLocation(); } else { destination = GeneralMethods.getTargetedLocation(player, range, getTransparentMaterial()); } direction = GeneralMethods.getDirection(currentLoc, destination).normalize(); currentLoc.add(direction.clone().multiply(speed)); if (player.getWorld() != currentLoc.getWorld()) { remove(); return; } else if (!player.isSneaking()) { remove(); return; } else if (player.getWorld().equals(currentLoc.getWorld()) && Math.abs(player.getLocation().distanceSquared(currentLoc)) > range * range) { remove(); return; } else if (affectedEntities.size() > 0 && System.currentTimeMillis() - time >= airStreamEntityCarryDuration) { remove(); return; } else if (!isTransparent(currentLoc.getBlock())) { remove(); return; } else if (currentLoc.getY() - origin.getY() > airStreamMaxEntityHeight) { remove(); return; } else if (GeneralMethods.isRegionProtectedFromBuild(this, currentLoc)) { remove(); return; } else if (FireAbility.isWithinFireShield(currentLoc)) { remove(); return; } else if (isWithinAirShield(currentLoc)) { remove(); return; } else if (!isTransparent(currentLoc.getBlock())) { currentLoc.subtract(direction.clone().multiply(speed)); } for (int i = 0; i < 10; i++) { BukkitRunnable br = new BukkitRunnable() { final Location loc = currentLoc.clone(); final Vector dir = direction.clone(); @Override public void run() { for (int angle = -180; angle <= 180; angle += 45) { Vector orthog = GeneralMethods.getOrthogonalVector(dir.clone(), angle, 0.5); playAirbendingParticles(loc.clone().add(orthog), 1, 0F, 0F, 0F); } } }; br.runTaskLater(ProjectKorra.plugin, i * 2); tasks.add(br); } for (Entity entity : GeneralMethods.getEntitiesAroundPoint(currentLoc, 2.8)) { if (affectedEntities.size() == 0) { // Set the timer to remove the ability time = System.currentTimeMillis(); } if (!entity.equals(player) && !affectedEntities.contains(entity)) { affectedEntities.add(entity); if (entity instanceof Player) { flights.add(new Flight((Player) entity, player)); } } } for (Entity entity : affectedEntities) { Vector force = GeneralMethods.getDirection(entity.getLocation(), currentLoc); entity.setVelocity(force.clone().normalize().multiply(speed)); entity.setFallDistance(0F); } } else if (abilityName.equalsIgnoreCase("AirSweep")) { if (origin == null) { direction = player.getEyeLocation().getDirection().normalize(); origin = player.getLocation().add(direction.clone().multiply(10)); } if (progressCounter < 8) { return; } if (destination == null) { destination = player .getLocation() .add(player.getEyeLocation().getDirection().normalize().multiply(10)); Vector origToDest = GeneralMethods.getDirection(origin, destination); for (double i = 0; i < 30; i++) { Vector vec = GeneralMethods.getDirection( player.getLocation(), origin.clone().add(origToDest.clone().multiply(i / 30))); FireComboStream fs = new FireComboStream(null, vec, player.getLocation(), range, speed, "AirSweep"); fs.setDensity(1); fs.setSpread(0F); fs.setUseNewParticles(true); fs.setParticleEffect(getAirbendingParticles()); fs.setCollides(false); fs.runTaskTimer(ProjectKorra.plugin, (long) (i / 2.5), 1L); tasks.add(fs); } } manageAirVectors(); } }
private boolean progress() { if (player.isDead() || !player.isOnline() || !GeneralMethods.canBend(player.getName(), "EarthBlast")) { breakBlock(); return false; } if (System.currentTimeMillis() - time >= interval) { time = System.currentTimeMillis(); if (falling) { breakBlock(); return false; } if (!EarthMethods.isEarthbendable(player, sourceblock) && sourceblock.getType() != Material.COBBLESTONE) { instances.remove(id); return false; } if (!progressing && !falling) { if (GeneralMethods.getBoundAbility(player) == null) { unfocusBlock(); return false; } if (!GeneralMethods.getBoundAbility(player).equalsIgnoreCase("EarthBlast")) { unfocusBlock(); return false; } if (sourceblock == null) { instances.remove(id); return false; } if (!player.getWorld().equals(sourceblock.getWorld())) { unfocusBlock(); return false; } if (sourceblock.getLocation().distance(player.getLocation()) > preparerange) { unfocusBlock(); return false; } } if (falling) { breakBlock(); } else { if (!progressing) { return false; } if (sourceblock.getY() == firstdestination.getBlockY()) { settingup = false; } Vector direction; if (settingup) { direction = GeneralMethods.getDirection(location, firstdestination).normalize(); } else { direction = GeneralMethods.getDirection(location, destination).normalize(); } location = location.clone().add(direction); WaterMethods.removeWaterSpouts(location, player); AirMethods.removeAirSpouts(location, player); Block block = location.getBlock(); if (block.getLocation().equals(sourceblock.getLocation())) { location = location.clone().add(direction); block = location.getBlock(); } if (EarthMethods.isTransparentToEarthbending(player, block) && !block.isLiquid()) { GeneralMethods.breakBlock(block); } else if (!settingup) { breakBlock(); return false; } else { location = location.clone().subtract(direction); direction = GeneralMethods.getDirection(location, destination).normalize(); location = location.clone().add(direction); WaterMethods.removeWaterSpouts(location, player); AirMethods.removeAirSpouts(location, player); double radius = FireBlast.AFFECTING_RADIUS; Player source = player; if (EarthBlast.annihilateBlasts(location, radius, source) || WaterManipulation.annihilateBlasts(location, radius, source) || FireBlast.annihilateBlasts(location, radius, source)) { breakBlock(); return false; } Combustion.removeAroundPoint(location, radius); Block block2 = location.getBlock(); if (block2.getLocation().equals(sourceblock.getLocation())) { location = location.clone().add(direction); block2 = location.getBlock(); } if (EarthMethods.isTransparentToEarthbending(player, block) && !block.isLiquid()) { GeneralMethods.breakBlock(block); } else { breakBlock(); return false; } } for (Entity entity : GeneralMethods.getEntitiesAroundPoint(location, FireBlast.AFFECTING_RADIUS)) { if (GeneralMethods.isRegionProtectedFromBuild( player, "EarthBlast", entity.getLocation())) { continue; } if (entity instanceof LivingEntity && (entity.getEntityId() != player.getEntityId() || hitself)) { AirMethods.breakBreathbendingHold(entity); Location location = player.getEyeLocation(); Vector vector = location.getDirection(); entity.setVelocity(vector.normalize().multiply(pushfactor)); double damage = this.damage; if (EarthMethods.isMetal(sourceblock) && EarthMethods.canMetalbend(player)) { damage = EarthMethods.getMetalAugment(this.damage); } GeneralMethods.damageEntity(player, entity, damage); progressing = false; } } if (!progressing) { breakBlock(); return false; } if (revert) { // Methods.addTempEarthBlock(sourceblock, block); if (sourceblock.getType() == Material.RED_SANDSTONE) { sourceblock.setType(sourcetype); if (sourcetype == Material.SAND) { sourceblock.setData((byte) 0x1); } } else { sourceblock.setType(sourcetype); } EarthMethods.moveEarthBlock(sourceblock, block); if (block.getType() == Material.SAND) { block.setType(Material.SANDSTONE); } if (block.getType() == Material.GRAVEL) { block.setType(Material.STONE); } } else { block.setType(sourceblock.getType()); sourceblock.setType(Material.AIR); } sourceblock = block; if (location.distance(destination) < 1) { if (sourcetype == Material.SAND || sourcetype == Material.GRAVEL) { progressing = false; if (sourceblock.getType() == Material.RED_SANDSTONE) { sourcetype = Material.SAND; sourceblock.setType(sourcetype); sourceblock.setData((byte) 0x1); } else { sourceblock.setType(sourcetype); } } falling = true; progressing = false; } return true; } } return false; }
public Suffocate(Player player) { super(player); ability = this; if (bPlayer.isOnCooldown(this)) { return; } else if (hasAbility(player, Suffocate.class)) { return; } this.started = false; this.requireConstantAim = getConfig().getBoolean("Abilities.Air.Suffocate.RequireConstantAim"); this.canSuffocateUndead = getConfig().getBoolean("Abilities.Air.Suffocate.CanBeUsedOnUndeadMobs"); this.particleCount = getConfig().getInt("Abilities.Air.Suffocate.AnimationParticleAmount"); this.animationSpeed = getConfig().getDouble("Abilities.Air.Suffocate.AnimationSpeed"); this.chargeTime = getConfig().getLong("Abilities.Air.Suffocate.ChargeTime"); this.cooldown = getConfig().getLong("Abilities.Air.Suffocate.Cooldown"); this.range = getConfig().getDouble("Abilities.Air.Suffocate.Range"); this.radius = getConfig().getDouble("Abilities.Air.Suffocate.AnimationRadius"); this.constantAimRadius = getConfig().getDouble("Abilities.Air.Suffocate.RequireConstantAimRadius"); this.damage = getConfig().getDouble("Abilities.Air.Suffocate.Damage"); this.damageDelay = getConfig().getDouble("Abilities.Air.Suffocate.DamageInitialDelay"); this.damageRepeat = getConfig().getDouble("Abilities.Air.Suffocate.DamageInterval"); this.slow = getConfig().getInt("Abilities.Air.Suffocate.SlowPotency"); this.slowRepeat = getConfig().getDouble("Abilities.Air.Suffocate.SlowInterval"); this.slowDelay = getConfig().getDouble("Abilities.Air.Suffocate.SlowDelay"); this.blind = getConfig().getInt("Abilities.Air.Suffocate.BlindPotentcy"); this.blindDelay = getConfig().getDouble("Abilities.Air.Suffocate.BlindDelay"); this.blindRepeat = getConfig().getDouble("Abilities.Air.Suffocate.BlindInterval"); this.targets = new ArrayList<>(); this.tasks = new ArrayList<>(); if (bPlayer.isAvatarState()) { cooldown = 0; chargeTime = 0; requireConstantAim = false; damage = AvatarState.getValue(damage); range *= 2; slow = AvatarState.getValue(slow); slowRepeat = AvatarState.getValue(slowRepeat); blind = AvatarState.getValue(blind); blindRepeat = AvatarState.getValue(blindRepeat); } if (particleCount < 1) { particleCount = 1; } else if (particleCount > 2) { particleCount = 2; } if (bPlayer.isAvatarState()) { for (Entity ent : GeneralMethods.getEntitiesAroundPoint(player.getLocation(), range)) { if (ent instanceof LivingEntity && !ent.equals(player)) { targets.add((LivingEntity) ent); } } } else { // Location location = GeneralMethods.getTargetedLocation(player, 6, // getTransparentMaterial()); // List<Entity> entities = GeneralMethods.getEntitiesAroundPoint(location, 1.5); List<Entity> entities = new ArrayList<Entity>(); for (int i = 0; i < 6; i++) { Location location = GeneralMethods.getTargetedLocation(player, i, getTransparentMaterial()); entities = GeneralMethods.getEntitiesAroundPoint(location, 1.7); if (entities.contains(player)) entities.remove(player); if (entities != null && !entities.isEmpty() && !entities.contains(player)) { break; } } if (entities == null || entities.isEmpty()) { return; } Entity target = entities.get(0); if (target != null && target instanceof LivingEntity) { targets.add((LivingEntity) target); } } if (!canSuffocateUndead) { for (int i = 0; i < targets.size(); i++) { LivingEntity target = targets.get(i); if (GeneralMethods.isUndead(target)) { targets.remove(i); i--; } } } bPlayer.addCooldown(this); start(); }
@Override public void progress() { for (int i = 0; i < targets.size(); i++) { LivingEntity target = targets.get(i); if (target.isDead() || !target.getWorld().equals(player.getWorld()) || target.getLocation().distanceSquared(player.getEyeLocation()) > range * range || GeneralMethods.isRegionProtectedFromBuild(this, target.getLocation())) { breakSuffocateLocal(target); i--; } else if (target instanceof Player) { Player targPlayer = (Player) target; if (!targPlayer.isOnline()) { breakSuffocateLocal(target); i--; } } } if (targets.size() == 0 || !bPlayer.canBendIgnoreCooldowns(this)) { remove(); return; } if (requireConstantAim) { double dist = player.getEyeLocation().distance(targets.get(0).getEyeLocation()); Location targetLoc = player .getEyeLocation() .clone() .add(player.getEyeLocation().getDirection().normalize().multiply(dist)); List<Entity> ents = GeneralMethods.getEntitiesAroundPoint(targetLoc, constantAimRadius); for (int i = 0; i < targets.size(); i++) { LivingEntity target = targets.get(i); if (!ents.contains(target)) { breakSuffocateLocal(target); i--; } } if (targets.size() == 0) { remove(); return; } } if (System.currentTimeMillis() - startTime < chargeTime) { return; } else if (!started) { started = true; for (LivingEntity targ : targets) { final LivingEntity target = targ; BukkitRunnable br1 = new BukkitRunnable() { @Override public void run() { GeneralMethods.damageEntity(ability, target, damage); } }; BukkitRunnable br2 = new BukkitRunnable() { @Override public void run() { target.addPotionEffect( new PotionEffect(PotionEffectType.SLOW, (int) (slowRepeat * 20), (int) slow)); } }; BukkitRunnable br3 = new BukkitRunnable() { @Override public void run() { target.addPotionEffect( new PotionEffect( PotionEffectType.BLINDNESS, (int) (blindRepeat * 20), (int) blind)); } }; tasks.add(br1); tasks.add(br2); tasks.add(br3); br1.runTaskTimer( ProjectKorra.plugin, (long) (damageDelay * 20), (long) (damageRepeat * 20)); br2.runTaskTimer( ProjectKorra.plugin, (long) (slowDelay * 20), (long) (slowRepeat * 20 / 0.25)); br3.runTaskTimer(ProjectKorra.plugin, (long) (blindDelay * 20), (long) (blindRepeat * 20)); } } animate(); if (!player.isSneaking()) { remove(); return; } }