Пример #1
0
  public AirSwipe(Player player, boolean charging) {
    super(player);

    ability = this;
    this.charging = charging;
    this.origin = player.getEyeLocation();
    this.charging = false;
    this.particles = getConfig().getInt("Abilities.Air.AirSwipe.Particles");
    this.arc = getConfig().getInt("Abilities.Air.AirSwipe.Arc");
    this.stepSize = getConfig().getInt("Abilities.Air.AirSwipe.StepSize");
    this.maxChargeTime = getConfig().getLong("Abilities.Air.AirSwipe.MaxChargeTime");
    this.cooldown = getConfig().getLong("Abilities.Air.AirSwipe.Cooldown");
    this.damage = getConfig().getDouble("Abilities.Air.AirSwipe.Damage");
    this.pushFactor = getConfig().getDouble("Abilities.Air.AirSwipe.Push");
    this.speed =
        getConfig().getDouble("Abilities.Air.AirSwipe.Speed") * (ProjectKorra.time_step / 1000.0);
    this.range = getConfig().getDouble("Abilities.Air.AirSwipe.Range");
    this.radius = getConfig().getDouble("Abilities.Air.AirSwipe.Radius");
    this.maxChargeFactor = getConfig().getDouble("Abilities.Air.AirSwipe.chargeFactor");
    this.random = new Random();
    this.elements = new ConcurrentHashMap<>();
    this.affectedEntities = new ArrayList<>();

    if (bPlayer.isOnCooldown(this) || player.getEyeLocation().getBlock().isLiquid()) {
      return;
    }

    if (!charging) {
      launch();
    }
    start();
  }
Пример #2
0
 public static boolean hitBox(
     Location paramLocation, org.bukkit.entity.Entity paramEntity, double paramDouble) {
   if (UtilMath.offset(paramLocation, paramEntity.getLocation().add(0.0D, 0.4D, 0.0D))
       < 0.6D * paramDouble) {
     return true;
   }
   if ((paramEntity instanceof Player)) {
     Player localPlayer = (Player) paramEntity;
     if (UtilMath.offset(paramLocation, localPlayer.getEyeLocation()) < 0.4D * paramDouble) {
       return true;
     }
     if (UtilMath.offset2d(paramLocation, localPlayer.getLocation()) < 0.6D * paramDouble) {
       if ((paramLocation.getY() > localPlayer.getLocation().getY())
           && (paramLocation.getY() < localPlayer.getEyeLocation().getY())) {
         return true;
       }
     }
   } else if ((paramEntity instanceof Giant)) {
     if ((paramLocation.getY() > paramEntity.getLocation().getY())
         && (paramLocation.getY() < paramEntity.getLocation().getY() + 12.0D)
         && (UtilMath.offset2d(paramLocation, paramEntity.getLocation()) < 4.0D)) {
       return true;
     }
   } else if ((paramLocation.getY() > paramEntity.getLocation().getY())
       && (paramLocation.getY() < paramEntity.getLocation().getY() + 2.0D)
       && (UtilMath.offset2d(paramLocation, paramEntity.getLocation()) < 0.5D * paramDouble)) {
     return true;
   }
   return false;
 }
Пример #3
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();
  }
Пример #4
0
  private void progress() {
    if (!hasEmptyWaterBottle()) {
      remove();
      return;
    }

    if (player.isDead() || !player.isOnline()) {
      remove();
      return;
    }

    if (player.getWorld() != location.getWorld()) {
      remove();
      return;
    }

    if (System.currentTimeMillis() < time + interval) return;

    time = System.currentTimeMillis();

    Vector direction = Methods.getDirection(location, player.getEyeLocation()).normalize();
    location = location.clone().add(direction);

    if (location == null || block == null) {
      remove();
      return;
    }

    if (location.getBlock().equals(block.getLocation().getBlock())) return;

    if (Methods.isRegionProtectedFromBuild(player, "WaterManipulation", location)) {
      remove();
      return;
    }

    if (location.distance(player.getEyeLocation())
        > Methods.waterbendingNightAugment(range, player.getWorld())) {
      remove();
      return;
    }

    if (location.distance(player.getEyeLocation()) <= 1.5) {
      fillBottle();
      return;
    }

    Block newblock = location.getBlock();
    if (Methods.isTransparentToEarthbending(player, newblock) && !newblock.isLiquid()) {
      block.revertBlock();
      block = new TempBlock(newblock, Material.WATER, full);
    } else {
      remove();
      return;
    }
  }
