本文整理汇总了Java中org.bukkit.event.entity.EntityTargetEvent.getTarget方法的典型用法代码示例。如果您正苦于以下问题:Java EntityTargetEvent.getTarget方法的具体用法?Java EntityTargetEvent.getTarget怎么用?Java EntityTargetEvent.getTarget使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.bukkit.event.entity.EntityTargetEvent
的用法示例。
在下文中一共展示了EntityTargetEvent.getTarget方法的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);
}
}
}
示例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;
}
}
示例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);
}
}
}
}
示例4: 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();
}
示例5: 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);
}
示例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);
}
}
}
}
示例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);
}
}
}
}
}
示例8: 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;
}
}
示例9: 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);
}
示例10: 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);
}
示例11: 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);
}
}
示例12: 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);
}
}
}
示例13: 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);
}
示例14: 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);
}
}
}
示例15: 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);
}
}