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


Java EntityDamageEvent.getDamage方法代碼示例

本文整理匯總了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);
            }
        }
    }
}
 
開發者ID:ArcadiaPlugins,項目名稱:Arcadia-Spigot,代碼行數:19,代碼來源:DamageListener.java

示例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);
                     }
                 });
        }
    }
}
 
開發者ID:OvercastNetwork,項目名稱:ProjectAres,代碼行數:19,代碼來源:BloodMatchModule.java

示例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);
        }
    }
}
 
開發者ID:EndlessCodeGroup,項目名稱:RPGInventory,代碼行數:20,代碼來源:ItemListener.java

示例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);
        }
    }
}
 
開發者ID:SamaGames,項目名稱:SamaGamesCore,代碼行數:17,代碼來源:ArmorModule.java

示例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();
    }
}
 
開發者ID:OvercastNetwork,項目名稱:ProjectAres,代碼行數:11,代碼來源:ShieldPlayerModule.java

示例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));
}
 
開發者ID:OvercastNetwork,項目名稱:ProjectAres,代碼行數:38,代碼來源:CombatLogTracker.java

示例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);
}
 
開發者ID:SamaGames,項目名稱:SurvivalAPI,代碼行數:16,代碼來源:PyroTechnicsModule.java


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