Java 类org.bukkit.event.entity.ProjectileHitEvent 实例源码

项目:Hub    文件:PaintballDisplayer.java   
@EventHandler
public void onProjectileHit(ProjectileHitEvent event)
{
    if (event.getEntity().getType() != EntityType.SNOWBALL || !event.getEntity().hasMetadata("paintball-ball") || !event.getEntity().getMetadata("paintball-ball").get(0).asString().equals(this.uuid.toString()))
        return;

    for (Block block : getNearbyBlocks(event.getEntity().getLocation(), 2))
    {
        if (block.getType() == Material.AIR || block.getType() == Material.SIGN || block.getType() == Material.SIGN_POST || block.getType() == Material.WALL_SIGN)
            continue;

        if (this.isBlockGloballyUsed(block.getLocation()))
            continue;

        SimpleBlock simpleBlock = new SimpleBlock(Material.STAINED_CLAY, DyeColor.values()[new Random().nextInt(DyeColor.values().length)].getWoolData());
        this.addBlockToUse(block.getLocation(), simpleBlock);

        block.setType(simpleBlock.getType());
        block.setData(simpleBlock.getData());
    }

    event.getEntity().remove();
}
项目:Recreator    文件:StructureTurret.java   
@EventHandler
public void onHit(ProjectileHitEvent evt) {
    Projectile projectile = evt.getEntity();
    String customId = projectile.getCustomName();
    if (customId == null || !customId.equals("recreator.structure.turret.tnt")) return;

    Location loc;
    Block block = evt.getHitBlock();
    if (block != null) {
        loc = block.getLocation();
        block.getWorld().createExplosion(loc.getX(), loc.getY(), loc.getZ(), 1.8F, true, true);
        return;
    }

    Entity entity = evt.getEntity();
    if (entity != null) {
        loc = entity.getLocation();
        entity.getWorld().createExplosion(loc.getX(), loc.getY(), loc.getZ(), 1.8F, true, true);
    }
}
项目:Recreator    文件:ItemFatMan.java   
@EventHandler
public void onHit(ProjectileHitEvent evt) {
    Projectile projectile = evt.getEntity();
    String customId = projectile.getCustomName();
    if (customId == null || !customId.equals("recreator.item.fatman")) return;

    Location loc;
    Block block = evt.getHitBlock();
    if (block != null) {
        loc = block.getLocation();
        block.getWorld().createExplosion(loc.getX(), loc.getY(), loc.getZ(), 50F, true, true);
        return;
    }

    Entity entity = evt.getEntity();
    if (entity != null) {
        loc = entity.getLocation();
        entity.getWorld().createExplosion(loc.getX(), loc.getY(), loc.getZ(), 50F, true, true);
    }
}
项目:GriefPreventionFlags    文件:FlagDef_InfiniteArrows.java   
@EventHandler(priority = EventPriority.LOW)
public void onProjectileHit(ProjectileHitEvent event)
{
    if(event.getEntityType() != EntityType.ARROW && event.getEntityType() != EntityType.SNOWBALL) return;

    Projectile arrow = event.getEntity();

    ProjectileSource source = arrow.getShooter();
    if(source == null || !(source instanceof Player)) return;

    Player player = (Player)source;
    if(player.getGameMode() == GameMode.CREATIVE) return;

    Flag flag = this.GetFlagInstanceAtLocation(arrow.getLocation(), player);
    if(flag == null) return;

    PlayerInventory inventory = player.getInventory();
    ItemMeta meta = inventory.getItemInMainHand().getItemMeta();
    if(meta != null && meta.hasEnchant(Enchantment.ARROW_INFINITE)) return;

    arrow.remove();
    inventory.addItem(new ItemStack(Material.ARROW));
}
项目:BloodMoon    文件:FireArrowsListener.java   
@EventHandler(priority = EventPriority.NORMAL)
public void onProjectileHit(ProjectileHitEvent event) {
    Projectile projectile = event.getEntity();
    World world = projectile.getWorld();
    PluginConfig worldConfig = plugin.getConfig(world);

    if (plugin.isActive(world) && plugin.isFeatureEnabled(world, Feature.FIRE_ARROWS) && worldConfig.getBoolean(Config.FEATURE_FIRE_ARROWS_IGNITE_TARGET)) {
        LivingEntity shooter = (LivingEntity) projectile.getShooter();
        if (shooter.getType() == EntityType.SKELETON) { //Not sure why this is here, or why fire arrows even work with it here
            return;
        }

        if (((CraftEntity) shooter).getHandle() instanceof EntitySkeleton && projectile.getFireTicks() > 0) {
            //if (shooter != null && ((CraftEntity)shooter).getHandle() instanceof EntitySkeleton && projectile.getFireTicks() > 0){
            Block block = projectile.getWorld().getBlockAt(projectile.getLocation());

            if (block.getType() == Material.AIR) {
                block.setType(Material.FIRE);
            }
        }
    }
}
项目:ZombieEscape    文件:ServerListener.java   
@EventHandler
public void onHit(ProjectileHitEvent event) {
    Projectile projectile = event.getEntity();

    if (projectile instanceof Arrow) {
        projectile.remove();
    } else if (projectile instanceof Snowball && event.getEntity() instanceof Player) {
        ((Player) event.getEntity()).addPotionEffect(new PotionEffect(PotionEffectType.SLOW, 20 * 2, 1));
    } else if (projectile instanceof Egg && projectile.getShooter() instanceof Player) {
        projectile.getWorld().createExplosion(projectile.getLocation(), 0.0F);

        for (Entity entity : projectile.getNearbyEntities(5, 5, 5)) {
            if (entity instanceof Player) {
                Player player = (Player) entity;
                if (plugin.getGameArena().isZombie(player)) {
                    player.addPotionEffect(new PotionEffect(PotionEffectType.BLINDNESS, 20 * 5, 1));
                    player.addPotionEffect(new PotionEffect(PotionEffectType.CONFUSION, 20 * 5, 1));
                }
            }
        }
    }
}
项目:IZenith-Main    文件:BowListener.java   
@EventHandler
public void onArrowLand(ProjectileHitEvent e) {
    if (arrows.contains(e.getEntity())) {
        arrows.remove(e.getEntity());
        Location start = e.getEntity().getLocation();
        if (arrowMaterials.containsKey(e.getEntity())) {
            Material material = arrowMaterials.get(e.getEntity());
            set(start, material);
            start.add(1, 1, 0);
            set(start, material);
            start.add(0, 1, 0);
            set(start, material);
            start.add(1, -2, 0);
            set(start, material);
            arrowMaterials.remove(e.getEntity());
        } else {
            setRandom(start);
            start.add(1, 1, 0);
            setRandom(start);
            start.add(0, 1, 0);
            setRandom(start);
            start.add(1, -2, 0);
            setRandom(start);
        }
    }
}
项目:StarQuestCode    文件:SQTurrets.java   
@EventHandler
public void eggBreak(final ProjectileHitEvent e) {

    if (e.getEntity() instanceof Egg && eggs.contains(e.getEntity())) {

        final Location l = e.getEntity().getLocation();
        int radius = 3;
        final int[][] newLocs = { { radius, 0 }, { -radius, 0 }, { 0, radius }, { 0, -radius }

        };
        for (int i = 0; i < 4; i++) {
            final int count = i;
            Bukkit.getScheduler().scheduleSyncDelayedTask(instance, new Runnable() {

                public void run() {

                    e.getEntity().getWorld().createExplosion(l.getX() + newLocs[count][0], l.getY(), l.getZ() + newLocs[count][1], 2.3F, false, true);
                }
            }, 4 * i);
        }
        eggs.remove(e.getEntity());
    }

}
项目:PvZ    文件:Events.java   
@SuppressWarnings("deprecation")
@EventHandler
private void onProjectileHitEvent(final ProjectileHitEvent event) {
    Projectile projectile = event.getEntity();
    if (!(projectile instanceof Snowball))
        return;
    if (projectile.getShooter() instanceof Player) {
        Player player = (Player) projectile.getShooter();
        Game game = api.getGameManager().getGame(player);
        if (game == null)
            return;
        if (game.getState() != GameState.PLAYING)
            return;
        PlantType type = game.getPlants().getMembers().get(player.getUniqueId());
        if (type == null)
            return;
        if (type == PlantType.WINTER_MELON) {
            freeze(getZombies(projectile, game), game);
        }
    }
}
项目:GoldRushPlugin    文件:GunLis.java   
@EventHandler(priority = EventPriority.HIGHEST)
public void onHit(ProjectileHitEvent e) {
    List<Block> bList = new ArrayList<>();
    Block b = e.getEntity().getLocation().getBlock();
    bList.add(b);
    bList.add(b.getRelative(BlockFace.DOWN));
    bList.add(b.getRelative(BlockFace.EAST));
    bList.add(b.getRelative(BlockFace.NORTH));
    bList.add(b.getRelative(BlockFace.SOUTH));
    bList.add(b.getRelative(BlockFace.WEST));
    bList.add(b.getRelative(BlockFace.UP));
    bList.add(b.getRelative(BlockFace.NORTH_EAST));
    bList.add(b.getRelative(BlockFace.NORTH_WEST));
    bList.add(b.getRelative(BlockFace.SOUTH_EAST));
    bList.add(b.getRelative(BlockFace.SOUTH_WEST));

    for(Block bl : bList){
        if(bl.getType().equals(Material.GLASS) || bl.getType().equals(Material.THIN_GLASS)) {
            Bukkit.getServer().getScheduler().runTaskLater(plugin, new ReplaceGlass(bl, bl.getType()), 1000);
            bl.breakNaturally();
        }
    }
}
项目:bukkit_ESB    文件:SBListener.java   
@EventHandler
public void onProjectileHit(ProjectileHitEvent event) {

    Entity entity = event.getEntity();

    // Config
    float size = plugin.getConfig().getInt("Size of Explosion");
    boolean damage = plugin.getConfig().getBoolean("Block Damage");
    boolean fire = plugin.getConfig().getBoolean("Set Fire");

    if (entity instanceof Snowball) {
        Snowball snowball = (Snowball) entity;
        Entity shooter = snowball.getShooter();

        if (shooter instanceof Player) {
            Player player = (Player) shooter;
            Location sb = snowball.getLocation();

            if (plugin.players.contains(player.getName())) {
                player.getWorld().createExplosion(sb.getX(), sb.getY(),
                        sb.getZ(), size, fire, damage);
            }
        }
    }
}
项目:RPG-Items    文件:Events.java   
@EventHandler
public void onProjectileHit(ProjectileHitEvent e) {
    final Entity entity = e.getEntity();
    if (removeArrows.contains(entity.getEntityId())) {
        entity.remove();
        removeArrows.remove(entity.getEntityId());
    } else if (rpgProjectiles.contains(entity.getEntityId())) {
        RPGItem item = ItemManager.getItemById(rpgProjectiles.get(entity.getEntityId()));
        new BukkitRunnable() {

            public void run() {
                rpgProjectiles.remove(entity.getEntityId());

            }
        }.runTask(Plugin.plugin);
        if (item == null)
            return;
        item.projectileHit((Player) ((Projectile) entity).getShooter(), (Projectile) entity);
    }
}
项目:RPG-Items-2    文件:Events.java   
@EventHandler
public void onProjectileHit(ProjectileHitEvent e) {
    final Entity entity = e.getEntity();
    if (removeArrows.contains(entity.getEntityId())) {
        entity.remove();
        removeArrows.remove(entity.getEntityId());
    } else if (rpgProjectiles.contains(entity.getEntityId())) {
        RPGItem item = ItemManager.getItemById(rpgProjectiles.get(entity.getEntityId()));
        new BukkitRunnable() {

            public void run() {
                rpgProjectiles.remove(entity.getEntityId());

            }
        }.runTask(Plugin.plugin);
        if (item == null)
            return;
        item.projectileHit((Player) ((Projectile) entity).getShooter(), (Projectile) entity);
    }
}
项目:Masters    文件:snowballHandler.java   
@EventHandler (priority = EventPriority.NORMAL)
public void onSnowballHit (ProjectileHitEvent event) {
    if (event.getEntityType() == EntityType.SNOWBALL) {

        UUID uuid = event.getEntity().getUniqueId();
        if (this.snowBalls.contains(uuid)) {
            Location loc = event.getEntity().getLocation();

            loc.setY(loc.getBlockY() - 1);
            Block lBlock = loc.getBlock();
            if (lBlock.getType().isSolid()) {
                growSnow(loc);
            }
            this.snowBalls.remove(uuid);
        }
    }
}
项目:MausWasHere    文件:ProjectileListener.java   
@EventHandler
public void onArrowImpactEvent(ProjectileHitEvent event) {
    if (!(event.getEntity().getShooter() instanceof Player)) return;
    Player player = (Player) event.getEntity().getShooter();
    if (event.getEntity() instanceof Arrow && arrows.contains(event.getEntity())) {
        arrows.remove(event.getEntity());
        player.sendMessage(ChatColor.YELLOW + "Boom!");
        final Location target = event.getEntity().getLocation();
        for (int i = 0; i < 60; i++) {
            final int k = i;
            Bukkit.getScheduler().scheduleSyncDelayedTask(MausWasHere.PLUGIN, new Runnable() {
                @Override
                public void run() {
                    nukeEffect(target, 110 + k, 30 * k, k / 4);
                }
            }, i);
        }
    }
}
项目:Warzone    文件:EntityDamageModule.java   
@EventHandler
public void onProjectileHit(ProjectileHitEvent event) {
    if (event.getEntityType() != EntityType.FISHING_HOOK &&
        event.getEntityType() != EntityType.SNOWBALL &&
        event.getEntityType() != EntityType.EGG) return;
    ProjectileSource shooter = ((Projectile) event.getEntity()).getShooter();
    if (shooter != null && shooter instanceof Player && event.getHitEntity() instanceof Damageable) {
        ((Damageable) event.getHitEntity()).damage(0.01, (Player) shooter);
    }

}
项目:Arcadia-Spigot    文件:SpleefGame.java   
@EventHandler
public void onSnowballHit(ProjectileHitEvent event) {
    if(event.getEntity() instanceof Snowball) {
        if(event.getHitBlock() != null && event.getHitBlock().getType() == Material.SNOW_BLOCK) {
            event.getHitBlock().breakNaturally(new ItemStack(Material.AIR));
        }
    }
}
项目:ProjectAres    文件:GrenadeListener.java   
@EventHandler(priority = EventPriority.MONITOR)
public void onGrenadeExplode(final ProjectileHitEvent event) {
    if (event.getEntity().getShooter() instanceof Player) {
        Grenade grenade = Grenade.get(event.getEntity());
        if(grenade != null) {
            NMSHacks.createExplosion(event.getEntity(), event.getEntity().getLocation(), grenade.power, grenade.fire, grenade.destroy);
            event.getEntity().remove();
        }
    }
}
项目:ProjectAres    文件:ProjectileTrailMatchModule.java   
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
public void onProjectileHit(ProjectileHitEvent event) {
    match.player(event.getActor()).ifPresent(shooter -> {
        final Projectile projectile = event.getEntity();
        projectile.removeMetadata(TRAIL_META, PGM.get());
        // Restore critical metadata to arrows if applicable
        if(projectile instanceof Arrow) {
            final Arrow arrow = (Arrow) projectile;
            if(arrow.hasMetadata(CRITICAL_META)) {
                arrow.setCritical(arrow.getMetadata(CRITICAL_META, PGM.get()).asBoolean());
            }
        }
    });
}
项目:ProjectAres    文件:ProjectileMatchModule.java   
@EventHandler
public void onProjectileHitEvent(ProjectileHitEvent event) {
    final Projectile projectile = event.getEntity();
    final ProjectileDefinition projectileDefinition = Projectiles.getProjectileDefinition(projectile);
    if(projectileDefinition == null) return;

    final Filter filter = projectileDefinition.destroyFilter();
    if(filter == null) return;

    final BlockIterator blockIterator = new BlockIterator(projectile.getWorld(), projectile.getLocation().toVector(), projectile.getVelocity().normalize(), 0d, 2);
    Block hitBlock = null;
    while(blockIterator.hasNext()) {
        hitBlock = blockIterator.next();
        if(hitBlock.getType() != Material.AIR) break;
    }

    if(hitBlock != null) {
        final MatchPlayer shooter = projectile.getShooter() instanceof Player ? getMatch().getPlayer((Player) projectile.getShooter()) : null;
        final IQuery query = shooter != null ? new PlayerBlockEventQuery(shooter, event, hitBlock.getState())
                                             : new BlockEventQuery(event, hitBlock);

        if(filter.query(query).isAllowed()) {
            final BlockTransformEvent bte = new BlockTransformEvent(event, hitBlock, Material.AIR);
            match.callEvent(bte);

            if(!bte.isCancelled()) {
                hitBlock.setType(Material.AIR);
                projectile.remove();
            }
        }
    }
}
项目:KingdomFactions    文件:Comet.java   
@EventHandler
public void onProjectileHit(ProjectileHitEvent e) throws Exception {
    if (fireballList.contains(e.getEntity().getUniqueId())) {
        Location fireballHitLocation = e.getEntity().getLocation();
        if(!KingdomFactionsPlugin.getInstance().getDataManager().getBoolean("Test.enabled")) {
        fireballHitLocation.getWorld().createExplosion(fireballHitLocation.getX(), fireballHitLocation.getY(),
                fireballHitLocation.getZ(), 4, true, true);
        } else {
            fireballHitLocation.getWorld().createExplosion(fireballHitLocation.getX(), fireballHitLocation.getY(),
                    fireballHitLocation.getZ(), 4, true, false);
        }

        FireworkEffect.Type type = FireworkEffect.Type.BALL_LARGE;
        Color c1 = Color.ORANGE;
        Color c2 = Color.RED;

        FireworkEffect effect = FireworkEffect.builder().flicker(true).withColor(c1).withFade(c2).with(type)
                .trail(true).build();

        FireworkEffectPlayer fireworkPlayer = new FireworkEffectPlayer();

        fireworkPlayer.playFirework(fireballHitLocation.getWorld(), fireballHitLocation, effect);
        for (Entity ent : Utils.getInstance().getNearbyEntities(fireballHitLocation, 5)) {
            if ((ent instanceof LivingEntity)) {
                ent.setFireTicks(ent.getFireTicks() + 60);
            }
        }
        fireballList.remove(e.getEntity().getUniqueId());
    }
}
项目:MystiCraft    文件:CustomProjectileListener.java   
@EventHandler
public void onEntityCollision(ProjectileHitEvent event) {
    if (event.getEntity().hasMetadata("mysti_projectile")) {
        CustomProjectile proj =  (CustomProjectile) event.getEntity().getMetadata("mysti_projectile");
        if (event.getHitEntity() != null) {
            proj.onEntityCollision(event.getHitEntity());
        } else if (event.getHitBlock() != null) {
            proj.onBlockCollision(event.getHitBlock());
        }
    }
}
项目:libtrails    文件:BasicExample.java   
@EventHandler
public void onProjectileHit(ProjectileHitEvent e) {
    if (e.getEntity() instanceof Arrow) {
        EntityTrail t = trails.remove(e.getEntity());
        if (t != null)
            t.stop();
    }
}
项目:libtrails    文件:ColorfulExample.java   
@EventHandler
public void onProjectileHit(ProjectileHitEvent e) {
    if (e.getEntity() instanceof Arrow) {
        EntityTrail t = trails.remove(e.getEntity());
        if (t != null)
            t.stop();
    }
}
项目:MiniWynn    文件:BowListener.java   
@EventHandler(priority = EventPriority.HIGHEST)
public void on(ProjectileHitEvent event){
    Entity entity = event.getEntity();
    Location loc = entity.getLocation();
    if (entity instanceof Arrow){
        Arrow arrow = (Arrow) entity;
        if(arrow instanceof SpectralArrow){
            loc.getWorld().createExplosion(loc.getX(), loc.getY(), loc.getZ(), 4.0F, false, false);
        }
        if(particleTasks.containsKey(arrow)){
            server.getScheduler().cancelTask(particleTasks.get(arrow));
        }
        arrow.remove();
    }
}
项目:HCFCore    文件:InfinityArrowFixListener.java   
@EventHandler(priority = EventPriority.NORMAL)
public void onProjectileHit(ProjectileHitEvent event) {
    Entity entity = event.getEntity();
    if (entity instanceof Arrow) {
        Arrow arrow = (Arrow) entity;
        if (!(arrow.getShooter() instanceof Player) || ((CraftArrow) arrow).getHandle().fromPlayer == 2) {
            arrow.remove();
        }
    }
}
项目:HCFCore    文件:InfinityArrowFixListener.java   
@EventHandler(priority = EventPriority.NORMAL)
public void onProjectileHit(ProjectileHitEvent event) {
    Entity entity = event.getEntity();
    if (entity instanceof Arrow) {
        Arrow arrow = (Arrow) entity;
        if (!(arrow.getShooter() instanceof Player) || ((CraftArrow) arrow).getHandle().fromPlayer == 2) {
            arrow.remove();
        }
    }
}
项目:ArchersBattle    文件:ProjectileListener.java   
@EventHandler
public void onHit(final ProjectileHitEvent e) {
    if (!Utils.isArenaWorld(e.getEntity().getWorld())) {
        return;
    }
    if (!e.getEntityType().equals(EntityType.ARROW)) {
        return;
    }
    new BukkitRunnable() {
        public void run() {
            Entity arrow = e.getEntity();
            arrow.remove();
        }
    }.runTaskLater(Main.getInstance(), 100L);
}
项目:CubeKrowd-Icerunner    文件:Game.java   
@EventHandler 
public void onProjectileHit(ProjectileHitEvent e){
    if(e.getEntity() instanceof Snowball){
        snowballs.remove(e.getEntity());
    }
    else if(e.getEntity() instanceof Arrow){
        breakBlocks(e.getEntity().getLocation());
        e.getEntity().remove();
    }
}
项目:CraftPlugins    文件:Blockode.java   
@EventHandler(priority = EventPriority.NORMAL,ignoreCancelled = true)
public void OnProjectileHit(ProjectileHitEvent e){
    //if(e.getEntity().getPassenger()!=null && isInList((Player)e.getEntity().getPassenger())){
        //e.getEntity().getPassenger().setVelocity(e.getEntity().getVelocity());
    //}

}
项目:CraftPlugins    文件:Blockode.java   
@EventHandler(priority = EventPriority.NORMAL,ignoreCancelled = true)
public void OnProjectileHit(ProjectileHitEvent e){
    //if(e.getEntity().getPassenger()!=null && isInList((Player)e.getEntity().getPassenger())){
        //e.getEntity().getPassenger().setVelocity(e.getEntity().getVelocity());
    //}

}
项目:CraftPlugins    文件:Blockode.java   
@EventHandler(priority = EventPriority.NORMAL,ignoreCancelled = true)
public void OnProjectileHit(ProjectileHitEvent e){
    //if(e.getEntity().getPassenger()!=null && isInList((Player)e.getEntity().getPassenger())){
        //e.getEntity().getPassenger().setVelocity(e.getEntity().getVelocity());
    //}

}
项目:CraftPlugins    文件:Blockode.java   
@EventHandler(priority = EventPriority.NORMAL,ignoreCancelled = true)
public void OnProjectileHit(ProjectileHitEvent e){
    //if(e.getEntity().getPassenger()!=null && isInList((Player)e.getEntity().getPassenger())){
        //e.getEntity().getPassenger().setVelocity(e.getEntity().getVelocity());
    //}

}
项目:EpicSpleef    文件:ProjectileHitListener.java   
@EventHandler
public void onProjectileHit(ProjectileHitEvent event) {     
    Player shooter = null;

    Projectile projectile = event.getEntity();

    if (projectile.getShooter() instanceof Player) {
        shooter = (Player) projectile.getShooter();
    }   

    if (shooter == null) {
        return;
    }

    SpleefArena arena = PlayerManager.getArena(shooter.getUniqueId());

    if (arena == null) {
        return;
    }

    if (projectile.hasMetadata("EpicSpleef:Grenade")) {
        for (Block block : getSphere(getHittenBlock(projectile).getLocation(), 3)) {
            remove(arena, block, shooter);
        }
        event.getEntity().remove();
        return;
    }

    Block hittenBlock = getHittenBlock(projectile);
    remove(arena, hittenBlock, shooter);
    event.getEntity().remove(); // remove the entity    
}
项目:civcraft    文件:BlockListener.java   
@EventHandler(priority = EventPriority.NORMAL)
public void onProjectileHitEvent(ProjectileHitEvent event) {
    if (event.getEntity() instanceof Arrow) {
        ArrowFiredCache afc = CivCache.arrowsFired.get(event.getEntity().getUniqueId());
        if (afc != null) {
            afc.setHit(true);
        }
    }

    if (event.getEntity() instanceof Fireball) {
        CannonFiredCache cfc = CivCache.cannonBallsFired.get(event.getEntity().getUniqueId());
        if (cfc != null) {

            cfc.setHit(true);

            FireworkEffect fe = FireworkEffect.builder().withColor(Color.RED).withColor(Color.BLACK).flicker(true).with(Type.BURST).build();

            Random rand = new Random();
            int spread = 30;
            for (int i = 0; i < 15; i++) {
                int x = rand.nextInt(spread) - spread/2;
                int y = rand.nextInt(spread) - spread/2;
                int z = rand.nextInt(spread) - spread/2;


                Location loc = event.getEntity().getLocation();
                Location location = new Location(loc.getWorld(), loc.getX(),loc.getY(), loc.getZ());
                location.add(x, y, z);

                TaskMaster.syncTask(new FireWorkTask(fe, loc.getWorld(), loc, 5), rand.nextInt(30));
            }

        }
    }
}
项目:Slimefun4    文件:BowListener.java   
@EventHandler
public void onArrowHit(final ProjectileHitEvent e) {
    Bukkit.getScheduler().scheduleSyncDelayedTask(SlimefunStartup.instance, new Runnable() {

        @Override
        public void run() {
            if (!e.getEntity().isValid()) return;
            if (Variables.arrows.containsKey(e.getEntity().getUniqueId())) Variables.arrows.remove(e.getEntity().getUniqueId());
            if (e.getEntity() instanceof Arrow) handleGrapplingHook((Arrow) e.getEntity());
        }
    }, 4L);
}
项目:EpicSpleef    文件:ProjectileHitListener.java   
@EventHandler
public void onProjectileHit(ProjectileHitEvent event) {     
    Player shooter = null;

    Projectile projectile = event.getEntity();

    if (projectile.getShooter() instanceof Player) {
        shooter = (Player) projectile.getShooter();
    }   

    if (shooter == null) {
        return;
    }

    SpleefArena arena = PlayerManager.getArena(shooter.getUniqueId());

    if (arena == null) {
        return;
    }

    if (projectile.hasMetadata("EpicSpleef:Grenade")) {
        for (Block block : getSphere(getHittenBlock(projectile).getLocation(), 3)) {
            remove(arena, block, shooter);
        }
        event.getEntity().remove();
        return;
    }

    Block hittenBlock = getHittenBlock(projectile);
    remove(arena, hittenBlock, shooter);
    event.getEntity().remove(); // remove the entity    
}
项目:Zephyrus-II    文件:ProjectileHandler.java   
@EventHandler
public void onProjectileHitBlock(ProjectileHitEvent event) {
    if (projectileData.containsKey(event.getEntity())) {
        Projectile projectile = projectileData.get(event.getEntity());
        projectile.onHitBlock(event.getEntity().getLocation());
        projectileData.remove(event.getEntity());
    }
}
项目:SnowballTeleporter    文件:SnowballTeleporterMain.java   
@EventHandler
public void onTP(ProjectileHitEvent e){
    Projectile proj = e.getEntity();

if(this.getConfig().getBoolean("teleporting-snowballs") == true){   
    if(proj instanceof Snowball){
        Snowball sb = (Snowball) proj;
        if(sb.getShooter() instanceof Player){
            LivingEntity p = (Player) sb.getShooter();
            p.teleport(sb);
            }
    }
        }
    }
项目:TheSurvivalGames    文件:TwiceAsNice.java   
@EventHandler(priority = EventPriority.LOW)
public void onHit(ProjectileHitEvent event) {

    if ((event.getEntity().getShooter() instanceof Player)) {
        Snowball snowball = (Snowball) event.getEntity();
        Player player = (Player) snowball.getShooter();
        World world = snowball.getWorld();
        BlockIterator bi = new BlockIterator(world, snowball.getLocation().toVector(), snowball.getVelocity().normalize(), 0, 4);
        Block hit = null;
        while (bi.hasNext()) {
            hit = bi.next();
            if (!hit.getType().equals(Material.AIR)) {
                break;
            }
        }
        if (hit != null) {
            System.out.println("The Real block is " + hit.getType() + " location is at  " + hit.getLocation().toVector().toString());

            BlockState blockState = hit.getState();
            player = (Player) event.getEntity().getShooter();
            System.out.println("Hit " + blockState.getType());

            if (blockState.getType().equals(Material.STONE)) {
                player.sendMessage(ChatColor.GOLD + "Turning Stone to Gold");
                blockState.setType(Material.GOLD_BLOCK);
                blockState.update(true);

            }

        }

    }

}