@Override public void notify(Player player, Object extra) { Location eye = player.getEyeLocation(); Vector direction = eye.getDirection().multiply(2); Block source = (Block) extra; Projectile projectile = player.getWorld().spawn(source.getRelative(BlockFace.UP).getLocation().setDirection(direction), LargeFireball.class); projectile.setShooter(player); projectile.setVelocity(direction); Inventory inv = player.getInventory(); if (inv.contains(Material.TNT)) { int slot = inv.first(Material.TNT); ItemStack ammo = inv.getItem(slot); int amount = ammo.getAmount(); if (amount > 1) { ammo.setAmount(amount - 1); inv.setItem(slot, ammo); } else { inv.setItem(slot, null); } projectile.setCustomName("recreator.structure.turret.tnt"); } AzureAPI.playSound(player, Sound.ITEM_FIRECHARGE_USE, true); }
@EventHandler public void onGhastShoot(ProjectileLaunchEvent event) { if (event.getEntity() instanceof LargeFireball) { // ghast fireball LargeFireball frb = (LargeFireball) event.getEntity(); if (frb.getShooter() instanceof Ghast) { Ghast g = (Ghast) frb.getShooter(); DroneFighter f = getFighter(g); if (f == null) { g.remove(); //System.out.println("f for ghast is null, removing!"); event.setCancelled(true); } else { event.setCancelled(true); //System.out.println("Dud fire!"); } } } }
public Bullet(SwornGuns plugin, GunPlayer shooter, Gun shotFrom, Vector velocity) { this.plugin = plugin; this.shotFrom = shotFrom; this.shooter = shooter; this.velocity = velocity; this.active = true; if (shotFrom.isThrowable()) { ItemStack thrown = shotFrom.getMaterial().newItemStack(1); this.projectile = shooter.getPlayer().getWorld().dropItem(shooter.getPlayer().getEyeLocation(), thrown); this.id = projectile.getEntityId(); ((Item) projectile).setPickupDelay(9999999); this.startLocation = projectile.getLocation(); } else { Class<? extends Projectile> mclass = Snowball.class; String check = shotFrom.getProjType().toLowerCase().replaceAll("_", "").replaceAll(" ", ""); switch (check) { case "arrow": mclass = Arrow.class; break; case "egg": mclass = Egg.class; break; case "enderpearl": mclass = EnderPearl.class; break; case "fireball": mclass = Fireball.class; break; case "fish": case "fishhook": mclass = FishHook.class; break; case "largefireball": mclass = LargeFireball.class; break; case "smallfireball": mclass = SmallFireball.class; break; case "thrownexpbottle": mclass = ThrownExpBottle.class; break; case "thrownpotion": mclass = ThrownPotion.class; break; case "witherskull": mclass = WitherSkull.class; break; default: break; } this.projectile = shooter.getPlayer().launchProjectile(mclass); this.id = projectile.getEntityId(); ((Projectile) projectile).setShooter(shooter.getPlayer()); this.startLocation = projectile.getLocation(); } if (shotFrom.getReleaseTime() == -1) { this.releaseTime = 80 + (shotFrom.isThrowable() ? 0 : 1) * 400; } else { this.releaseTime = shotFrom.getReleaseTime(); } }