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