Search in sources :

Example 1 with DenizenSpeechController

use of net.aufdemrand.denizen.npc.speech.DenizenSpeechController 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.");
        }
    }
}
Also used : Entity(org.bukkit.entity.Entity) net.aufdemrand.denizen.objects.dEntity(net.aufdemrand.denizen.objects.dEntity) net.aufdemrand.denizen.objects.dEntity(net.aufdemrand.denizen.objects.dEntity) net.aufdemrand.denizencore.objects.dList(net.aufdemrand.denizencore.objects.dList) Element(net.aufdemrand.denizencore.objects.Element) DenizenSpeechController(net.aufdemrand.denizen.npc.speech.DenizenSpeechController) DenizenSpeechContext(net.aufdemrand.denizen.npc.speech.DenizenSpeechContext)

Aggregations

DenizenSpeechContext (net.aufdemrand.denizen.npc.speech.DenizenSpeechContext)1 DenizenSpeechController (net.aufdemrand.denizen.npc.speech.DenizenSpeechController)1 net.aufdemrand.denizen.objects.dEntity (net.aufdemrand.denizen.objects.dEntity)1 Element (net.aufdemrand.denizencore.objects.Element)1 net.aufdemrand.denizencore.objects.dList (net.aufdemrand.denizencore.objects.dList)1 Entity (org.bukkit.entity.Entity)1