Esempio n. 1
0
  private void throwIce() {
    if (!prepared) return;
    LivingEntity target =
        (LivingEntity) GeneralMethods.getTargetedEntity(player, range, new ArrayList<Entity>());
    if (target == null) {
      destination =
          GeneralMethods.getTargetedLocation(player, range, EarthMethods.transparentToEarthbending);
    } else {
      destination = target.getEyeLocation();
    }

    location = sourceblock.getLocation();
    if (destination.distance(location) < 1) return;
    firstdestination = location.clone();
    if (destination.getY() - location.getY() > 2) {
      firstdestination.setY(destination.getY() - 1);
    } else {
      firstdestination.add(0, 2, 0);
    }
    destination = GeneralMethods.getPointOnLine(firstdestination, destination, range);
    progressing = true;
    settingup = true;
    prepared = false;

    new TempBlock(sourceblock, Material.AIR, (byte) 0);

    source = new TempBlock(sourceblock, Material.PACKED_ICE, data);
  }
Esempio n. 2
0
  public AirScooter(Player player) {
    super(player);

    if (check(player)) return;
    else if (!player.isSprinting()
        || GeneralMethods.isSolid(player.getEyeLocation().getBlock())
        || player.getEyeLocation().getBlock().isLiquid()) return;
    else if (GeneralMethods.isSolid(player.getLocation().add(0, -.5, 0).getBlock())) return;
    else if (bPlayer.isOnCooldown(this)) return;

    this.speed = getConfig().getDouble("Abilities.Air.AirScooter.Speed");
    this.interval = getConfig().getDouble("Abilities.Air.AirScooter.Interval");
    this.radius = getConfig().getDouble("Abilities.Air.AirScooter.Radius");
    this.cooldown = getConfig().getLong("Abilities.Air.AirScooter.Cooldown");
    this.maxHeightFromGround =
        getConfig().getDouble("Abilities.Air.AirScooter.MaxHeightFromGround");
    this.random = new Random();
    this.angles = new ArrayList<>();
    canFly = player.getAllowFlight();
    hadFly = player.isFlying();

    new Flight(player);
    player.setAllowFlight(true);
    player.setFlying(true);
    player.setSprinting(false);

    for (int i = 0; i < 5; i++) {
      angles.add((double) (60 * i));
    }

    start();
  }
Esempio n. 3
0
  private void affect(LivingEntity entity) {
    int damage = (int) WaterMethods.waterbendingNightAugment(defaultdamage, player.getWorld());
    if (entity instanceof Player) {
      BendingPlayer bPlayer = GeneralMethods.getBendingPlayer(player.getName());
      if (bPlayer.canBeSlowed()) {
        PotionEffect effect = new PotionEffect(PotionEffectType.SLOW, 70, 2);
        new TempPotionEffect(entity, effect);
        bPlayer.slow(10);
        // entity.damage(damage, player);
        GeneralMethods.damageEntity(player, entity, damage, "IceBlast");
      }
    } else {
      PotionEffect effect = new PotionEffect(PotionEffectType.SLOW, 70, 2);
      new TempPotionEffect(entity, effect);
      // entity.damage(damage, player);
      GeneralMethods.damageEntity(player, entity, damage, "IceBlast");
    }
    AirMethods.breakBreathbendingHold(entity);

    for (int x = 0; x < 30; 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)),
          .3f,
          location,
          257.0D);
    }
  }
