当前位置: 首页>>代码示例>>Java>>正文


Java EntityDamageByBlockEvent类代码示例

本文整理汇总了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;
}
 
开发者ID:nfell2009,项目名称:Skript,代码行数:18,代码来源:ExprAttackerAlt.java

示例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);
}
 
开发者ID:AlmuraDev,项目名称:Almura-Server,代码行数:20,代码来源:BlockCactus.java

示例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);
}
 
开发者ID:glen3b,项目名称:BukkitLib,代码行数:20,代码来源:Utilities.java

示例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();
		}
	}
}
 
开发者ID:timvisee,项目名称:simple-survival-games,代码行数:17,代码来源:SSGEntityListener.java

示例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);
}
 
开发者ID:didoupimpon,项目名称:Craft-city,代码行数:20,代码来源:BlockCactus.java

示例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;
}
 
开发者ID:WarzoneMC,项目名称:Warzone,代码行数:11,代码来源:BlockDamageResolver.java

示例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());
    }
}
 
开发者ID:OvercastNetwork,项目名称:ProjectAres,代码行数:10,代码来源:EventResolver.java

示例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());
}
 
开发者ID:rutgerkok,项目名称:Pokkit,代码行数:31,代码来源:EntityEvents.java

示例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());
}
 
开发者ID:rutgerkok,项目名称:Pokkit,代码行数:16,代码来源:EntityEvents.java

示例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);
        }
    }
}
 
开发者ID:ddonofrio,项目名称:libelula,代码行数:9,代码来源:EventManager.java

示例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);
    }
}
 
开发者ID:AlmuraDev,项目名称:Almura-Server,代码行数:39,代码来源:Entity.java

示例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);
}
 
开发者ID:dobrakmato,项目名称:pexel-platform,代码行数:8,代码来源:EventProcessor.java

示例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);
    }
}
 
开发者ID:didoupimpon,项目名称:Craft-city,代码行数:39,代码来源:Entity.java

示例14: onEntityDamageByBlock

import org.bukkit.event.entity.EntityDamageByBlockEvent; //导入依赖的package包/类
@EventHandler
public void onEntityDamageByBlock(EntityDamageByBlockEvent e){
    e.setCancelled(true);
}
 
开发者ID:SamaGames,项目名称:AgarMC,代码行数:5,代码来源:WorldListener.java

示例15: getParentEvent

import org.bukkit.event.entity.EntityDamageByBlockEvent; //导入依赖的package包/类
/**
 * Get the parent {@link EntityDamageByBlockEvent}.
 */
@Override
public EntityDamageByBlockEvent getParentEvent() {
    return (EntityDamageByBlockEvent)super.getParentEvent();
}
 
开发者ID:JCThePants,项目名称:NucleusFramework,代码行数:8,代码来源:NpcDamageByBlockEvent.java


注:本文中的org.bukkit.event.entity.EntityDamageByBlockEvent类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。