当前位置: 首页>>代码示例>>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;未经允许,请勿转载。