@Override public void run() { CitizensConversation conv = (CitizensConversation) event.getConversation(); NPC npc = conv.getNPC(); Integer i = npcs.get(npc); i--; if (i == 0) { npcs.remove(npc); if (npc.isSpawned()) { Navigator nav = npc.getNavigator(); nav.setPaused(false); nav.setTarget(locs.remove(npc)); } } else { npcs.put(npc, i); } } }.runTask(BetonQuest.getInstance());
@Override public void run() { CitizensConversation conv = (CitizensConversation) event.getConversation(); NPC npc = conv.getNPC(); if (!npcs.containsKey(npc)) { Navigator nav = npc.getNavigator(); npcs.put(npc, 1); locs.put(npc, nav.getTargetAsLocation()); nav.setPaused(true); nav.cancelNavigation(); nav.setTarget(conv.getNPC().getEntity().getLocation()); nav.setPaused(true); nav.cancelNavigation(); } else { npcs.put(npc, npcs.get(npc) + 1); } } }.runTask(BetonQuest.getInstance());
@Override public boolean shouldExecute() { if (!npc.isSpawned() || npc.getNavigator().isNavigating() || paused) return false; Location dest = findRandomPosition(); if (dest == null) return false; npc.getNavigator().setTarget(dest); CitizensAPI.registerEvents(this); return true; }
/** * Causes the NPC to immediately path over to a position. */ public void pathTo(Location target) { pauseWaypoints(); pathingTo = target; npc.getNavigator().getDefaultParameters().distanceMargin(1.5); getNPC().getNavigator().setTarget(target); chasing = null; needsSafeReturn = true; }
@Override public boolean shouldExecute() { if (targets.size() == 0 || !npc.isSpawned()) return false; Collection<Entity> nearby = npc.getEntity().getNearbyEntities(radius, radius, radius); this.target = null; for (Entity entity : nearby) { if (targets.contains(entity.getType())) { target = entity; break; } } if (target != null) { npc.getNavigator().setTarget(target, aggressive); npc.getNavigator().getLocalParameters().addSingleUseCallback(new NavigatorCallback() { @Override public void onCompletion(CancelReason cancelReason) { reason = cancelReason; finished = true; } }); return true; } return false; }
@Override public boolean shouldExecute() { boolean executing = !npc.getNavigator().isNavigating() && target != null; if (executing) { npc.getNavigator().setTarget(target); npc.getNavigator().getLocalParameters().addSingleUseCallback(new NavigatorCallback() { @Override public void onCompletion(CancelReason cancelReason) { finished = true; reason = cancelReason; } }); } return executing; } }
CitizensWalkingListener.getInstance().setNewTargetLocation(npc, next); } else { npc.getNavigator().setTarget(next); npc.getNavigator().setTarget(locationsIterator.previous().getLocation(currentPlayer)); } catch (QuestRuntimeException e) { Debug.error("Error while finishing NPC " + npc.getId() + " navigation: " + e.getMessage());
CitizensWalkingListener.getInstance().setNewTargetLocation(npc, firstLocation.getLocation(playerID)); } else { npc.getNavigator().setTarget(firstLocation.getLocation(playerID));
npc.getNavigator().getDefaultParameters().range(100); npc.getNavigator().getDefaultParameters().stuckAction(TeleportStuckAction.INSTANCE); npc.getNavigator().setTarget(SentinelUtilities.pickNear(player.getLocation(), SentinelPlugin.instance.guardDistanceSelectionRange)); npc.getNavigator().getLocalParameters().speedModifier((float) speed); chased = true; npc.getNavigator().setTarget(near); npc.getNavigator().getLocalParameters().speedModifier((float) speed); needsSafeReturn = false;