コード例 #1
0
ファイル: MachineGun.java プロジェクト: glatteis/DuckMode
  @Override
  public void shoot(PlayerInteractEvent event) {
    if (event.getMaterial() == null) return;
    final List<String> itemLore = event.getItem().getItemMeta().getLore();

    if (WeaponWatch.durability.get(itemLore) == null) WeaponWatch.durability.put(itemLore, 4);
    if (WeaponWatch.durability.get(itemLore) == 0) return;
    if (WeaponWatch.cooldown.contains(itemLore)) return;

    if (shotsLeft.get(itemLore) != null && shotsLeft.get(itemLore) == 0) {
      WeaponWatch.cooldown.add(itemLore);
      shotsLeft.remove(itemLore);
      new BukkitRunnable() {
        @Override
        public void run() {
          WeaponWatch.durability.put(itemLore, WeaponWatch.durability.get(itemLore) - 1);
          WeaponWatch.cooldown.remove(itemLore);
        }
      }.runTaskLater(DuckMain.getPlugin(), 80);
    }

    int shotsPerRound = 6; // @Balancing: Specify shots per round here

    if (shotsLeft.get(itemLore) == null) shotsLeft.put(itemLore, shotsPerRound);
    else shotsLeft.put(itemLore, shotsLeft.get(itemLore) - 1);

    DuckMain.getWorld().playSound(event.getPlayer().getLocation(), Sound.ENTITY_BLAZE_HURT, 10, 1);
    Arrow a =
        event
            .getPlayer()
            .launchProjectile(Arrow.class, event.getPlayer().getLocation().getDirection());
    a.setShooter(event.getPlayer());
    a.setVelocity(a.getVelocity().multiply(6));
    a.setCustomName("MachineGun");
  }
コード例 #2
0
ファイル: ArrowSign.java プロジェクト: Bronski/PailStone-Duo
  protected void triggersign(TriggerType type, Object args) {
    InputState is = this.getInput(1, (BlockRedstoneEvent) args);

    if (is == InputState.HIGH && !lastState) {
      lastState = true;

      Vector v =
          new Vector(
              to.getBlockX() - from.getBlockX(),
              to.getBlockY() - from.getBlockY(),
              to.getBlockZ() - from.getBlockZ());

      v.normalize();

      v.multiply(speed);

      while (from.getBlock().getType() != Material.AIR) {
        from = from.toVector().add(v.clone().normalize().multiply(.2)).toLocation(this.getWorld());
      }

      for (int i = 0; i < arrows; i++) {

        Arrow a = this.getWorld().spawn(from, Arrow.class);
        a.setVelocity(v.clone().add(getVariance(variance)));
        this.main.cleaner.register(a, 5000);
      }

      this.getWorld().playEffect(from, org.bukkit.Effect.BOW_FIRE, 0);
    } else if ((is == InputState.LOW || is == InputState.DISCONNECTED) && lastState) {
      lastState = false;
    } else {
      return;
    }
  }
コード例 #3
0
ファイル: DodgeL.java プロジェクト: TheRemixPvP/cKitPVP
 @EventHandler
 public void DodgeHit(EntityDamageByEntityEvent e) {
   if (e.getCause() == DamageCause.PROJECTILE) {
     if (e.getEntity() instanceof Player) {
       Player p = (Player) e.getEntity();
       if (PDUtils.getByName(p.getName()).getKit() != null
           && PDUtils.getByName(p.getName()).getKit().equalsIgnoreCase("Dodge")) {
         PData pd = PDUtils.getByName(p.getName());
         Arrow a = p.launchProjectile(Arrow.class);
         a.setShooter(p);
         a.setVelocity(e.getDamager().getVelocity().multiply(-1));
         e.setCancelled(true);
       }
     }
   }
 }
コード例 #4
0
ファイル: PlayerListeners.java プロジェクト: jayserp/minekoth
 @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);
           }
         }
       }
     }
   }
 }
