本文整理匯總了Java中org.bukkit.event.entity.EntityDamageEvent.DamageCause.WITHER屬性的典型用法代碼示例。如果您正苦於以下問題:Java DamageCause.WITHER屬性的具體用法?Java DamageCause.WITHER怎麽用?Java DamageCause.WITHER使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在類org.bukkit.event.entity.EntityDamageEvent.DamageCause
的用法示例。
在下文中一共展示了DamageCause.WITHER屬性的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: onPlayerDeath
@EventHandler
public void onPlayerDeath(PlayerDeathEvent event) {
if (event.getEntity().getLastDamageCause() != null) {
if (event.getEntity().getLastDamageCause().getCause() == DamageCause.WITHER) {
if (plugin.getValueManager().getValue(FoodType.PROTEIN, event.getEntity()) <= -6) {
event.setDeathMessage(Broadcast.getMsg(Message.DEATH_PROTEINS_LACK));
plugin.getValueManager().resetValues(event.getEntity());
return;
}
}
}
Player player = (Player) event.getEntity();
String uuid = player.getUniqueId().toString();
if (plugin.getDeathMessages().getDeathMessageBans().contains(uuid)) {
event.setDeathMessage(null);
plugin.getDeathMessages().getDeathMessageBans().remove(uuid);
}
plugin.getValueManager().resetValues(player);
}
示例2: onPlayerDeath
@EventHandler(priority=EventPriority.MONITOR, ignoreCancelled=true)
public void onPlayerDeath(EntityDamageEvent event) {
if ((event.getCause() == DamageCause.MAGIC ||
event.getCause() == DamageCause.WITHER) &&
event.getEntity() instanceof Player &&
((Player)event.getEntity()).getHealth() - event.getDamage() <= 0) {
Player player = (Player) event.getEntity();
for (AffectedPlayer ap : affected) {
if (ap.getAffectee() == player && player.hasPotionEffect(ap.getEffect().getType())) {
event.setCancelled(true);
player.damage(event.getDamage(), ap.getAffecter());
affected.remove(player.getName());
}
}
}
}
示例3: damageEntity
@Override
public boolean damageEntity(DamageSource source, float damage) {
if (invulnerable || noDamageTicks > 0) {
return false;
}
DamageCause cause = null;
org.bukkit.entity.Entity bEntity = null;
if (source instanceof EntityDamageSource) {
Entity damager = source.getEntity();
cause = DamageCause.ENTITY_ATTACK;
if (source instanceof EntityDamageSourceIndirect) {
damager = ((EntityDamageSourceIndirect) source).getProximateDamageSource();
if (damager.getBukkitEntity() instanceof ThrownPotion) {
cause = DamageCause.MAGIC;
} else if (damager.getBukkitEntity() instanceof Projectile) {
cause = DamageCause.PROJECTILE;
}
}
bEntity = damager.getBukkitEntity();
} else if (source == DamageSource.FIRE)
cause = DamageCause.FIRE;
else if (source == DamageSource.STARVE)
cause = DamageCause.STARVATION;
else if (source == DamageSource.WITHER)
cause = DamageCause.WITHER;
else if (source == DamageSource.STUCK)
cause = DamageCause.SUFFOCATION;
else if (source == DamageSource.DROWN)
cause = DamageCause.DROWNING;
else if (source == DamageSource.BURN)
cause = DamageCause.FIRE_TICK;
else if (source == CraftEventFactory.MELTING)
cause = DamageCause.MELTING;
else if (source == CraftEventFactory.POISON)
cause = DamageCause.POISON;
else if (source == DamageSource.MAGIC) {
cause = DamageCause.MAGIC;
} else if (source == DamageSource.OUT_OF_WORLD) {
cause = DamageCause.VOID;
}
if (cause != null) {
NPCDamageEvent event = new NPCDamageEvent(npc, bEntity, cause, (double) damage);
Bukkit.getPluginManager().callEvent(event);
if (!event.isCancelled()) {
return super.damageEntity(source, (float) event.getDamage());
} else {
return false;
}
}
if (super.damageEntity(source, damage)) {
if (bEntity != null) {
Entity e = ((CraftEntity) bEntity).getHandle();
double d0 = e.locX - this.locX;
double d1;
for (d1 = e.locZ - this.locZ; d0 * d0 + d1 * d1 < 0.0001D; d1 = (Math.random() - Math.random()) * 0.01D) {
d0 = (Math.random() - Math.random()) * 0.01D;
}
a(e, damage, d0, d1);
}
return true;
} else {
return false;
}
}
示例4: damageEntity
@Override
public boolean damageEntity(DamageSource source, float damage) {
if(godmode || noDamageTicks > 0) {
return false;
}
DamageCause cause = null;
org.bukkit.entity.Entity bEntity = null;
if(source instanceof EntityDamageSource) {
Entity damager = source.getEntity();
cause = DamageCause.ENTITY_ATTACK;
if(source instanceof EntityDamageSourceIndirect) {
damager = ((EntityDamageSourceIndirect) source).getProximateDamageSource();
if(damager.getBukkitEntity() instanceof ThrownPotion) {
cause = DamageCause.MAGIC;
} else if(damager.getBukkitEntity() instanceof Projectile) {
cause = DamageCause.PROJECTILE;
}
}
bEntity = damager.getBukkitEntity();
} else if(source == DamageSource.FIRE)
cause = DamageCause.FIRE;
else if(source == DamageSource.STARVE)
cause = DamageCause.STARVATION;
else if(source == DamageSource.WITHER)
cause = DamageCause.WITHER;
else if(source == DamageSource.STUCK)
cause = DamageCause.SUFFOCATION;
else if(source == DamageSource.DROWN)
cause = DamageCause.DROWNING;
else if(source == DamageSource.BURN)
cause = DamageCause.FIRE_TICK;
else if(source == CraftEventFactory.MELTING)
cause = DamageCause.MELTING;
else if(source == CraftEventFactory.POISON)
cause = DamageCause.POISON;
else if(source == DamageSource.MAGIC) {
cause = DamageCause.MAGIC;
} else if(source == DamageSource.OUT_OF_WORLD) {
cause = DamageCause.VOID;
}
if(cause != null) {
NPCDamageEvent event = new NPCDamageEvent(this, bEntity, cause, (double) damage);
Bukkit.getPluginManager().callEvent(event);
if(!event.isCancelled()) {
return super.damageEntity(source, (float) event.getDamage());
} else {
return false;
}
}
if(super.damageEntity(source, damage)) {
if(bEntity != null) {
Entity e = ((CraftEntity) bEntity).getHandle();
double d0 = e.locX - this.locX;
double d1;
for(d1 = e.locZ - this.locZ; d0 * d0 + d1 * d1 < 0.0001D; d1 = (Math.random() - Math.random()) * 0.01D) {
d0 = (Math.random() - Math.random()) * 0.01D;
}
a(e, damage, d0, d1);
}
return true;
} else {
return false;
}
}
示例5: 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;
}
}
}