本文整理汇总了Java中org.bukkit.event.entity.EntityDamageEvent.DamageCause.ENTITY_EXPLOSION属性的典型用法代码示例。如果您正苦于以下问题:Java DamageCause.ENTITY_EXPLOSION属性的具体用法?Java DamageCause.ENTITY_EXPLOSION怎么用?Java DamageCause.ENTITY_EXPLOSION使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类org.bukkit.event.entity.EntityDamageEvent.DamageCause
的用法示例。
在下文中一共展示了DamageCause.ENTITY_EXPLOSION属性的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onEntityDamage
@EventHandler
public void onEntityDamage(EntityDamageEvent event) {
if (damageTypes.contains(event.getCause()) && (event.getCause() != DamageCause.BLOCK_EXPLOSION || event.getCause() != DamageCause.ENTITY_EXPLOSION)) {
event.setCancelled(true);
} else if (event.getCause() == DamageCause.BLOCK_EXPLOSION || event.getCause() == DamageCause.ENTITY_EXPLOSION) {
if (event instanceof EntityDamageByEntityEvent) {
if (event.getEntity() instanceof Player && TntTracker.getWhoPlaced(((EntityDamageByEntityEvent) event).getDamager()) != null) {
Player player = (Player) event.getEntity();
UUID source = TntTracker.getWhoPlaced(((EntityDamageByEntityEvent) event).getDamager());
Match match = GameHandler.getGameHandler().getMatch();
if (Bukkit.getOfflinePlayer(source).isOnline()) {
if (Bukkit.getPlayer(source).equals(player)) {
event.setCancelled(!blockExplosionSelf);
} else if (TeamUtils.getTeamByPlayer(Bukkit.getPlayer(source)) == TeamUtils.getTeamByPlayer(player)) {
event.setCancelled(!blockExplosionAlly);
} else if (TeamUtils.getTeamByPlayer(Bukkit.getPlayer(source)) != TeamUtils.getTeamByPlayer(player)) {
event.setCancelled(!blockExplosionEnemy);
} else {
event.setCancelled(!blockExplosionOther);
}
}
}
} else if (damageTypes.contains(DamageCause.BLOCK_EXPLOSION)) event.setCancelled(true);
}
}
示例2: onEntityDamage
@EventHandler
public void onEntityDamage(EntityDamageEvent event) {
if (damageTypes.contains(event.getCause()) && (event.getCause() != DamageCause.BLOCK_EXPLOSION || event.getCause() != DamageCause.ENTITY_EXPLOSION)) {
event.setCancelled(true);
} else if (event.getCause() == DamageCause.BLOCK_EXPLOSION || event.getCause() == DamageCause.ENTITY_EXPLOSION) {
if (event instanceof EntityDamageByEntityEvent) {
if (event.getEntity() instanceof Player && TntTracker.getWhoPlaced(((EntityDamageByEntityEvent) event).getDamager()) != null) {
Player player = (Player) event.getEntity();
UUID source = TntTracker.getWhoPlaced(((EntityDamageByEntityEvent) event).getDamager());
Match match = GameHandler.getGameHandler().getMatch();
if (Bukkit.getOfflinePlayer(source).isOnline()) {
if (Bukkit.getPlayer(source).equals(player)) {
event.setCancelled(!blockExplosionSelf);
} else if (Teams.getTeamByPlayer(Bukkit.getPlayer(source)) == Teams.getTeamByPlayer(player)) {
event.setCancelled(!blockExplosionAlly);
} else if (Teams.getTeamByPlayer(Bukkit.getPlayer(source)) != Teams.getTeamByPlayer(player)) {
event.setCancelled(!blockExplosionEnemy);
} else {
event.setCancelled(!blockExplosionOther);
}
}
}
} else if (damageTypes.contains(DamageCause.BLOCK_EXPLOSION)) event.setCancelled(true);
}
}
示例3: IsEnviromentKill
private boolean IsEnviromentKill(DamageCause damageCause)
{
boolean env = this.model.getConfig().getZombieSpawnCondition().getEnv();
if(env)
{
if(damageCause == DamageCause.ENTITY_ATTACK || damageCause == DamageCause.ENTITY_EXPLOSION)
{
return false;
}
return true;
}
return false;
}
示例4: onDamage
@EventHandler
public void onDamage(EntityDamageEvent e) {
if (e.getEntity() instanceof Player) {
if (e.getCause() == DamageCause.BLOCK_EXPLOSION || e.getCause() == DamageCause.ENTITY_EXPLOSION) {
Player p = (Player) e.getEntity();
e.setDamage(e.getDamage() * (1 - EnchantmentZ.calcInventoryPieceAmount(BLAST_PROTECTION, p.getInventory()) * 0.0625));
}
}
}
示例5: toBukkit
public static DamageCause toBukkit(cn.nukkit.event.entity.EntityDamageEvent.DamageCause nukkit) {
// TODO Direct mapping via DamageCause.valueOf?
switch (nukkit) {
case CONTACT:
return DamageCause.CONTACT;
case ENTITY_ATTACK:
return DamageCause.ENTITY_ATTACK;
case PROJECTILE:
return DamageCause.PROJECTILE;
case SUFFOCATION:
return DamageCause.SUFFOCATION;
case FALL:
return DamageCause.FALL;
case FIRE:
return DamageCause.FIRE;
case FIRE_TICK:
return DamageCause.FIRE_TICK;
case LAVA:
return DamageCause.LAVA;
case DROWNING:
return DamageCause.DROWNING;
case BLOCK_EXPLOSION:
return DamageCause.BLOCK_EXPLOSION;
case ENTITY_EXPLOSION:
return DamageCause.ENTITY_EXPLOSION;
case VOID:
return DamageCause.VOID;
case SUICIDE:
return DamageCause.SUICIDE;
case MAGIC:
return DamageCause.MAGIC;
case LIGHTNING:
return DamageCause.LIGHTNING;
case CUSTOM:
default:
return DamageCause.CUSTOM;
}
}
示例6: onEntityDamage
/**
* On entity damage.
*
* @param event the event
*/
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
public void onEntityDamage(EntityDamageEvent event) {
if (conf.isOverrideExplosions()
&& event.getEntity() instanceof Hanging
&& (event.getCause() == DamageCause.BLOCK_EXPLOSION || event.getCause() == DamageCause.ENTITY_EXPLOSION
|| event.getCause() == DamageCause.PROJECTILE)) {
// Check for ItemFrame
Factoid.getThisPlugin().iLog().write("Cancel HangingBreak : " + event.getEntity() + ", Cause: " + event.getCause());
event.setCancelled(true);
}
}
示例7: onEntityDamage
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
public void onEntityDamage(final ExtendedEntityDamageEvent ext) {
final EntityDamageEvent event = (EntityDamageEvent)ext.getBaseEvent();
if (event.getCause() == DamageCause.ENTITY_EXPLOSION) {
if (event.getEntityType() == EntityType.DROPPED_ITEM) {
if (ext.getEntityRegion() != null && ext.getEntityRegion().getFlag(Flag.EXPLOSION_ITEM) || ext.getDamagerRegion() != null && ext.getDamagerRegion().getFlag(Flag.EXPLOSION_ITEM)) {
event.setCancelled(true);
}
} else if (event.getEntityType() == EntityType.PLAYER) {
if (ext.getEntityRegion() != null && ext.getEntityRegion().getFlag(Flag.EXPLOSION_PLAYER) || ext.getDamagerRegion() != null && ext.getDamagerRegion().getFlag(Flag.EXPLOSION_PLAYER)) {
event.setCancelled(true);
}
}
}
}
示例8: IsPvEKill
private boolean IsPvEKill(DamageCause damageCause)
{
boolean pve = this.model.getConfig().getZombieSpawnCondition().getPvE();
if(pve)
{
if(damageCause == DamageCause.ENTITY_ATTACK || damageCause == DamageCause.ENTITY_EXPLOSION || damageCause == DamageCause.PROJECTILE)
{
return true;
}
}
return false;
}
示例9: onSteveHurt
@EventHandler
public void onSteveHurt(EntityDamageEvent e) {
if(e.getEntity() instanceof Player) {
Player p = (Player) e.getEntity();
//p.getWorld().playSound(p.getLocation(), Sound.HURT, 1, 1);
if(e.getCause() == DamageCause.BLOCK_EXPLOSION) {
p.getWorld().playSound(p.getLocation(), Sound.HURT, 1, 1);
return;
} else if(e.getCause() == DamageCause.DROWNING) {
p.getWorld().playSound(p.getLocation(), Sound.HURT, 1, 1);
return;
} else if(e.getCause() == DamageCause.ENTITY_ATTACK) {
p.getWorld().playSound(p.getLocation(), Sound.HURT, 1, 1);
return;
} else if(e.getCause() == DamageCause.ENTITY_EXPLOSION) {
p.getWorld().playSound(p.getLocation(), Sound.HURT, 1, 1);
return;
} else if(e.getCause() == DamageCause.FALL) {
p.getWorld().playSound(p.getLocation(), Sound.HURT, 1, 1);
return;
} else if(e.getCause() == DamageCause.FALLING_BLOCK) {
p.getWorld().playSound(p.getLocation(), Sound.HURT, 1, 1);
return;
} else if(e.getCause() == DamageCause.FIRE_TICK) {
p.getWorld().playSound(p.getLocation(), Sound.HURT, 1, 1);
return;
} else if(e.getCause() == DamageCause.LIGHTNING) {
p.getWorld().playSound(p.getLocation(), Sound.HURT, 1, 1);
return;
} else if(e.getCause() == DamageCause.MELTING) {
p.getWorld().playSound(p.getLocation(), Sound.HURT, 1, 1);
return;
} else if(e.getCause() == DamageCause.POISON) {
p.getWorld().playSound(p.getLocation(), Sound.HURT, 1, 1);
return;
} else if(e.getCause() == DamageCause.PROJECTILE) {
p.getWorld().playSound(p.getLocation(), Sound.HURT, 1, 1);
return;
} else if(e.getCause() == DamageCause.STARVATION) {
p.getWorld().playSound(p.getLocation(), Sound.HURT, 1, 1);
return;
} else if(e.getCause() == DamageCause.SUFFOCATION) {
p.getWorld().playSound(p.getLocation(), Sound.HURT, 1, 1);
return;
} else if(e.getCause() == DamageCause.SUICIDE) {
p.getWorld().playSound(p.getLocation(), Sound.HURT, 1, 1);
return;
} else if(e.getCause() == DamageCause.THORNS) {
p.getWorld().playSound(p.getLocation(), Sound.HURT, 1, 1);
return;
} else if(e.getCause() == DamageCause.VOID) {
p.getWorld().playSound(p.getLocation(), Sound.HURT, 1, 1);
return;
} else if(e.getCause() == DamageCause.WITHER) {
p.getWorld().playSound(p.getLocation(), Sound.HURT, 1, 1);
return;
}
}
}