Esempio n. 4
0
  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;
  }
  private static void block(Player player) {
    for (int id : instances.keySet()) {
      EarthBlast blast = instances.get(id);

      if (blast.player.equals(player)) {
        continue;
      }

      if (!blast.location.getWorld().equals(player.getWorld())) {
        continue;
      }

      if (!blast.progressing) {
        continue;
      }

      if (GeneralMethods.isRegionProtectedFromBuild(player, "EarthBlast", blast.location)) {
        continue;
      }

      Location location = player.getEyeLocation();
      Vector vector = location.getDirection();
      Location mloc = blast.location;
      if (mloc.distance(location) <= RANGE
          && GeneralMethods.getDistanceFromLine(vector, location, blast.location) < deflectrange
          && mloc.distance(location.clone().add(vector))
              < mloc.distance(location.clone().add(vector.clone().multiply(-1)))) {
        blast.breakBlock();
      }
    }
  }
  private static void redirectTargettedBlasts(Player player, ArrayList<EarthBlast> ignore) {
    for (int id : instances.keySet()) {
      EarthBlast blast = instances.get(id);

      if (!blast.progressing || ignore.contains(blast)) {
        continue;
      }

      if (!blast.location.getWorld().equals(player.getWorld())) {
        continue;
      }

      if (GeneralMethods.isRegionProtectedFromBuild(player, "EarthBlast", blast.location)) {
        continue;
      }

      if (blast.player.equals(player)) {
        blast.redirect(player, getTargetLocation(player));
      }

      Location location = player.getEyeLocation();
      Vector vector = location.getDirection();
      Location mloc = blast.location;
      if (mloc.distance(location) <= RANGE
          && GeneralMethods.getDistanceFromLine(vector, location, blast.location) < deflectrange
          && mloc.distance(location.clone().add(vector))
              < mloc.distance(location.clone().add(vector.clone().multiply(-1)))) {
        blast.redirect(player, getTargetLocation(player));
      }
    }
  }
 @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);
         }
       }
     }
   }
 }
Esempio n. 8
0
  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);
      }
    }
  }
Esempio n. 9
0
  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 static Location getTargetLocation(Player player) {
   Entity target = GeneralMethods.getTargetedEntity(player, RANGE, new ArrayList<Entity>());
   Location location;
   if (target == null) {
     location = GeneralMethods.getTargetedLocation(player, RANGE);
   } else {
     location = ((LivingEntity) target).getEyeLocation();
   }
   return location;
 }
Esempio n. 11
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;
  }
Esempio n. 12
0
  public QuickStrike(Player player) {
    if (!isEligible(player)) return;

    Entity e = GeneralMethods.getTargetedEntity(player, 2, new ArrayList<Entity>());

    if (e == null) return;

    GeneralMethods.damageEntity(player, e, damage);

    if (GeneralMethods.rand.nextInt(100) < blockChance && e instanceof Player) {
      ChiPassive.blockChi((Player) e);
    }

    ChiComboManager.addCombo(player, ChiCombo.QuickStrike);
  }
Esempio n. 13
0
 private void addLava(Block block) {
   if (GeneralMethods.isRegionProtectedFromBuild(player, "LavaSurge", block.getLocation())) return;
   if (!TempBlock.isTempBlock(block)) {
     new TempBlock(block, Material.STATIONARY_LAVA, (byte) 8);
     AFFECTED_BLOCKS.put(block, block);
   }
 }
Esempio n. 14
0
 public static void removeAll() {
   for (final Player player : TouchOfEvil.instances.keySet()) {
     // instances.get(player).revert();
     TouchOfEvil.instances.remove(player);
     GeneralMethods.getBendingPlayer(player.getName()).eviltouch = false;
     player.sendMessage(ChatColor.DARK_GRAY + "The dark spirit returns to your body.");
   }
 }
Esempio n. 15
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;
  }
Esempio n. 16
0
 private void removeLava(Block block) {
   if (block != null) {
     if (AFFECTED_BLOCKS.containsKey(block)) {
       if (!GeneralMethods.isAdjacentToThreeOrMoreSources(block)) {
         TempBlock.revertBlock(block, Material.AIR);
       }
       AFFECTED_BLOCKS.remove(block);
     }
   }
 }
Esempio n. 17
0
 private void getFloor() {
   floorblock = null;
   for (int i = 0; i <= maxHeightFromGround; i++) {
     Block block = player.getEyeLocation().getBlock().getRelative(BlockFace.DOWN, i);
     if (GeneralMethods.isSolid(block) || block.isLiquid()) {
       floorblock = block;
       return;
     }
   }
 }
