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


Java EntityTargetEvent.isCancelled方法代码示例

本文整理汇总了Java中org.bukkit.event.entity.EntityTargetEvent.isCancelled方法的典型用法代码示例。如果您正苦于以下问题:Java EntityTargetEvent.isCancelled方法的具体用法?Java EntityTargetEvent.isCancelled怎么用?Java EntityTargetEvent.isCancelled使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.bukkit.event.entity.EntityTargetEvent的用法示例。


在下文中一共展示了EntityTargetEvent.isCancelled方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: c

import org.bukkit.event.entity.EntityTargetEvent; //导入方法依赖的package包/类
private void c(Entity entity, EntityTargetEvent.TargetReason reason) { // add TargetReason
    EntityTargetEvent event = new EntityTargetEvent(this.getBukkitEntity(), entity.getBukkitEntity(), reason);
    this.world.getServer().getPluginManager().callEvent(event);

    if (event.isCancelled()) {
        return;
    }

    if (event.getTarget() == null) {
        this.target = null;
        return;
    }
    entity = ((org.bukkit.craftbukkit.entity.CraftEntity) event.getTarget()).getHandle();
    // CraftBukkit end

    this.target = entity;
    this.angerLevel = 400 + this.random.nextInt(400);
    this.soundDelay = this.random.nextInt(40);
}
 
开发者ID:OvercastNetwork,项目名称:CraftBukkit,代码行数:20,代码来源:EntityPigZombie.java

示例2: onEntityTarget

import org.bukkit.event.entity.EntityTargetEvent; //导入方法依赖的package包/类
@EventHandler(priority = EventPriority.NORMAL)
public void onEntityTarget(EntityTargetEvent event)
{
    if (!event.isCancelled())
    {
        if (event.getTarget() instanceof Player)
        {
            Player player = (Player) event.getTarget();
            PlayerProfile profile = CoreData.getProfile(player);
            Long timeLeft = profile.getData("Godmode", Long.class);

            if (timeLeft != null && timeLeft > System.currentTimeMillis())
            {
                event.setCancelled(true);
            }
        }
    }
}
 
开发者ID:Vanillacraft,项目名称:vanillacraft,代码行数:19,代码来源:God.java

示例3: onTarget

import org.bukkit.event.entity.EntityTargetEvent; //导入方法依赖的package包/类
public void onTarget(EntityTargetEvent event) {
	if (event.isCancelled()) {
		return;
	}
	
	if ((event.getReason().equals(TargetReason.CLOSEST_PLAYER) ||
			event.getReason().equals(TargetReason.OWNER_ATTACKED_TARGET)) &&
			(event.getTarget() instanceof Player)) {
		
		double followRange = this.getFollowRange();
		double distance = event.getEntity().getLocation().distance(event.getTarget().getLocation());
		if ((distance-0.5) <= followRange) {
			this.targetName = ((Player)event.getTarget()).getName();
			this.lastLocation = event.getEntity().getLocation();
		}
	} else {
		this.targetName = null;
		this.lastLocation = null;
	}
}
 
开发者ID:netizen539,项目名称:civcraft,代码行数:21,代码来源:CommonCustomMob.java

示例4: c

import org.bukkit.event.entity.EntityTargetEvent; //导入方法依赖的package包/类
private void c(Entity entity) {
    // CraftBukkit start
    org.bukkit.entity.Entity bukkitTarget = entity == null ? null : entity.getBukkitEntity();

    EntityTargetEvent event = new EntityTargetEvent(this.getBukkitEntity(), bukkitTarget, EntityTargetEvent.TargetReason.PIG_ZOMBIE_TARGET);
    this.world.getServer().getPluginManager().callEvent(event);

    if (event.isCancelled()) {
        return;
    }

    if (event.getTarget() == null) {
        this.target = null;
        return;
    }
    entity = ((org.bukkit.craftbukkit.entity.CraftEntity) event.getTarget()).getHandle();
    // CraftBukkit end

    this.target = entity;
    this.angerLevel = 400 + this.random.nextInt(400);
    this.soundDelay = this.random.nextInt(40);
}
 
