Search in sources :

Example 11 with BukkitScriptEntryData

use of com.denizenscript.denizen.utilities.implementation.BukkitScriptEntryData in project Denizen-For-Bukkit by DenizenScript.

the class EnchantmentScriptContainer method runSubScript.

public void runSubScript(String pathName, Entity attacker, Entity victim, Entity primary, int level) {
    validateThread();
    List<ScriptEntry> entries = getEntries(new BukkitScriptEntryData(new EntityTag(primary)), pathName);
    if (entries == null || entries.isEmpty()) {
        return;
    }
    InstantQueue queue = new InstantQueue(getName());
    queue.addEntries(entries);
    ContextSource.SimpleMap src = new ContextSource.SimpleMap();
    src.contexts = new HashMap<>();
    if (attacker != null) {
        src.contexts.put("attacker", new EntityTag(attacker));
    }
    if (victim != null) {
        src.contexts.put("victim", new EntityTag(victim));
    }
    src.contexts.put("level", new ElementTag(level));
    queue.contextSource = src;
    queue.start();
}
Also used : BukkitScriptEntryData(com.denizenscript.denizen.utilities.implementation.BukkitScriptEntryData) ContextSource(com.denizenscript.denizencore.scripts.queues.ContextSource) ScriptEntry(com.denizenscript.denizencore.scripts.ScriptEntry) EntityTag(com.denizenscript.denizen.objects.EntityTag) InstantQueue(com.denizenscript.denizencore.scripts.queues.core.InstantQueue) ElementTag(com.denizenscript.denizencore.objects.core.ElementTag)

Example 12 with BukkitScriptEntryData

use of com.denizenscript.denizen.utilities.implementation.BukkitScriptEntryData in project Denizen-For-Bukkit by DenizenScript.

the class InteractScriptContainer method getEntriesFor.

public List<ScriptEntry> getEntriesFor(Class<? extends AbstractTrigger> trigger, PlayerTag player, NPCTag npc, String id, boolean quiet) {
    // Get the trigger name
    String triggerName = Denizen.getInstance().triggerRegistry.get(trigger).getName();
    // Check for entries
    String key = "steps." + InteractScriptHelper.getCurrentStep(player, getName()) + "." + triggerName + " trigger." + (id == null ? "script" : id + ".script");
    if (containsScriptSection(key)) {
        // Entries exist, so get them and return the list of ScriptEntries
        return getEntries(new BukkitScriptEntryData(player, npc), key);
    // No entries, so just return an empty list to avoid NPEs
    } else {
        if (!quiet) {
            Debug.echoDebug(this, "No entries in script for " + key);
        }
        return Collections.emptyList();
    }
}
Also used : BukkitScriptEntryData(com.denizenscript.denizen.utilities.implementation.BukkitScriptEntryData)

Example 13 with BukkitScriptEntryData

use of com.denizenscript.denizen.utilities.implementation.BukkitScriptEntryData in project Denizen-For-Bukkit by DenizenScript.

the class BukkitTagContext method getScriptEntryData.

@Override
public ScriptEntryData getScriptEntryData() {
    BukkitScriptEntryData bsed = new BukkitScriptEntryData(player, npc);
    bsed.scriptEntry = entry;
    return bsed;
}
Also used : BukkitScriptEntryData(com.denizenscript.denizen.utilities.implementation.BukkitScriptEntryData)

Example 14 with BukkitScriptEntryData

use of com.denizenscript.denizen.utilities.implementation.BukkitScriptEntryData in project Denizen-For-Bukkit by DenizenScript.

the class CommandScriptContainer method runCommandScript.

public ScriptQueue runCommandScript(PlayerTag player, NPCTag npc, Map<String, ObjectTag> context) {
    ScriptQueue queue = new InstantQueue(getName());
    queue.addEntries(getBaseEntries(new BukkitScriptEntryData(player, npc)));
    if (context != null) {
        ContextSource.SimpleMap src = new ContextSource.SimpleMap();
        src.contexts = context;
        queue.setContextSource(src);
    }
    queue.start();
    return queue;
}
Also used : BukkitScriptEntryData(com.denizenscript.denizen.utilities.implementation.BukkitScriptEntryData) ContextSource(com.denizenscript.denizencore.scripts.queues.ContextSource) InstantQueue(com.denizenscript.denizencore.scripts.queues.core.InstantQueue) ScriptQueue(com.denizenscript.denizencore.scripts.queues.ScriptQueue)

Example 15 with BukkitScriptEntryData

use of com.denizenscript.denizen.utilities.implementation.BukkitScriptEntryData in project Denizen-For-Bukkit by DenizenScript.

the class EntityKilledScriptEvent method getScriptEntryData.

@Override
public ScriptEntryData getScriptEntryData() {
    PlayerTag player = entity.isPlayer() ? EntityTag.getPlayerFrom(event.getEntity()) : null;
    if (damager != null && player == null && damager.isPlayer()) {
        player = EntityTag.getPlayerFrom(damager.getBukkitEntity());
    }
    NPCTag npc = entity.isCitizensNPC() ? entity.getDenizenNPC() : null;
    if (damager != null && npc == null && damager.isCitizensNPC()) {
        npc = damager.getDenizenNPC();
    }
    return new BukkitScriptEntryData(player, npc);
}
Also used : PlayerTag(com.denizenscript.denizen.objects.PlayerTag) BukkitScriptEntryData(com.denizenscript.denizen.utilities.implementation.BukkitScriptEntryData) NPCTag(com.denizenscript.denizen.objects.NPCTag)

Aggregations

BukkitScriptEntryData (com.denizenscript.denizen.utilities.implementation.BukkitScriptEntryData)15 ScriptEntry (com.denizenscript.denizencore.scripts.ScriptEntry)8 PlayerTag (com.denizenscript.denizen.objects.PlayerTag)7 NPCTag (com.denizenscript.denizen.objects.NPCTag)6 ScriptQueue (com.denizenscript.denizencore.scripts.queues.ScriptQueue)6 InstantQueue (com.denizenscript.denizencore.scripts.queues.core.InstantQueue)6 ContextSource (com.denizenscript.denizencore.scripts.queues.ContextSource)5 ElementTag (com.denizenscript.denizencore.objects.core.ElementTag)3 ArrayList (java.util.ArrayList)3 Player (org.bukkit.entity.Player)3 ScriptTag (com.denizenscript.denizencore.objects.core.ScriptTag)2 EntityTag (com.denizenscript.denizen.objects.EntityTag)1 InteractScriptContainer (com.denizenscript.denizen.scripts.containers.core.InteractScriptContainer)1 BukkitTagContext (com.denizenscript.denizen.tags.BukkitTagContext)1 Utilities (com.denizenscript.denizen.utilities.Utilities)1 Debug (com.denizenscript.denizen.utilities.debugging.Debug)1 InvalidArgumentsException (com.denizenscript.denizencore.exceptions.InvalidArgumentsException)1 InvalidArgumentsRuntimeException (com.denizenscript.denizencore.exceptions.InvalidArgumentsRuntimeException)1 Argument (com.denizenscript.denizencore.objects.Argument)1 ObjectTag (com.denizenscript.denizencore.objects.ObjectTag)1