Esempio n. 18
0
 private void affect(LivingEntity entity) {
   entity.setVelocity(thrown);
   GeneralMethods.damageEntity(player, entity, damage, "IceSpike");
   damaged.add(entity);
   long slowCooldown = IceSpike2.slowCooldown;
   int mod = 2;
   if (entity instanceof Player) {
     BendingPlayer bPlayer = GeneralMethods.getBendingPlayer(player.getName());
     if (bPlayer.canBeSlowed()) {
       PotionEffect effect = new PotionEffect(PotionEffectType.SLOW, 70, mod);
       new TempPotionEffect(entity, effect);
       bPlayer.slow(slowCooldown);
     }
   } else {
     PotionEffect effect = new PotionEffect(PotionEffectType.SLOW, 70, mod);
     new TempPotionEffect(entity, effect);
   }
   AirMethods.breakBreathbendingHold(entity);
 }
Esempio n. 19
0
 private static boolean isFreezable(Player player, Block block) {
   if (GeneralMethods.isRegionProtectedFromBuild(player, "PhaseChange", block.getLocation())) {
     return false;
   }
   if (block.getType() == Material.WATER || block.getType() == Material.STATIONARY_WATER) {
     if (WaterManipulation.canPhysicsChange(block) && !TempBlock.isTempBlock(block)) {
       return true;
     }
   }
   return false;
 }
Esempio n. 20
0
 private void cancel() {
   if (progressing) {
     if (source != null) source.revertBlock();
     progressing = false;
   }
   BendingPlayer bPlayer = GeneralMethods.getBendingPlayer(player.getName());
   if (bPlayer != null) {
     bPlayer.addCooldown("IceBlast", cooldown);
   }
   instances.remove(id);
 }
Esempio n. 21
0
  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);
    }
  }
Esempio n. 22
0
  public static void activate(Player player) {

    BendingPlayer bPlayer = GeneralMethods.getBendingPlayer(player.getName());

    if (bPlayer.isOnCooldown("IceBlast")) return;

    for (IceBlast ice : getInstances(player)) {
      if (ice.prepared) {
        ice.throwIce();
      }
    }
  }
Esempio n. 23
0
  public TouchOfEvil(final Player 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") {
          found = true;
          this.effect = (HelixEffect) e;
        } else {
          player.sendMessage("Didn't find Helix but found:" + bPlayer.effects.get(e));
        }
      }
    }
    if (!found) {
      final HelixEffect effect = new HelixEffect(MegaBending.getEM());
      bPlayer.effects.put(effect, "Helix");
      this.start = true;
    }
    if (TouchOfEvil.instances.containsKey(player)) {
      // instances.get(player).revert();
      bPlayer.eviltouch = false;
      TouchOfEvil.instances.remove(player);

    } else {
      if (bPlayer.isOnCooldown("TouchOfEvil") && !bPlayer.isOnCooldown("EvilAura")) {
        player.sendMessage(
            ChatColor.DARK_GRAY
                + "You must wait a while before activating the Touch of Evil ability again.");
        return;
      }
      if (bPlayer.isOnCooldown("EvilAura")) {
        player.sendMessage(ChatColor.DARK_GRAY + "That ability is already active!");
        return;
      }
      if (bPlayer.isOnCooldown("DrainAura")) {
        player.sendMessage(
            ChatColor.DARK_GRAY + "You may only have one aura ability active at a time!");
        return;
      }
      if (MegaBendingScarecrowMethods.isChiBlocked(player.getName())) {
        player.sendMessage(ChatColor.DARK_GRAY + "Your abilities have been temporarily blocked!");
        return;
      }
      set();
      TouchOfEvil.instances.put(player, this);
      bPlayer.addCooldown("TouchOfEvil", 90000);
      bPlayer.addCooldown("EvilAura", 9000);
      player.sendMessage(
          ChatColor.DARK_GRAY + "The dark spirit swirls around your body looking for prey.");
      bPlayer.eviltouch = true;
    }
  }
 @SuppressWarnings("deprecation")
 public void throwEarth() {
   if (sourceblock != null) {
     if (sourceblock.getWorld().equals(player.getWorld())) {
       if (EarthMethods.movedearth.containsKey(sourceblock)) {
         if (!revert) {
           EarthMethods.removeRevertIndex(sourceblock);
         }
       }
       Entity target = GeneralMethods.getTargetedEntity(player, range, new ArrayList<Entity>());
       // Methods.verbose(target);
       if (target == null) {
         destination =
             player
                 .getTargetBlock(EarthMethods.getTransparentEarthbending(), (int) range)
                 .getLocation();
         firstdestination = sourceblock.getLocation().clone();
         firstdestination.setY(destination.getY());
       } else {
         destination = ((LivingEntity) target).getEyeLocation();
         firstdestination = sourceblock.getLocation().clone();
         firstdestination.setY(destination.getY());
         destination = GeneralMethods.getPointOnLine(firstdestination, destination, range);
       }
       if (destination.distance(location) <= 1) {
         progressing = false;
         destination = null;
       } else {
         progressing = true;
         EarthMethods.playEarthbendingSound(sourceblock.getLocation());
         // direction = getDirection().normalize();
         if (sourcetype != Material.SAND && sourcetype != Material.GRAVEL) {
           sourceblock.setType(sourcetype);
         }
       }
     }
   }
 }
