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


Java EntityDamageByEntityEvent.getDamage方法代码示例

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


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

示例1: onPlayerKillsPlayer

import org.bukkit.event.entity.EntityDamageByEntityEvent; //导入方法依赖的package包/类
@EventHandler
public void onPlayerKillsPlayer(EntityDamageByEntityEvent e) {
	if (!(e.getDamager() instanceof Player) || !(e.getEntity() instanceof Player))
		return;

	Player killer = (Player) e.getDamager();
	Player target = (Player) e.getEntity();

	// Check if the target is dead
	if (target.getHealth() - e.getDamage() <= 0) {
		PlayerObject killerObject = main.getPlayerManager().getMortuusPlayer(killer.getUniqueId());

		// Sets the time in SECONDS.
		killerObject.setLastPlayerKillTime(System.currentTimeMillis() / 1000);
		killerObject.addPlayerKills(1);

		for (PKStates state : PKStates.values()) {
			if (killerObject.getPlayerKills() == state.getRequiredKills()) {
				killerObject.setPkState(state);
				main.getScoreboards().switchTeam(killer, state.name());
				break;
			}
		}
	}
}
 
开发者ID:kadeska,项目名称:MT_Core,代码行数:26,代码来源:PlayerListener.java

示例2: onPlayerGotDamage

import org.bukkit.event.entity.EntityDamageByEntityEvent; //导入方法依赖的package包/类
@EventHandler
public void onPlayerGotDamage(EntityDamageByEntityEvent event){
    Entity dagager = event.getDamager();
    Entity wounded = event.getEntity();
    int damage = (int)(event.getDamage() + 0.5);

    if (wounded instanceof Player){
        ((Player)wounded).sendMessage("§d[伤害] §b"+ dagager.getName() + "§e对你造成 §b" + damage +" §e点伤害");
    }

    if (dagager instanceof Player){
        ((Player)dagager).sendMessage("§d[伤害]" + "§e你对 §b"+wounded.getName()+ "§e造成 §b" + damage +" §e点伤害");

    }

}
 
开发者ID:kncxstudio,项目名称:BasicSurvivalPlus,代码行数:17,代码来源:PlayerDamageListener.java

示例3: onEntityDamageByEntity

import org.bukkit.event.entity.EntityDamageByEntityEvent; //导入方法依赖的package包/类
@EventHandler(priority = EventPriority.LOWEST)
public void onEntityDamageByEntity(EntityDamageByEntityEvent event)
{
    if (api.getGameManager().isLegacyPvP()) {
        Entity attacker = event.getDamager();
        if (attacker instanceof Player) {
            Player player = (Player) attacker;
            ItemStack inHand = player.getInventory().getItemInMainHand();
            if (inHand != null) {
                double baseDamage = event.getDamage(EntityDamageEvent.DamageModifier.BASE);
                double currentDamage = this.getCurrentDamage(inHand.getType());
                if (currentDamage != 0.0D) {
                    double damageFactor = baseDamage / currentDamage;
                    double legacyDamage = this.getLegacyDamage(inHand.getType()) * damageFactor;
                    event.setDamage(EntityDamageEvent.DamageModifier.BASE, legacyDamage);
                }
            }
        }
    }
}
 
开发者ID:SamaGames,项目名称:SamaGamesCore,代码行数:21,代码来源:CooldownModule.java


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