use of net.citizensnpcs.npc.ai.speech.TalkableEntity in project Denizen-For-Bukkit by DenizenScript.
the class DenizenChat method talkToBystanders.
private void talkToBystanders(Talkable talkable, String text, DenizenSpeechContext context) {
double range = context.getChatRange();
List<Entity> bystanderEntities = new ArrayList<Entity>();
if (range == 0D) {
for (Player player : Bukkit.getServer().getOnlinePlayers()) {
bystanderEntities.add(player);
}
} else {
bystanderEntities = talkable.getEntity().getNearbyEntities(range, range, range);
}
for (Entity bystander : bystanderEntities) {
boolean shouldTalk = true;
// Exclude targeted recipients
if (context.hasRecipients()) {
for (Talkable target : context) {
if (target.getEntity().equals(bystander)) {
shouldTalk = false;
break;
}
}
}
// talkNear it if 'should_talk'
if (shouldTalk) {
new TalkableEntity(bystander).talkNear(context, text, this);
}
}
}
Aggregations