Esempio n. 25
0
  private static void block(Player player) {
    for (int id : instances.keySet()) {
      IceBlast ice = instances.get(id);

      if (ice.player.equals(player)) continue;

      if (!ice.location.getWorld().equals(player.getWorld())) continue;

      if (!ice.progressing) continue;

      if (GeneralMethods.isRegionProtectedFromBuild(player, "IceBlast", ice.location)) continue;

      Location location = player.getEyeLocation();
      Vector vector = location.getDirection();
      Location mloc = ice.location;
      if (mloc.distance(location) <= defaultrange
          && GeneralMethods.getDistanceFromLine(vector, location, ice.location) < deflectrange
          && mloc.distance(location.clone().add(vector))
              < mloc.distance(location.clone().add(vector.clone().multiply(-1)))) {
        ice.cancel();
      }
    }
  }
Esempio n. 26
0
  public EarthColumn(Player player) {
    BendingPlayer bPlayer = GeneralMethods.getBendingPlayer(player.getName());

    if (bPlayer.isOnCooldown("RaiseEarth")) return;

    try {
      if (AvatarState.isAvatarState(player)) {
        height = (int) (2. / 5. * (double) AvatarState.getValue(height));
      }
      block = BlockSource.getEarthSourceBlock(player, range, ClickType.LEFT_CLICK);
      if (block == null) return;
      origin = block.getLocation();
      location = origin.clone();
      distance =
          EarthMethods.getEarthbendableBlocksLength(
              player, block, direction.clone().multiply(-1), height);
    } catch (IllegalStateException e) {
      return;
    }

    this.player = player;

    loadAffectedBlocks();

    if (distance != 0) {
      if (canInstantiate()) {
        id = ID;
        instances.put(id, this);
        bPlayer.addCooldown("RaiseEarth", GeneralMethods.getGlobalCooldown());
        if (ID >= Integer.MAX_VALUE) {
          ID = Integer.MIN_VALUE;
        }
        ID++;
        time = System.currentTimeMillis() - interval;
      }
    }
  }