开发者ID:AlmuraDev,项目名称:Almura-Server,代码行数:23,代码来源:EntityPigZombie.java

示例5: becomeAngryAt

import org.bukkit.event.entity.EntityTargetEvent; //导入方法依赖的package包/类
private void becomeAngryAt(Entity p_70835_1_)
{
    // CraftBukkit start
    org.bukkit.entity.Entity bukkitTarget = p_70835_1_ == null ? null : p_70835_1_.getBukkitEntity();
    EntityTargetEvent event = new EntityTargetEvent(this.getBukkitEntity(), bukkitTarget, EntityTargetEvent.TargetReason.PIG_ZOMBIE_TARGET);
    this.worldObj.getServer().getPluginManager().callEvent(event);

    if (event.isCancelled())
    {
        return;
    }

    if (event.getTarget() == null)
    {
        this.entityToAttack = null;
        return;
    }

    p_70835_1_ = ((org.bukkit.craftbukkit.entity.CraftEntity) event.getTarget()).getHandle();
    // CraftBukkit end
    this.entityToAttack = p_70835_1_;
    this.angerLevel = 400 + this.rand.nextInt(400);
    this.randomSoundDelay = this.rand.nextInt(40);
}
 
开发者ID:xtrafrancyz,项目名称:Cauldron,代码行数:25,代码来源:EntityPigZombie.java

示例6: p

import org.bukkit.event.entity.EntityTargetEvent; //导入方法依赖的package包/类
private void p(Entity entity) {
    // CraftBukkit start
    org.bukkit.entity.Entity bukkitTarget = entity == null ? null : entity.getBukkitEntity();

    EntityTargetEvent event = new EntityTargetEvent(this.getBukkitEntity(), bukkitTarget, EntityTargetEvent.TargetReason.PIG_ZOMBIE_TARGET);
    this.world.getServer().getPluginManager().callEvent(event);

    if (event.isCancelled()) {
        return;
    }

    if (event.getTarget() == null) {
        this.target = null;
        return;
    }
    entity = ((org.bukkit.craftbukkit.entity.CraftEntity) event.getTarget()).getHandle();
    // CraftBukkit end

    this.target = entity;
    this.angerLevel = 400 + this.random.nextInt(400);
    this.soundDelay = this.random.nextInt(40);
}
 
开发者ID:didoupimpon,项目名称:Craft-city,代码行数:23,代码来源:EntityPigZombie.java

示例7: bQ

import org.bukkit.event.entity.EntityTargetEvent; //导入方法依赖的package包/类
private void bQ() {
    this.bz = false;
    if (this.random.nextInt(2) == 0 && !this.world.players.isEmpty()) {
        // CraftBukkit start
        Entity target = (Entity) this.world.players.get(this.random.nextInt(this.world.players.size()));
        EntityTargetEvent event = new EntityTargetEvent(this.getBukkitEntity(), target.getBukkitEntity(), EntityTargetEvent.TargetReason.RANDOM_TARGET);
        this.world.getServer().getPluginManager().callEvent(event);

        if (!event.isCancelled()) {
            if (event.getTarget() == null) {
                this.bD = null;
            } else {
                this.bD = ((org.bukkit.craftbukkit.entity.CraftEntity) event.getTarget()).getHandle();
            }
        }
        // CraftBukkit end
    } else {
        boolean flag = false;

        do {
            this.h = 0.0D;
            this.i = (double) (70.0F + this.random.nextFloat() * 50.0F);
            this.bm = 0.0D;
            this.h += (double) (this.random.nextFloat() * 120.0F - 60.0F);
            this.bm += (double) (this.random.nextFloat() * 120.0F - 60.0F);
            double d0 = this.locX - this.h;
            double d1 = this.locY - this.i;
            double d2 = this.locZ - this.bm;

            flag = d0 * d0 + d1 * d1 + d2 * d2 > 100.0D;
        } while (!flag);

        this.bD = null;
    }
}
 
开发者ID:OvercastNetwork,项目名称:CraftBukkit,代码行数:36,代码来源:EntityEnderDragon.java

