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


Java EntityDamageEvent.getEntityType方法代碼示例

本文整理匯總了Java中org.bukkit.event.entity.EntityDamageEvent.getEntityType方法的典型用法代碼示例。如果您正苦於以下問題:Java EntityDamageEvent.getEntityType方法的具體用法?Java EntityDamageEvent.getEntityType怎麽用?Java EntityDamageEvent.getEntityType使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.bukkit.event.entity.EntityDamageEvent的用法示例。


在下文中一共展示了EntityDamageEvent.getEntityType方法的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: onItemDamage

import org.bukkit.event.entity.EntityDamageEvent; //導入方法依賴的package包/類
@EventHandler
public void onItemDamage(EntityDamageEvent event) {
    if (event.getEntityType() == EntityType.DROPPED_ITEM && (event.getCause() == DamageCause.LAVA || event.getCause() == DamageCause.FIRE_TICK || event.getCause() == DamageCause.FIRE)) {
        Vector v = Vector.getRandom().normalize();
        v = v.setX(v.getX() - 0.5f);
        v = v.setZ(v.getZ() - 0.5f);
        v = v.multiply(0.35);
        if (v.getX() > 0 && v.getX() < 0.10)
            v.setX(0.10);
        if (v.getZ() > 0 && v.getZ() < 0.10)
            v.setZ(0.10);
        if (v.getX() < 0 && v.getX() > -0.10)
            v.setX(-0.10);
        if (v.getZ() < 0 && v.getZ() > -0.10)
            v.setZ(-0.10);
        v.setY(0.3);
        event.getEntity().setVelocity(v);
        event.setCancelled(true);
        RScheduler.schedule(plugin, () -> {
            event.getEntity().setFireTicks(0);
        }, RTicks.seconds(1));
    }
    if (event.getEntityType() == EntityType.ARMOR_STAND && (event.getCause() == DamageCause.LAVA || event.getCause() == DamageCause.FIRE_TICK || event.getCause() == DamageCause.FIRE)) {
        event.setCancelled(true);
    }
}
 
開發者ID:edasaki,項目名稱:ZentrelaRPG,代碼行數:27,代碼來源:EnvironmentManager.java

示例2: onDamageWhenPlayerNotLoaded

import org.bukkit.event.entity.EntityDamageEvent; //導入方法依賴的package包/類
@EventHandler(ignoreCancelled = true, priority = EventPriority.LOW)
public void onDamageWhenPlayerNotLoaded(EntityDamageEvent event) {
    if (event.getEntityType() != EntityType.PLAYER) {
        return;
    }

    Player player = (Player) event.getEntity();
    if (InventoryManager.playerIsLoaded(player)) {
        return;
    }

    if (event.getCause() == EntityDamageEvent.DamageCause.FALL) {
        PlayerLoader.setDamageForPlayer(player, event.getFinalDamage());
    }

    event.setCancelled(true);
}
 
開發者ID:EndlessCodeGroup,項目名稱:RPGInventory,代碼行數:18,代碼來源:PlayerListener.java

示例3: onEntityDamageEvent

import org.bukkit.event.entity.EntityDamageEvent; //導入方法依賴的package包/類
@EventHandler
   public void onEntityDamageEvent(EntityDamageEvent e) {
	if (!(e.getEntity() instanceof ArmorStand) && e.getEntityType() != EntityType.ARMOR_STAND && e.getEntityType() != EntityType.DROPPED_ITEM) {
		Hologram h = new Hologram(ChatColor.RED + "-" + Double.toString(e.getDamage()) + " \u2764", e.getEntity().getLocation());
		h.getHologram().addScoreboardTag("dindicator");
		h.setKillTimer(2);
	}
	if (e.getEntity() instanceof Player) {
		Player player = (Player) e.getEntity();
		player.sendMessage(ChatColor.GRAY + "[DamageIndicator] " + e.getCause().name() + " did " + new DecimalFormat("#0.0").format(((double) Math.round(e.getDamage())) / 2) + ChatColor.RED + " \u2764");
	}
}
 
開發者ID:GigaGamma,項目名稱:SuperiorCraft,代碼行數:13,代碼來源:DamageIndicator.java

示例4: onDamage

import org.bukkit.event.entity.EntityDamageEvent; //導入方法依賴的package包/類
/**
 * Cancel fall damages
 *
 * @param event Event instance
 */
@EventHandler
public void onDamage(EntityDamageEvent event)
{
    if (event.getEntityType() == EntityType.PLAYER && event.getCause() == EntityDamageEvent.DamageCause.FALL)
    {
        event.setCancelled(true);
        event.setDamage(0);
    }
}
 
開發者ID:SamaGames,項目名稱:SurvivalAPI,代碼行數:15,代碼來源:SuperheroesModule.java

示例5: 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

示例6: onDamage

import org.bukkit.event.entity.EntityDamageEvent; //導入方法依賴的package包/類
/**
 * Cancel regen 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)
        ((Player)event.getEntity()).removePotionEffect(PotionEffectType.REGENERATION);
}
 
開發者ID:SamaGames,項目名稱:SurvivalAPI,代碼行數:12,代碼來源:GapZapModule.java

示例7: onVoidDamage

import org.bukkit.event.entity.EntityDamageEvent; //導入方法依賴的package包/類
@GameEvent
public void onVoidDamage(@Nonnull EntityDamageEvent event) {
    if (event.getEntityType() != EntityType.PLAYER)
        return;

    if (event.getCause().equals(EntityDamageEvent.DamageCause.VOID)) {
        Player player = (Player) event.getEntity();

        player.teleport(getPhase().getFeature(SpawnFeature.class).getSpawn(player.getUniqueId()));

        event.setCancelled(true);
    }
}
 
開發者ID:VoxelGamesLib,項目名稱:VoxelGamesLibv2,代碼行數:14,代碼來源:VoidTeleportFeature.java


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