當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。