@EventHandler
 public void bowFire(EntityShootBowEvent event) {
   if (event.getEntityType().equals(EntityType.PLAYER)) {
     ((Player) event.getEntity())
         .getInventory()
         .setItemInHand(plugin.fixItem(((Player) event.getEntity()).getItemInHand()));
   }
 }
 @EventHandler
 public void onEntityDeath(EntityShootBowEvent e) {
   if (e.getEntity() instanceof Player) {
     Player p = (Player) e.getEntity();
     int game = GameManager.getInstance().getPlayerGameId(p);
     if (game != -1) {
       gm.getGame(game).getPlayerClass(p).PlayerShootArrow(e.getProjectile());
     }
   }
 }
Exemple #3
0
 @EventHandler
 public void onEntityShootBow(EntityShootBowEvent event) {
   if (event.getEntity() instanceof Player && ((Player) event.getEntity()) == player) {
     if (step == 1) {
       long v = getAbsoluteLong();
       if (v != -1) {
         projectileTime = v;
       }
     }
   }
 }
 /**
  * Cancels firing a bow with a disabled weapon
  *
  * @param event event details
  */
 @EventHandler
 public void onShoot(EntityShootBowEvent event) {
   if (event.getEntity() instanceof Player) {
     if (InventoryTask.cannotUse(
         SkillAPI.getPlayerData((Player) event.getEntity()), event.getBow())) {
       SkillAPI.getLanguage()
           .sendMessage(ErrorNodes.CANNOT_USE, event.getEntity(), FilterType.COLOR);
       event.setCancelled(true);
     }
   }
 }
 @EventHandler
 public void onEntityShootBow(EntityShootBowEvent event) {
   if (!ScrimMatchHandler.isRunning()) {
     event.setCancelled(true);
     return;
   }
   if (event.getEntity() instanceof Player) {
     if (ScrimTeamHandler.isObserver((Player) event.getEntity())) {
       event.setCancelled(true);
     }
   }
 }
 @EventHandler(priority = EventPriority.MONITOR)
 public void onEntityShootBow(EntityShootBowEvent event) {
   if ((event.isCancelled())
       || (!(event.getEntity() instanceof Player))
       || (!(event.getProjectile() instanceof Arrow))) {
     return;
   }
   Hero hero =
       SkillExplodingArrow.this.plugin.getCharacterManager().getHero((Player) event.getEntity());
   if (hero.hasEffect("ExplodingArrowBuff")) {
     int mana = SkillConfigManager.getUseSetting(hero, this.skill, "mana-per-shot", 1, true);
     if (hero.getMana() < mana) hero.removeEffect(hero.getEffect("ExplodingArrowBuff"));
     else hero.setMana(hero.getMana() - mana);
   }
 }
 @EventHandler(priority = EventPriority.HIGHEST)
 public void onEntityShootBowEvent(EntityShootBowEvent event) {
   if (event.isCancelled()) {
     return;
   }
   if (!(event.getEntity() instanceof Player)) {
     return;
   }
   Player p = (Player) event.getEntity();
   ItemStack iimh = p.getEquipment().getItemInMainHand();
   Tier t = iimh != null ? TierUtil.getTierFromItemStack(iimh) : null;
   if (t != null && t.isInfiniteDurability()) {
     iimh.setDurability((short) 0);
   }
 }
Exemple #8
0
  @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
  public void EntityShootBowEvent(EntityShootBowEvent e) {

    Entity shooter = e.getEntity();

    if (shooter instanceof Player) CEventHandler.handleEvent((Player) shooter, e, shootBow);
  }
Exemple #9
0
  @EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
  private void onEntityShootBow(EntityShootBowEvent event) {
    Entity entity = event.getEntity();

    if (entity instanceof Player) {
      DurabilityUtils.handleInfiniteDurability(((Player) entity).getItemInHand());
    }
  }
