本文整理匯總了Java中org.bukkit.event.entity.EntityDamageEvent.DamageCause.PROJECTILE屬性的典型用法代碼示例。如果您正苦於以下問題:Java DamageCause.PROJECTILE屬性的具體用法?Java DamageCause.PROJECTILE怎麽用?Java DamageCause.PROJECTILE使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在類org.bukkit.event.entity.EntityDamageEvent.DamageCause
的用法示例。
在下文中一共展示了DamageCause.PROJECTILE屬性的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: EntityDamageByEntityListener
@EventHandler
public void EntityDamageByEntityListener(EntityDamageByEntityEvent e) {
if (!GameManager.getGameSituation()) {
e.setCancelled(true);
}
if (e.getDamager() instanceof Player) {
if (e.getEntity() instanceof Player) {
Player damager = (Player) e.getDamager();
Player victim = (Player) e.getEntity();
if (SettingsManager.shotinfo) {
if (e.getCause() == DamageCause.PROJECTILE) {
if(victim.getLocation().distance(damager.getLocation()) < 20) {
Bukkit.broadcastMessage(SettingsManager.niceshot.replace("%s", victim.getName()).replace("%s", damager.getName()).replace("%d", String.valueOf(victim.getLocation().distance(damager.getLocation()))));
}
}
}
}
}
}
示例2: onDamageGet
@EventHandler(priority=EventPriority.MONITOR)
public void onDamageGet(EntityDamageEvent e) {
if (!e.isCancelled()) {
if (e instanceof EntityDamageByEntityEvent) {
if (((EntityDamageByEntityEvent) e).getDamager() instanceof Player && SlimefunStartup.chance(100, 45)) {
if (SlimefunManager.isItemSimiliar(((Player) ((EntityDamageByEntityEvent) e).getDamager()).getInventory().getItemInMainHand(), SlimefunItem.getItem("BLADE_OF_VAMPIRES"), true)) {
((Player) ((EntityDamageByEntityEvent) e).getDamager()).playSound(((EntityDamageByEntityEvent) e).getDamager().getLocation(), Sound.ENTITY_ARROW_HIT_PLAYER, 0.7F, 0.7F);
((Player) ((EntityDamageByEntityEvent) e).getDamager()).addPotionEffect(new PotionEffect(PotionEffectType.HEAL, 1, 1));
}
}
}
if (e.getEntity() instanceof Player) {
if (!e.isCancelled()) {
if (e.getCause() == DamageCause.LAVA) Talisman.checkFor(e, SlimefunItem.getByID("LAVA_TALISMAN"));
if (e.getCause() == DamageCause.DROWNING) Talisman.checkFor(e, SlimefunItem.getByID("WATER_TALISMAN"));
if (e.getCause() == DamageCause.FALL) Talisman.checkFor(e, SlimefunItem.getByID("ANGEL_TALISMAN"));
if (e.getCause() == DamageCause.FIRE) Talisman.checkFor(e, SlimefunItem.getByID("FIRE_TALISMAN"));
if (e.getCause() == DamageCause.ENTITY_ATTACK) Talisman.checkFor(e, SlimefunItem.getByID("WARRIOR_TALISMAN"));
if (e.getCause() == DamageCause.ENTITY_ATTACK) Talisman.checkFor(e, SlimefunItem.getByID("KNIGHT_TALISMAN"));
if (e.getCause() == DamageCause.PROJECTILE) {
if (Talisman.checkFor(e, SlimefunItem.getByID("WHIRLWIND_TALISMAN"))) {
if (((EntityDamageByEntityEvent) e).getDamager() instanceof Projectile) {
Vector direction = ((Player) e.getEntity()).getEyeLocation().getDirection().multiply(2.0);
Projectile projectile = (Projectile) e.getEntity().getWorld().spawnEntity(((LivingEntity) e.getEntity()).getEyeLocation().add(direction.getX(), direction.getY(), direction.getZ()), ((EntityDamageByEntityEvent) e).getDamager().getType());
projectile.setVelocity(direction);
((EntityDamageByEntityEvent) e).getDamager().remove();
}
}
}
}
}
}
}
示例3: onDamage
@EventHandler
public void onDamage(EntityDamageEvent e) {
if (e.getEntity() instanceof Player) {
if (e.getCause() == DamageCause.PROJECTILE) {
Player p = (Player) e.getEntity();
e.setDamage(e.getDamage() * (1 - EnchantmentZ.calcInventoryPieceAmount(PROTECTION, p.getInventory()) * 0.03125));
}
}
}
示例4: onDamage
@EventHandler
public void onDamage(EntityDamageEvent e) {
if (e.getEntity() instanceof Player) {
if (e.getCause() == DamageCause.PROJECTILE) {
Player p = (Player) e.getEntity();
e.setDamage(e.getDamage() * (1 - EnchantmentZ.calcInventoryPieceAmount(PROJECTILE_PROTECTION, p.getInventory()) * 0.0625));
}
}
}
示例5: onEntityDamage
@EventHandler(priority = EventPriority.LOWEST)
public void onEntityDamage(EntityDamageEvent event)
{
Entity entity = event.getEntity();
DamageCause cause = event.getCause();
if(cause == DamageCause.ENTITY_ATTACK || cause == DamageCause.PROJECTILE)
{
EntityDamageByEntityEvent event2 = (EntityDamageByEntityEvent)event;
Entity attacker = event2.getDamager();
if(attacker != null && attacker.getType() == EntityType.PLAYER) return;
if(attacker instanceof Projectile)
{
ProjectileSource source = ((Projectile)attacker).getShooter();
if(source != null && source instanceof Player) return;
}
}
if(entity instanceof Animals || entity instanceof WaterMob || entity.getType() == EntityType.VILLAGER || entity.getCustomName() != null)
{
Flag flag = this.GetFlagInstanceAtLocation(entity.getLocation(), null);
if(flag == null) return;
event.setCancelled(true);
}
}
示例6: 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;
}
}
示例7: 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);
}
}
示例8: onEntityDamage
@EventHandler
public void onEntityDamage(EntityDamageEvent event) {
if (event.getEntity() instanceof Player) {
if (event.getCause() == DamageCause.ENTITY_ATTACK || event.getCause() == DamageCause.PROJECTILE) {
if (((Player) event.getEntity()).isBlocking()) {
event.setCancelled(true);
} else {
CharacterPlugin characterPlugin = plugin.getServer().getServicesManager().getRegistration(CharacterPlugin.class).getProvider();
characterPlugin.getActiveCharacter((Player) event.getEntity()).setHealth(((Player) event.getEntity()).getHealth());
}
}
}
}
示例9: onEntityDamageEvent
@EventHandler(priority = EventPriority.HIGHEST)
public void onEntityDamageEvent(final EntityDamageEvent event) {
if (!(event.getEntity() instanceof Player)) {
return;
}
Player player = (Player) event.getEntity();
if (event.getCause() == DamageCause.FALL) {
//Check if player actually performed /leap
if (sccp.canLeap.contains(player)) {
event.setCancelled(true);
}
if (sccp.swActionDamage.contains(player)) {
sccp.swPlayers.remove(player);
sccp.swActionDamage.remove(player);
}
}
if (event.getCause() == DamageCause.PROJECTILE) {
if (sccp.swActionProjectile.contains(player)) {
sccp.swPlayers.remove(player);
sccp.swActionProjectile.remove(player);
}
}
if (sccp.swActionDamage.contains(player)) {
sccp.swPlayers.remove(player);
sccp.swActionDamage.remove(player);
}
}
示例10: 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;
}
示例11: handleEntityDamageEvent
public static EntityDamageEvent handleEntityDamageEvent(net.minecraft.entity.Entity entity, net.minecraft.util.DamageSource source, int damage) {
net.minecraft.entity.Entity damager = source.func_76346_g();
DamageCause cause = DamageCause.ENTITY_ATTACK;
if (source instanceof net.minecraft.util.EntityDamageSourceIndirect) {
damager = ((net.minecraft.util.EntityDamageSourceIndirect) source).getProximateDamageSource();
if (damager.getBukkitEntity() instanceof ThrownPotion) {
cause = DamageCause.MAGIC;
} else if (damager.getBukkitEntity() instanceof Projectile) {
cause = DamageCause.PROJECTILE;
}
}
return callEntityDamageEvent(damager, entity, cause, damage);
}
示例12: revealOnArrow
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void revealOnArrow(final EntityDamageByEntityEvent event) {
if(event.getCause() == DamageCause.PROJECTILE && event.getDamager() instanceof Arrow && event.getEntity() instanceof Player) {
this.reveal((Player) event.getEntity(), GhostSquadron.ARROW_REVEAL_DURATION);
}
}
示例13: 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;
}
}
示例14: 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;
}
}
示例15: 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;
}
}
}