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


Java EntityTargetLivingEntityEvent.setCancelled方法代码示例

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


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

示例1: onTarget

import org.bukkit.event.entity.EntityTargetLivingEntityEvent; //导入方法依赖的package包/类
@EventHandler
public void onTarget(EntityTargetLivingEntityEvent event) {
    if (!(event.getEntity() instanceof Tameable) || !(event.getEntity() instanceof LivingEntity)
            || event.getTarget() == null || !InventoryManager.isAllowedWorld(event.getTarget().getWorld())) {
        return;
    }

    LivingEntity petEntity = (LivingEntity) event.getEntity();
    final OfflinePlayer player = (OfflinePlayer) ((Tameable) petEntity).getOwner();

    if (!InventoryManager.playerIsLoaded(player)) {
        return;
    }

    PlayerWrapper playerWrapper = InventoryManager.get(player);
    if (playerWrapper.hasPet() && petEntity == playerWrapper.getPet()) {
        PetType petType = PetManager.getPetFromEntity(petEntity, player);

        if (petType == null) {
            return;
        }

        if (event.getTarget() != null && event.getTarget().getType() == EntityType.PLAYER) {
            event.setCancelled(!petType.isAttackPlayers());
        } else {
            event.setCancelled(!petType.isAttackMobs());
        }
    }
}
 
开发者ID:EndlessCodeGroup,项目名称:RPGInventory,代码行数:30,代码来源:PetListener.java

示例2: onTargetWhenPlayerNotLoaded

import org.bukkit.event.entity.EntityTargetLivingEntityEvent; //导入方法依赖的package包/类
@EventHandler(ignoreCancelled = true, priority = EventPriority.LOW)
public void onTargetWhenPlayerNotLoaded(EntityTargetLivingEntityEvent event) {
    if (event.getTarget() == null || event.getTarget().getType() != EntityType.PLAYER) {
        return;
    }

    if (!InventoryManager.playerIsLoaded((Player) event.getTarget())) {
        event.setCancelled(true);
    }
}
 
开发者ID:EndlessCodeGroup,项目名称:RPGInventory,代码行数:11,代码来源:PlayerListener.java

示例3: onTarget

import org.bukkit.event.entity.EntityTargetLivingEntityEvent; //导入方法依赖的package包/类
@EventHandler
public void onTarget(EntityTargetLivingEntityEvent event)
{
    if (event.getTarget() instanceof Player && event.getEntity().hasMetadata("Creator") && event.getEntity().getMetadata("Creator").get(0).asString() == ((Player) event.getTarget()).getName())
    {
        event.setCancelled(true);
    }
}
 
开发者ID:ColonelHedgehog,项目名称:Equestrian-Dash,代码行数:9,代码来源:EntityTargetLivingEntityListener.java

示例4: onEntityTargetLivingEntity

import org.bukkit.event.entity.EntityTargetLivingEntityEvent; //导入方法依赖的package包/类
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void onEntityTargetLivingEntity(EntityTargetLivingEntityEvent event) {
    LivingEntity livingEntity = event.getTarget();

    if (livingEntity instanceof Player) {
        Player player = (Player) livingEntity;

        if (Ghosts.p.getGhostManager().isGhost(player)) {
            event.setCancelled(true);
        }
    }
}
 
开发者ID:TfT-02,项目名称:Ghosts,代码行数:13,代码来源:EntityListener.java

示例5: getZombieTarget

import org.bukkit.event.entity.EntityTargetLivingEntityEvent; //导入方法依赖的package包/类
@EventHandler
public void getZombieTarget(EntityTargetLivingEntityEvent e) {
	if(e.getEntity() instanceof Zombie) {
		if(e.getTarget() instanceof Player) {
			if(e.getEntity().getLocation().distance(e.getTarget().getLocation()) > pl.getConfiguration().getEntityConfig().getCustomZombieAggroRange()) {
				e.setCancelled(true);
			}
		}
	}
}
 
开发者ID:xEssentials,项目名称:xEssentials-deprecated-bukkit,代码行数:11,代码来源:CustomZombieAggroRangeEvent.java

示例6: onTarget