コード例 #5
0
ファイル: DodgeL.java プロジェクト: TheRemixPvP/cKitPVP
 @EventHandler
 public void ProjectileHit(ProjectileHitEvent e) {
   List<Entity> nbe =
       e.getEntity()
           .getNearbyEntities(
               e.getEntity().getLocation().getX(),
               e.getEntity().getLocation().getY(),
               e.getEntity().getLocation().getZ());
   for (Entity ee : nbe) {
     if (ee instanceof Player) {
       Player ph = (Player) ee;
       PData pd = PDUtils.getByName(ph.getName());
       if (pd.getKit() != null && pd.getKit().equalsIgnoreCase("Dodge")) {
         Arrow a = ph.launchProjectile(Arrow.class);
         a.setShooter(ph);
         a.setVelocity(e.getEntity().getShooter().getLocation().toVector());
       }
     }
   }
 }
コード例 #6
0
 @Override
 public void run() {
   Arrow shot = player.launchProjectile(Arrow.class);
   shot.setVelocity(shot.getVelocity().multiply(2.0));
 }
コード例 #7
0
  @EventHandler(ignoreCancelled = true)
  public void onEntityDamageEntity(EntityDamageByEntityEvent e) {
    if (e.getEntity() instanceof Player) { // Hit player
      Player damaged = (Player) e.getEntity();
      if (e.getDamager() instanceof Player) { // Player
        Player damager = (Player) e.getDamager();
        if (cancelBothIngame(damaged, damager)) {
          e.setCancelled(true);
          return;
        }
        if (checkForShadowBlade(damager)) {
          e.setCancelled(true);
          return;
        }
        if (pl.ingameList.get(damager).getAttackType() == 2) {
          if (damager.getItemInHand().getType().equals(Material.IRON_SWORD)
              || damager.getItemInHand().getType().equals(Material.DIAMOND_SWORD)
              || damager.getItemInHand().getType().equals(Material.GOLD_SWORD)) {
            e.setCancelled(true);
            return;
          }
        }
        if (!e.isCancelled()) {
          checkTeleport(damager);
        }
      } else if (e.getDamager() instanceof Projectile) { // Arrow
        Projectile proj = (Projectile) e.getDamager();
        if (proj.getShooter() instanceof Player) {
          Player shooter = (Player) proj.getShooter();
          if (cancelBothIngame(damaged, shooter)) {
            e.setCancelled(true);
            return;
          }
          if (pl.ingameList.get(shooter).getAttackType() == 1) {
            e.setCancelled(true);
            return;
          }
          if (checkForShadowBlade(shooter)) {
            e.setCancelled(true);
            return;
          }

          checkTeleport(shooter);
          if (!e.isCancelled()) {
            if (!checkIngame(damaged)
                && checkIngame(shooter)) { // spectator wont get hurt, and the arrow wont stop
              proj.setBounce(false);
              Vector vel = proj.getVelocity();
              damaged.teleport(damaged.getLocation().add(0, 3, 0));
              damaged.setFlying(true);
              Arrow newArrow = shooter.launchProjectile(Arrow.class);
              newArrow.setShooter(shooter);
              newArrow.setVelocity(vel);
              e.setCancelled(true);
              proj.remove();
            } else if (checkIngame(damaged) && checkIngame(shooter)) {
              // e.setCancelled(true);
              // damaged.damage(e.getDamage());
              checkTarrasque(damaged);
              checkTeleport(damaged);
              checkTeleport(shooter);
              pl.breakEffect(damaged.getLocation(), 3, 11);
            }
          }
        }
      }
    } else { // Hit a non-player
      if (e.getDamager() instanceof Player) { // Player
        Player damager = (Player) e.getDamager();
        if (checkSpectator(damager)) {
          e.setCancelled(true);
          return;
        }
        if (checkForShadowBlade(damager)) {
          e.setCancelled(true);
          return;
        }
        if (pl.ingameList.get(damager).getAttackType() == 2) {
          if (damager.getItemInHand().getType().equals(Material.IRON_SWORD)
              || damager.getItemInHand().getType().equals(Material.DIAMOND_SWORD)
              || damager.getItemInHand().getType().equals(Material.GOLD_SWORD)) {
            e.setCancelled(true);
            return;
          }
        }
        checkTeleport(damager);
      } else if (e.getDamager() instanceof Projectile) { // Arrow
        Projectile proj = (Projectile) e.getDamager();
        if (proj.getShooter() instanceof Player) {
          Player shooter = (Player) proj.getShooter();
          if (!checkIngame(shooter)) {
            if (checkSpectator(shooter)) {
              e.setCancelled(true);
              return;
            }
          } else {
            if (pl.ingameList.get(shooter).getAttackType() == 1) {
              e.setCancelled(true);
              return;
            }
            if (checkForShadowBlade(shooter)) {
              e.setCancelled(true);
              return;
            }
            checkTeleport(shooter);
          }
        }
      }
      if (!e.isCancelled()) {
        pl.breakEffect(e.getEntity().getLocation(), 2, 55);
      }
    }
  }
