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


Java EntityTargetEvent.getEntity方法代码示例

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


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

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

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

示例5: onEntityTarget

import org.bukkit.event.entity.EntityTargetEvent; //导入方法依赖的package包/类
/**
 * Handle EntityTarget events.
 *
 * @param event The event to process
 */
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void onEntityTarget(EntityTargetEvent event) {
    Entity entity = event.getEntity();
    Entity target = event.getTarget();

    if (!(entity instanceof Tameable) || !(target instanceof Player)) {
        return;
    }

    Player player = (Player) target;
    Tameable tameable = (Tameable) entity;

    if (!UserManager.hasPlayerDataKey(player) || !CombatUtils.isFriendlyPet(player, tameable)) {
        return;
    }

    // isFriendlyPet ensures that the Tameable is: Tamed, owned by a player, and the owner is in the same party
    // So we can make some assumptions here, about our casting and our check
    if (!(Permissions.friendlyFire(player) && Permissions.friendlyFire((Player) tameable.getOwner()))) {
        event.setCancelled(true);
    }
}
 
开发者ID:Pershonkey,项目名称:McMMOPlus,代码行数:28,代码来源:EntityListener.java

示例6: onEntityTarget

import org.bukkit.event.entity.EntityTargetEvent; //导入方法依赖的package包/类
@EventHandler
public void onEntityTarget(EntityTargetEvent event) {
	Entity e = event.getEntity();
	Entity target = event.getTarget();
	ArenaManager am = SimpleSurvivalGames.instance.getArenaManager();
	
	// The entity or the target may not be null
	if(e == null || target == null)
		return;
	
	// If the target is a player, he may not be targeted if he's in the lobby or when he's a spectator
	if(target instanceof Player) {
		Player p = (Player) target;
		
		// Is the target player currently in any arena
		if(am.isInArena(p)) {
			ArenaPlayer ap = am.getPlayer(p);
			
			// The player may not be targeted
			if(ap.isInLobby() || ap.isSpectator())
				event.setCancelled(true);
		}
	}
}
 
开发者ID:timvisee,项目名称:simple-survival-games,代码行数:25,代码来源:SSGEntityListener.java

示例7: onEntityTarget

import org.bukkit.event.entity.EntityTargetEvent; //导入方法依赖的package包/类
@EventHandler
protected void onEntityTarget(EntityTargetEvent e) {
	// On entity target - Stop mobs targeting spectators
	// Check to make sure it isn't an NPC (Citizens NPC's will be detectable using 'entity.hasMetadata("NPC")')
	if (e.getTarget() != null && e.getTarget() instanceof Player && !e.getTarget().hasMetadata("NPC") && SkyWarsReloaded.getPC().getPlayer(((Player) e.getTarget()).getUniqueId()).isSpectating()) {
		e.setCancelled(true);
	}
	if (e.getTarget() instanceof Player && e.getTarget() != null && SkyWarsReloaded.getPC().getPlayer(((Player) e.getTarget()).getUniqueId()).isSpectating()) {
		if (e.getEntity() instanceof ExperienceOrb) {
			repellExpOrb((Player) e.getTarget(), (ExperienceOrb) e.getEntity());
			e.setCancelled(true);
			e.setTarget(null);
		}
	}
}
 
开发者ID:smessie,项目名称:SkyWarsReloaded,代码行数:16,代码来源:SpectatorListener.java

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

示例9: onEvent

import org.bukkit.event.entity.EntityTargetEvent; //导入方法依赖的package包/类
/**
 * Various entity target events, these must be done by hand, and directly in this method.
 *
 * @param event The target event.
 */
@EventHandler(priority = EventPriority.HIGHEST)
private void onEvent(EntityTargetEvent event) {
    Entity entity = event.getEntity();

    if (event.getTarget() instanceof Player) {
        // Demon Aspect III
        if (entity instanceof Zombie || entity instanceof Skeleton) {
            if (DGData.PLAYER_R.fromPlayer((Player) event.getTarget()).hasAspect(Aspects.DEMON_ASPECT_HERO)) {
                event.setCancelled(true);
            }
        }
    }
}
 
开发者ID:DemigodsRPG,项目名称:DemigodsRPG,代码行数:19,代码来源:AbilityListener.java

示例10: onEntityTarget

import org.bukkit.event.entity.EntityTargetEvent; //导入方法依赖的package包/类
@EventHandler
public void onEntityTarget(EntityTargetEvent e) {
	if(e.getEntityType() == EntityType.GIANT){
		return;
	}
	if (e.getEntity().getLocation().getWorld().getName() == "Christmas"
			&& e.getEntity() != null
			&& e.getEntity().getLocation().getWorld() != null
			){
		if ((e.getTarget() instanceof Player) || e.getTarget() instanceof Villager) {
			e.setCancelled(true);
		}
	}
}
 
开发者ID:EmilHernvall,项目名称:tregmine,代码行数:15,代码来源:TargetingListener.java


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