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


Java EntityTargetEvent类代码示例

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


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

示例1: onTarget

import org.bukkit.event.entity.EntityTargetEvent; //导入依赖的package包/类
@EventHandler(ignoreCancelled = true)
public void onTarget(EntityTargetEvent event) {
    if(!(event.getEntity() instanceof ExperienceOrb)) {
        ParticipantState victimState = null;
        if(event.getTarget() instanceof Player) {
            // Don't target allies
            MatchPlayer victim = getVictim(event.getTarget());
            if(victim == null) return;
            victimState = victim.getParticipantState();
        } else if(event.getTarget() != null) {
            // Don't target other mobs owned by allies
            victimState = entityResolver.getOwner(event.getTarget());
        }
        if(victimState == null) return;
        DamageInfo damageInfo = damageResolver.resolveDamage(EntityDamageEvent.DamageCause.ENTITY_ATTACK, event.getTarget(), event.getEntity());
        if(queryHostile(event, victimState, damageInfo).isDenied()) {
            event.setCancelled(true);
        }
    }
}
 
开发者ID:OvercastNetwork,项目名称:ProjectAres,代码行数:21,代码来源:DamageMatchModule.java

示例2: onTarget

import org.bukkit.event.entity.EntityTargetEvent; //导入依赖的package包/类
@EventHandler
public void onTarget(EntityTargetEvent e) {
	if(!(e.getTarget() instanceof Player)) return;
		KingdomFactionsPlayer player = PlayerModule.getInstance().getPlayer((Player) e.getTarget());
        if(MonsterModule.getInstance().isGuard((LivingEntity) e.getEntity())) return;
        if(MonsterModule.getInstance().isGuard((LivingEntity)e.getTarget())) e.setCancelled(true);
        INexus guard = MonsterModule.getInstance().getGuard((LivingEntity) e.getEntity()).getNexus();
        switch(guard.getType()) {
		case CAPITAL:
			if(player.getKingdom().getType() == ((CapitalNexus) guard).getKingdom()) {
				e.setCancelled(true);
			}
			break;
		case FACTION:
			if(player.getFaction().equals(((Nexus)guard).getOwner())) {
				e.setCancelled(true);
			}
			break;
        
        }
	}
 
开发者ID:ThEWiZ76,项目名称:KingdomFactions,代码行数:22,代码来源:EntityTargetListener.java

示例3: onEntityTarget

import org.bukkit.event.entity.EntityTargetEvent; //导入依赖的package包/类
@EventHandler(priority = EventPriority.HIGH)
public void onEntityTarget(EntityTargetEvent event)
{
	if( event.getEntity() instanceof Skeleton && NavyCraft.aaSkelesList.contains((Skeleton)event.getEntity()) )
	{
		if( event.getTarget() instanceof Player )
		{
			Player target = (Player)event.getTarget();
			Craft skeleCraft = Craft.getCraft(target.getLocation().getBlockX(), target.getLocation().getBlockY(), target.getLocation().getBlockZ());
			if( skeleCraft != null && !skeleCraft.crewNames.isEmpty() && skeleCraft.crewNames.contains(target.getName()) )
			{
				event.setCancelled(true);
			}
		}
	}
}
 
开发者ID:Maximuspayne,项目名称:NavyCraft2-Lite,代码行数:17,代码来源:MoveCraft_EntityListener.java

示例4: onEntityTarget

import org.bukkit.event.entity.EntityTargetEvent; //导入依赖的package包/类
@EventHandler
public void onEntityTarget(EntityTargetEvent event) {
	if (event.getReason() == TargetReason.TARGET_DIED)
		return;
	
	PetInstance pet = null;
	for (PetInstance p : PetInstance.getList()) {
		if (p.getEntity() == null)
			continue;
		if (p.getEntity().getUniqueId().equals(event.getEntity().getUniqueId())) {
			pet = p;
			break;
		}
	}
	
	if (pet != null)
		event.setCancelled(true);
}
 
开发者ID:thekeenant,项目名称:mczone,代码行数:19,代码来源:PetEvents.java

示例5: get

import org.bukkit.event.entity.EntityTargetEvent; //导入依赖的package包/类
@Override
protected Entity[] get(final Event e, final LivingEntity[] source) {
	return get(source, new Converter<LivingEntity, Entity>() {
		@Override
		@Nullable
		public Entity convert(final LivingEntity en) {
			if (getTime() >= 0 && e instanceof EntityTargetEvent && en.equals(((EntityTargetEvent) e).getEntity()) && !Delay.isDelayed(e)) {
				final Entity t = ((EntityTargetEvent) e).getTarget();
				if (t == null || type != null && !type.isInstance(t))
					return null;
				return t;
			}
			return Utils.getTarget(en, type);
		}
	});
}
 
