@EventHandler
  public void onEntityTarget(EntityTargetEvent event) {
    if (event.isCancelled()) {
      return;
    }

    Entity entity = event.getEntity();
    if (!(entity instanceof Player)) {
      return;
    }

    Player player = (Player) entity;
    String name = player.getName().toLowerCase();

    if (PlayerCache.getInstance().isAuthenticated(name)) {
      return;
    }

    if (!data.isAuthAvailable(name)) {
      if (!Settings.isForcedRegistrationEnabled) {
        return;
      }
    }

    event.setCancelled(true);
  }
Ejemplo n.º 2
0
 @EventHandler(priority = EventPriority.LOWEST)
 public void onEntityTarget(EntityTargetEvent event) {
   if (event.getTarget() instanceof SpoutPlayer) {
     event.setCancelled(
         event.isCancelled() || !((SpoutPlayer) event.getTarget()).isPreCachingComplete());
   }
 }
Ejemplo n.º 3
0
 @EventHandler
 public void onEntityTarget(EntityTargetEvent event) {
   if (!event.isCancelled() && event.getTarget() instanceof Player) {
     if (invisibles.containsKey(((Player) event.getTarget()).getName())) {
       event.setCancelled(true);
     }
   }
 }
Ejemplo n.º 4
0
  public void onEntityTarget(EntityTargetEvent event) {
    if (event.isCancelled() && !(event.getTarget() instanceof Player)) return;

    if (event.getTarget() instanceof Player) {
      Player player = ((Player) event.getTarget());
      if ((AdminHandler.isGod(player.getName()) || AdminHandler.isInvisible(player.getName()))
          && AdminPermissions.has(player, Perms.NO_AGGRO)) event.setCancelled(true);
    }
  }
Ejemplo n.º 5
0
  public boolean damageEntity(DamageSource damagesource, int i) {
    if (this.isInvulnerable()) {
      return false;
    } else if (super.damageEntity(damagesource, i)) {
      Entity entity = damagesource.getEntity();

      if (this.passenger != entity && this.vehicle != entity) {
        if (entity != this) {
          // CraftBukkit start - we still need to call events for entities without goals
          if (entity != this.target
              && (this instanceof EntityBlaze
                  || this instanceof EntityEnderman
                  || this instanceof EntitySpider
                  || this instanceof EntityGiantZombie
                  || this instanceof EntitySilverfish)) {
            EntityTargetEvent event =
                org.bukkit.craftbukkit.event.CraftEventFactory.callEntityTargetEvent(
                    this, entity, EntityTargetEvent.TargetReason.TARGET_ATTACKED_ENTITY);

            if (!event.isCancelled()) {
              if (event.getTarget() == null) {
                this.target = null;
              } else {
                this.target =
                    ((org.bukkit.craftbukkit.entity.CraftEntity) event.getTarget()).getHandle();
              }
            }
          } else {
            this.target = entity;
          }
          // CraftBukkit end
        }

        return true;
      } else {
        return true;
      }
    } else {
      return false;
    }
  }
 @EventHandler(priority = EventPriority.HIGHEST)
 public void onEntityTarget(final EntityTargetEvent event) {
   if (event.isCancelled()) {
     return;
   }
   if (!(event.getTarget() instanceof Player)) {
     return;
   }
   final User user = ess.getUser(event.getTarget());
   if ((event.getReason() == TargetReason.CLOSEST_PLAYER
           || event.getReason() == TargetReason.TARGET_ATTACKED_ENTITY
           || event.getReason() == TargetReason.PIG_ZOMBIE_TARGET
           || event.getReason() == TargetReason.RANDOM_TARGET
           || event.getReason() == TargetReason.TARGET_ATTACKED_OWNER
           || event.getReason() == TargetReason.OWNER_ATTACKED_TARGET)
       && prot.getSettingBool(ProtectConfig.prevent_entitytarget)
       && !user.isAuthorized("essentials.protect.entitytarget.bypass")) {
     event.setCancelled(true);
     return;
   }
 }
Ejemplo n.º 7
0
  @EventHandler(priority = EventPriority.NORMAL)
  public void onEntityTarget(EntityTargetEvent event) {
    if (event.isCancelled()) return;

    // If a player is targeted...
    if (!(event.getTarget() instanceof Player)) return;

    // ... by creature that cares about the truce with vampires ...
    if (!(Conf.creatureTypeTruceMonsters.contains(
        EntityUtil.creatureTypeFromEntity(event.getEntity())))) return;

    VPlayer vplayer = VPlayers.i.get((Player) event.getTarget());

    // ... and that player is a vampire ...
    if (!vplayer.isVampire()) return;

    // ... that has not recently done something to break the truce...
    if (vplayer.truceIsBroken()) return;

    // Then the creature will not attack.
    event.setCancelled(true);
  }
Ejemplo n.º 8
0
  private void c(Entity entity) {
    org.bukkit.entity.Entity bukkitTarget = entity == null ? null : entity.getBukkitEntity();

    EntityTargetEvent event =
        new EntityTargetEvent(
            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 = ((CraftEntity) event.getTarget()).getHandle();

    this.target = entity;
    this.angerLevel = (400 + this.random.nextInt(400));
    this.soundDelay = this.random.nextInt(40);
  }