當前位置: 首頁>>代碼示例>>Java>>正文


Java EntityDamageByEntityEvent.getEntity方法代碼示例

本文整理匯總了Java中org.bukkit.event.entity.EntityDamageByEntityEvent.getEntity方法的典型用法代碼示例。如果您正苦於以下問題:Java EntityDamageByEntityEvent.getEntity方法的具體用法?Java EntityDamageByEntityEvent.getEntity怎麽用?Java EntityDamageByEntityEvent.getEntity使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.bukkit.event.entity.EntityDamageByEntityEvent的用法示例。


在下文中一共展示了EntityDamageByEntityEvent.getEntity方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: onDamageEntity

import org.bukkit.event.entity.EntityDamageByEntityEvent; //導入方法依賴的package包/類
@EventHandler
public void onDamageEntity(EntityDamageByEntityEvent e){
    Player p;

    if (e.getDamager() instanceof Player && e.getEntity() instanceof Zombie){
        p = (Player)e.getDamager();
        Weapon weapon;

        if (p.getInventory().getItemInMainHand() == null || !Weapon.isWeapon(p.getInventory().getItemInMainHand())) return;
        if (Weapon.getWeaponByItemStack(p.getInventory().getItemInMainHand()) == null) {
            e.setDamage(0);
            return;
        }
        weapon = Weapon.getWeaponByItemStack(p.getInventory().getItemInMainHand());

        if (weapon.getId() != 0) return;

        e.setDamage(((Zombie) e.getEntity()).getMaxHealth());
    }

    if (e.getDamager() instanceof Zombie && e.getEntity() instanceof Player) {
        p = (Player) e.getEntity();
        if (this.plugin.getBlooding().contains(new TWDPlayer(p.getUniqueId()))) return;
        this.plugin.getBlooding().add(new TWDPlayer(p.getUniqueId()));
    }
}
 
開發者ID:cadox8,項目名稱:WC,代碼行數:27,代碼來源:Weapons.java

示例2: onEntityDamageByEntity

import org.bukkit.event.entity.EntityDamageByEntityEvent; //導入方法依賴的package包/類
@EventHandler
public void onEntityDamageByEntity(EntityDamageByEntityEvent event) {
    Player attacker = getDamageSource(event.getDamager());
    Entity eDefender = event.getEntity();
    if (!(eDefender instanceof Player)) {
        forbidIfInProtectedTerritory(attacker, eDefender, event, ATTACK);
        return;
    }
    Player defender = (Player) eDefender;
    Faction aFaction = plugin.getFactionCache().getByMember(attacker);
    Faction dFaction = plugin.getFactionCache().getByMember(defender);
    Faction rFaction = plugin.getFactionCache().getByLocation(defender.getLocation());
    if (aFaction.getRelation(dFaction).isProtected()) {
        ParsingUtil.sendMessage(attacker, FMessage.PROTECTION_CANNOT_ATTACK_PLAYER.getMessage(), dFaction);
        event.setCancelled(true);
    } else if (rFaction != null && rFaction.getRelation(dFaction).isProtected()) {
        if (plugin.getFConfig().isTerritoryProtectionEnabled() && (!plugin.getFConfig().isCapitalProtectionEnabled()
                || rFaction.getCapital().equals(plugin.getBoard().getByLocation(eDefender.getLocation())))) {
            ParsingUtil.sendMessage(attacker, FMessage.PROTECTION_CANNOT_ATTACK_FACTION.getMessage(), rFaction);
            event.setCancelled(true);
        } else if (plugin.getFConfig().getTerritoryShield() != 0) {
            event.setDamage(event.getDamage() * plugin.getFConfig().getTerritoryShield());
        }
    }
}
 
開發者ID:DRE2N,項目名稱:FactionsXL,代碼行數:26,代碼來源:EntityProtectionListener.java

示例3: onProjectileHurtEvent

import org.bukkit.event.entity.EntityDamageByEntityEvent; //導入方法依賴的package包/類
@EventHandler
public void onProjectileHurtEvent(EntityDamageByEntityEvent event) {
    if(!(event.getEntity() instanceof LivingEntity)) return;
    final LivingEntity damagedEntity = (LivingEntity) event.getEntity();

    final ProjectileDefinition projectileDefinition = Projectiles.getProjectileDefinition(event.getDamager());
    if(projectileDefinition == null) return;

    if(!projectileDefinition.potion().isEmpty()) {
        damagedEntity.addPotionEffects(projectileDefinition.potion());
    }

    if(projectileDefinition.damage() != null) {
        event.setDamage(projectileDefinition.damage());
    }
}
 
開發者ID:OvercastNetwork,項目名稱:ProjectAres,代碼行數:17,代碼來源:ProjectileMatchModule.java