开发者ID:nfell2009,项目名称:Skript,代码行数:17,代码来源:ExprTarget.java

示例6: change

import org.bukkit.event.entity.EntityTargetEvent; //导入依赖的package包/类
@Override
public void change(final Event e, final @Nullable Object[] delta, final ChangeMode mode) {
	if (mode == ChangeMode.SET || mode == ChangeMode.DELETE) {
		final LivingEntity target = delta == null ? null : (LivingEntity) delta[0];
		for (final LivingEntity entity : getExpr().getArray(e)) {
			if (getTime() >= 0 && e instanceof EntityTargetEvent && entity.equals(((EntityTargetEvent) e).getEntity()) && !Delay.isDelayed(e)) {
				((EntityTargetEvent) e).setTarget(target);
			} else {
				if (entity instanceof Creature)
					((Creature) entity).setTarget(target);
			}
		}
	} else {
		super.change(e, delta, mode);
	}
}
 
开发者ID:nfell2009,项目名称:Skript,代码行数:17,代码来源:ExprTarget.java

示例7: onEntityTarget

import org.bukkit.event.entity.EntityTargetEvent; //导入依赖的package包/类
@EventHandler(ignoreCancelled = true)
public void onEntityTarget(EntityTargetEvent event)
{
    Entity target = event.getTarget();
    if(target == null) return;
    
    Entity entity = event.getEntity();
    if(!this.isMonster(entity)) return;
    if(entity.hasMetadata(this.ALLOW_TARGET_TAG)) return;
    
    Flag flag = this.GetFlagInstanceAtLocation(target.getLocation(), null);
    if(flag == null) return;
    
    event.setCancelled(true);
    entity.remove();
}
 
开发者ID:BigScary,项目名称:GriefPreventionFlags,代码行数:17,代码来源:FlagDef_NoMonsterSpawns.java

示例8: damageEntity

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

        if (entity instanceof EntityHuman) {
            List list = this.world.getEntities(this, this.boundingBox.grow(32.0D, 32.0D, 32.0D));

            for (int i = 0; i < list.size(); ++i) {
                Entity entity1 = (Entity) list.get(i);

                if (entity1 instanceof EntityPigZombie) {
                    EntityPigZombie entitypigzombie = (EntityPigZombie) entity1;

                    entitypigzombie.c(entity, EntityTargetEvent.TargetReason.PIG_ZOMBIE_TARGET);
                }
            }

            this.c(entity, EntityTargetEvent.TargetReason.TARGET_ATTACKED_ENTITY);
        }

        return super.damageEntity(damagesource, f);
    }
}
 
开发者ID:OvercastNetwork,项目名称:CraftBukkit,代码行数:26,代码来源:EntityPigZombie.java

示例9: 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

示例10: 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

示例11: onTarget

import org.bukkit.event.entity.EntityTargetEvent; //导入依赖的package包/类
@EventHandler(priority = EventPriority.HIGHEST)
public void onTarget(EntityTargetEvent ev) {
	if ((ev.getTarget() instanceof Player)) {
		Player pl = (Player)ev.getTarget();
		
		// Is the player in game?
		if (this.am.isInGame(pl)) {
			for (Arena a : this.am.arenas) {
				if ((a.deadPlayers.contains(pl.getName())) || (a.notStarted) || (a.waitingNextWave)) {
					// If the player is dead, cancel the targetting
					ev.setCancelled(true);
				}
			}
		}
	}
}
 
开发者ID:odarriba,项目名称:defend-the-village,代码行数:17,代码来源:Main.java

示例12: 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

示例13: onEntityTarget

import org.bukkit.event.entity.EntityTargetEvent; //导入依赖的package包/类
@EventHandler(priority = EventPriority.NORMAL)
public void onEntityTarget(EntityTargetEvent event) {
	if (!(event.getEntity() instanceof LivingEntity)) {
		return;
	}
	
	if (!MobLib.isMobLibEntity((LivingEntity) event.getEntity())) {
		return;
	}
		
	CommonCustomMob mob = CommonCustomMob.getCCM(event.getEntity());
	if (mob != null) {
		mob.onTarget(event);
	}
	
}
 
开发者ID:netizen539,项目名称:civcraft,代码行数:17,代码来源:MobListener.java

示例14: 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

示例15: 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


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