Esempio n. 27
0
  public FreezeMelt(Player player) {
    BendingPlayer bPlayer = GeneralMethods.getBendingPlayer(player.getName());

    if (!WaterMethods.canIcebend(player)) {
      return;
    }
    if (bPlayer.isOnCooldown("PhaseChange")) {
      return;
    }
    bPlayer.addCooldown("PhaseChange", cooldown);

    int range = (int) WaterMethods.waterbendingNightAugment(defaultrange, player.getWorld());
    int radius = (int) WaterMethods.waterbendingNightAugment(defaultradius, player.getWorld());
    if (AvatarState.isAvatarState(player)) {
      range = AvatarState.getValue(range);
    }

    Location location = GeneralMethods.getTargetedLocation(player, range);
    for (Block block : GeneralMethods.getBlocksAroundPoint(location, radius)) {
      if (isFreezable(player, block)) {
        freeze(player, block);
      }
    }
  }
Esempio n. 28
0
 @SuppressWarnings("deprecation")
 static void freeze(Player player, Block block) {
   if (GeneralMethods.isRegionProtectedFromBuild(player, "PhaseChange", block.getLocation())) {
     return;
   }
   if (TempBlock.isTempBlock(block)) {
     return;
   }
   byte data = block.getData();
   block.setType(Material.ICE);
   if (frozenblocks.size() % 50 == 0) {
     WaterMethods.playIcebendingSound(block.getLocation());
   }
   frozenblocks.put(block, data);
 }
  public static void throwEarth(Player player) {
    ArrayList<EarthBlast> ignore = new ArrayList<EarthBlast>();

    BendingPlayer bPlayer = GeneralMethods.getBendingPlayer(player.getName());
    if (bPlayer.isOnCooldown("EarthBlast")) {
      return;
    }

    boolean cooldown = false;
    for (int id : instances.keySet()) {
      EarthBlast blast = instances.get(id);
      if (blast.player == player && !blast.progressing) {
        blast.throwEarth();
        cooldown = true;
        ignore.add(blast);
      }
    }

    if (cooldown) {
      bPlayer.addCooldown("EarthBlast", GeneralMethods.getGlobalCooldown());
    }

    redirectTargettedBlasts(player, ignore);
  }
  /**
   * Permanently removes a player's bending, or restores it if it had already been permaremoved.
   *
   * @param sender The CommandSender who issued the permaremove command
   * @param target The Player who's bending should be permaremoved
   */
  private void permaremove(CommandSender sender, String target) {
    Player player = Bukkit.getPlayer(target);
    if (player == null) {
      sender.sendMessage(ChatColor.RED + "That player is not online.");
      return;
    }

    BendingPlayer bPlayer = GeneralMethods.getBendingPlayer(player.getName());
    if (bPlayer == null) {
      GeneralMethods.createBendingPlayer(player.getUniqueId(), player.getName());
      bPlayer = GeneralMethods.getBendingPlayer(player);
    }

    if (bPlayer.isPermaRemoved()) {
      bPlayer.setPermaRemoved(false);
      GeneralMethods.savePermaRemoved(bPlayer);
      player.sendMessage(ChatColor.GREEN + "Your bending has been restored.");
      if (!(sender instanceof Player) || sender.getName().equals(target)) {
        sender.sendMessage(
            ChatColor.GREEN
                + "You have restored the bending of: "
                + ChatColor.DARK_AQUA
                + player.getName());
      }
    } else {
      bPlayer.getElements().clear();
      GeneralMethods.removeUnusableAbilities(player.getName());
      GeneralMethods.saveElements(bPlayer);
      bPlayer.setPermaRemoved(true);
      GeneralMethods.savePermaRemoved(bPlayer);
      player.sendMessage(ChatColor.RED + "Your bending has been permanently removed.");
      if (!(sender instanceof Player) || sender.getName().equals(target)) {
        sender.sendMessage(
            ChatColor.RED
                + "You have permenantly removed the bending of: "
                + ChatColor.DARK_AQUA
                + player.getName());
      }
      Bukkit.getServer()
          .getPluginManager()
          .callEvent(new PlayerChangeElementEvent(sender, player, null, Result.PERMAREMOVE));
    }
  }