本文整理匯總了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);
}
}
}
}
}