Esempio n. 1
0
 @EventHandler
 public void onTarget(EntityTargetEvent event) {
   EntityUtil entity = (EntityUtil) event.getEntity();
   if (entity.checkInVillage()) {
     event.setCancelled(true);
   }
 }
Esempio n. 2
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);
        }
      }
    }
  }