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