Beispiel #1
0
 @EventHandler
 public void click(NPCRightClickEvent event) {
   // Handle a click on a NPC. The event has a getNPC() method.
   // Be sure to check event.getNPC() == this.getNPC() so you only handle
   // clicks on this NPC!
   NpcData npcData = null;
   if (event.getNPC() != this.getNPC()) {
     //			System.out.println("[REALMS] Trait Settler , wrong NPC instance !  :
     // "+event.getNPC().getId());
     return;
   } else {
     System.out.println("[REALMS] Trait Settler , NPC : " + event.getNPC().getId());
     npcData = plugin.getData().getNpcs().getCitizenId(this.getNPC().getId());
     if (npcData == null) {
       System.out.println("No regular npcData ! ");
       return;
     }
     if (plugin.getData().getNpcs().getCitizenId(this.getNPC().getId()).isAlive() == false) {
       npc.despawn();
       return;
     }
   }
   if (event.getClicker().getItemInHand().getType() == Material.BLAZE_ROD) {
     showBlazerod(event);
     return;
   }
   if (event.getClicker().getItemInHand().getType() == Material.STICK) {
     return;
   } else {
     // simple message
     showSimple(event);
     return;
   }
 }
Beispiel #2
0
  private void showSimple(NPCRightClickEvent event) {
    String playerName = "stranger";
    boolean isSeen = false;
    if (seenPlayer.contains(event.getClicker().getUniqueId().toString())) {
      playerName = ChatColor.GREEN + event.getClicker().getDisplayName() + ChatColor.YELLOW;
      isSeen = true;
    } else {
      seenPlayer.add(event.getClicker().getUniqueId().toString());
    }
    if (this.npcType == NPCType.CHILD) {
      event.getClicker().sendMessage("I dont speak with alien !");
      return;
    }
    event
        .getClicker()
        .sendMessage(
            ChatColor.YELLOW
                + "Hallo, "
                + playerName
                + ". My name is "
                + this.getNPC().getFullName());
    if (this.settleId > 0) {
      event
          .getClicker()
          .sendMessage(
              "This is the settlement "
                  + plugin.getRealmModel().getSettlements().getSettlement(this.settleId).getName());
    }
    if (isSeen) {
      event.getClicker().sendMessage("I have seen you before ");

    } else {
      event.getClicker().sendMessage("I have never seen you before ");
    }
  }
Beispiel #3
0
  private void showBlazerod(NPCRightClickEvent event) {
    NpcData npcData = plugin.getData().getNpcs().getCitizenId(this.getNPC().getId());
    if (npcData == null) {
      return;
    }
    Settlement settle = plugin.getData().getSettlements().getSettlement(npcData.getSettleId());
    if (settle != null) {
      event.getClicker().sendMessage("I am a Settler of " + settle.getName());
    } else {
      event.getClicker().sendMessage("I have no home and hiking around ");
    }
    event
        .getClicker()
        .sendMessage(
            "my name is "
                + this.getNPC().getFullName()
                + " | "
                + npcData.getAge()
                + " years old "
                + npcData.getGender());
    event
        .getClicker()
        .sendMessage(
            this.getNPC().getId()
                + ":"
                + npcData.getId()
                + " job "
                + npcData.getNpcAction()
                + " as "
                + npcData.getNpcType()
                + " : pregnant "
                + npcData.isSchwanger());
    Equipment equip = npc.getTrait(Equipment.class);
    for (ItemStack item : equip.getEquipment()) {
      if (item != null) {
        event
            .getClicker()
            .sendMessage(
                ": " + item.getType() + ":" + item.getAmount() + ":" + item.getDurability());
      }
    }

    npc.getTrait(LookClose.class).lookClose(true);
  }