示例4: onTag

import org.bukkit.event.entity.EntityDamageByEntityEvent; //導入方法依賴的package包/類
@EventHandler
public void onTag(EntityDamageByEntityEvent e)
{
  if ((!(e.getEntity() instanceof Player)) || (!(e.getDamager() instanceof Player))) {
    return;
  }
  Player staff = (Player)e.getDamager();
  if (modMode.contains(staff.getName())) {
    e.setCancelled(true);
  }
}
 
開發者ID:funkemunky,項目名稱:HCFCore,代碼行數:12,代碼來源:ModeratorMode.java

示例5: onEntityDamageByEntity

import org.bukkit.event.entity.EntityDamageByEntityEvent; //導入方法依賴的package包/類
@EventHandler
public void onEntityDamageByEntity(EntityDamageByEntityEvent event) {
	Entity entity = event.getEntity();
	
	if (!(entity instanceof EnderCrystal) || event.getEntity().getWorld().getEnvironment() != Environment.THE_END
			|| !entity.isInvulnerable()) return;
	
	event.setCancelled(true);
}
 
開發者ID:2008Choco,項目名稱:DragonEggDrop,代碼行數:10,代碼來源:LootListeners.java

示例6: onEntityDamageByEntity

import org.bukkit.event.entity.EntityDamageByEntityEvent; //導入方法依賴的package包/類
/**
 * Removes the hit cooldown upon a player attack and reduces the amount of damage dealt according to a modifier.
 *
 * @param event The event
 */
@EventHandler(ignoreCancelled = true)
public void onEntityDamageByEntity(EntityDamageByEntityEvent event) {
  Entity entity = event.getEntity();
  if (entity instanceof Player
      && event.getDamager() instanceof Player
      && event.getCause().equals(EntityDamageEvent.DamageCause.ENTITY_ATTACK)) {
    event.setDamage(event.getDamage() * damageReduction);
    Bukkit.getScheduler().runTask(OpenUHC.getInstance(), () -> ((Player) entity).setNoDamageTicks(0));
  }
}
 
開發者ID:twizmwazin,項目名稱:OpenUHC,代碼行數:16,代碼來源:MeleeFun.java

示例7: onEntityDamageByEntity

import org.bukkit.event.entity.EntityDamageByEntityEvent; //導入方法依賴的package包/類
@EventHandler(ignoreCancelled = true, priority = EventPriority.MONITOR)
public void onEntityDamageByEntity(EntityDamageByEntityEvent event) {
    Player attacker = BukkitUtils.getFinalAttacker(event, true);
    Entity entity;
    if (attacker != null && (entity = event.getEntity()) instanceof Player) {
        Player attacked = (Player) entity;
        setCooldown(attacker, attacker.getUniqueId(), defaultCooldown, false);
        setCooldown(attacked, attacked.getUniqueId(), defaultCooldown, false);
    }
}
 
開發者ID:funkemunky,項目名稱:HCFCore,代碼行數:11,代碼來源:CombatTimer.java

示例8: onEntityDamageByEntity

import org.bukkit.event.entity.EntityDamageByEntityEvent; //導入方法依賴的package包/類
@EventHandler
public void onEntityDamageByEntity(EntityDamageByEntityEvent e) {
	e.setCancelled(true);
	
	if(e.getDamager() instanceof Player && e.getEntity() instanceof Player) {
		GamePlayer damager = Absorption.getPlayer((Player) e.getDamager());
		GamePlayer player = Absorption.getPlayer((Player) e.getEntity());
		
		if(damager == null || player == null) return;
		
		player.hitByPlayer(damager);
	}
}
 
開發者ID:SamaGames,項目名稱:Absorption,代碼行數:14,代碼來源:PlayerListener.java

示例9: onEntityDamageByEntityEvent

import org.bukkit.event.entity.EntityDamageByEntityEvent; //導入方法依賴的package包/類
@EventHandler
   public void onEntityDamageByEntityEvent(EntityDamageByEntityEvent e) {
	if (e.getDamager() instanceof Player && !(e.getEntity() instanceof ArmorStand)) {
		((Player) e.getDamager()).sendMessage(ChatColor.GRAY + "You did " + Math.round(e.getDamage()) + ChatColor.RED + " \u2764 " + ChatColor.GRAY + "to " + e.getEntity().getName());
	}
	if (e.getDamager() instanceof Projectile && ((Projectile) e.getDamager()).getShooter() instanceof Player) {
		((Player) (((Projectile) e.getDamager()).getShooter())).sendMessage(ChatColor.GRAY + "You did " + Math.round(e.getDamage()) + ChatColor.RED + " \u2764 " + ChatColor.GRAY + "to " + e.getEntity().getName());
	}
}
 
