}
if (NPCManager.isNPC(event.getTarget())) {
NPCManager.get(event.getTarget()).callTargetEvent(event);
}
NPCTargetEvent e = event;
HumanNPC npc = NPCManager.get(e.getEntity());
if (npc != null && event.getTarget() instanceof Player) {
Player player = (Player) event.getTarget();
if (npc.getNPCData().isLookClose()) {
NPCManager.faceEntity(npc, player);
}
if (UtilityProperties.isHoldingTool("SelectItems", player)) {
if (!NPCManager.hasSelected(player, npc.getUID())) {
NPCDataManager.selectNPC(player, npc);
if (PermissionManager.hasPermission(player, "citizens.basic.modify.select"))
Messaging.send(player, npc, Settings.getString("SelectionMessage"));
if (!Settings.getBoolean("QuickSelect")) {
return;
}
}
}
// Call NPC talk event
if (npc.getNPCData().isTalk() && UtilityProperties.isHoldingTool("TalkItems", player)) {
Player target = (Player) e.getTarget();
NPCTalkEvent talkEvent = new NPCTalkEvent(npc, target, MessageUtils.getText(npc, target));
Bukkit.getServer().getPluginManager().callEvent(talkEvent);
if (!talkEvent.isCancelled()) {
if (!talkEvent.getText().isEmpty()) {
Messaging.send(target, npc, talkEvent.getText());
}
}
}
NPCRightClickEvent rightClickEvent = new NPCRightClickEvent(npc, player);
Bukkit.getServer().getPluginManager().callEvent(rightClickEvent);
if (!rightClickEvent.isCancelled()) {
NPCDataManager.handleEquipmentEditor(rightClickEvent);
NPCDataManager.handlePathRestart(rightClickEvent);
if (npc.getWaypoints().isStarted() && npc.getWaypoints().current() != null) {
npc.getWaypoints().scheduleDelay(npc, npc.getWaypoints().current().getLocation(),
Settings.getInt("RightClickPause"));
}
npc.callRightClick(player, npc);
}
}
}