Exemplo n.º 1
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);
  }
  @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);
  }
Exemplo n.º 3
0
 @EventHandler
 public void onTarget(EntityTargetEvent event) {
   EntityUtil entity = (EntityUtil) event.getEntity();
   if (entity.checkInVillage()) {
     event.setCancelled(true);
   }
 }
Exemplo n.º 4
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);
        }
      }
    }
  }
Exemplo n.º 5
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);
    }
  }
Exemplo n.º 6
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);
   }
 }
Exemplo n.º 7
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);
         }
       }
     }
   }
 }
Exemplo n.º 8
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);
  }
Exemplo n.º 9
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);
    }
  }
Exemplo n.º 10
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);
 }