Java 类org.bukkit.event.entity.EntityTargetLivingEntityEvent 实例源码

项目:RPGInventory    文件:PetListener.java   
@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());
        }
    }
}
项目:RPGInventory    文件:PlayerListener.java   
@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);
    }
}
项目:uSkyBlock    文件:GriefEvents.java   
@EventHandler
public void onTargeting(EntityTargetLivingEntityEvent e) {
    if (!witherEnabled || e == null || e.isCancelled() || !plugin.isSkyAssociatedWorld(e.getEntity().getWorld())) {
        return;
    }
    if (e.getEntity() instanceof Wither && e.getTarget() != null) {
        handleWitherRampage(e, (Wither) e.getEntity(), e.getTarget().getLocation());
    }
}
项目:Equestrian-Dash    文件:EntityTargetLivingEntityListener.java   
@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);
    }
}
项目:Ghosts    文件:EntityListener.java   
@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);
        }
    }
}
项目:xEssentials-deprecated-bukkit    文件:CustomZombieAggroRangeEvent.java   
@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);
            }
        }
    }
}
项目:xEssentials-deprecated-bukkit    文件:ChairDisableMonsterEvent.java   
@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);
            }
        }
    }
}
项目:xEssentials-deprecated-bukkit    文件:AfkCheckEvent.java   
@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);
            }
        }
    }
}
项目:xEssentials-deprecated-bukkit    文件:VanishEvent.java   
@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);
            }
        }
    }
}
项目:xEssentials_old_Source    文件:vanishEntity.java   
@EventHandler
public void ignoremob(EntityTargetLivingEntityEvent e) {
    if(e.getTarget() instanceof Player) {
        Player p = (Player) e.getTarget();
        if(vanishApi.isVanished(p)) {
            e.setCancelled(true);
        }
    }
}
项目:xEssentials_old_Source    文件:zombieTarget.java   
@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);
            }
        }
    }
}
项目:xEssentials_old_Source    文件:afkCheck.java   
@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);
            }
        }
    }
}
项目:SpigotSource    文件:EntityExperienceOrb.java   
public void m() {
    super.m();
    EntityHuman prevTarget = this.targetPlayer;// CraftBukkit - store old target
    if (this.c > 0) {
        --this.c;
    }

    this.lastX = this.locX;
    this.lastY = this.locY;
    this.lastZ = this.locZ;
    this.motY -= 0.029999999329447746D;
    if (this.world.getType(new BlockPosition(this)).getMaterial() == Material.LAVA) {
        this.motY = 0.20000000298023224D;
        this.motX = (double) ((this.random.nextFloat() - this.random.nextFloat()) * 0.2F);
        this.motZ = (double) ((this.random.nextFloat() - this.random.nextFloat()) * 0.2F);
        this.a(SoundEffects.bA, 0.4F, 2.0F + this.random.nextFloat() * 0.4F);
    }

    this.j(this.locX, (this.getBoundingBox().b + this.getBoundingBox().e) / 2.0D, this.locZ);
    double d0 = 8.0D;

    if (this.targetTime < this.a - 20 + this.getId() % 100) {
        if (this.targetPlayer == null || this.targetPlayer.h(this) > d0 * d0) {
            this.targetPlayer = this.world.findNearbyPlayer(this, d0);
        }

        this.targetTime = this.a;
    }

    if (this.targetPlayer != null && this.targetPlayer.isSpectator()) {
        this.targetPlayer = null;
    }

    if (this.targetPlayer != null) {
        // CraftBukkit start
        boolean cancelled = false;
        if (this.targetPlayer != prevTarget) {
            EntityTargetLivingEntityEvent event = CraftEventFactory.callEntityTargetLivingEvent(this, targetPlayer, EntityTargetEvent.TargetReason.CLOSEST_PLAYER);
            EntityLiving target = event.getTarget() == null ? null : ((org.bukkit.craftbukkit.entity.CraftLivingEntity) event.getTarget()).getHandle();
            targetPlayer = target instanceof EntityHuman ? (EntityHuman) target : null;
            cancelled = event.isCancelled();
        }

        if (!cancelled && targetPlayer != null) {
        double d1 = (this.targetPlayer.locX - this.locX) / d0;
        double d2 = (this.targetPlayer.locY + (double) this.targetPlayer.getHeadHeight() / 2.0D - this.locY) / d0;
        double d3 = (this.targetPlayer.locZ - this.locZ) / d0;
        double d4 = Math.sqrt(d1 * d1 + d2 * d2 + d3 * d3);
        double d5 = 1.0D - d4;

        if (d5 > 0.0D) {
            d5 *= d5;
            this.motX += d1 / d4 * d5 * 0.1D;
            this.motY += d2 / d4 * d5 * 0.1D;
            this.motZ += d3 / d4 * d5 * 0.1D;
        }
        }
        // CraftBukkit end
    }

    this.move(this.motX, this.motY, this.motZ);
    float f = 0.98F;

    if (this.onGround) {
        f = this.world.getType(new BlockPosition(MathHelper.floor(this.locX), MathHelper.floor(this.getBoundingBox().b) - 1, MathHelper.floor(this.locZ))).getBlock().frictionFactor * 0.98F;
    }

    this.motX *= (double) f;
    this.motY *= 0.9800000190734863D;
    this.motZ *= (double) f;
    if (this.onGround) {
        this.motY *= -0.8999999761581421D;
    }

    ++this.a;
    ++this.b;
    if (this.b >= 6000) {
        this.die();
    }

}
项目:NPlugins    文件:LoggedOutUserHandler.java   
@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);
    }
}