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


Java EntityDamageByEntityEvent.getCause方法代码示例

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


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

示例1: EntityDamageByEntityListener

import org.bukkit.event.entity.EntityDamageByEntityEvent; //导入方法依赖的package包/类
@EventHandler
public void EntityDamageByEntityListener(EntityDamageByEntityEvent e) {
	if (!GameManager.getGameSituation()) {
		e.setCancelled(true);
	}
	if (e.getDamager() instanceof Player) {
		if (e.getEntity() instanceof Player) {
			Player damager = (Player) e.getDamager();
			Player victim = (Player) e.getEntity();
			if (SettingsManager.shotinfo) {
				if (e.getCause() == DamageCause.PROJECTILE) {
					if(victim.getLocation().distance(damager.getLocation()) < 20) {
						Bukkit.broadcastMessage(SettingsManager.niceshot.replace("%s", victim.getName()).replace("%s", damager.getName()).replace("%d", String.valueOf(victim.getLocation().distance(damager.getLocation()))));
					}
				}
			}
		}
	}
}
 
开发者ID:masste,项目名称:McPlayUHC,代码行数:20,代码来源:EntityDamageByEntityListener.java

示例2: onAttack

import org.bukkit.event.entity.EntityDamageByEntityEvent; //导入方法依赖的package包/类
@EventHandler(priority = EventPriority.HIGHEST)
public void onAttack(EntityDamageByEntityEvent event)
{
	if(event.isCancelled()) return;
	if(event.getDamager() instanceof Player && event.getEntity() instanceof LivingEntity && event.getCause() == DamageCause.ENTITY_ATTACK)
	{
		Player player = (Player)event.getDamager();
		ItemStack mainItem = player.getInventory().getItemInMainHand();
		LivingEntity enemy = (LivingEntity)event.getEntity();
		
		if(mainItem.getType() == Material.GOLD_SPADE)
		{
			enemy.addPotionEffect(new PotionEffect(PotionEffectType.WEAKNESS, 100, 0, false));
			enemy.addPotionEffect(new PotionEffect(PotionEffectType.SLOW, 100, 0, false));
			player.addPotionEffect(new PotionEffect(PotionEffectType.REGENERATION, 48, 2, true));
			Location particleLoc = player.getLocation();
			particleLoc.setY(particleLoc.getY() + 2);
               ParticleEffect.HEART.display(0.5f, 0, 0.5f, 1, 2, particleLoc, 64);
		}
	}
}
 
开发者ID:FattyMieo,项目名称:SurvivalPlus,代码行数:22,代码来源:ObsidianMaceWeakness.java

示例3: onAttack

import org.bukkit.event.entity.EntityDamageByEntityEvent; //导入方法依赖的package包/类
@EventHandler(priority = EventPriority.HIGHEST)
public void onAttack(EntityDamageByEntityEvent event)
{
	if(event.isCancelled()) return;
	if(event.getDamager() instanceof Player && event.getEntity() instanceof LivingEntity && event.getCause() == DamageCause.ENTITY_ATTACK)
	{
		Player player = (Player)event.getDamager();
		ItemStack mainItem = player.getInventory().getItemInMainHand();
		LivingEntity enemy = (LivingEntity)event.getEntity();

		Random rand = new Random();
		
		if(mainItem.getType() == Material.GOLD_AXE)
		{
			enemy.addPotionEffect(new PotionEffect(PotionEffectType.WITHER, 480, 2, false));
			enemy.addPotionEffect(new PotionEffect(PotionEffectType.BLINDNESS, 480, 0, false));
           	enemy.getLocation().getWorld().playSound(enemy.getLocation(), Sound.ENTITY_WITHER_SPAWN, 1.0F, rand.nextFloat() * 0.4F + 0.8F);
		}
	}
}
 
开发者ID:FattyMieo,项目名称:SurvivalPlus,代码行数:21,代码来源:StarBattleaxeWither.java

示例4: call

import org.bukkit.event.entity.EntityDamageByEntityEvent; //导入方法依赖的package包/类
@Override
public void call(Event event) {
	if (event instanceof EntityDamageByEntityEvent) {
		EntityDamageByEntityEvent edbe = (EntityDamageByEntityEvent) event;

		if (edbe.getCause() != DamageCause.ENTITY_ATTACK) {
			return;
		}

		callback(!isInLineOfSight(edbe.getEntity(), 2.0));
	}
}
 
开发者ID:davidm98,项目名称:Crescent,代码行数:13,代码来源:KillauraB.java

示例5: onMelee

import org.bukkit.event.entity.EntityDamageByEntityEvent; //导入方法依赖的package包/类
@TargetedEventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onMelee(EntityDamageByEntityEvent event) {
    if(knockback.isPresent() &&
       victim.equals(event.getEntity()) &&
       event.getCause() == EntityDamageEvent.DamageCause.ENTITY_ATTACK &&
       event.getDamager() instanceof LivingEntity &&
       victim.getNoDamageTicks() <= 0) {

        applyImpulses((LivingEntity) event.getDamager());
    }
}
 
开发者ID:OvercastNetwork,项目名称:ProjectAres,代码行数:12,代码来源:KnockbackPlayerFacet.java

示例6: onAttack

