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


Java EntityShootBowEvent.getBow方法代码示例

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


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

示例1: onEntityShootBowEvent

import org.bukkit.event.entity.EntityShootBowEvent; //导入方法依赖的package包/类
@EventHandler(priority = EventPriority.HIGHEST)
public void onEntityShootBowEvent(EntityShootBowEvent event) {
    if ((event.getBow().hasItemMeta() && event.getBow().getItemMeta().getDisplayName().equals("Ender bow")) || event
            .getBow() instanceof EnderBowPlugin.EnderBow) {
        // Create custom event
        EntityShootEnderBowEvent entityShootEnderBowEvent = new EntityShootEnderBowEvent(event);

        // Call the custom event
        EnderBowPlugin.getInstance().getServer().getPluginManager().callEvent(entityShootEnderBowEvent);

        // Do the following, if it wasn't cancelled
        if (!entityShootEnderBowEvent.isCancelled()) {
            // Fire an ender pearl
            event.getEntity().launchProjectile(EnderPearl.class).setVelocity(event.getProjectile().getVelocity());

            // Play the 'ENDERMAN_TELEPORT' sound
            event.getEntity().getWorld().playSound(event.getEntity().getLocation(), Sound.ENDERMAN_TELEPORT, 1, 1);
        }

        // Cancel the original Event, so no arrows are fired
        event.setCancelled(true);
    }
}
 
开发者ID:jamierocks,项目名称:EnderBow,代码行数:24,代码来源:EnderBowListener.java

示例2: onEntityShootBow

import org.bukkit.event.entity.EntityShootBowEvent; //导入方法依赖的package包/类
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onEntityShootBow(EntityShootBowEvent event) {
    Entity projectile = event.getProjectile();

    if (!(projectile instanceof Arrow)) {
        return;
    }

    ItemStack bow = event.getBow();

    if (bow != null && bow.containsEnchantment(Enchantment.ARROW_INFINITE)) {
        projectile.setMetadata(mcMMO.infiniteArrowKey, mcMMO.metadataValue);
    }

    projectile.setMetadata(mcMMO.bowForceKey, new FixedMetadataValue(plugin, Math.min(event.getForce() * AdvancedConfig.getInstance().getForceMultiplier(), 1.0)));
    projectile.setMetadata(mcMMO.arrowDistanceKey, new FixedMetadataValue(plugin, projectile.getLocation()));
}
 
开发者ID:Pershonkey,项目名称:McMMOPlus,代码行数:18,代码来源:EntityListener.java

示例3: entityShootBow

import org.bukkit.event.entity.EntityShootBowEvent; //导入方法依赖的package包/类
@EventHandler
private void entityShootBow(EntityShootBowEvent event) {
	if (event.getEntity() instanceof Player) {
		Player player = (Player) event.getEntity();
		CustomItem customItem = CustomItemManager.getCustomItem(event.getBow());
		if (verifyCustomItem(customItem, player, false)) {
			DelayedPlayerDetails details = new DelayedPlayerDetails(event.getBow(), player);
			((CustomBow) customItem).onShootBow(event, details);
			if (!event.isCancelled() && event.getProjectile() instanceof Projectile) {
				details.lock();
				event.getProjectile().setMetadata("CustomItem-bow", new FixedMetadataValue(CustomItemManager._plugin, new Object[] { customItem, details }));
			}
		}
	}
}
 
开发者ID:goncalomb,项目名称:NBTEditor,代码行数:16,代码来源:CustomItemListener.java

示例4: onShoot

import org.bukkit.event.entity.EntityShootBowEvent; //导入方法依赖的package包/类
@EventHandler
public void onShoot(EntityShootBowEvent event)
{
	if(event.getEntity() instanceof Player)
	{
		Player player = (Player)event.getEntity();
		ItemStack mainItem = event.getBow();
		
		if(mainItem.getItemMeta().getLore() != null)
		{
			Random rand = new Random();
			if(event.getForce() >= 1.0F)
			{
				final Entity arrow = event.getProjectile();
				final Vector velocity = player.getLocation().getDirection().add(new Vector(0, 0.025, 0)).multiply(4);
				arrow.setVelocity(velocity);
	
	            player.getWorld().playSound(player.getLocation(), Sound.BLOCK_LEVER_CLICK, 1.0F, rand.nextFloat() * 0.4F + 0.8F);
	            player.getWorld().playSound(player.getLocation(), Sound.ENTITY_SHULKER_BULLET_HURT, 0.5F, rand.nextFloat() * 0.4F + 0.8F);
				
				final Runnable task = new Runnable()
				{
					int times = 4;
					public void run()
					{								
						if(!arrow.isOnGround())
						{
							arrow.setVelocity(velocity);
							if(times-- > 0)
								Bukkit.getScheduler().scheduleSyncDelayedTask(Survival.instance, this, 5);
						}
					}
				};
				
				Bukkit.getScheduler().scheduleSyncDelayedTask(Survival.instance, task, -1);
			}
			else
			{
				event.setCancelled(true);
	            player.getWorld().playSound(player.getLocation(), Sound.BLOCK_LEVER_CLICK, 0.5F, rand.nextFloat() * 0.4F + 0.8F);
			}
		}
	}
}
 
开发者ID:FattyMieo,项目名称:SurvivalPlus,代码行数:45,代码来源:RecurvedBow.java

示例5: EntityShootEnderBowEvent

import org.bukkit.event.entity.EntityShootBowEvent; //导入方法依赖的package包/类
public EntityShootEnderBowEvent(EntityShootBowEvent event) {
    this(event.getEntity(), event.getBow(), event.getForce());
}
 
开发者ID:jamierocks,项目名称:EnderBow,代码行数:4,代码来源:EntityShootEnderBowEvent.java

示例6: onEntityBowShoot

import org.bukkit.event.entity.EntityShootBowEvent; //导入方法依赖的package包/类
@EventHandler(priority = EventPriority.MONITOR)
public void onEntityBowShoot(EntityShootBowEvent event) {
    if (event.getBow() != null && event.getBow().containsEnchantment(Enchantment.ARROW_DAMAGE) && event.getBow().getEnchantmentLevel(Enchantment.ARROW_DAMAGE) > 1) {
        event.getProjectile().setMetadata("rage", new FixedMetadataValue(GameHandler.getGameHandler().getPlugin(), true));
    }
}
 
开发者ID:dentmaged,项目名称:Cardinal-Plus,代码行数:7,代码来源:Rage.java


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