Пример #5
0
 private boolean canInstantiate() {
   if (block.getType() != Material.ICE) return false;
   for (Block block : affectedblocks.keySet()) {
     if (blockInAllAffectedBlocks(block)
         || alreadydoneblocks.containsKey(block)
         || block.getType() != Material.AIR
         || (block.getX() == player.getEyeLocation().getBlock().getX()
             && block.getZ() == player.getEyeLocation().getBlock().getZ())) {
       return false;
     }
   }
   return true;
 }
Пример #6
0
  @Override
  public void cast(Entity entity) {
    // entity.getWorld().playSound(entity.getLocation(), Sound.GHAST_FIREBALL, 1F, 1F);
    entity.getWorld().playSound(entity.getLocation(), Sound.NOTE_STICKS, 1F, 0.4F);

    // TODO - find a better way to launch block without needing Player
    if (entity instanceof Player) {
      Player player = (Player) entity;

      Vector velocity = player.getEyeLocation().getDirection();
      velocity.normalize().multiply(power);

      FallingBlock fb =
          DeprecatedMethods.spawnFallingBlock(
              entity.getLocation().clone().add(0, 1, 0),
              DeprecatedMethods.getMaterialByID(blockID),
              (byte) 0);
      fb.setDropItem(false);
      fb.setVelocity(velocity);

      // make it do damage
      if (damage) {
        DynamicClassFunctions.setFallingBlockHurtEntities(fb, hurt, hurt);
      }
    }
  }
Пример #7
0
 public FireJet(Player player) {
   if (instances.containsKey(player)) {
     // player.setAllowFlight(canfly);
     instances.remove(player);
     return;
   }
   if (timers.containsKey(player)) {
     if (System.currentTimeMillis()
         < timers.get(player)
             + (long) ((double) cooldown / Tools.getFirebendingDayAugment(player.getWorld()))) {
       return;
     }
   }
   factor = Tools.firebendingDayAugment(defaultfactor, player.getWorld());
   Block block = player.getLocation().getBlock();
   if (FireStream.isIgnitable(player, block)
       || block.getType() == Material.AIR
       || AvatarState.isAvatarState(player)) {
     player.setVelocity(
         player.getEyeLocation().getDirection().clone().normalize().multiply(factor));
     block.setType(Material.FIRE);
     this.player = player;
     // canfly = player.getAllowFlight();
     player.setAllowFlight(true);
     time = System.currentTimeMillis();
     timers.put(player, time);
     instances.put(player, this);
   }
 }
Пример #8
0
 public static Location getRandomPlayerLocation(Player player) {
   if (MCore.random.nextBoolean()) {
     return player.getLocation();
   } else {
     return player.getEyeLocation();
   }
 }
  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));
      }
    }
  }
Пример #10
0
  public Entity getTarget(Player player) {

    BlockIterator iterator =
        new BlockIterator(
            player.getWorld(),
            player.getLocation().toVector(),
            player.getEyeLocation().getDirection(),
            0,
            100);
    Entity target = null;
    while (iterator.hasNext()) {
      Block item = iterator.next();
      for (Entity entity : player.getNearbyEntities(100, 100, 100)) {
        int acc = 2;
        for (int x = -acc; x < acc; x++) {
          for (int z = -acc; z < acc; z++) {
            for (int y = -acc; y < acc; y++) {
              if (entity.getLocation().getBlock().getRelative(x, y, z).equals(item)) {
                return target = entity;
              }
            }
          }
        }
      }
    }
    return target;
  }
 @EventHandler
 public void onDamage(EntityDamageByEntityEvent event) {
   if (!(event.getEntity() instanceof Player && event.getDamager() instanceof Player))
     return; // We only want to check this if players hit each other
   final Player attacker = (Player) event.getDamager();
   if (attacker.getInventory().getHeldItemSlot() != 8) return;
   final Player victim = (Player) event.getEntity();
   if (AbilityManager.getInstance().getCurrentSpell(attacker) instanceof AbilityHealing) {
     event.setCancelled(true);
     victim.setHealth(victim.getMaxHealth());
     ParticleEffect.HEART.display(
         Vector.getRandom(), 1, victim.getEyeLocation().add(0, 0, .25), Bukkit.getOnlinePlayers());
   }
   if (!(AbilityManager.getInstance().getCurrentSpell(attacker) instanceof AbilityHeartripping))
     return; // Make sure the person punching has heartripping active
   if (!AbilityManager.getInstance().getCurrentSpell(attacker).canUse(attacker)) return;
   if (victim.hasPermission("heart.block")) {
     ChatManager.messageBad(attacker, "That player is too powerful!");
     ChatManager.messageGood(
         victim, attacker.getName() + " attempted to rip out your heart but was too weak!");
     return;
   }
   if (!spellSelection.containsKey(attacker) || !spellSelection.get(attacker).equals(victim)) {
     ChatManager.messageGood(
         attacker, "You ripped " + victim.getName() + "'s heart out of their body!");
     ChatManager.messageBad(
         victim, attacker.getName() + " has ripped your heart out of your body!");
     spellSelection.put(attacker, victim);
   }
   attacker.getInventory().setItemInMainHand(getValidBook(attacker));
 }
