/** * 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(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); } } } }
@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 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()); }
@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); } } } } } } } }