本文整理汇总了Java中org.bukkit.event.entity.EntityDamageEvent.getDamage方法的典型用法代码示例。如果您正苦于以下问题:Java EntityDamageEvent.getDamage方法的具体用法?Java EntityDamageEvent.getDamage怎么用?Java EntityDamageEvent.getDamage使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.bukkit.event.entity.EntityDamageEvent
的用法示例。
在下文中一共展示了EntityDamageEvent.getDamage方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onEntityDamage
import org.bukkit.event.entity.EntityDamageEvent; //导入方法依赖的package包/类
@EventHandler
public void onEntityDamage(EntityDamageEvent event) {
if(event.getCause() == EntityDamageEvent.DamageCause.CUSTOM) return;
if(Arcadia.getPlugin(Arcadia.class).getAPI().getGameManager().getGameState() != GameState.INGAME) {
event.setCancelled(true);
} else {
if(!Arcadia.getPlugin(Arcadia.class).getAPI().getGameManager().getCurrentGame().allowPVP) event.setCancelled(true);
}
if(!event.isCancelled() && event.getEntity() instanceof Player) {
Player player = (Player) event.getEntity();
if((player.getHealth()-event.getDamage()) <= 0) {
event.setDamage(0);
if(Arcadia.getPlugin(Arcadia.class).getAPI().getGameManager().isAlive(player)) {
Arcadia.getPlugin(Arcadia.class).getAPI().getGameManager().setAlive(player, false);
}
}
}
}
示例2: onEntityDamage
import org.bukkit.event.entity.EntityDamageEvent; //导入方法依赖的package包/类
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onEntityDamage(final EntityDamageEvent event) {
if(event.getEntity() instanceof Player) {
Player victim = (Player) event.getEntity();
Location location = victim.getBoundingBox().center().toLocation(match.getWorld());
if(event.getDamage() > 0 && location.getY() >= 0 && !victim.hasPotionEffect(PotionEffectType.INVISIBILITY)) {
EntityUtils.entities(match.getWorld(), Player.class)
.filter(player -> settings.getManager(player).getValue(Settings.BLOOD, Boolean.class, false))
.forEach(player -> {
if(event instanceof EntityDamageByEntityEvent) {
player.playEffect(location, Effect.STEP_SOUND, Material.REDSTONE_WIRE);
} else {
player.playEffect(location, Effect.STEP_SOUND, Material.LAVA);
}
});
}
}
}
示例3: onPlayerFall
import org.bukkit.event.entity.EntityDamageEvent; //导入方法依赖的package包/类
@EventHandler
public void onPlayerFall(EntityDamageEvent event) {
if (event.getEntity().getType() == EntityType.PLAYER
&& event.getCause() == EntityDamageEvent.DamageCause.FALL) {
Player player = (Player) event.getEntity();
if (!InventoryManager.playerIsLoaded(player)) {
return;
}
Modifier jumpModifier = ItemManager.getModifier(player, ItemStat.StatType.JUMP);
double height = (1.5D + jumpModifier.getBonus()) * jumpModifier.getMultiplier() * 1.5;
event.setDamage(event.getDamage() - height);
if (event.getDamage() <= 0.0D) {
event.setCancelled(true);
}
}
}
示例4: onEntityDamage
import org.bukkit.event.entity.EntityDamageEvent; //导入方法依赖的package包/类
@EventHandler(
priority = EventPriority.LOW
)
public void onEntityDamage(EntityDamageEvent event) {
if (api.getGameManager().isLegacyPvP())
{
Entity entity = event.getEntity();
if(entity instanceof Player) {
Player player = (Player)entity;
double baseDamage = event.getDamage(EntityDamageEvent.DamageModifier.BASE);
int defensePoints = this.getDefensePoints(player.getInventory());
double armorDamage = baseDamage * this.getLegacyDamageFactor(defensePoints);
event.setDamage(EntityDamageEvent.DamageModifier.ARMOR, armorDamage - baseDamage);
}
}
}
示例5: 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();
}
}
示例6: onPlayerDamage
import org.bukkit.event.entity.EntityDamageEvent; //导入方法依赖的package包/类
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onPlayerDamage(EntityDamageEvent event) {
if(event.getDamage() <= 0) return;
if(!(event.getEntity() instanceof Player)) return;
Player player = (Player) event.getEntity();
if(player.getGameMode() == GameMode.CREATIVE) return;
if(player.isDead()) return;
if(player.getNoDamageTicks() > 0) return;
if(getResistanceFactor(player) <= 0) return;
switch(event.getCause()) {
case ENTITY_EXPLOSION:
case BLOCK_EXPLOSION:
case CUSTOM:
case FALL:
case FALLING_BLOCK:
case LIGHTNING:
case MELTING:
case SUICIDE:
case THORNS:
return; // Skip damage causes that are not particularly likely to be followed by more damage
case FIRE:
case FIRE_TICK:
case LAVA:
if(hasFireResistance(player)) return;
break;
}
// Record the player's damage with a timestamp
this.recentDamage.put(player, new Damage(Instant.now(), event));
}
示例7: onDamage
import org.bukkit.event.entity.EntityDamageEvent; //导入方法依赖的package包/类
/**
* Fire player on damage
* @param event Event
*/
@EventHandler(priority = EventPriority.LOWEST)
public void onDamage(EntityDamageEvent event)
{
if (((SurvivalGame) SamaGamesAPI.get().getGameManager().getGame()).isDamagesActivated()
&& event.getEntityType() == EntityType.PLAYER
&& event.getCause() != EntityDamageEvent.DamageCause.FIRE
&& event.getCause() != EntityDamageEvent.DamageCause.FIRE_TICK
&& event.getDamage() > 0
&& !event.isCancelled())
event.getEntity().setFireTicks((int) this.moduleConfiguration.get("fire-time") * 20);
}