Пример #12
0
  private void formOctopus() {
    Location location = player.getLocation();
    newblocks.clear();
    for (double theta = startangle; theta < startangle + angle; theta += 10) {
      double rtheta = Math.toRadians(theta);
      Block block =
          location
              .clone()
              .add(new Vector(radius * Math.cos(rtheta), 0, radius * Math.sin(rtheta)))
              .getBlock();
      addWater(block);
    }

    double tentacleangle =
        (new Vector(1, 0, 0)).angle(player.getEyeLocation().getDirection()) + dta / 2;

    int astep = animstep;
    for (double tangle = tentacleangle; tangle < tentacleangle + 360; tangle += dta) {
      astep += 1;
      double phi = Math.toRadians(tangle);
      tentacle(
          location.clone().add(new Vector(radius * Math.cos(phi), 0, radius * Math.sin(phi))),
          astep);
    }

    for (TempBlock block : blocks) {
      if (!newblocks.contains(block)) block.revertBlock();
    }

    blocks.clear();

    blocks.addAll(newblocks);

    if (blocks.isEmpty()) remove();
  }
Пример #13
0
  public static void useJailStick(Player player) {
    Boolean enabled = Jail.jailStickToggle.get(player);
    if (enabled == null || !enabled) return;

    if (!InputOutput.global.getBoolean(Setting.EnableJailStick.getString(), false)
        || !InputOutput.jailStickParameters.containsKey(player.getItemInHand().getTypeId())) return;
    if (!Util.permission(
        player,
        "jail.usejailstick." + String.valueOf(player.getItemInHand().getTypeId()),
        PermissionDefault.OP)) return;
    String[] param = InputOutput.jailStickParameters.get(player.getItemInHand().getTypeId());

    List<Block> targets = player.getLineOfSight(null, Integer.parseInt(param[1]));
    for (Block b : targets) {
      for (Player p : Bukkit.getServer().getOnlinePlayers()) {
        if (p == player) continue;
        if ((b.getLocation().equals(p.getLocation().getBlock().getLocation())
                || b.getLocation().equals(p.getEyeLocation().getBlock().getLocation()))
            && Util.permission(player, "jail.canbestickjailed", PermissionDefault.TRUE)) {
          String args[] = new String[4];
          args[0] = p.getName();
          args[1] = param[2];
          args[2] = param[3];
          args[3] = param[4];
          PrisonerManager.PrepareJail((CommandSender) player, args);
        }
      }
    }
  }
  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();
      }
    }
  }
