当前位置: 首页>>代码示例>>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;未经允许,请勿转载。