示例#1
0
  @SuppressWarnings("deprecation")
  private void advanceSwipe() {
    affectedentities.clear();
    for (Vector direction : elements.keySet()) {
      Location location = elements.get(direction);
      if (direction != null && location != null) {
        location = location.clone().add(direction.clone().multiply(speedfactor));
        elements.replace(direction, location);

        if (location.distance(origin) > range
            || GeneralMethods.isRegionProtectedFromBuild(player, "AirSwipe", location)) {
          elements.remove(direction);
        } else {
          AirMethods.removeAirSpouts(location, player);
          WaterMethods.removeWaterSpouts(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)
              || Combustion.removeAroundPoint(location, radius)) {
            elements.remove(direction);
            damage = 0;
            remove();
            continue;
          }

          Block block = location.getBlock();
          for (Block testblock : GeneralMethods.getBlocksAroundPoint(location, affectingradius)) {
            if (testblock.getType() == Material.FIRE) {
              testblock.setType(Material.AIR);
            }
            if (isBlockBreakable(testblock)) {
              GeneralMethods.breakBlock(testblock);
            }
          }

          if (block.getType() != Material.AIR) {
            if (isBlockBreakable(block)) {
              GeneralMethods.breakBlock(block);
            } else {
              elements.remove(direction);
            }
            if (block.getType() == Material.LAVA || block.getType() == Material.STATIONARY_LAVA) {
              if (block.getData() == full) {
                block.setType(Material.OBSIDIAN);
              } else {
                block.setType(Material.COBBLESTONE);
              }
            }
          } else {
            AirMethods.playAirbendingParticles(location, 3, 0.2F, 0.2F, 0);
            if (GeneralMethods.rand.nextInt(4) == 0) {
              AirMethods.playAirbendingSound(location);
            }
            affectPeople(location, direction);
          }
        }
        // } else {
        // elements.remove(direction);
      }
    }

    if (elements.isEmpty()) {
      remove();
    }
  }
 /**
  * updates the water abilities based on a players bending effect attributes
  *
  * @param player the player that has the effects
  * @param ability an instance of a water ability
  * @param attribs the map of the players effects
  * @return if the ability was updated correctly
  */
 public static boolean updateAbility(
     Player player, Object ability, ConcurrentHashMap<String, Double> attribs) {
   if (ability instanceof IceBlast) {
     IceBlast abil = (IceBlast) ability;
     if (attribs.containsKey("IceBlastRange")) {
       abil.setRange(abil.getRange() + abil.getRange() * attribs.get("IceBlastRange") / 100.0);
     }
     if (attribs.containsKey("IceBlastDamage")) {
       abil.setDefaultdamage(
           abil.getDefaultdamage()
               + abil.getDefaultdamage() * attribs.get("IceBlastDamage") / 100.0);
     }
     return true;
   } else if (ability instanceof IceSpike) {
     IceSpike abil = (IceSpike) ability;
     if (attribs.containsKey("IceSpikeDamage")) {
       abil.setDamage(abil.getDamage() + abil.getDamage() * attribs.get("IceSpikeDamage") / 100.0);
     }
     if (attribs.containsKey("IceSpikeRange")) {
       abil.setRange(abil.getRange() + abil.getRange() * attribs.get("IceSpikeRange") / 100.0);
     }
     return true;
   } else if (ability instanceof IceSpike2) {
     IceSpike2 abil = (IceSpike2) ability;
     if (attribs.containsKey("IceSpikePillarDamage")) {
       abil.setDefaultdamage(
           abil.getDefaultdamage()
               + abil.getDefaultdamage() * attribs.get("IceSpikePillarDamage") / 100.0);
     }
     if (attribs.containsKey("IceSpikePillarRange")) {
       abil.setDefaultrange(
           abil.getDefaultrange()
               + abil.getDefaultrange() * attribs.get("IceSpikePillarRange") / 100.0);
     }
     return true;
   } else if (ability instanceof OctopusForm) {
     OctopusForm abil = (OctopusForm) ability;
     if (attribs.containsKey("OctopusFormRange")) {
       abil.setRange(
           (int) (abil.getRange() + abil.getRange() * attribs.get("OctopusFormRange") / 100.0));
     }
     if (attribs.containsKey("OctopusFormDamage")) {
       abil.setDamage(
           (int) (abil.getDamage() + abil.getDamage() * attribs.get("OctopusFormDamage") / 100.0));
     }
     if (attribs.containsKey("OctopusFormInterval")) {
       abil.setInterval(
           (long)
               (abil.getInterval()
                   + abil.getInterval() * attribs.get("OctopusFormInterval") / 100.0));
     }
     if (attribs.containsKey("OctopusFormKnockback")) {
       abil.setKnockback(
           abil.getKnockback()
               + abil.getKnockback() * attribs.get("OctopusFormKnockback") / 100.0);
     }
     if (attribs.containsKey("OctopusFormRadius")) {
       abil.setRadius(
           abil.getRadius() + abil.getRadius() * attribs.get("OctopusFormRadius") / 100.0);
     }
     return true;
   } else if (ability instanceof Torrent) {
     Torrent abil = (Torrent) ability;
     if (attribs.containsKey("TorrentDamage")) {
       abil.setDamage(
           (int) (abil.getDamage() + abil.getDamage() * attribs.get("TorrentDamage") / 100.0));
     }
     if (attribs.containsKey("TorrentRange")) {
       abil.setRange(abil.getRange() + abil.getRange() * attribs.get("TorrentRange") / 100.0);
     }
     if (attribs.containsKey("TorrentStreamingDamage")) {
       abil.setDeflectdamage(
           (int)
               (abil.getDeflectdamage()
                   + abil.getDeflectdamage() * attribs.get("TorrentStreamingDamage") / 100.0));
     }
     return true;
   } else if (ability instanceof TorrentBurst) {
     TorrentBurst abil = (TorrentBurst) ability;
     if (attribs.containsKey("TorrentWaveRadius")) {
       abil.setMaxradius(
           abil.getMaxradius() + abil.getMaxradius() * attribs.get("TorrentWaveRadius") / 100.0);
     }
     if (attribs.containsKey("TorrentWaveForce")) {
       abil.setFactor(
           abil.getFactor() + abil.getFactor() * attribs.get("TorrentWaveForce") / 100.0);
     }
     if (attribs.containsKey("TorrentWaveHeight")) {
       abil.setMaxheight(
           abil.getMaxheight() + abil.getMaxheight() * attribs.get("TorrentWaveHeight") / 100.0);
     }
     return true;
   } else if (ability instanceof WaterManipulation) {
     WaterManipulation abil = (WaterManipulation) ability;
     if (attribs.containsKey("WaterManipulationRange")) {
       abil.setRange(
           abil.getRange() + abil.getRange() * attribs.get("WaterManipulationRange") / 100.0);
     }
     if (attribs.containsKey("WaterManipulationForce")) {
       abil.setPushfactor(
           abil.getPushfactor()
               + abil.getPushfactor() * attribs.get("WaterManipulationForce") / 100.0);
     }
     if (attribs.containsKey("WaterManipulationDamage")) {
       abil.setDamage(
           abil.getDamage() + abil.getDamage() * attribs.get("WaterManipulationDamage") / 100.0);
     }
     if (attribs.containsKey("WaterManipulationCooldown")) {
       abil.setCooldown(
           (long)
               (abil.getCooldown()
                   + abil.getCooldown() * attribs.get("WaterManipulationCooldown") / 100.0));
     }
     return true;
   } else if (ability instanceof WaterSpout) {
     WaterSpout abil = (WaterSpout) ability;
     if (attribs.containsKey("WaterSpoutHeight")) {
       abil.setDefaultheight(
           (int)
               (abil.getDefaultheight()
                   + abil.getDefaultheight() * attribs.get("WaterSpoutHeight") / 100.0));
     }
     return true;
   } else if (ability instanceof WaterWave) {
     WaterWave abil = (WaterWave) ability;
     if (attribs.containsKey("WaterSpoutWaveRadius")) {
       abil.setWaveRadius(
           abil.getWaveRadius()
               + abil.getWaveRadius() * attribs.get("WaterSpoutWaveRadius") / 100.0);
     }
     if (attribs.containsKey("WaterSpoutWaveRange")) {
       abil.setRange(
           abil.getRange() + abil.getRange() * attribs.get("WaterSpoutWaveRange") / 100.0);
     }
     if (attribs.containsKey("WaterSpoutWaveSpeed")) {
       abil.setSpeed(
           abil.getSpeed() + abil.getSpeed() * attribs.get("WaterSpoutWaveSpeed") / 100.0);
     }
     if (attribs.containsKey("WaterSpoutWaveChargeTime")) {
       abil.setChargeTime(
           abil.getChargeTime()
               + abil.getChargeTime() * attribs.get("WaterSpoutWaveChargeTime") / 100.0);
     }
     if (attribs.containsKey("WaterSpoutWaveFlightTime")) {
       abil.setFlightTime(
           abil.getFlightTime()
               + abil.getFlightTime() * attribs.get("WaterSpoutWaveFlightTime") / 100.0);
     }
     if (attribs.containsKey("IceWaveDamage")) {
       abil.setDamage(abil.getDamage() + abil.getDamage() * attribs.get("IceWaveDamage") / 100.0);
     }
     return true;
   } else if (ability instanceof WaterWall) {
     WaterWall abil = (WaterWall) ability;
     if (attribs.containsKey("SurgeWallRadius")) {
       abil.setRadius(
           abil.getRadius() + abil.getRadius() * attribs.get("SurgeWallRadius") / 100.0);
     }
     if (attribs.containsKey("SurgeWallRange")) {
       abil.setRange(abil.getRange() + abil.getRange() * attribs.get("SurgeWallRange") / 100.0);
     }
     return true;
   } else if (ability instanceof Wave) {
     Wave abil = (Wave) ability;
     if (attribs.containsKey("SurgeWaveRadius")) {
       abil.setMaxradius(
           abil.getMaxradius() + abil.getMaxradius() * attribs.get("SurgeWaveRadius") / 100.0);
     }
     if (attribs.containsKey("SurgeWaveKnockback")) {
       abil.setFactor(
           abil.getFactor() + abil.getFactor() * attribs.get("SurgeWaveKnockback") / 100.0);
     }
     if (attribs.containsKey("SurgeWaveKnockup")) {
       abil.setUpfactor(
           abil.getUpfactor() + abil.getUpfactor() * attribs.get("SurgeWaveKnockup") / 100.0);
     }
     if (attribs.containsKey("SurgeWaveFreezeSize")) {
       abil.setMaxfreezeradius(
           abil.getMaxfreezeradius()
               + abil.getMaxfreezeradius() * attribs.get("SurgeWaveFreezeSize") / 100.0);
     }
     return true;
   }
   return false;
 }
