本文整理汇总了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);
}
}
示例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);
}
示例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");
}
}
示例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);
}
}
示例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);
}
示例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);
}
示例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);
}
}