import org.bukkit.event.entity.EntityTargetLivingEntityEvent; //导入方法依赖的package包/类
@EventHandler
public void onTarget(EntityTargetLivingEntityEvent e) {
	if(e.getTarget() instanceof Player) {
		Player p = (Player) e.getTarget();
		if(pl.getManagers().getPlayerManager().isOnline(p.getName())) {
			XPlayer xp = pl.getManagers().getPlayerManager().getPlayer(p.getName());
			if(xp.isInChair()) {
				e.setCancelled(true);
			}
		}
	}
}
 
开发者ID:xEssentials,项目名称:xEssentials-deprecated-bukkit,代码行数:13,代码来源:ChairDisableMonsterEvent.java

示例7: isGodModeAfk

import org.bukkit.event.entity.EntityTargetLivingEntityEvent; //导入方法依赖的package包/类
@EventHandler
public void isGodModeAfk(EntityTargetLivingEntityEvent e) {
	if(e.getTarget() instanceof Player) {
		Player p = (Player) e.getTarget();
		if(pl.getConfiguration().getPlayerConfig().isGodModeInAfkEnabled()) {
			XPlayer xp = pl.getManagers().getPlayerManager().getPlayer(p.getName());
			if(xp.isAfk()) {
				e.setCancelled(true);
			}
		}
	}
}
 
开发者ID:xEssentials,项目名称:xEssentials-deprecated-bukkit,代码行数:13,代码来源:AfkCheckEvent.java

示例8: onTarget

import org.bukkit.event.entity.EntityTargetLivingEntityEvent; //导入方法依赖的package包/类
@EventHandler
public void onTarget(EntityTargetLivingEntityEvent e) {
	if(e.getTarget() instanceof Player) {
		Player p = (Player) e.getTarget();
		if(pl.getManagers().getPlayerManager().isOnline(p.getName())) {
			XPlayer xp = pl.getManagers().getPlayerManager().getPlayer(p.getName());
			if(xp.isVanished()) {
				e.setCancelled(true);
			}
		}
	}
}
 
开发者ID:xEssentials,项目名称:xEssentials-deprecated-bukkit,代码行数:13,代码来源:VanishEvent.java

示例9: ignoremob

import org.bukkit.event.entity.EntityTargetLivingEntityEvent; //导入方法依赖的package包/类
@EventHandler
public void ignoremob(EntityTargetLivingEntityEvent e) {
	if(e.getTarget() instanceof Player) {
		Player p = (Player) e.getTarget();
		if(vanishApi.isVanished(p)) {
			e.setCancelled(true);
		}
	}
}
 
开发者ID:xize,项目名称:xEssentials_old_Source,代码行数:10,代码来源:vanishEntity.java

示例10: getZombieTarget

import org.bukkit.event.entity.EntityTargetLivingEntityEvent; //导入方法依赖的package包/类
@EventHandler
public void getZombieTarget(EntityTargetLivingEntityEvent e) {
	if(e.getEntity() instanceof Zombie) {
		if(e.getTarget() instanceof Player) {
			if(e.getEntity().getLocation().distance(e.getTarget().getLocation()) > xEssentialsMemory.zombieRange) {
				e.setCancelled(true);
			}
		}
	}
}
 
开发者ID:xize,项目名称:xEssentials_old_Source,代码行数:11,代码来源:zombieTarget.java

示例11: GodModeAfk

import org.bukkit.event.entity.EntityTargetLivingEntityEvent; //导入方法依赖的package包/类
@EventHandler
public void GodModeAfk(EntityTargetLivingEntityEvent e) {
	if(xEssentialsMemory.playerGodmodeAfk) {
		if(e.getTarget() instanceof Player) {
			Player p = (Player) e.getTarget();
			if(afkList.contains(p.getName())) {
				e.setCancelled(true);
			}
		}
	}
}
 
开发者ID:xize,项目名称:xEssentials_old_Source,代码行数:12,代码来源:afkCheck.java

示例12: onEntityTarget

import org.bukkit.event.entity.EntityTargetLivingEntityEvent; //导入方法依赖的package包/类
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
public void onEntityTarget(final EntityTargetLivingEntityEvent event) {
    if (event.getTarget().getType() == EntityType.PLAYER && this.loggedOutPlayers.containsKey(event.getTarget().getUniqueId())) {
        event.setCancelled(true);
    }
}
 
开发者ID:Ribesg,项目名称:NPlugins,代码行数:7,代码来源:LoggedOutUserHandler.java


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