本文整理汇总了Java中org.bukkit.event.entity.EntityDamageByBlockEvent类的典型用法代码示例。如果您正苦于以下问题:Java EntityDamageByBlockEvent类的具体用法?Java EntityDamageByBlockEvent怎么用?Java EntityDamageByBlockEvent使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
EntityDamageByBlockEvent类属于org.bukkit.event.entity包,在下文中一共展示了EntityDamageByBlockEvent类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getAttacker
import org.bukkit.event.entity.EntityDamageByBlockEvent; //导入依赖的package包/类
private static Object getAttacker(final Event e) {
if (e instanceof EntityDamageByEntityEvent) {
if (((EntityDamageByEntityEvent) e).getDamager() instanceof Projectile) {
return ((Projectile) ((EntityDamageByEntityEvent) e).getDamager()).getShooter();
}
return ((EntityDamageByEntityEvent) e).getDamager();
} else if (e instanceof EntityDamageByBlockEvent) {
return ((EntityDamageByBlockEvent) e).getDamager();
} else if (e instanceof EntityDeathEvent) {
return getAttacker(((EntityDeathEvent) e).getEntity().getLastDamageCause());
} else if (e instanceof VehicleDamageEvent) {
return ((VehicleDamageEvent) e).getAttacker();
} else if (e instanceof VehicleDestroyEvent) {
return ((VehicleDestroyEvent) e).getAttacker();
}
return null;
}
示例2: a
import org.bukkit.event.entity.EntityDamageByBlockEvent; //导入依赖的package包/类
public void a(World world, int i, int j, int k, Entity entity) {
// CraftBukkit start - EntityDamageByBlock event
if (entity instanceof EntityLiving) {
org.bukkit.block.Block damager = world.getWorld().getBlockAt(i, j, k);
org.bukkit.entity.Entity damagee = (entity == null) ? null : entity.getBukkitEntity();
EntityDamageByBlockEvent event = new EntityDamageByBlockEvent(damager, damagee, org.bukkit.event.entity.EntityDamageEvent.DamageCause.CONTACT, 1D);
world.getServer().getPluginManager().callEvent(event);
if (!event.isCancelled()) {
damagee.setLastDamageCause(event);
entity.damageEntity(DamageSource.CACTUS, (float) event.getDamage());
}
return;
}
// CraftBukkit end
entity.damageEntity(DamageSource.CACTUS, 1.0F);
}
示例3: onHealthLoss
import org.bukkit.event.entity.EntityDamageByBlockEvent; //导入依赖的package包/类
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onHealthLoss(final EntityDamageEvent event){
Deque<DamageData> damagers = getDamageInformationDeque(event.getEntity().getUniqueId());
Object dmgSrc = null;
if(event instanceof EntityDamageByEntityEvent){
dmgSrc = ((EntityDamageByEntityEvent)event).getDamager();
}else if(event instanceof EntityDamageByBlockEvent){
dmgSrc = ((EntityDamageByBlockEvent)event).getDamager();
}
// Similiar objects are not supported here, but are used in the getter methods
DamageData info = new DamageData();
info.setCause(event.getCause());
info.setRawSource(dmgSrc);
info.setDamageAmount(info.getDamageAmount() + event.getDamage());
damagers.addFirst(info);
}
示例4: onEntityDamageByBlock
import org.bukkit.event.entity.EntityDamageByBlockEvent; //导入依赖的package包/类
@EventHandler
public void onEntityDamageByBlock(EntityDamageByBlockEvent event) {
Entity e = event.getEntity();
ArenaManager am = SimpleSurvivalGames.instance.getArenaManager();
// Is the entity a player
if(e instanceof Player) {
Player p = (Player) e;
// Is the current in any arean
if(am.isInArena(p)) {
ArenaPlayer ap = am.getPlayer(p);
ap.resetLastDamageByPlayer();
}
}
}
示例5: a
import org.bukkit.event.entity.EntityDamageByBlockEvent; //导入依赖的package包/类
public void a(World world, int i, int j, int k, Entity entity) {
// CraftBukkit start - EntityDamageByBlock event
if (entity instanceof EntityLiving) {
org.bukkit.block.Block damager = world.getWorld().getBlockAt(i, j, k);
org.bukkit.entity.Entity damagee = (entity == null) ? null : entity.getBukkitEntity();
EntityDamageByBlockEvent event = new EntityDamageByBlockEvent(damager, damagee, org.bukkit.event.entity.EntityDamageEvent.DamageCause.CONTACT, 1);
world.getServer().getPluginManager().callEvent(event);
if (!event.isCancelled()) {
damagee.setLastDamageCause(event);
entity.damageEntity(DamageSource.CACTUS, event.getDamage());
}
return;
}
// CraftBukkit end
entity.damageEntity(DamageSource.CACTUS, 1);
}
示例6: resolve
import org.bukkit.event.entity.EntityDamageByBlockEvent; //导入依赖的package包/类
public @Nullable
DamageInfo resolve(@Nonnull LivingEntity entity, @Nonnull Lifetime lifetime, @Nonnull EntityDamageEvent damageEvent) {
if(damageEvent instanceof EntityDamageByBlockEvent && damageEvent.getCause() == DamageCause.CONTACT) {
EntityDamageByBlockEvent blockEvent = (EntityDamageByBlockEvent) damageEvent;
return new SimpleBlockDamageInfo(blockEvent.getDamager().getState());
}
return null;
}
示例7: resolveDamage
import org.bukkit.event.entity.EntityDamageByBlockEvent; //导入依赖的package包/类
default DamageInfo resolveDamage(EntityDamageEvent damageEvent) {
if(damageEvent instanceof EntityDamageByEntityEvent) {
return resolveDamage((EntityDamageByEntityEvent) damageEvent);
} else if(damageEvent instanceof EntityDamageByBlockEvent) {
return resolveDamage((EntityDamageByBlockEvent) damageEvent);
} else {
return resolveDamage(damageEvent.getCause(), damageEvent.getEntity());
}
}
示例8: onEntityDamage
import org.bukkit.event.entity.EntityDamageByBlockEvent; //导入依赖的package包/类
@EventHandler(ignoreCancelled = false)
public void onEntityDamage(cn.nukkit.event.entity.EntityDamageEvent event) {
if (canIgnore(EntityDamageEvent.getHandlerList())) {
return;
}
// EntityDamageEvent and EntityDamageBy*Event share their handler
// lists. So this method can also be called with the event parameter set
// to an EntityDamageByEntityEvent or EntityDamageByBlockEvent. In that
// case, the event translation is a bit more involved.
if (event instanceof cn.nukkit.event.entity.EntityDamageByEntityEvent) {
onEntityDamageByEntity((cn.nukkit.event.entity.EntityDamageByEntityEvent) event);
return;
}
if (event instanceof cn.nukkit.event.entity.EntityDamageByBlockEvent) {
onEntityDamageByBlock((cn.nukkit.event.entity.EntityDamageByBlockEvent) event);
return;
}
// For now, only base damage is taken into account. Potions, armor etc
// are ignored
EntityDamageEvent bukkitEvent = new EntityDamageEvent(
PokkitEntity.toBukkit(event.getEntity()),
PokkitDamageCause.toBukkit(event.getCause()),
getDamageMap(event.getDamage()),
getDamageModifierMap());
callCancellable(event, bukkitEvent);
event.setDamage((float) bukkitEvent.getDamage());
}
示例9: onEntityDamageByBlock
import org.bukkit.event.entity.EntityDamageByBlockEvent; //导入依赖的package包/类
private void onEntityDamageByBlock(cn.nukkit.event.entity.EntityDamageByBlockEvent event) {
// Called by onEntityDamage, so don't use an @EventHandler annotation
// For now, only base damage is taken into account. Potions, armor etc
// are ignored
EntityDamageByBlockEvent bukkitEvent = new EntityDamageByBlockEvent(
PokkitBlock.toBukkit(event.getDamager()),
PokkitEntity.toBukkit(event.getEntity()),
PokkitDamageCause.toBukkit(event.getCause()),
getDamageMap(event.getDamage()),
getDamageModifierMap());
callCancellable(event, bukkitEvent);
event.setDamage((float) bukkitEvent.getDamage());
}
示例10: onEntityDamage
import org.bukkit.event.entity.EntityDamageByBlockEvent; //导入依赖的package包/类
@EventHandler(ignoreCancelled = true, priority = EventPriority.HIGHEST)
public void onEntityDamage(EntityDamageByBlockEvent e) {
if (e.getEntity() instanceof Player) {
if (plugin.pm.isSpectator((Player) e.getEntity())) {
e.setCancelled(true);
}
}
}
示例11: A
import org.bukkit.event.entity.EntityDamageByBlockEvent; //导入依赖的package包/类
protected void A() {
if (!this.fireProof) {
// CraftBukkit start - Fallen in lava TODO: this event spams!
if (this instanceof EntityLiving) {
Server server = this.world.getServer();
// TODO: shouldn't be sending null for the block.
org.bukkit.block.Block damager = null; // ((WorldServer) this.l).getWorld().getBlockAt(i, j, k);
org.bukkit.entity.Entity damagee = this.getBukkitEntity();
EntityDamageByBlockEvent event = new EntityDamageByBlockEvent(damager, damagee, EntityDamageEvent.DamageCause.LAVA, 4D);
server.getPluginManager().callEvent(event);
if (!event.isCancelled()) {
damagee.setLastDamageCause(event);
this.damageEntity(DamageSource.LAVA, (float) event.getDamage());
}
if (this.fireTicks <= 0) {
// not on fire yet
EntityCombustEvent combustEvent = new org.bukkit.event.entity.EntityCombustByBlockEvent(damager, damagee, 15);
server.getPluginManager().callEvent(combustEvent);
if (!combustEvent.isCancelled()) {
this.setOnFire(combustEvent.getDuration());
}
} else {
// This will be called every single tick the entity is in lava, so don't throw an event
this.setOnFire(15);
}
return;
}
// CraftBukkit end - we also don't throw an event unless the object in lava is living, to save on some event calls
this.damageEntity(DamageSource.LAVA, 4);
this.setOnFire(15);
}
}
示例12: onPlayerDamageByBlock
import org.bukkit.event.entity.EntityDamageByBlockEvent; //导入依赖的package包/类
@EventHandler
private void onPlayerDamageByBlock(final EntityDamageByBlockEvent event) {
if (event.getEntity() instanceof Player)
if (!this.hasPermission(event.getEntity().getLocation(),
(Player) event.getEntity(), AreaFlag.PLAYER_GETDAMAGE))
event.setCancelled(true);
}
示例13: z
import org.bukkit.event.entity.EntityDamageByBlockEvent; //导入依赖的package包/类
protected void z() {
if (!this.fireProof) {
// CraftBukkit start - Fallen in lava TODO: this event spams!
if (this instanceof EntityLiving) {
Server server = this.world.getServer();
// TODO: shouldn't be sending null for the block.
org.bukkit.block.Block damager = null; // ((WorldServer) this.l).getWorld().getBlockAt(i, j, k);
org.bukkit.entity.Entity damagee = this.getBukkitEntity();
EntityDamageByBlockEvent event = new EntityDamageByBlockEvent(damager, damagee, EntityDamageEvent.DamageCause.LAVA, 4);
server.getPluginManager().callEvent(event);
if (!event.isCancelled()) {
damagee.setLastDamageCause(event);
this.damageEntity(DamageSource.LAVA, event.getDamage());
}
if (this.fireTicks <= 0) {
// not on fire yet
EntityCombustEvent combustEvent = new org.bukkit.event.entity.EntityCombustByBlockEvent(damager, damagee, 15);
server.getPluginManager().callEvent(combustEvent);
if (!combustEvent.isCancelled()) {
this.setOnFire(combustEvent.getDuration());
}
} else {
// This will be called every single tick the entity is in lava, so don't throw an event
this.setOnFire(15);
}
return;
}
// CraftBukkit end - we also don't throw an event unless the object in lava is living, to save on some event calls
this.damageEntity(DamageSource.LAVA, 4);
this.setOnFire(15);
}
}
示例14: onEntityDamageByBlock
import org.bukkit.event.entity.EntityDamageByBlockEvent; //导入依赖的package包/类
@EventHandler
public void onEntityDamageByBlock(EntityDamageByBlockEvent e){
e.setCancelled(true);
}
示例15: getParentEvent
import org.bukkit.event.entity.EntityDamageByBlockEvent; //导入依赖的package包/类
/**
* Get the parent {@link EntityDamageByBlockEvent}.
*/
@Override
public EntityDamageByBlockEvent getParentEvent() {
return (EntityDamageByBlockEvent)super.getParentEvent();
}