Пример #15
0
 @EventHandler
 public void onInteract(PlayerInteractEvent pie) {
   if (pie.getAction().equals(Action.RIGHT_CLICK_BLOCK)
       || pie.getAction().equals(Action.RIGHT_CLICK_AIR)) {
     Player player = pie.getPlayer();
     World world = player.getWorld();
     if (player.getInventory().getItemInHand() != null) {
       ItemStack item = player.getInventory().getItemInHand();
       if (item.getType().equals(Material.DOUBLE_PLANT)) {
         pie.setCancelled(true);
         Item bomb = world.dropItem(player.getEyeLocation(), new ItemStack(Material.GOLD_BLOCK));
         bomb.setPickupDelay(Integer.MAX_VALUE);
         bomb.setVelocity(player.getLocation().getDirection().multiply(0.5));
         double radius = 1.5;
         for (double i = 0; i <= 20D; i += 0.1) {
           Item coin = world.dropItem(bomb.getLocation(), new ItemStack(Material.DOUBLE_PLANT));
           double x = Math.sin(radius * i);
           double z = Math.cos(radius * i);
           Bukkit.getScheduler()
               .scheduleSyncDelayedTask(
                   Factions.instance,
                   new Runnable() {
                     public void run() {}
                   },
                   1);
         }
       }
     }
   }
 }
    public ItemProjectile(Player caster, float power) {
      this.caster = caster;
      this.power = power;
      Location location = caster.getEyeLocation().add(0, yOffset, 0);
      location.setPitch(0f);
      if (vertSpeedUsed) {
        vel = caster.getLocation().getDirection().setY(0).multiply(speed).setY(vertSpeed);
      } else {
        vel = caster.getLocation().getDirection().multiply(speed);
      }
      entity = caster.getWorld().dropItem(location, item.clone());
      MagicSpells.getVolatileCodeHandler().setGravity(entity, projectileHasGravity);
      playSpellEffects(EffectPosition.PROJECTILE, entity);
      playTrackingLinePatterns(
          EffectPosition.DYNAMIC_CASTER_PROJECTILE_LINE,
          caster.getLocation(),
          entity.getLocation(),
          caster,
          entity);
      entity.teleport(location);
      entity.setPickupDelay(1000000);
      entity.setVelocity(vel);

      taskId = MagicSpells.scheduleRepeatingTask(this, 3, 3);
    }
Пример #17
0
  private void launch() {
    origin = player.getEyeLocation();
    for (int i = -arc; i <= arc; i += stepsize) {
      double angle = Math.toRadians((double) i);
      Vector direction = player.getEyeLocation().getDirection().clone();

      double x, z, vx, vz;
      x = direction.getX();
      z = direction.getZ();

      vx = x * Math.cos(angle) - z * Math.sin(angle);
      vz = x * Math.sin(angle) + z * Math.cos(angle);

      direction.setX(vx);
      direction.setZ(vz);

      elements.put(direction, origin);
    }
  }
Пример #18
0
  public AirSwipe(Player player, boolean charging) {
    /* Initial Check */
    BendingPlayer bPlayer = GeneralMethods.getBendingPlayer(player.getName());
    if (bPlayer.isOnCooldown("AirSwipe")) return;
    if (player.getEyeLocation().getBlock().isLiquid()) {
      return;
    }
    /* End Initial Check */
    // reloadVariables();
    this.player = player;
    this.charging = charging;
    origin = player.getEyeLocation();
    time = System.currentTimeMillis();

    instances.put(player, this);

    bPlayer.addCooldown(
        "AirSwipe", ProjectKorra.plugin.getConfig().getLong("Abilities.Air.AirSwipe.Cooldown"));

    if (!charging) launch();
  }
Пример #19
0
 public boolean onCommand(CommandSender cs, Command cmd, String label, String[] args) {
   if (cmd.getName().equalsIgnoreCase("fireball")) {
     if (!plugin.isAuthorized(cs, "rcmds.fireball")) {
       RUtils.dispNoPerms(cs);
       return true;
     }
     if (!(cs instanceof Player)) {
       cs.sendMessage(ChatColor.RED + "This command is only available to players!");
       return true;
     }
     Player p = (Player) cs;
     // Fireball fb = p.launchProjectile(Fireball.class);
     Vector dir = p.getEyeLocation().getDirection().multiply(2);
     Fireball fb =
         p.getWorld()
             .spawn(p.getEyeLocation().add(dir.getX(), dir.getY(), dir.getZ()), Fireball.class);
     fb.setDirection(dir);
     // fb.teleport(p.getEyeLocation().add(dir.getX(), dir.getY(), dir.getZ()));
     fb.setIsIncendiary(true);
     return true;
   }
   return false;
 }