コード例 #8
0
ファイル: Bows.java プロジェクト: FriedCream/lol-
 @EventHandler
 public void onBowShoot(final EntityShootBowEvent e) {
   if (!Api.allowsPVP(e.getEntity())) return;
   if (e.getBow().hasItemMeta()) {
     if (e.getBow().getItemMeta().hasLore()) {
       for (String lore : e.getBow().getItemMeta().getLore()) {
         if (lore.contains(Api.getEnchName("Boom"))) {
           if (Api.isEnchantmentEnabled("Boom")) {
             Arrow.put(
                 (Projectile) e.getProjectile(), Api.getPower(lore, Api.getEnchName("Boom")));
             P.put((Projectile) e.getProjectile(), e.getEntity());
             Enchant.put((Projectile) e.getProjectile(), "Boom");
           }
         }
         if (lore.contains(Api.getEnchName("Doctor"))) {
           if (Api.isEnchantmentEnabled("Doctor")) {
             Arrow.put(
                 (Projectile) e.getProjectile(), Api.getPower(lore, Api.getEnchName("Doctor")));
             P.put((Projectile) e.getProjectile(), e.getEntity());
             Enchant.put((Projectile) e.getProjectile(), "Doctor");
           }
         }
         if (lore.contains(Api.getEnchName("IceFreeze"))) {
           if (Api.isEnchantmentEnabled("IceFreeze")) {
             Arrow.put(
                 (Projectile) e.getProjectile(), Api.getPower(lore, Api.getEnchName("IceFreeze")));
             P.put((Projectile) e.getProjectile(), e.getEntity());
             Enchant.put((Projectile) e.getProjectile(), "IceFreeze");
           }
         }
         if (lore.contains(Api.getEnchName("Lightning"))) {
           if (Api.isEnchantmentEnabled("Lightning")) {
             Arrow.put(
                 (Projectile) e.getProjectile(), Api.getPower(lore, Api.getEnchName("Lightning")));
             P.put((Projectile) e.getProjectile(), e.getEntity());
             Enchant.put((Projectile) e.getProjectile(), "Lightning");
           }
         }
         if (lore.contains(Api.getEnchName("Piercing"))) {
           if (Api.isEnchantmentEnabled("Piercing")) {
             Arrow.put(
                 (Projectile) e.getProjectile(), Api.getPower(lore, Api.getEnchName("Piercing")));
             P.put((Projectile) e.getProjectile(), e.getEntity());
             Enchant.put((Projectile) e.getProjectile(), "Piercing");
           }
         }
         if (lore.contains(Api.getEnchName("Venom"))) {
           if (Api.isEnchantmentEnabled("Venom")) {
             Arrow.put(
                 (Projectile) e.getProjectile(), Api.getPower(lore, Api.getEnchName("Venom")));
             P.put((Projectile) e.getProjectile(), e.getEntity());
             Enchant.put((Projectile) e.getProjectile(), "Venom");
           }
         }
         if (lore.contains(Api.getEnchName("MultiArrow"))) {
           if (Api.isEnchantmentEnabled("MultiArrow")) {
             int power = Api.getPower(lore, Api.getEnchName("MultiArrow"));
             if (Api.randomPicker(2)) {
               for (int i = 1; i <= power; i++) {
                 Arrow arrow =
                     e.getEntity().getWorld().spawn(e.getProjectile().getLocation(), Arrow.class);
                 arrow.setShooter(e.getEntity());
                 arrow.setBounce(false);
                 Vector v = new Vector(Vec(), 0, Vec());
                 arrow.setVelocity(e.getProjectile().getVelocity().add(v));
                 if (((Arrow) e.getProjectile()).isCritical()) arrow.setCritical(true);
               }
             }
           }
         }
       }
     }
   }
 }
