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


Java ProjectileHitEvent.getEntity方法代码示例

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


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

示例1: 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

示例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.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

示例3: 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

示例4: 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

示例5: 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

示例6: 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

示例7: 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

示例8: 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

示例9: 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

示例10: 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

示例11: onSnowballHit

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

示例12: onProjectileHitEvent

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

示例13: onProjectileHit

import org.bukkit.event.entity.ProjectileHitEvent; //导入方法依赖的package包/类
@EventHandler
public void onProjectileHit(ProjectileHitEvent e) {
    if (e.getEntity() instanceof Arrow) {
        EntityTrail t = trails.remove(e.getEntity());
        if (t != null)
            t.stop();
    }
}
 
开发者ID:devcexx,项目名称:libtrails,代码行数:9,代码来源:BasicExample.java

示例14: on

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

示例15: onProjectileHit

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


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