本文整理汇总了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;
}
}
}
}
示例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点伤害");
}
}
示例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);
}
}
}
}
}