use of net.citizensnpcs.api.ai.speech.SpeechContext in project Denizen-For-Bukkit by DenizenScript.
the class ChatbotTrait method chatTo.
public void chatTo(Entity entity, String input) {
SpeechContext context = new SpeechContext(response(input));
context.addRecipient(entity);
context.setTalker(getNPC().getEntity());
npc.getDefaultSpeechController().speak(context, "chat");
}
use of net.citizensnpcs.api.ai.speech.SpeechContext in project Citizens2 by CitizensDev.
the class NPCCommands method speak.
@Command(aliases = { "npc" }, usage = "speak message to speak --target npcid|player_name --type vocal_type", desc = "Uses the NPCs SpeechController to talk", modifiers = { "speak" }, min = 2, permission = "citizens.npc.speak")
public void speak(CommandContext args, CommandSender sender, NPC npc) throws CommandException {
String type = npc.getTrait(Speech.class).getDefaultVocalChord();
String message = Colorizer.parseColors(args.getJoinedStrings(1));
if (message.length() <= 0) {
Messaging.send(sender, "Default Vocal Chord for " + npc.getName() + ": " + npc.getTrait(Speech.class).getDefaultVocalChord());
return;
}
SpeechContext context = new SpeechContext(message);
if (args.hasValueFlag("target")) {
if (args.getFlag("target").matches("\\d+")) {
NPC target = CitizensAPI.getNPCRegistry().getById(Integer.valueOf(args.getFlag("target")));
if (target != null)
context.addRecipient(target.getEntity());
} else {
Player player = Bukkit.getPlayer(args.getFlag("target"));
if (player != null) {
context.addRecipient((Entity) player);
}
}
}
if (args.hasValueFlag("type")) {
if (CitizensAPI.getSpeechFactory().isRegistered(args.getFlag("type")))
type = args.getFlag("type");
}
npc.getDefaultSpeechController().speak(context, type);
}
use of net.citizensnpcs.api.ai.speech.SpeechContext in project Citizens2 by CitizensDev.
the class Text method sendText.
private boolean sendText(Player player) {
if (!player.hasPermission("citizens.admin") && !player.hasPermission("citizens.npc.talk"))
return false;
if (text.size() == 0)
return false;
int index = 0;
if (randomTalker)
index = RANDOM.nextInt(text.size());
else {
if (currentIndex > text.size() - 1)
currentIndex = 0;
index = currentIndex++;
}
npc.getDefaultSpeechController().speak(new SpeechContext(text.get(index), player));
return true;
}
use of net.citizensnpcs.api.ai.speech.SpeechContext in project Sentinel by mcmonkey4eva.
the class SentinelTrait method sayTo.
/**
* Causes the NPC to speak a message to a player.
*/
public void sayTo(Player player, String message) {
SpeechContext sc = new SpeechContext(npc, message, player);
npc.getDefaultSpeechController().speak(sc, "chat");
}
Aggregations