Пример #20
0
  private void attack() {
    if (!formed) return;
    double tentacleangle =
        (new Vector(1, 0, 0)).angle(player.getEyeLocation().getDirection()) + dta / 2;

    for (double tangle = tentacleangle; tangle < tentacleangle + 360; tangle += dta) {
      double phi = Math.toRadians(tangle);
      affect(
          player
              .getLocation()
              .clone()
              .add(new Vector(radius * Math.cos(phi), 1, radius * Math.sin(phi))));
    }
  }
  @EventHandler
  public void onPlayerMonkeyBomb(PlayerInteractEvent event) {
    if (!(event.getAction().equals(Action.RIGHT_CLICK_AIR))
        || !(event.getAction().equals(Action.RIGHT_CLICK_AIR))) {
      return;
    }
    if (event.getAction().equals(Action.RIGHT_CLICK_BLOCK)) {
      if (event.getClickedBlock().getType().equals(Material.SIGN)
          || event.getClickedBlock().getType().equals(Material.SIGN_POST)
          || event.getClickedBlock().getType().equals(Material.WALL_SIGN)) {
        return;
      }
    }
    final Player player = event.getPlayer();
    if (plugin.manager.isPlayerInGame(player)) {
      Game game = plugin.manager.getGame(player);
      if (!(game.mode == ArenaStatus.INGAME)) {
        return;
      }
      if (player.getItemInHand().getType().equals(Material.MAGMA_CREAM)) {
        player.getInventory().removeItem(new ItemStack(Material.MAGMA_CREAM, 1));
        final Item item =
            player
                .getWorld()
                .dropItemNaturally(player.getEyeLocation(), new ItemStack(Material.MAGMA_CREAM));
        // Location Iloc = item.getLocation();
        item.setVelocity(player.getLocation().getDirection().multiply(1));
        item.setPickupDelay(1000);
        /*for(Entity e: game.spawnManager.mobs)
        {

        }*/
        Bukkit.getScheduler()
            .scheduleSyncDelayedTask(
                plugin,
                new Runnable() {
                  @Override
                  public void run() {
                    Location loc = item.getLocation();
                    player
                        .getWorld()
                        .createExplosion(loc.getX(), loc.getY(), loc.getZ(), 4.0F, false, false);
                    item.remove();
                  }
                },
                140);
      }
    }
  }
Пример #22
0
    @EventHandler
    public void onCustomEvent(ToPlayerInRegionEvent event) {
      Location l = event.getLocation();
      RegionManager rm = getPlugin().getRegionManager();
      Region r = rm.getRegion(l);
      if (r == null) return;
      RegionType rt = rm.getRegionType(r.getType());

      int jumpMult = effect.regionHasEffect(rt.getEffects(), "man_cannon");

      // Check if the region is a teleporter
      if (jumpMult == 0) return;

      // Check to see if the Townships has enough reagents
      if (!effect.hasReagents(l)) {
        return;
      }

      // Run upkeep but don't need to know if upkeep occured
      effect.forceUpkeep(event);

      // Launch the player into the air
      Player player = event.getPlayer();
      float pitch = player.getEyeLocation().getPitch();
      int jumpForwards = 1;
      if (pitch > 45) {
        jumpForwards = 1;
      }
      if (pitch > 0) {
        pitch = -pitch;
      }
      float multiplier = ((90f + pitch) / 50f);
      Vector v =
          player
              .getVelocity()
              .setY(1)
              .add(
                  player
                      .getLocation()
                      .getDirection()
                      .setY(0)
                      .normalize()
                      .multiply(multiplier * jumpForwards));
      NCPExemptionManager.exemptPermanently(player, CheckType.MOVING);
      player.setVelocity(v.multiply(jumpMult));
      player.setFallDistance(-8f * jumpMult);
      NCPExemptionManager.unexempt(player, CheckType.MOVING);
    }
Пример #23
0
  public static boolean Damage(Player attacker, Player victim, Double damage) {

    if (victim.isDead()) {
      return false;
    }
    if (attacker != null && !attacker.isOnline()) {
      return false;
    }
    if (DataUtils.getPlayer(victim).isVanished()) {
      return false;
    }
    if (attacker != null && DataUtils.getPlayer(attacker).isVanished()) {
      return false;
    }

    // Multiply and reduce by team stats.

    SmashPredamageEvent event = new SmashPredamageEvent(attacker, victim, damage);
    Bukkit.getPluginManager().callEvent(event);
    if (event.isCancelled()) {
      return false;
    }
    damage = event.getDamage();

    victim.playEffect(EntityEffect.HURT);
    Location loc = victim.getLocation().add(0, 1, 0);
    ParticleUtils.SendPacket(
        ParticleUtils.createBlockPacket(
            EnumParticle.BLOCK_CRACK, 152, 0, loc, new Vector(0.1, 0.1, 0.1), 0F, 50),
        loc);
    ParticleUtils.SendPacket(
        ParticleUtils.createNormalPacket(
            EnumParticle.VILLAGER_ANGRY, victim.getEyeLocation(), new Vector(0, 0, 0), 0F, 1),
        loc);

    Double totalDamage = damage;

    damage = BarrierUtils.takeDamage(victim, damage);

    HologramUtils.displayAlertHolo(victim, "&c-" + Integer.toString(totalDamage.intValue()) + " ❤");

    boolean result = addDamage(attacker, victim, damage);

    Bukkit.getPluginManager().callEvent(new SmashDamageEvent(attacker, victim, totalDamage));

    return result;
  }