Exemple #10
0
  @EventHandler(priority = EventPriority.HIGHEST)
  private void onShootBow(EntityShootBowEvent evt) {
    if (!(evt.getEntity() instanceof Player)) {
      return;
    }

    Player player = (Player) evt.getEntity();
    PlayerDataClass playerData = plugin.getPlayerHandler().findPlayer(player.getDisplayName());

    if (playerData != null) {
      if (playerData.getType().equals("sniper")
          && evt.getForce() == 1
          && playerData.isScoped() == true) {
        evt.getProjectile().setMetadata("charged", new FixedMetadataValue(plugin, true));
      }
    }
  }
  @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
  public void onEntityShootBow(EntityShootBowEvent event) {
    Entity projectile = event.getProjectile();

    if (!(projectile instanceof Arrow)) {
      return;
    }

    ItemStack bow = event.getBow();

    if (bow != null && bow.containsEnchantment(Enchantment.ARROW_INFINITE)) {
      projectile.setMetadata(mcMMO.infiniteArrowKey, mcMMO.metadataValue);
    }

    projectile.setMetadata(
        mcMMO.bowForceKey,
        new FixedMetadataValue(
            plugin,
            Math.min(event.getForce() * AdvancedConfig.getInstance().getForceMultiplier(), 1.0)));
    projectile.setMetadata(
        mcMMO.arrowDistanceKey,
        new FixedMetadataValue(plugin, Archery.locationToString(projectile.getLocation())));
  }
  @EventHandler(priority = EventPriority.MONITOR)
  public void onBowShoot(EntityShootBowEvent event) {

    if (event.isCancelled() == false && !worlds.contains(event.getEntity().getWorld().getName())) {
      if (event.getEntity() instanceof Player) {
        Player p = (Player) event.getEntity();

        // total shots fired
        playerStatManager.getPlayerBlob(p.getName()).getStat("bow", "shots").incrementStat(1);

        if (event.getBow().containsEnchantment(Enchantment.ARROW_FIRE)) {
          playerStatManager.getPlayerBlob(p.getName()).getStat("bow", "fireshots").incrementStat(1);
        }

        if (event.getBow().containsEnchantment(Enchantment.ARROW_INFINITE)) {
          playerStatManager
              .getPlayerBlob(p.getName())
              .getStat("bow", "infiniteshots")
              .incrementStat(1);
        }
      }
    }
  }
Exemple #13
0
  /**
   * called when the player releases the use item button. Args: itemstack, world, entityplayer,
   * itemInUseCount
   */
  public void a(ItemStack var1, World var2, EntityHuman var3, int var4) {
    // Forge start
    int var5 = this.a(var1) - var4;
    ArrowLooseEvent var6 = new ArrowLooseEvent(var3, var1, var5);
    MinecraftForge.EVENT_BUS.post(var6);

    if (var6.isCanceled()) {
      return;
    }
    var5 = var6.charge;
    // Forge end
    boolean var7 =
        var3.abilities.canInstantlyBuild
            || EnchantmentManager.getEnchantmentLevel(Enchantment.ARROW_INFINITE.id, var1) > 0;

    if (var7 || var3.inventory.e(Item.ARROW.id)) {
      float var8 = (float) var5 / 20.0F;
      var8 = (var8 * var8 + var8 * 2.0F) / 3.0F;

      if ((double) var8 < 0.1D) {
        return;
      }

      if (var8 > 1.0F) {
        var8 = 1.0F;
      }

      EntityArrow var9 = new EntityArrow(var2, var3, var8 * 2.0F);

      if (var8 == 1.0F) {
        var9.e(true);
      }

      int var10 = EnchantmentManager.getEnchantmentLevel(Enchantment.ARROW_DAMAGE.id, var1);

      if (var10 > 0) {
        var9.b(var9.c() + (double) var10 * 0.5D + 0.5D);
      }

      int var11 = EnchantmentManager.getEnchantmentLevel(Enchantment.ARROW_KNOCKBACK.id, var1);

      if (var11 > 0) {
        var9.a(var11);
      }

      if (EnchantmentManager.getEnchantmentLevel(Enchantment.ARROW_FIRE.id, var1) > 0) {
        var9.setOnFire(100);
      }

      // CraftBukkit start
      org.bukkit.event.entity.EntityShootBowEvent event =
          org.bukkit.craftbukkit.event.CraftEventFactory.callEntityShootBowEvent(
              var3, var1, var9, var8);
      if (event.isCancelled()) {
        event.getProjectile().remove();
        return;
      }

      if (event.getProjectile() == var9.getBukkitEntity()) {
        var2.addEntity(var9);
      }
      // CraftBukkit end

      var1.damage(1, var3);
      var2.makeSound(var3, "random.bow", 1.0F, 1.0F / (d.nextFloat() * 0.4F + 1.2F) + var8 * 0.5F);

      if (var7) {
        var9.fromPlayer = 2;
      } else {
        var3.inventory.d(Item.ARROW.id);
      }
    }
  }
 @EventHandler
 public void onBowUse(EntityShootBowEvent e) {
   if (!(e.getEntity() instanceof Player) || !(e.getProjectile() instanceof Arrow)) return;
   if (SlimefunItem.getByItem(e.getBow()) != null)
     Variables.arrows.put(e.getProjectile().getUniqueId(), e.getBow());
 }