import org.bukkit.event.entity.EntityDamageByEntityEvent; //导入方法依赖的package包/类
@SuppressWarnings("deprecation")
@EventHandler(priority = EventPriority.HIGHEST)
public void onAttack(EntityDamageByEntityEvent event)
{
	if(event.isCancelled()) return;
	if(event.getDamager() instanceof Player && event.getEntity() instanceof LivingEntity && event.getCause() == DamageCause.ENTITY_ATTACK)
	{
		Player player = (Player)event.getDamager();
		ItemStack item = player.getItemInHand();
		if(item.getType() == Material.WOOD_SPADE)
		{
			item.setDurability((short)(item.getDurability() - 2));
		}
	}
}
 
开发者ID:FattyMieo,项目名称:SurvivalPlus,代码行数:16,代码来源:FirestrikerClick.java

示例7: playerShotEvent

import org.bukkit.event.entity.EntityDamageByEntityEvent; //导入方法依赖的package包/类
@EventHandler
public void playerShotEvent(final EntityDamageByEntityEvent event) {
    if (GameState.current() == GameState.LOBBY || GameState.current() == GameState.ENDED) {
        return;
    }

    if (event.getCause() == EntityDamageEvent.DamageCause.PROJECTILE && event.getDamager() instanceof Arrow &&
            ((Arrow) event.getDamager()).getShooter() instanceof Player && event.getEntity() instanceof Player) {
        Player shot = (Player) event.getEntity();
        Player shooter = (Player) ((Arrow) event.getDamager()).getShooter();
        shooter.sendMessage(ChatColor.GRAY + "➵ " + ChatColor.AQUA + shot.getName() + " " + ChatColor.RED +
            new BigDecimal(shot.getHealth() / 2).setScale(1, BigDecimal.ROUND_HALF_UP));
    }
}
 
开发者ID:Project-Coalesce,项目名称:UHC,代码行数:15,代码来源:ArcheryHandler.java

示例8: onAttack

import org.bukkit.event.entity.EntityDamageByEntityEvent; //导入方法依赖的package包/类
@EventHandler(priority = EventPriority.HIGHEST)
public void onAttack(EntityDamageByEntityEvent event)
{
	if(event.isCancelled()) return;
	if(event.getDamager() instanceof Player && event.getEntity() instanceof LivingEntity && event.getCause() == DamageCause.ENTITY_ATTACK)
	{
		Player player = (Player)event.getDamager();
		ItemStack mainItem = player.getInventory().getItemInMainHand();
		ItemStack offItem = player.getInventory().getItemInOffHand();
		LivingEntity enemy = (LivingEntity)event.getEntity();

		Random rand = new Random();
		
		if(mainItem.getType() == Material.WOOD_HOE)
		{
			enemy.addPotionEffect(new PotionEffect(PotionEffectType.POISON, 80, 0, false));
			if(mainItem.getDurability() >= 59)
			{
				player.getLocation().getWorld().playSound(player.getLocation(), Sound.ENTITY_ITEM_BREAK, 1.0F, rand.nextFloat() * 0.4F + 0.8F);
				player.getInventory().setItemInMainHand(null);
			}
		}
		
		if(offItem.getType() == Material.WOOD_HOE)
		{
			int chance_poison = rand.nextInt(4) + 1;
			switch(chance_poison)
			{
				case 1:
				case 2:
				enemy.addPotionEffect(new PotionEffect(PotionEffectType.POISON, 80, 0, false));
				break;
				default:
			}
			offItem.setDurability((short)(offItem.getDurability() + 1));
			if(offItem.getDurability() >= 59)
			{
				player.getLocation().getWorld().playSound(player.getLocation(), Sound.ENTITY_ITEM_BREAK, 1.0F, rand.nextFloat() * 0.4F + 0.8F);
				player.getInventory().setItemInOffHand(null);
			}
		}
	}
}
 
开发者ID:FattyMieo,项目名称:SurvivalPlus,代码行数:44,代码来源:ShivPoison.java

示例9: onAttack

import org.bukkit.event.entity.EntityDamageByEntityEvent; //导入方法依赖的package包/类
@SuppressWarnings("deprecation")
@EventHandler(priority = EventPriority.HIGHEST)
public void onAttack(EntityDamageByEntityEvent event)
{
	if(event.isCancelled()) return;
	if(event.getEntity() instanceof Player)
	{
		Player player = (Player)event.getEntity();
		ItemStack offItem = player.getInventory().getItemInOffHand();

		if(dualWield.getScore(player).getScore() == 1)
		{
			event.setCancelled(true);
			return;
		}
		
		Random rand = new Random();
		
		if(offItem.getType() == Material.GOLD_HOE)
		{
			if(event.getDamager() instanceof LivingEntity && event.getCause() == DamageCause.ENTITY_ATTACK)
			{
				LivingEntity enemy = (LivingEntity)event.getDamager();
				enemy.damage(event.getDamage() * 40 / 100, player);
			}
			
			int chance_reduceDur = rand.nextInt(10) + 1;
			switch(chance_reduceDur)
			{
				case 1:
					offItem.setDurability((short)(offItem.getDurability() + 1));
					break;
				default:
			}

			if(offItem.getDurability() >= 32)
			{
				player.getLocation().getWorld().playSound(player.getLocation(), Sound.ENTITY_ITEM_BREAK, 1.0F, rand.nextFloat() * 0.4F + 0.8F);
				player.getInventory().setItemInOffHand(null);
			}
		}
	}
}
 
开发者ID:FattyMieo,项目名称:SurvivalPlus,代码行数:44,代码来源:GiantBlade.java


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