Пример #24
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;
  }
Пример #25
0
 public void progress() {
   if (player.isDead() || !player.isOnline()) {
     // player.setAllowFlight(canfly);
     instances.remove(player);
     return;
   }
   if ((Tools.isWater(player.getLocation().getBlock())
           || System.currentTimeMillis() > time + duration)
       && !AvatarState.isAvatarState(player)) {
     // player.setAllowFlight(canfly);
     instances.remove(player);
   } else {
     player.getWorld().playEffect(player.getLocation(), Effect.MOBSPAWNER_FLAMES, 1);
     player.setVelocity(
         player.getEyeLocation().getDirection().clone().normalize().multiply(factor));
     player.setFallDistance(0);
   }
 }
Пример #26
0
 @EventHandler(priority = EventPriority.HIGHEST)
 private void onProjectileLaunch(ProjectileLaunchEvent evt) {
   if (evt.getEntity() instanceof Arrow) {
     Arrow arrow = (Arrow) evt.getEntity();
     if (arrow.getShooter() instanceof Player) {
       Player shooter = (Player) arrow.getShooter();
       PlayerDataClass shooterData =
           plugin.getPlayerHandler().findPlayer(shooter.getDisplayName());
       if (shooterData != null) {
         if (shooter.getInventory().contains(Material.ARROW)) {
           if (shooterData.getType().equalsIgnoreCase("sniper") && arrow.hasMetadata("charged")) {
             evt.setCancelled(true);
             // shooter.getInventory().removeItem(new ItemStack (Material.ARROW, 1));
             // shooter.updateInventory();
             // ItemStack is = shooter.getInventory().getItem(Material.ARROW.getId());
             // is.setAmount(is.getAmount() - 1);
             // shooter.getInventory().setItem(Material.ARROW.getId(), is);
             // Location loc = shooter.getLocation();
             // loc.add(0,1,0);
             Location arrowLocation = shooter.getEyeLocation();
             arrowLocation.setY(arrowLocation.getY() + 0.1);
             Arrow sniperArrow =
                 shooter
                     .getWorld()
                     .spawnArrow(arrowLocation, shooter.getLocation().getDirection(), 0.6f, 1);
             sniperArrow.setShooter(shooter);
             sniperArrow.setBounce(false);
             sniperArrow.setVelocity(
                 shooter.getLocation().getDirection().normalize().multiply(10));
           }
           if (shooterData.getType().equalsIgnoreCase("soldier")) {
             arrow.setMetadata("rocket", new FixedMetadataValue(plugin, true));
             ArrowDataClass arrowData = new ArrowDataClass();
             arrowData.setArrow(arrow);
             arrow.setTicksLived(30);
             arrowData.setVector(shooter.getLocation().getDirection());
             plugin.getArrowsFired().add(arrowData);
           }
         }
       }
     }
   }
 }