示例8: a

import org.bukkit.event.entity.EntityTargetEvent; //导入方法依赖的package包/类
protected void a(Entity entity, float f) {
    float f1 = this.d(1.0F);

    if (f1 > 0.5F && this.random.nextInt(100) == 0) {
        // CraftBukkit start
        EntityTargetEvent event = new EntityTargetEvent(this.getBukkitEntity(), null, EntityTargetEvent.TargetReason.FORGOT_TARGET);
        this.world.getServer().getPluginManager().callEvent(event);

        if (!event.isCancelled()) {
            if (event.getTarget() == null) {
                this.target = null;
            } else {
                this.target = ((org.bukkit.craftbukkit.entity.CraftEntity) event.getTarget()).getHandle();
            }
            return;
        }
        // CraftBukkit end
    } else {
        if (f > 2.0F && f < 6.0F && this.random.nextInt(10) == 0) {
            if (this.onGround) {
                double d0 = entity.locX - this.locX;
                double d1 = entity.locZ - this.locZ;
                float f2 = MathHelper.sqrt(d0 * d0 + d1 * d1);

                this.motX = d0 / (double) f2 * 0.5D * 0.800000011920929D + this.motX * 0.20000000298023224D;
                this.motZ = d1 / (double) f2 * 0.5D * 0.800000011920929D + this.motZ * 0.20000000298023224D;
                this.motY = 0.4000000059604645D;
            }
        } else {
            super.a(entity, f);
        }
    }
}
 
开发者ID:OvercastNetwork,项目名称:CraftBukkit,代码行数:34,代码来源:EntitySpider.java

示例9: damageEntity

import org.bukkit.event.entity.EntityTargetEvent; //导入方法依赖的package包/类
public boolean damageEntity(DamageSource damagesource, float f) {
    if (this.isInvulnerable()) {
        return false;
    } else if (super.damageEntity(damagesource, f)) {
        Entity entity = damagesource.getEntity();

        if (this.passenger != entity && this.vehicle != entity) {
            if (entity != this) {
                // CraftBukkit start - We still need to call events for entities without goals
                if (entity != this.target && (this instanceof EntityBlaze || this instanceof EntityEnderman || this instanceof EntitySpider || this instanceof EntityGiantZombie || this instanceof EntitySilverfish)) {
                    EntityTargetEvent event = org.bukkit.craftbukkit.event.CraftEventFactory.callEntityTargetEvent(this, entity, EntityTargetEvent.TargetReason.TARGET_ATTACKED_ENTITY);

                    if (!event.isCancelled()) {
                        if (event.getTarget() == null) {
                            this.target = null;
                        } else {
                            this.target = ((org.bukkit.craftbukkit.entity.CraftEntity) event.getTarget()).getHandle();
                        }
                    }
                } else {
                    this.target = entity;
                }
                // CraftBukkit end
            }

            return true;
        } else {
            return true;
        }
    } else {
        return false;
    }
}
 
开发者ID:OvercastNetwork,项目名称:CraftBukkit,代码行数:34,代码来源:EntityMonster.java

示例10: onEntityTarget

import org.bukkit.event.entity.EntityTargetEvent; //导入方法依赖的package包/类
@EventHandler(priority = EventPriority.LOW)
public void onEntityTarget(EntityTargetEvent event)
{
    if (!event.isCancelled() && event.getEntity() instanceof Player)
    {
        PlayerProfile profile = CoreData.getProfile((Player) event.getEntity());

        if (profile.getData("Nerfed", long.class) != null)
        {
            event.setCancelled(true);
        }
    }
}
 
开发者ID:Vanillacraft,项目名称:vanillacraft,代码行数:14,代码来源:Nerf.java

示例11: a

