@EventHandler(priority = EventPriority.LOW)
 public void onPlayerAnimation(PlayerAnimationEvent e) {
   Player p = e.getPlayer();
   List<String> allowedMoves =
       Probending.plugin.getConfig().getStringList("TeamSettings.AllowedMoves");
   String playerTeam = PBMethods.getPlayerTeam(p.getUniqueId());
   if (playerTeam != null) {
     if (playerTeam.equalsIgnoreCase(PBMethods.TeamOne)
         || playerTeam.equalsIgnoreCase(PBMethods.TeamTwo)) {
       if (PBMethods.matchStarted) {
         if (!allowedMoves.contains(GeneralMethods.getBoundAbility(p).toString())
             && GeneralMethods.getBoundAbility(p) != null) {
           e.setCancelled(true);
         }
       }
     }
   }
   if (PBMethods.allowedZone.containsKey(p.getName())) {
     if (PBMethods.matchStarted
         && PBMethods.getWorldGuard() != null
         && PBMethods.AutomateMatches) {
       Location loc = p.getLocation();
       Set<String> regions = PBMethods.RegionsAtLocation(loc);
       String allowedZone = PBMethods.allowedZone.get(p.getName());
       if (regions != null && !regions.isEmpty()) {
         if (!regions.contains(allowedZone)) {
           e.setCancelled(true);
         }
       }
     }
   }
 }
Exemplo n.º 2
0
  public boolean isEligible(Player player) {
    if (!GeneralMethods.canBend(player.getName(), "QuickStrike")) return false;

    if (GeneralMethods.getBoundAbility(player) == null) return false;

    if (!GeneralMethods.getBoundAbility(player).equalsIgnoreCase("QuickStrike")) return false;

    if (GeneralMethods.isRegionProtectedFromBuild(player, "QuickStrike", player.getLocation()))
      return false;

    return true;
  }
Exemplo n.º 3
0
  public boolean progress() {
    if (player.isDead() || !player.isOnline()) {
      remove();
      return false;
    }
    speedfactor = speed * (ProjectKorra.time_step / 1000.);
    if (!charging) {
      if (elements.isEmpty()) {
        remove();
        return false;
      }

      advanceSwipe();
    } else {
      if (GeneralMethods.getBoundAbility(player) == null) {
        remove();
        return false;
      }
      if (!GeneralMethods.getBoundAbility(player).equalsIgnoreCase("AirSwipe")
          || !GeneralMethods.canBend(player.getName(), "AirSwipe")) {
        remove();
        return false;
      }

      if (!player.isSneaking()) {
        double factor = 1;
        if (System.currentTimeMillis() >= time + maxchargetime) {
          factor = maxfactor;
        } else if (AvatarState.isAvatarState(player)) {
          factor = AvatarState.getValue(factor);
        } else {
          factor =
              maxfactor * (double) (System.currentTimeMillis() - time) / (double) maxchargetime;
        }
        charging = false;
        launch();
        if (factor < 1) factor = 1;
        damage *= factor;
        pushfactor *= factor;
        return true;
      } else if (System.currentTimeMillis() >= time + maxchargetime) {
        AirMethods.playAirbendingParticles(player.getEyeLocation(), 3);
      }
    }
    return true;
  }
Exemplo n.º 4
0
  /**
   * 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;
  }
Exemplo n.º 5
0
  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);
    }
  }
  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;
  }