Ejemplo n.º 1
0
 @EventHandler
 public void onEntityTarget(EntityTargetEvent event) {
   if (event.getTarget() instanceof Player) {
     Player p = (Player) event.getTarget();
     if (um.isSpectator(p.getName())) 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 onTarget(EntityTargetEvent event) {
   EntityUtil entity = (EntityUtil) event.getEntity();
   if (entity.checkInVillage()) {
     event.setCancelled(true);
   }
 }
Ejemplo n.º 4
0
 @EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
 public void onEntityTarget(EntityTargetEvent event) {
   Entity target = event.getTarget();
   if (target instanceof Player && plugin.noInteract((Player) target)) {
     event.setCancelled(true);
   }
 }
  @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.º 6
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.º 7
0
 @EventHandler
 public void onEntityTarget(EntityTargetEvent event) {
   if (event.getTarget() instanceof Player) {
     if (plugin.isUnconscious((Player) event.getTarget())) {
       event.setCancelled(true);
     }
   }
 }
Ejemplo n.º 8
0
 @SuppressWarnings("static-access")
 @Override
 public void onTarget(EntityTargetEvent event) {
   super.onTarget(event);
   if (event.getReason().equals(TargetReason.FORGOT_TARGET)
       || event.getReason().equals(TargetReason.TARGET_DIED)) {
     this.customMobs.remove(this.entity.getUniqueID());
   }
 }
Ejemplo n.º 9
0
  @EventHandler()
  public void onEntityTarget(EntityTargetEvent event) {
    if (!(event.getEntity() instanceof Creature)) return;

    JailPrisoner prisoner = Jail.guards.get(event.getEntity());

    if (prisoner != null && !prisoner.getPossibleGuardTargets().contains(event.getTarget()))
      event.setCancelled(true);
  }
Ejemplo n.º 10
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.º 11
0
  @Override
  public void onTarget(EntityTargetEvent event) {
    super.onTarget(event);

    if (event.getReason().equals(TargetReason.FORGOT_TARGET)
        || event.getReason().equals(TargetReason.TARGET_DIED)) {
      this.angry = false;
      for (Entity e : minions) {
        e.getBukkitEntity().remove();
      }
    }
  }
Ejemplo n.º 12
0
 @EventHandler(ignoreCancelled = true)
 public void onEntityTarget(EntityTargetEvent e) {
   if (e.getTarget() != null) {
     if (e.getTarget().getType().equals(EntityType.PLAYER)) {
       Player target = (Player) e.getTarget();
       if (pl.invisible.containsKey(target)) {
         e.setCancelled(true);
       } else if (checkSpectator(target)) {
         e.setCancelled(true);
       }
     }
   }
 }
Ejemplo n.º 13
0
  @Override
  public void onEntityTarget(EntityTargetEvent event) {

    if (event instanceof NpcEntityTargetEvent) {
      NpcEntityTargetEvent nevent = (NpcEntityTargetEvent) event;

      BasicHumanNpc npc = parent.HumanNPCList.getBasicHumanNpc(event.getEntity());

      if (npc != null && event.getTarget() instanceof Player) {
        if (nevent.getNpcReason() == NpcTargetReason.CLOSEST_PLAYER) {
          Player p = (Player) event.getTarget();
          p.sendMessage("<" + npc.getName() + "> Hello friend, I'm an NPC!");
          event.setCancelled(true);

        } else if (nevent.getNpcReason() == NpcTargetReason.NPC_RIGHTCLICKED) {
          Player p = (Player) event.getTarget();
          p.sendMessage("<" + npc.getName() + "> You right-clicked me!");
          event.setCancelled(true);

        } else if (nevent.getNpcReason() == NpcTargetReason.NPC_BOUNCED) {
          Player p = (Player) event.getTarget();
          p.sendMessage("<" + npc.getName() + "> Stop bouncing on me!");
          event.setCancelled(true);
        }
      }
    }
  }
Ejemplo n.º 14
0
  public void onEntityTarget(EntityTargetEvent event) {
    Entity entity = event.getEntity();
    if (entity instanceof Player) {
      return;
    }

    Entity target = event.getTarget();
    if (!(target instanceof Player)) {
      return;
    }
    Player targetPlayer = (Player) target;

    if (!plugin.checkAuth(targetPlayer)) {
      event.setCancelled(true);
    }
  }
Ejemplo n.º 15
0
 @EventHandler
 public void onWolfTarget(EntityTargetEvent e) {
   Entity targeter = e.getEntity();
   Entity target = e.getTarget();
   if (targeter instanceof Wolf == false) return;
   Wolf wTargeter = (Wolf) targeter;
   if (!wTargeter.isTamed()) return;
   if (target instanceof Player == false) return;
   Player pTarget = (Player) target;
   Squad targetSquad = squad.getPlayerSquad(pTarget.getName());
   if (targetSquad == null) return;
   Player p = (Player) wTargeter.getOwner();
   if (p == null) return;
   if (targetSquad.contains(p.getName())) {
     e.setCancelled(true);
   }
 }
Ejemplo n.º 16
0
 @EventHandler
 public void MobNerf(EntityTargetEvent event) {
   Entity target = event.getTarget();
   Entity e = event.getEntity();
   if (e instanceof Player) {
     return;
   }
   if (target instanceof Player) {
     String targetName = ((Player) target).getName();
     for (i = 0; i < plugin.Watching.size(); i++) {
       if (plugin.Watching.get(i) != null) {
         if (plugin.Watching.get(i).contains(targetName)) {
           event.setTarget(null);
         }
       }
     }
   }
 }
Ejemplo n.º 17
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;
    }
  }
Ejemplo n.º 18
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.º 19
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);
  }
Ejemplo n.º 20
0
  /**
   * 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 (!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);
    }
  }
 @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.º 22
0
  @Override
  public void onEntityTarget(EntityTargetEvent event) {
    if (!(event instanceof NPCEntityTargetEvent)) return;
    NPCEntityTargetEvent e = (NPCEntityTargetEvent) event;
    HumanNPC npc = NPCManager.getNPC(e.getEntity());

    if (npc != null && event.getTarget() instanceof Player) {
      if (e.getNpcReason() == NpcTargetReason.NPC_RIGHTCLICKED) {
        CitizensBasicNPCEvent ev =
            new CitizensBasicNPCEvent(
                npc.getName(),
                MessageUtils.getText(npc, e.getTarget(), plugin),
                npc,
                Reason.RIGHT_CLICK,
                (Player) e.getTarget());
        plugin.getServer().getPluginManager().callEvent(ev);
      } else if (e.getNpcReason() == NpcTargetReason.CLOSEST_PLAYER) {
      }
    }
  }
Ejemplo n.º 23
0
 @EventHandler(ignoreCancelled = true, priority = EventPriority.HIGHEST)
 public void EntityTargetEvent(final EntityTargetEvent event) {
   if (event.getTarget() == null) return;
   if (event.getEntity().hasMetadata(PeacefulMeta.METAHEADER)) event.setCancelled(true);
 }