Exemple #15
0
  public void a(ItemStack itemstack, World world, EntityHuman entityhuman, int i) {
    boolean flag =
        entityhuman.abilities.canInstantlyBuild
            || EnchantmentManager.getEnchantmentLevel(Enchantment.ARROW_INFINITE.id, itemstack) > 0;

    if (flag || entityhuman.inventory.b(Items.ARROW)) {
      int j = this.d(itemstack) - i;
      float f = (float) j / 20.0F;

      f = (f * f + f * 2.0F) / 3.0F;
      if ((double) f < 0.1D) {
        return;
      }

      if (f > 1.0F) {
        f = 1.0F;
      }

      EntityArrow entityarrow = new EntityArrow(world, entityhuman, f * 2.0F);
      entityarrow.damage = 2.3D;

      if (f == 1.0F) {
        entityarrow.setCritical(true);
      }

      int k = EnchantmentManager.getEnchantmentLevel(Enchantment.ARROW_DAMAGE.id, itemstack);

      if (k > 0) {
        entityarrow.b(entityarrow.j() + (double) k * 0.5D + 0.5D);
      }

      int l = EnchantmentManager.getEnchantmentLevel(Enchantment.ARROW_KNOCKBACK.id, itemstack);

      if (l > 0) {
        entityarrow.a(l);
      }

      if (EnchantmentManager.getEnchantmentLevel(Enchantment.ARROW_FIRE.id, itemstack) > 0) {
        EntityCombustEvent event = new EntityCombustEvent(entityarrow.getBukkitEntity(), 100);
        entityarrow.world.getServer().getPluginManager().callEvent(event);

        if (!event.isCancelled()) {
          entityarrow.setOnFire(event.getDuration());
        }
      }

      // CraftBukkit start
      EntityShootBowEvent event =
          CraftEventFactory.callEntityShootBowEvent(entityhuman, itemstack, entityarrow, f);
      if (event.isCancelled()) {
        event.getProjectile().remove();
        return;
      }

      if (event.getProjectile() == entityarrow.getBukkitEntity()) {
        world.addEntity(entityarrow);
      }
      // CraftBukkit end

      itemstack.damage(1, entityhuman);

      world.makeSound(
          entityhuman, "random.bow", 1.0F, 1.0F / (g.nextFloat() * 0.4F + 1.2F) + f * 0.5F);
      if (flag) {
        entityarrow.fromPlayer = 2;
      } else {
        entityhuman.inventory.a(Items.ARROW);
      }

      entityhuman.b(StatisticList.USE_ITEM_COUNT[Item.getId(this)]);
    }
  }
Exemple #16
0
 @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);
               }
             }
           }
         }
       }
     }
   }
 }