import org.bukkit.event.entity.EntityTargetEvent; //导入方法依赖的package包/类
protected void a(Entity entity, float f) {
    float f1 = this.c(1.0F);

    if (f1 > 0.5F && this.random.nextInt(100) == 0) {
        // CraftBukkit start
        EntityTargetEvent event = new EntityTargetEvent(this.getBukkitEntity(), null, EntityTargetEvent.TargetReason.FORGOT_TARGET);
        this.world.getServer().getPluginManager().callEvent(event);

        if (!event.isCancelled()) {
            if (event.getTarget() == null) {
                this.target = null;
            } else {
                this.target = ((org.bukkit.craftbukkit.entity.CraftEntity) event.getTarget()).getHandle();
            }
            return;
        }
        // CraftBukkit end
    } else {
        if (f > 2.0F && f < 6.0F && this.random.nextInt(10) == 0) {
            if (this.onGround) {
                double d0 = entity.locX - this.locX;
                double d1 = entity.locZ - this.locZ;
                float f2 = MathHelper.sqrt(d0 * d0 + d1 * d1);

                this.motX = d0 / (double) f2 * 0.5D * 0.800000011920929D + this.motX * 0.20000000298023224D;
                this.motZ = d1 / (double) f2 * 0.5D * 0.800000011920929D + this.motZ * 0.20000000298023224D;
                this.motY = 0.4000000059604645D;
            }
        } else {
            super.a(entity, f);
        }
    }
}
 
开发者ID:didoupimpon,项目名称:Craft-city,代码行数:34,代码来源:EntitySpider.java

示例12: damageEntity

import org.bukkit.event.entity.EntityTargetEvent; //导入方法依赖的package包/类
public boolean damageEntity(DamageSource damagesource, int i) {
    if (this.isInvulnerable()) {
        return false;
    } else if (super.damageEntity(damagesource, i)) {
        Entity entity = damagesource.getEntity();

        if (this.passenger != entity && this.vehicle != entity) {
            if (entity != this) {
                // CraftBukkit start - We still need to call events for entities without goals
                if (entity != this.target && (this instanceof EntityBlaze || this instanceof EntityEnderman || this instanceof EntitySpider || this instanceof EntityGiantZombie || this instanceof EntitySilverfish)) {
                    EntityTargetEvent event = org.bukkit.craftbukkit.event.CraftEventFactory.callEntityTargetEvent(this, entity, EntityTargetEvent.TargetReason.TARGET_ATTACKED_ENTITY);

                    if (!event.isCancelled()) {
                        if (event.getTarget() == null) {
                            this.target = null;
                        } else {
                            this.target = ((org.bukkit.craftbukkit.entity.CraftEntity) event.getTarget()).getHandle();
                        }
                    }
                } else {
                    this.target = entity;
                }
                // CraftBukkit end
            }

            return true;
        } else {
            return true;
        }
    } else {
        return false;
    }
}
 
开发者ID:didoupimpon,项目名称:Craft-city,代码行数:34,代码来源:EntityMonster.java

示例13: bq

import org.bukkit.event.entity.EntityTargetEvent; //导入方法依赖的package包/类
protected void bq() {
    this.w();
    // CraftBukkit start
    Entity entityhuman = this.world.findNearbyVulnerablePlayer(this, 16.0D); // EntityHuman -> Entity
    EntityTargetEvent event = null;

    if (entityhuman != null && !entityhuman.equals(lastTarget)) {
        event = CraftEventFactory.callEntityTargetEvent(this, entityhuman, EntityTargetEvent.TargetReason.CLOSEST_PLAYER);
    } else if (lastTarget != null && entityhuman == null) {
        event = CraftEventFactory.callEntityTargetEvent(this, entityhuman, EntityTargetEvent.TargetReason.FORGOT_TARGET);
    }

    if (event != null && !event.isCancelled()) {
        entityhuman = event.getTarget() == null ? null : ((CraftEntity) event.getTarget()).getHandle();
    }

    this.lastTarget = entityhuman;
    // CraftBukkit end

    if (entityhuman != null) {
        this.a(entityhuman, 10.0F, 20.0F);
    }

    if (this.onGround && this.jumpDelay-- <= 0) {
        this.jumpDelay = this.bR();
        if (entityhuman != null) {
            this.jumpDelay /= 3;
        }

        this.bc = true;
        if (this.bY()) {
            this.makeSound(this.bV(), this.bf(), ((this.random.nextFloat() - this.random.nextFloat()) * 0.2F + 1.0F) * 0.8F);
        }

        this.bd = 1.0F - this.random.nextFloat() * 2.0F;
        this.be = (float) (1 * this.getSize());
    } else {
        this.bc = false;
        if (this.onGround) {
            this.bd = this.be = 0.0F;
        }
    }
}
 
