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