當前位置: 首頁>>代碼示例>>Java>>正文


Java EntityTargetEvent.setCancelled方法代碼示例

本文整理匯總了Java中org.bukkit.event.entity.EntityTargetEvent.setCancelled方法的典型用法代碼示例。如果您正苦於以下問題:Java EntityTargetEvent.setCancelled方法的具體用法?Java EntityTargetEvent.setCancelled怎麽用?Java EntityTargetEvent.setCancelled使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.bukkit.event.entity.EntityTargetEvent的用法示例。


在下文中一共展示了EntityTargetEvent.setCancelled方法的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: 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

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

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

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

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

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

示例11: onEntityTarget

import org.bukkit.event.entity.EntityTargetEvent; //導入方法依賴的package包/類
@EventHandler
public void onEntityTarget(EntityTargetEvent event) {
	if (Scheduler.getState() != State.PVP)
		event.setCancelled(true);
	if (event.getTarget() instanceof Player) {
		Gamer g = Gamer.get(((Player) event.getTarget()).getName());
		if (g == null) {
			((Player) event.getTarget()).kickPlayer("ERROR");
			return;
		}
		if (g.isInvisible())
			event.setCancelled(true);
	}
}
 
開發者ID:thekeenant,項目名稱:mczone,代碼行數:15,代碼來源:Events.java

示例12: onTarget

import org.bukkit.event.entity.EntityTargetEvent; //導入方法依賴的package包/類
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void onTarget(EntityTargetEvent event)
{
	if(event.getTarget() instanceof Player)
	{
		Player player = (Player) event.getTarget();
		
		if(userManager.get(player.getUniqueId()).getVanishType() != VanishType.TOTAL)
		{
			return;
		}
		
		event.setCancelled(true);
	}
}
 
開發者ID:Shortninja66,項目名稱:StaffPlus,代碼行數:16,代碼來源:EntityTarget.java

示例13: onTarget

import org.bukkit.event.entity.EntityTargetEvent; //導入方法依賴的package包/類
@EventHandler(priority = EventPriority.HIGH)
public void onTarget(EntityTargetEvent e) {
    try {
        if (!(e.getTarget() instanceof Player)) return;
        if (!config.getBoolean("InvisibilityFeatures.DisableMobTarget")) return;
        Player p = (Player) e.getTarget();
        if (plugin.getVanishStateMgr().isVanished(p.getUniqueId())) {
            e.setCancelled(true);
        }
    } catch (Exception er) {
        plugin.logException(er);
    }
}
 
開發者ID:MyzelYam,項目名稱:SuperVanish,代碼行數:14,代碼來源:GeneralEventHandler.java

示例14: onEntityTarget

import org.bukkit.event.entity.EntityTargetEvent; //導入方法依賴的package包/類
@EventHandler(priority = EventPriority.HIGHEST)
public void onEntityTarget(EntityTargetEvent e) {
	if (e.getTarget() != null && e.getTarget().getType() == EntityType.PLAYER) {
		for (Minigame mg : Minigame.getMinigameInstances()) {
			MGPlayer mp = mg.getMGPlayer(((Player)e.getTarget()).getName());
			if (mp != null && (!mg.getConfigManager().isEntityTargetingEnabled() || mp.isSpectating())) {
				e.setCancelled(true);
			}
		}
	}
}
 
開發者ID:myiume,項目名稱:MyiuLib,代碼行數:12,代碼來源:MGListener.java

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


注:本文中的org.bukkit.event.entity.EntityTargetEvent.setCancelled方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。