Пример #27
0
  public static void Death(Player victim) {
    DeathEffectUtils.playDeathEffect(victim);
    SoundUtils.playSound(Sound.HURT_FLESH, victim.getEyeLocation(), 2F, 0F);

    Player attacker = DataUtils.getPlayer(victim).getLastAttacker();

    StatisticUtils.addDeath(victim);

    if (attacker == null) {
      TitleUtils.sendTitle(victim, "&c&lYou have died!", "&7&lMistakes were made", 10, 80, 10);
      ChatUtils.sendMessage(victim, "&7&m-----------------------------------------------------");
      ChatUtils.sendMessage(victim, "&8[&c&lDeath&8] &7Mistakes were made.");
      ChatUtils.sendMessage(victim, "&7&m-----------------------------------------------------");
    } else {

      String prefixAttacker = DataUtils.getPlayer(attacker).getPrefix();
      String colorAttacker = prefixAttacker.substring(0, 2);
      ChatUtils.sendMessage(victim, "&7&m-----------------------------------------------------");
      ChatUtils.sendMessage(
          victim,
          "&8[&c&lDeath&8] &7You have been slain by " + prefixAttacker + attacker.getDisplayName());
      ChatUtils.sendMessage(victim, "&7&m-----------------------------------------------------");
      TitleUtils.sendTitle(
          victim,
          "&c&lYou have been slain!",
          "&7&lKiller: " + colorAttacker + attacker.getDisplayName(),
          10,
          80,
          10);

      MoneyUtils.deathCoinsPayout(victim);

      StatisticUtils.addDeath(attacker);
    }
    victim.addPotionEffect(new PotionEffect(PotionEffectType.BLINDNESS, 60, 0, true, true));

    //		victim.teleport(Main.SpawnLoc);
    // Location teleport to team spawn.
    victim.setVelocity(new Vector(0, 0, 0));
  }
Пример #28
0
  /**
   * Check if a player looks at a target of a specific size, with a specific precision value
   * (roughly).
   *
   * @param player the player
   * @param targetX the target x
   * @param targetY the target y
   * @param targetZ the target z
   * @param targetWidth the target width
   * @param targetHeight the target height
   * @param precision the precision
   * @return the double
   */
  public static double directionCheck(
      final Player player,
      final double targetX,
      final double targetY,
      final double targetZ,
      final double targetWidth,
      final double targetHeight,
      final double precision) {

    // Get the eye location of the player.
    final Location eyes = player.getEyeLocation();

    final double factor =
        Math.sqrt(
            Math.pow(eyes.getX() - targetX, 2)
                + Math.pow(eyes.getY() - targetY, 2)
                + Math.pow(eyes.getZ() - targetZ, 2));

    // Get the view direction of the player.
    final Vector direction = eyes.getDirection();

    final double x = targetX - eyes.getX();
    final double y = targetY - eyes.getY();
    final double z = targetZ - eyes.getZ();

    final double xPrediction = factor * direction.getX();
    final double yPrediction = factor * direction.getY();
    final double zPrediction = factor * direction.getZ();

    double off = 0.0D;

    off += Math.max(Math.abs(x - xPrediction) - (targetWidth / 2 + precision), 0.0D);
    off += Math.max(Math.abs(z - zPrediction) - (targetWidth / 2 + precision), 0.0D);
    off += Math.max(Math.abs(y - yPrediction) - (targetHeight / 2 + precision), 0.0D);

    if (off > 1) off = Math.sqrt(off);

    return off;
  }
Пример #29
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();
      }
    }
  }
Пример #30
0
 @EventHandler
 public final void PIE(final PlayerInteractEvent event) {
   if (event.getAction() != Action.RIGHT_CLICK_AIR
       && event.getAction() != Action.RIGHT_CLICK_BLOCK) return;
   final Player player = event.getPlayer();
   if (!player.isSneaking()) return;
   final ItemStack item = event.getItem();
   if (item == null
       || item.getType()
           != Material.getMaterial(
               getConfig().getString("id").trim().toUpperCase().replace(' ', '_'))) return;
   final String name = getConfig().getString("name");
   if (!name.isEmpty()
       && (!item.hasItemMeta()
           || !item.getItemMeta().hasDisplayName()
           || !item.getItemMeta()
               .getDisplayName()
               .equals(ChatColor.translateAlternateColorCodes('&', name)))) return;
   final Item entity =
       player
           .getWorld()
           .dropItem(
               player.getEyeLocation().clone().subtract(0, 0.3, 0), new ItemStack(item.getType()));
   entity.setVelocity(
       player.getLocation().getDirection().normalize().multiply(getConfig().getDouble("speed")));
   entity.setMetadata("isminebomb", new FixedMetadataValue(this, player.getName()));
   if (getConfig().getBoolean("use")) {
     if (item.getAmount() == 1) player.setItemInHand(new ItemStack(Material.AIR));
     else {
       item.setAmount(item.getAmount() - 1);
       player.setItemInHand(item);
     }
   }
   new ExplodeTimer(entity, getConfig().getInt("power"))
       .runTaskLater(this, getConfig().getInt("delay") * 20L);
 }