示例#3
0
  @SuppressWarnings("deprecation")
  private void advanceSwipe() {
    affectedEntities.clear();
    for (Vector direction : elements.keySet()) {
      Location location = elements.get(direction);
      if (direction != null && location != null) {
        location = location.clone().add(direction.clone().multiply(speed));
        elements.replace(direction, location);

        if (location.distanceSquared(origin) > range * range
            || GeneralMethods.isRegionProtectedFromBuild(this, location)) {
          elements.remove(direction);
        } else {
          removeAirSpouts(location, player);
          WaterAbility.removeWaterSpouts(location, player);

          if (EarthBlast.annihilateBlasts(location, radius, player)
              || WaterManipulation.annihilateBlasts(location, radius, player)
              || FireBlast.annihilateBlasts(location, radius, player)
              || Combustion.removeAroundPoint(location, radius)) {
            elements.remove(direction);
            damage = 0;
            remove();
            continue;
          }

          Block block = location.getBlock();
          for (Block testblock : GeneralMethods.getBlocksAroundPoint(location, radius)) {
            if (testblock.getType() == Material.FIRE) {
              testblock.setType(Material.AIR);
            }
            if (isBlockBreakable(testblock)) {
              GeneralMethods.breakBlock(testblock);
            }
          }

          if (block.getType() != Material.AIR) {
            if (isBlockBreakable(block)) {
              GeneralMethods.breakBlock(block);
            } else {
              elements.remove(direction);
            }
            if (isLava(block)) {
              if (block.getData() == 0x0) {
                block.setType(Material.OBSIDIAN);
              } else {
                block.setType(Material.COBBLESTONE);
              }
            }
          } else {
            playAirbendingParticles(location, particles, 0.2F, 0.2F, 0);
            if (random.nextInt(4) == 0) {
              playAirbendingSound(location);
            }
            affectPeople(location, direction);
          }
        }
      }
    }
    if (elements.isEmpty()) {
      remove();
    }
  }
  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;
  }