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();
}
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();
}
}
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;
}
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;
}
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);
}
Aggregations