开发者ID:OvercastNetwork,项目名称:CraftBukkit,代码行数:44,代码来源:EntitySlime.java

示例14: bl

import org.bukkit.event.entity.EntityTargetEvent; //导入方法依赖的package包/类
protected void bl() {
    this.u();
    // CraftBukkit start
    Entity entityhuman = this.world.findNearbyVulnerablePlayer(this, 16.0D); // EntityHuman -> Entity
    EntityTargetEvent event = null;

    if (entityhuman != null && !entityhuman.equals(lastTarget)) {
        event = CraftEventFactory.callEntityTargetEvent(this, entityhuman, EntityTargetEvent.TargetReason.CLOSEST_PLAYER);
    } else if (lastTarget != null && entityhuman == null) {
        event = CraftEventFactory.callEntityTargetEvent(this, entityhuman, EntityTargetEvent.TargetReason.FORGOT_TARGET);
    }

    if (event != null && !event.isCancelled()) {
        entityhuman = event.getTarget() == null ? null : ((CraftEntity) event.getTarget()).getHandle();
    }

    this.lastTarget = entityhuman;
    // CraftBukkit end

    if (entityhuman != null) {
        this.a(entityhuman, 10.0F, 20.0F);
    }

    if (this.onGround && this.jumpDelay-- <= 0) {
        this.jumpDelay = this.bL();
        if (entityhuman != null) {
            this.jumpDelay /= 3;
        }

        this.bd = true;
        if (this.bS()) {
            this.makeSound(this.bP(), this.ba(), ((this.random.nextFloat() - this.random.nextFloat()) * 0.2F + 1.0F) * 0.8F);
        }

        this.be = 1.0F - this.random.nextFloat() * 2.0F;
        this.bf = (float) (1 * this.getSize());
    } else {
        this.bd = false;
        if (this.onGround) {
            this.be = this.bf = 0.0F;
        }
    }
}
 
开发者ID:AlmuraDev,项目名称:Almura-Server,代码行数:44,代码来源:EntitySlime.java

示例15: attackEntityFrom

import org.bukkit.event.entity.EntityTargetEvent; //导入方法依赖的package包/类
public boolean attackEntityFrom(DamageSource p_70097_1_, float p_70097_2_)
{
    if (this.isEntityInvulnerable())
    {
        return false;
    }
    else if (super.attackEntityFrom(p_70097_1_, p_70097_2_))
    {
        Entity entity = p_70097_1_.getEntity();

        if (this.riddenByEntity != entity && this.ridingEntity != entity)
        {
            if (entity != this)
            {
                // CraftBukkit start - We still need to call events for entities without goals
                if (entity != this.entityToAttack && (this instanceof EntityBlaze || this instanceof EntityEnderman || this instanceof EntitySpider || this instanceof EntityGiantZombie || this instanceof EntitySilverfish))
                {
                    EntityTargetEvent event = org.bukkit.craftbukkit.event.CraftEventFactory.callEntityTargetEvent(this, entity, EntityTargetEvent.TargetReason.TARGET_ATTACKED_ENTITY);

                    if (!event.isCancelled())
                    {
                        if (event.getTarget() == null)
                        {
                            this.entityToAttack = null;
                        }
                        else
                        {
                            this.entityToAttack = ((org.bukkit.craftbukkit.entity.CraftEntity) event.getTarget()).getHandle();
                        }
                    }
                }
                else
                {
                    this.entityToAttack = entity;
                }

                // CraftBukkit end
            }

            return true;
        }
        else
        {
            return true;
        }
    }
    else
    {
        return false;
    }
}
 
开发者ID:xtrafrancyz,项目名称:Cauldron,代码行数:52,代码来源:EntityMob.java


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