コード例 #9
0
ファイル: HFEffects.java プロジェクト: Yoshor13/Zenchantments
  @Override
  public void run() {
    for (Location l : Storage.blackholes.keySet()) {
      for (Entity e : Utilities.getNearbyEntities(l, 10, 10, 10)) {
        if (e instanceof Player) {
          if (((Player) e).getGameMode().equals(CREATIVE)) {
            continue;
          }
        }
        if (Storage.blackholes.get(l)) {
          Vector v = l.clone().subtract(e.getLocation()).toVector();
          v.setX(v.getX() + (-.5f + Storage.rnd.nextFloat()) * 10);
          v.setY(v.getY() + (-.5f + Storage.rnd.nextFloat()) * 10);
          v.setZ(v.getZ() + (-.5f + Storage.rnd.nextFloat()) * 10);
          e.setVelocity(v.multiply(.35f));
          e.setFallDistance(0);
        } else {
          Vector v = e.getLocation().subtract(l.clone()).toVector();
          v.setX(v.getX() + (-.5f + Storage.rnd.nextFloat()) * 2);
          v.setY(v.getY() + Storage.rnd.nextFloat());
          v.setZ(v.getZ() + (-.5f + Storage.rnd.nextFloat()) * 2);
          e.setVelocity(v.multiply(.35f));
        }
      }
    }
    // Arrows
    toRemove.clear();
    for (Set<CustomArrow> pro : Storage.advancedProjectiles.values()) {
      for (CustomArrow a : pro) {
        a.onFlight();
        a.tick++;
        if (a.entity.isDead() || a.tick > 600) {
          toRemove.add(a);
        }
      }
    }
    for (CustomArrow pro : toRemove) {
      Storage.advancedProjectiles.remove(pro.entity);
      pro.entity.remove();
    }
    for (Block block : Storage.webs) {
      if (Storage.rnd.nextInt(175) == 0 && block.getChunk().isLoaded()) {
        block.setType(AIR);
        websToRemove.add(block);
      }
    }
    for (Block block : websToRemove) {
      Storage.webs.remove(block);
    }
    websToRemove.clear();
    for (LivingEntity ent : Storage.derpingEntities) {
      Location loc = ent.getLocation();
      loc.setYaw(Storage.rnd.nextFloat() * 360F);
      loc.setPitch(Storage.rnd.nextFloat() * 180F - 90F);
      ent.teleport(loc);
    }
    tick++;
    // Other stuff
    for (FallingBlock b : Storage.anthMobs2) {
      if (!Storage.anthVortex.contains(Storage.anthMobs.get(b))) {
        for (Entity e : b.getNearbyEntities(7, 7, 7)) {
          if (e instanceof LivingEntity) {
            LivingEntity lE = (LivingEntity) e;
            if (!(lE instanceof Player) && lE instanceof Monster) {
              b.setVelocity(e.getLocation().subtract(b.getLocation()).toVector().multiply(.25));
              if (lE.getLocation().getWorld().equals(b.getLocation().getWorld())) {
                if (lE.getLocation().distance(b.getLocation()) < 1.2) {
                  EntityDamageEvent evt =
                      new EntityDamageEvent(lE, EntityDamageEvent.DamageCause.SUFFOCATION, 100);
                  Bukkit.getPluginManager().callEvent(evt);
                  lE.setLastDamageCause(evt);
                  if (!evt.isCancelled()) {
                    lE.damage(8f);
                  }
                }
              }
            }
          }
        }
      }
    }
    boolean r = Storage.fallBool;
    Storage.fallBool = !Storage.fallBool;
    for (FallingBlock b : Storage.anthMobs.keySet()) {
      if (Storage.anthVortex.contains(Storage.anthMobs.get(b))) {
        Location loc = Storage.anthMobs.get(b).getLocation();
        Vector v;
        if (b.getLocation().getWorld().equals(Storage.anthMobs.get(b).getLocation().getWorld())) {
          if (r && b.getLocation().distance(Storage.anthMobs.get(b).getLocation()) < 10) {
            v = b.getLocation().subtract(loc).toVector();
          } else {
            int x = Storage.rnd.nextInt(12) - 6;
            int z = Storage.rnd.nextInt(12) - 6;
            Location tLoc = loc.clone();
            tLoc.setX(tLoc.getX() + x);
            tLoc.setZ(tLoc.getZ() + z);
            v = tLoc.subtract(b.getLocation()).toVector();
          }
          v.multiply(.05);
          boolean close = false;
          for (int x = -3; x < 0; x++) {
            if (b.getLocation().getBlock().getRelative(0, x, 0).getType() != AIR) {
              close = true;
            }
          }
          if (close) {
            v.setY(5);
          } else {
            v.setY(-.1);
          }
          b.setVelocity(v);
        }
      }
    }

    for (Arrow e : Storage.tracer.keySet()) {
      Entity close = null;
      double distance = 100;
      int level = Storage.tracer.get(e);
      level = level + 2;
      for (Entity e1 : e.getNearbyEntities(level, level, level)) {
        if (e1.getLocation().getWorld().equals(e.getLocation().getWorld())) {
          double d = e1.getLocation().distance(e.getLocation());
          if (e.getLocation()
              .getWorld()
              .equals(((Entity) e.getShooter()).getLocation().getWorld())) {
            if (d < distance
                && e1 instanceof LivingEntity
                && !e1.equals(e.getShooter())
                && e.getLocation().distance(((Entity) e.getShooter()).getLocation()) > 15) {
              distance = d;
              close = e1;
            }
          }
        }
      }
      if (close != null) {
        Location location = close.getLocation();
        org.bukkit.util.Vector v = new org.bukkit.util.Vector(0D, 0D, 0D);
        Location pos = e.getLocation();
        double its =
            Math.sqrt(
                (location.getBlockX() - pos.getBlockX()) * (location.getBlockX() - pos.getBlockX())
                    + (location.getBlockY() - pos.getBlockY())
                        * (location.getBlockY() - pos.getBlockY())
                    + (location.getBlockZ() - pos.getBlockZ())
                        * (location.getBlockZ() - pos.getBlockZ()));
        if (its == 0) {
          its = (double) 1;
        }
        v.setX((location.getBlockX() - pos.getBlockX()) / its);
        v.setY((location.getBlockY() - pos.getBlockY()) / its);
        v.setZ((location.getBlockZ() - pos.getBlockZ()) / its);
        e.setVelocity(v.multiply(2));
      }
    }

    for (Guardian g : Storage.guardianMove.keySet()) {
      if (g.getLocation().distance(Storage.guardianMove.get(g).getLocation()) > 2
          && g.getTicksLived() < 160) {
        g.setVelocity(
            Storage.guardianMove
                .get(g)
                .getLocation()
                .toVector()
                .subtract(g.getLocation().toVector()));
      } else {
        Storage.guardianMove.remove(g);
      }
    }

    for (Player player : Bukkit.getOnlinePlayers()) {
      Config config = Config.get(player.getWorld());
      for (ItemStack stk : player.getInventory().getArmorContents()) {
        HashMap<CustomEnchantment, Integer> map = config.getEnchants(stk);
        for (CustomEnchantment ench : map.keySet()) {
          ench.onFastScan(player, map.get(ench));
        }
      }
      HashMap<CustomEnchantment, Integer> map = config.getEnchants(player.getItemInHand());
      for (CustomEnchantment ench : map.keySet()) {
        ench.onFastScanHand(player, map.get(ench));
      }
    }
    HashSet<Player> toDelete = new HashSet<>();
    for (Player player : Storage.hungerPlayers.keySet()) {
      if (Storage.hungerPlayers.get(player) < 1) {
        toDelete.add(player);
      } else {
        Storage.hungerPlayers.put(player, Storage.hungerPlayers.get(player) - 1);
      }
    }
    for (Player p : toDelete) {
      Storage.hungerPlayers.remove(p);
    }
    toDelete.clear();
    for (Player player : Storage.moverBlockDecay.keySet()) {
      Storage.moverBlockDecay.put(player, Storage.moverBlockDecay.get(player) + 1);
      if (Storage.moverBlockDecay.get(player) > 5) {
        Storage.moverBlocks.remove(player);
        toDelete.add(player);
      }
    }
    for (Player p : toDelete) {
      Storage.moverBlockDecay.remove(p);
    }
  }