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


Java EntityDamageEvent.getFinalDamage方法代碼示例

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


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

示例1: onEvent

import org.bukkit.event.entity.EntityDamageEvent; //導入方法依賴的package包/類
void onEvent(EntityDamageEvent event) {
    if(event.getFinalDamage() > 0) {
        // Absorbed damage is applied to the shield before any potion effect
        double shieldDamage = -event.getDamage(EntityDamageEvent.DamageModifier.ABSORPTION);
        logger.fine("Absorbing damage with shield: shield=" + shieldHealth + " shieldDamage=" + shieldDamage);
        shieldHealth = Math.max(0, shieldHealth - shieldDamage);

        damage();
    }
}
 
開發者ID:OvercastNetwork,項目名稱:ProjectAres,代碼行數:11,代碼來源:ShieldPlayerModule.java

示例2: customDeathNonPlayerFallback

import org.bukkit.event.entity.EntityDamageEvent; //導入方法依賴的package包/類
@EventHandler(priority=EventPriority.LOWEST)
public void customDeathNonPlayerFallback(EntityDamageEvent e){
	if(e.getCause().equals(DamageCause.FALL)) return;
	if(e.getEntity() instanceof Player){
		Player p = (Player) e.getEntity();
		if(e.getCause().equals(DamageCause.ENTITY_ATTACK)){
			// no need to do anything here, this part is controlled in the customDeath method
		}else{
			if(e.getFinalDamage() >= p.getHealth()){
				e.setCancelled(true);
				Bukkit.getServer().broadcastMessage(ChatColor.GRAY + p.getName() + " died");
				// Set statistics
				//p.setStatistic(Statistic.DEATHS, p.getStatistic(Statistic.DEATHS) + 1);
				// Reset health, so they dont die
				p.setHealth(p.getMaxHealth());
				// Inventory clearing
				p.getInventory().clear();
				ItemStack air = new ItemStack(Material.AIR);
				p.getInventory().setHelmet(air);
				p.getInventory().setChestplate(air);
				p.getInventory().setLeggings(air);
				p.getInventory().setBoots(air);
				// Clear potion effects
				for(PotionEffect pe : p.getActivePotionEffects()){
					p.removePotionEffect(pe.getType());
				}
				// Stop infinite kill glitch
				p.setGameMode(GameMode.SPECTATOR);
				p.setGameMode(GameMode.ADVENTURE);
				// send them to the SPAWN of the world
				p.teleport(p.getWorld().getSpawnLocation());
				p.setFireTicks(0);
			}
		}
	}
}
 
開發者ID:OverloadedCore,項目名稱:kaosEssentials,代碼行數:37,代碼來源:Core.java

示例3: onDamage

import org.bukkit.event.entity.EntityDamageEvent; //導入方法依賴的package包/類
@EventHandler
public void onDamage(EntityDamageEvent event) {
    if (!(event.getEntity() instanceof Player)) return;
    Player player = (Player) event.getEntity();
    if (!TGM.get().getMatchManager().getMatch().getMatchStatus().equals(MatchStatus.MID) || teamManagerModule.getTeam(player).isSpectator()) return;
    if (player.getHealth() - event.getFinalDamage() >= 0.5) return;

    createDeath(event);
    removeLife(player);

    event.setDamage(0);
    TGM.get().getModule(SpawnPointHandlerModule.class).spawnPlayer(TGM.get().getPlayerManager().getPlayerContext(player), teamManagerModule.getTeam(player), false);

    if (getLives(player) <= 0) {
        player.setGameMode(GameMode.SPECTATOR);
        player.setAllowFlight(true);
        player.setFlying(true);
        player.getInventory().clear();

        if (player.getLocation().getY() < 0) {
            player.teleport(teamManagerModule.getTeam(player).getSpawnPoints().get(0).getLocation(), PlayerTeleportEvent.TeleportCause.PLUGIN);
        }

        MatchTeam team = teamManagerModule.getTeam(player);
        updateScoreboardTeamLine(team, getAlivePlayers(team).size());

        Bukkit.broadcastMessage(team.getColor() + player.getName() + ChatColor.RED + " has been eliminated!");
        player.sendTitle("", ChatColor.RED + "You have been eliminated.");

    } else {
        showLives(player);
        player.teleport(teamManagerModule.getTeam(player).getSpawnPoints().get(0).getLocation(), PlayerTeleportEvent.TeleportCause.PLUGIN);
    }

    if (lastTeamAlive()) {
        MatchTeam winnerTeam = teamManagerModule.getTeams().stream().filter(matchTeam -> !matchTeam.isSpectator()).filter(matchTeam -> getAlivePlayers(matchTeam).size() > 0).findFirst().get();
        if (winnerTeam == null) {
            winnerTeam = teamManagerModule.getTeams().get(1);
        }
        TGM.get().getMatchManager().endMatch(winnerTeam);
        return;
    }
}
 
開發者ID:WarzoneMC,項目名稱:Warzone,代碼行數:44,代碼來源:BlitzModule.java


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