当前位置: 首页>>代码示例>>Java>>正文


Java ProjectileHitEvent类代码示例

本文整理汇总了Java中org.bukkit.event.entity.ProjectileHitEvent的典型用法代码示例。如果您正苦于以下问题:Java ProjectileHitEvent类的具体用法?Java ProjectileHitEvent怎么用?Java ProjectileHitEvent使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


ProjectileHitEvent类属于org.bukkit.event.entity包,在下文中一共展示了ProjectileHitEvent类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: onProjectileHit

import org.bukkit.event.entity.ProjectileHitEvent; //导入依赖的package包/类
@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();
}
 
开发者ID:SamaGames,项目名称:Hub,代码行数:24,代码来源:PaintballDisplayer.java

示例2: onHit

import org.bukkit.event.entity.ProjectileHitEvent; //导入依赖的package包/类
@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);
    }
}
 
开发者ID:Recraft,项目名称:Recreator,代码行数:21,代码来源:StructureTurret.java

示例3: onHit

import org.bukkit.event.entity.ProjectileHitEvent; //导入依赖的package包/类
@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);
    }
}
 
开发者ID:Recraft,项目名称:Recreator,代码行数:21,代码来源:ItemFatMan.java

示例4: onProjectileHit

import org.bukkit.event.entity.ProjectileHitEvent; //导入依赖的package包/类
@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));
}
 
开发者ID:BigScary,项目名称:GriefPreventionFlags,代码行数:24,代码来源:FlagDef_InfiniteArrows.java

示例5: onProjectileHit

import org.bukkit.event.entity.ProjectileHitEvent; //导入依赖的package包/类
@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);
            }
        }
    }
}
 
开发者ID:Samistine,项目名称:BloodMoon,代码行数:23,代码来源:FireArrowsListener.java

示例6: onHit

import org.bukkit.event.entity.ProjectileHitEvent; //导入依赖的package包/类
@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));
                }
            }
        }
    }
}
 
开发者ID:sgtcaze,项目名称:ZombieEscape,代码行数:23,代码来源:ServerListener.java

示例7: onArrowLand

import org.bukkit.event.entity.ProjectileHitEvent; //导入依赖的package包/类
@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);
		}
	}
}
 
开发者ID:iZenith,项目名称:IZenith-Main,代码行数:27,代码来源:BowListener.java

示例8: eggBreak

import org.bukkit.event.entity.ProjectileHitEvent; //导入依赖的package包/类
@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());
	}

}
 
开发者ID:StarQuestMinecraft,项目名称:StarQuestCode,代码行数:25,代码来源:SQTurrets.java

示例9: onProjectileHitEvent

import org.bukkit.event.entity.ProjectileHitEvent; //导入依赖的package包/类
@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);
		}
	}
}
 
开发者ID:Lactem,项目名称:PvZ,代码行数:22,代码来源:Events.java

示例10: onHit

import org.bukkit.event.entity.ProjectileHitEvent; //导入依赖的package包/类
@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();
        }
    }
}
 
开发者ID:GoldRushMC,项目名称:GoldRushPlugin,代码行数:24,代码来源:GunLis.java

示例11: onProjectileHit

import org.bukkit.event.entity.ProjectileHitEvent; //导入依赖的package包/类
@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);
			}
		}
	}
}
 
开发者ID:ddarkpolice,项目名称:bukkit_ESB,代码行数:26,代码来源:SBListener.java

示例12: onProjectileHit

import org.bukkit.event.entity.ProjectileHitEvent; //导入依赖的package包/类
@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);
    }
}
 
开发者ID:Thinkofname,项目名称:RPG-Items,代码行数:21,代码来源:Events.java

示例13: onSnowballHit

import org.bukkit.event.entity.ProjectileHitEvent; //导入依赖的package包/类
@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);
		}
	}
}
 
开发者ID:Jsawrus,项目名称:Masters,代码行数:18,代码来源:snowballHandler.java

示例14: onArrowImpactEvent

import org.bukkit.event.entity.ProjectileHitEvent; //导入依赖的package包/类
@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);
        }
    }
}
 
开发者ID:janie177,项目名称:MausWasHere,代码行数:20,代码来源:ProjectileListener.java

示例15: onProjectileHit

import org.bukkit.event.entity.ProjectileHitEvent; //导入依赖的package包/类
@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);
    }

}
 
开发者ID:WarzoneMC,项目名称:Warzone,代码行数:12,代码来源:EntityDamageModule.java


注:本文中的org.bukkit.event.entity.ProjectileHitEvent类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。