use of net.aufdemrand.denizen.npc.speech.DenizenSpeechContext in project Denizen-For-Bukkit by DenizenScript.
the class ChatCommand method execute.
@Override
public void execute(ScriptEntry scriptEntry) throws CommandExecutionException {
dList talkers = scriptEntry.getdObject("talkers");
dList targets = scriptEntry.getdObject("targets");
Element message = scriptEntry.getElement("message");
Element chatRange = scriptEntry.getElement("range");
dB.report(scriptEntry, getName(), talkers.debug() + targets.debug() + message.debug() + chatRange.debug());
// Create new speech context
DenizenSpeechContext context = new DenizenSpeechContext(TagManager.cleanOutputFully(message.asString()), scriptEntry, chatRange.asDouble());
if (!targets.isEmpty()) {
for (dEntity ent : targets.filter(dEntity.class)) {
context.addRecipient(ent.getBukkitEntity());
}
}
for (dEntity talker : talkers.filter(dEntity.class)) {
Entity entity = talker.getBukkitEntity();
if (entity != null) {
context.setTalker(entity);
new DenizenSpeechController(entity).speak(context);
} else {
dB.echoDebug(scriptEntry, "Chat Talker is not spawned! Cannot talk.");
}
}
}
Aggregations