@EventHandler public void onPlayerInteract(PlayerInteractEvent e) { Player p = e.getPlayer(); if (p.getItemInHand().getType() == Material.EYE_OF_ENDER && p.getItemInHand().getDurability() == 1) { Action a = e.getAction(); if ((a == Action.RIGHT_CLICK_AIR) || (a == Action.RIGHT_CLICK_BLOCK)) { try { if (p.getInventory().getHelmet().getEnchantmentLevel(Enchantment.PROTECTION_EXPLOSIONS) == 7) { if (p.getInventory() .getChestplate() .getEnchantmentLevel(Enchantment.PROTECTION_EXPLOSIONS) == 7) { if (p.getInventory() .getLeggings() .getEnchantmentLevel(Enchantment.PROTECTION_EXPLOSIONS) == 7) { if (p.getInventory() .getBoots() .getEnchantmentLevel(Enchantment.PROTECTION_EXPLOSIONS) == 7) { p.launchProjectile(EnderPearl.class); } } } } else if (p.getInventory().getChestplate() != null) { if (p.getInventory().getChestplate().hasItemMeta()) { if (p.getInventory().getChestplate().getItemMeta().hasDisplayName()) { if (p.getInventory() .getChestplate() .getItemMeta() .getDisplayName() .equalsIgnoreCase( ChatColor.BLUE + "" + ChatColor.BOLD + "Uber" + ChatColor.GOLD + "" + ChatColor.BOLD + "Chestplate")) { if (p.getInventory() .getChestplate() .getItemMeta() .getLore() .contains(ChatColor.GRAY + "Ender Fake")) { p.launchProjectile(EnderPearl.class); } } } } } } catch (Exception x) { } e.setCancelled(true); } } }
@Override public boolean use(Player player) { boolean containsBow = false; for (ItemStack item : player.getInventory().getContents()) { if (item.getType() == Material.BOW) { containsBow = true; break; } } if (containsBow) { if (player.getInventory().containsAtLeast(new ItemStack(Material.ARROW), 1)) { player.launchProjectile(Arrow.class); player .getInventory() .removeItem( new ItemStack(Material.ARROW), new ItemStack(Material.FERMENTED_SPIDER_EYE)); return true; } else { player.sendMessage(ChatColor.RED + "You require an arrow."); } } else { player.sendMessage(ChatColor.RED + "You require a bow."); } return false; }
@Override public PostCastAction castSpell(Player player, SpellCastState state, float power, String[] args) { if (state == SpellCastState.NORMAL) { Random rand = new Random(); Vector mod; for (int i = 0; i < snowballs; i++) { Snowball snowball = player.launchProjectile(Snowball.class); MagicSpells.getVolatileCodeHandler().setGravity(snowball, snowballGravity); playSpellEffects(EffectPosition.PROJECTILE, snowball); playTrackingLinePatterns( EffectPosition.DYNAMIC_CASTER_PROJECTILE_LINE, player.getLocation(), snowball.getLocation(), player, snowball); snowball.setFallDistance(identifier); // tag the snowballs mod = new Vector( (rand.nextDouble() - .5) * horizSpread, (rand.nextDouble() - .5) * vertSpread, (rand.nextDouble() - .5) * horizSpread); snowball.setVelocity(snowball.getVelocity().add(mod)); } playSpellEffects(EffectPosition.CASTER, player); } return PostCastAction.HANDLE_NORMALLY; }
@Override public boolean effect(Event event, Player player) { int slot = player.getInventory().getHeldItemSlot(); ItemStack potion = player.getInventory().getItem(slot + 1); Location loc = player.getLocation(); if (potion != null && potion.getType().toString().contains("POTION")) { ThrownPotion tp = player.launchProjectile(ThrownPotion.class); EffectManager.playSound(loc, "ENTITY_GENERIC_EXPLODE", 0.5f, 2f); try { tp.setItem(potion); } catch (IllegalArgumentException ex) { ItemStack pt = potion.clone(); if (potion.getType().equals(Material.POTION) || potion.getType().equals(Material.LINGERING_POTION)) pt.setType(Material.SPLASH_POTION); tp.setItem(pt); } tp.setBounce(false); tp.setVelocity(loc.getDirection().multiply(ProjectileSpeedMultiplier)); if (!player.getGameMode().equals(GameMode.CREATIVE)) { potion.setAmount(potion.getAmount() - 1); player.getInventory().setItem(slot + 1, potion); player.updateInventory(); } return true; } else { player.sendMessage( ChatColor.RED + "You need a Potion in the slot to the right of the Potion Launcher!"); player.getWorld().playEffect(loc, Effect.CLICK1, 5); } return false; }
@EventHandler(priority = EventPriority.HIGH) public void onPlayerInteract(org.bukkit.event.player.PlayerInteractEvent event) { Player p = event.getPlayer(); if (event.getAction().equals(Action.RIGHT_CLICK_AIR)) { if (p.getItemInHand().getType() == Material.EYE_OF_ENDER) { for (Player other : Bukkit.getServer().getOnlinePlayers()) { other.hidePlayer(p); p.hidePlayer(other); Inventory inventory = p.getInventory(); inventory.setItem(8, new ItemStack(Material.ENDER_PEARL, 1)); } } else if (p.getItemInHand().getType() == Material.ENDER_PEARL) { for (Player other : Bukkit.getServer().getOnlinePlayers()) { other.showPlayer(p); p.showPlayer(other); Inventory inventory = p.getInventory(); inventory.setItem(8, new ItemStack(Material.EYE_OF_ENDER, 1)); } } else if (p.getItemInHand().getType() == Material.GOLD_AXE) { p.launchProjectile(EnderPearl.class); } } else { } }
@Override public void castSpell(Player player) { // Launch a fireball and make it 2x faster Fireball fireball = player.launchProjectile(Fireball.class); fireball.setVelocity(fireball.getVelocity().multiply(2)); SoundHandler.playSound(player, Sound.GHAST_FIREBALL); PlayerHandler.sendMessage(player, "&7Pew pew!"); }
@EventHandler public void throwSnowball(PlayerInteractEvent e) { final Player p = e.getPlayer(); if (UtilBlock.usable(e.getClickedBlock())) { return; } if (e.getPlayer().getItemInHand() == null) { return; } if (e.getPlayer().getItemInHand().getType() != Material.FIREWORK_CHARGE) { return; } if (_coolDown.contains(p.getUniqueId())) { return; } if (((e.getAction() == Action.RIGHT_CLICK_AIR) || (e.getAction() == Action.RIGHT_CLICK_BLOCK)) && (disName(p.getItemInHand()) != null) && (disName(p.getItemInHand()) .equalsIgnoreCase( ChatColor.DARK_AQUA + "EnderDoge " + ChatColor.DARK_RED + EnderDogeAmmoManager.balaceEnderDogeAmmo(p)))) { Player player = e.getPlayer(); e.setCancelled(true); _coolDown.add(p.getUniqueId()); Bukkit.getScheduler() .runTaskLater( Main.getInstance(), new Runnable() { public void run() { _coolDown.remove(p.getUniqueId()); } }, 5L); Projectile proj = player.launchProjectile(Snowball.class); proj.setVelocity(proj.getVelocity().multiply(2)); _balls.add(proj); player.getWorld().playSound(player.getLocation(), Sound.CHICKEN_EGG_POP, 1.5F, 1.5F); EnderDogeAmmoManager.takeEnderDogeAmmo(p, 1); if (EnderDogeAmmoManager.balaceEnderDogeAmmo(p) < 1) { player.getInventory().setItemInHand(null); player.sendMessage( StringManager.getPrefix(MessageType.ERROR) + ChatColor.AQUA + "You ran out of ammo!"); return; } ItemStack snow = new ItemStack(Material.FIREWORK_CHARGE, 1); ItemMeta sno = snow.getItemMeta(); sno.setDisplayName( ChatColor.DARK_AQUA + "EnderDoge " + ChatColor.DARK_RED + EnderDogeAmmoManager.balaceEnderDogeAmmo(p)); snow.setItemMeta(sno); player.getInventory().setItemInHand(snow); } }
@EventHandler public void onChat(AsyncPlayerChatEvent event) { Player player = event.getPlayer(); String message = event.getMessage(); if (message.equalsIgnoreCase("test")) { event.setCancelled(true); player.sendMessage(message); Vector vector = getPlayerVector(player); // player.setVelocity(vector.multiply(2)); player.launchProjectile(Fireball.class).setVelocity(vector.multiply(5)); } }
@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); } } } }
@EventHandler(priority = EventPriority.NORMAL) public void fishing(PlayerFishEvent event) { Player player = event.getPlayer(); ItemStack itemStack = player.getItemInHand(); Material material = itemStack.getType(); Location location = player.getLocation(); Location bobber = event.getHook().getLocation(); if (location.getWorld().getName().equals(getName())) { if (material == Material.FISHING_ROD) { if (event.getHook().getVelocity().getY() < 0.02 && isLocationNearBlock(bobber)) { player.launchProjectile(Snowball.class); } } } }
@EventHandler(priority = EventPriority.NORMAL) public void fishing(PlayerFishEvent event) { PlayerFishEvent.State state = event.getState(); Player p = event.getPlayer(); ItemStack is = p.getItemInHand(); Material mat = is.getType(); Location loc = p.getLocation(); if (contains(loc, x1, x2, y1, y2, z1, z2) == true) { if (mat == Material.FISHING_ROD) { if (state == State.IN_GROUND) { p.launchProjectile(Snowball.class); } } } }
@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()); } } } }
public void shoot() { if (containsUser()) { if (canShoot) { Vector v = p.getLocation().getDirection().normalize().multiply(5); Snowball s = p.launchProjectile(Snowball.class, v); s.setCustomName("stun"); p.playSound(p.getLocation(), Sound.FIREWORK_BLAST2, 3F, 1F); canShoot = false; new BukkitRunnable() { @Override public void run() { canShoot = true; } }.runTaskLater(Main.getInstance(), 40); } else { p.sendMessage(Color.np("&cThis turret is reloading!")); } } }
@EventHandler public void gun(PlayerInteractEvent event) { if (!event.getPlayer().getWorld().getName().equals(getName())) return; if (event.getPlayer().getGameMode() == GameMode.SURVIVAL) { Player player = event.getPlayer(); Location loc = player.getLocation(); Action action = event.getAction(); ItemStack i = player.getItemInHand(); Inventory inv = player.getInventory(); Material tool = i.getType(); final World world = loc.getWorld(); if (tool == Material.BLAZE_ROD) { if (action == Action.RIGHT_CLICK_AIR || action == Action.RIGHT_CLICK_BLOCK) { if (inv.contains(Material.FLINT)) { player.launchProjectile(Arrow.class); world.playSound(loc, Sound.COW_WALK, 10, 10); ItemStack AMMO = new ItemStack(Material.FLINT, 1); inv.removeItem(AMMO); ItemMeta ammo = AMMO.getItemMeta(); ammo.setDisplayName(ChatColor.BLUE + "Ammunition"); AMMO.setItemMeta(ammo); inv.removeItem(AMMO); // Make it remove normal flints, too. player.updateInventory(); } else { world.playSound(loc, Sound.CLICK, 10, 10); } } } } }
@Override public PostCastAction castSpell(Player player, SpellCastState state, float power, String[] args) { if (state == SpellCastState.NORMAL) { if (projectileClass != null) { Projectile projectile = player.launchProjectile(projectileClass); playSpellEffects(EffectPosition.PROJECTILE, projectile); playTrackingLinePatterns( EffectPosition.DYNAMIC_CASTER_PROJECTILE_LINE, player.getLocation(), projectile.getLocation(), player, projectile); projectile.setBounce(false); MagicSpells.getVolatileCodeHandler().setGravity(projectile, projectileHasGravity); if (velocity > 0) { projectile.setVelocity(player.getLocation().getDirection().multiply(velocity)); } if (horizSpread > 0 || vertSpread > 0) { Vector v = projectile.getVelocity(); v.add( new Vector( (random.nextDouble() - .5) * horizSpread, (random.nextDouble() - .5) * vertSpread, (random.nextDouble() - .5) * horizSpread)); projectile.setVelocity(v); } if (applySpellPowerToVelocity) { projectile.setVelocity(projectile.getVelocity().multiply(power)); } projectile.setMetadata( METADATA_KEY, new FixedMetadataValue(MagicSpells.plugin, "ProjectileSpell_" + internalName)); projectiles.put( projectile, new ProjectileInfo( player, power, (effectInterval > 0 ? new RegularProjectileMonitor(projectile) : null))); playSpellEffects(EffectPosition.CASTER, projectile); } else if (projectileItem != null) { Item item = player.getWorld().dropItem(player.getEyeLocation(), projectileItem.clone()); MagicSpells.getVolatileCodeHandler().setGravity(item, projectileHasGravity); Vector v = player.getLocation().getDirection().multiply(velocity > 0 ? velocity : 1); if (horizSpread > 0 || vertSpread > 0) { v.add( new Vector( (random.nextDouble() - .5) * horizSpread, (random.nextDouble() - .5) * vertSpread, (random.nextDouble() - .5) * horizSpread)); } if (applySpellPowerToVelocity) { v.multiply(power); } item.setVelocity(v); item.setPickupDelay(10); itemProjectiles.put( item, new ProjectileInfo(player, power, new ItemProjectileMonitor(item))); playSpellEffects(EffectPosition.CASTER, item); } } return PostCastAction.HANDLE_NORMALLY; }
@Override public Fireball shootSmallFireball(Player player) { return player.launchProjectile(SmallFireball.class); }
@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); } } }
@Override public void run() { Arrow shot = player.launchProjectile(Arrow.class); shot.setVelocity(shot.getVelocity().multiply(2.0)); }