開發者ID:GigaGamma,項目名稱:SuperiorCraft,代碼行數:10,代碼來源:DamageIndicator.java

示例10: checkItemFrameItemRemove

import org.bukkit.event.entity.EntityDamageByEntityEvent; //導入方法依賴的package包/類
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
public void checkItemFrameItemRemove(EntityDamageByEntityEvent event) {
    // This event is fired when popping an item out of an item frame, without breaking the frame itself
    if(event.getEntity() instanceof ItemFrame && ((ItemFrame) event.getEntity()).getItem() != null) {
        this.handleHangingBreak(event, (Hanging) event.getEntity(), event.getDamager());
    }
}
 
開發者ID:OvercastNetwork,項目名稱:ProjectAres,代碼行數:8,代碼來源:EventRuleMatchModule.java

示例11: onEntityDamage

import org.bukkit.event.entity.EntityDamageByEntityEvent; //導入方法依賴的package包/類
/**
 * Set NoDamageTicks to 0 on player -> player damage
 *
 * @param event Event
 */
@EventHandler(ignoreCancelled = true, priority = EventPriority.LOWEST)
public void onEntityDamage(EntityDamageByEntityEvent event)
{
    if (!(event.getEntity() instanceof Player) || (!(event.getDamager() instanceof Player)) && !(event.getDamager() instanceof Projectile))
        return;

    ((Player) event.getEntity()).setNoDamageTicks(0);
    this.plugin.getServer().getScheduler().runTaskLater(this.plugin, () -> ((Player)event.getEntity()).setNoDamageTicks(0), 1);
}
 
開發者ID:SamaGames,項目名稱:SurvivalAPI,代碼行數:15,代碼來源:MeleeFunModule.java

示例12: onPlayerDamage

import org.bukkit.event.entity.EntityDamageByEntityEvent; //導入方法依賴的package包/類
@EventHandler(ignoreCancelled = true, priority = EventPriority.MONITOR)
public void onPlayerDamage(EntityDamageByEntityEvent event) {
    Entity entity = event.getEntity();
    if (entity instanceof Player && BukkitUtils.getFinalAttacker(event, false) != null) {
        Player player = (Player) entity;
        if (plugin.getPvpClassManager().hasClassEquipped(player, this)) {
            removeInvisibilitySafely(player);
        }
    }
}
 
開發者ID:funkemunky,項目名稱:HCFCore,代碼行數:11,代碼來源:MinerClass.java

示例13: onHangingDamageByEntity

import org.bukkit.event.entity.EntityDamageByEntityEvent; //導入方法依賴的package包/類
@EventHandler(ignoreCancelled = true, priority = EventPriority.HIGH)
public void onHangingDamageByEntity(final EntityDamageByEntityEvent event) {
    final Entity entity = event.getEntity();
    if (entity instanceof Hanging) {
        final Player attacker = BukkitUtils.getFinalAttacker((EntityDamageEvent)event, false);
        if (!attemptBuild((Entity)attacker, entity.getLocation(), ChatColor.GRAY + "You may not build in the territory of %1$s" + ChatColor.GRAY + '.')) {
            event.setCancelled(true);
        }
    }
}
 
開發者ID:funkemunky,項目名稱:HCFCore,代碼行數:11,代碼來源:CoreListener.java

示例14: onEntityDamage

import org.bukkit.event.entity.EntityDamageByEntityEvent; //導入方法依賴的package包/類
@EventHandler()
public void onEntityDamage(EntityDamageByEntityEvent e) {
    if (!ClaimChunk.getInstance().getChunkHandler().isClaimed(e.getEntity().getLocation().getChunk())) {
        return;
    }
    if (e.getDamager() instanceof Player && e.getEntity() instanceof Animals)
        ChunkHelper.cancelAnimalDamage((Player) e.getDamager(), e.getDamager().getLocation().getChunk(), e);
}
 
開發者ID:cjburkey01,項目名稱:ClaimChunk,代碼行數:9,代碼來源:CancellableChunkEvents.java

示例15: onDamaged

import org.bukkit.event.entity.EntityDamageByEntityEvent; //導入方法依賴的package包/類
@SuppressWarnings("deprecation")
@EventHandler(priority = EventPriority.HIGHEST)
public void onDamaged(EntityDamageByEntityEvent event)
{
	if(event.isCancelled()) return;
	if(event.getEntity() instanceof Player)
	{
		Player player = (Player)event.getEntity();
		healing.getScore(player).setScore(0);
	}
}
 
開發者ID:FattyMieo,項目名稱:SurvivalPlus,代碼行數:12,代碼來源:MedicKit.java


注:本文中的org.bukkit.event.entity.EntityDamageByEntityEvent.getEntity方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。