use of net.aufdemrand.denizen.BukkitScriptEntryData in project Denizen-For-Bukkit by DenizenScript.
the class AssignmentCommand method execute.
@Override
public void execute(ScriptEntry scriptEntry) throws CommandExecutionException {
dScript script = scriptEntry.getdObject("script");
// Report to dB
dB.report(scriptEntry, getName(), aH.debugObj("action", scriptEntry.getObject("action")) + script.debug());
// Perform desired action
if (scriptEntry.getObject("action").equals(Action.SET)) {
((BukkitScriptEntryData) scriptEntry.entryData).getNPC().getCitizen().getTrait(AssignmentTrait.class).setAssignment(script.getName(), ((BukkitScriptEntryData) scriptEntry.entryData).getPlayer());
} else if (scriptEntry.getObject("action").equals(Action.REMOVE)) {
((BukkitScriptEntryData) scriptEntry.entryData).getNPC().getCitizen().getTrait(AssignmentTrait.class).removeAssignment(((BukkitScriptEntryData) scriptEntry.entryData).getPlayer());
}
}
use of net.aufdemrand.denizen.BukkitScriptEntryData in project Denizen-For-Bukkit by DenizenScript.
the class EngageCommand method execute.
@Override
public void execute(ScriptEntry scriptEntry) throws CommandExecutionException {
Duration duration = scriptEntry.getdObject("duration");
dNPC npc = ((BukkitScriptEntryData) scriptEntry.entryData).getNPC();
// Report to dB
dB.report(scriptEntry, getName(), npc.debug() + duration.debug());
if (duration.getSecondsAsInt() > 0) {
setEngaged(npc.getCitizen(), duration.getSecondsAsInt());
} else {
setEngaged(npc.getCitizen(), true);
}
}
use of net.aufdemrand.denizen.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 net.aufdemrand.denizen.BukkitScriptEntryData in project Denizen-For-Bukkit by DenizenScript.
the class NPCTags method navBegin.
// <--[event]
// @Events
// npc begins navigation
//
// @Warning This event may fire very rapidly.
//
// @Triggers when an NPC begins navigating.
//
// @Context
// None
//
// -->
// <--[action]
// @Actions
// begin navigation
//
// @Triggers when the NPC has received a 'walk' command,
// or is about to follow a path.
//
// @Context
// None
//
// -->
@EventHandler
public void navBegin(NavigationBeginEvent event) {
dNPC npc = DenizenAPI.getDenizenNPC(event.getNPC());
// Do world script event 'On NPC Completes Navigation'
if (NPCNavigationSmartEvent.IsActive()) {
OldEventManager.doEvents(Arrays.asList("npc begins navigation"), new BukkitScriptEntryData(null, npc), null);
}
if (!event.getNPC().hasTrait(AssignmentTrait.class)) {
return;
}
npc.action("begin navigation", null);
if (event.getNPC().getNavigator().getTargetType() == TargetType.ENTITY) {
LivingEntity entity = (LivingEntity) event.getNPC().getNavigator().getEntityTarget().getTarget();
// and that entity is not dead, trigger "on attack" command
if (event.getNPC().getNavigator().getEntityTarget().isAggressive() && !entity.isDead()) {
dPlayer player = null;
// Check if the entity attacked by this NPC is a player
if (entity instanceof Player) {
player = dPlayer.mirrorBukkitPlayer((Player) entity);
}
// <--[action]
// @Actions
// attack
// attack on <entity>
//
// @Triggers when the NPC is about to attack an enemy.
//
// @Context
// None
//
// -->
npc.action("attack", player);
npc.action("attack on " + entity.getType().toString(), player);
}
previousLocations.put(event.getNPC().getId(), npc.getLocation());
}
}
use of net.aufdemrand.denizen.BukkitScriptEntryData in project Denizen-For-Bukkit by DenizenScript.
the class NPCTags method navComplete.
// <--[event]
// @Events
// npc completes navigation
//
// @Warning This event may fire very rapidly.
//
// @Triggers when an NPC finishes navigating.
//
// @Context
// None
//
// -->
// <--[action]
// @Actions
// complete navigation
//
// @Triggers when the NPC has finished a 'walk' command,
// or has reached a path point.
//
// @Context
// None
//
// -->
@EventHandler
public void navComplete(NavigationCompleteEvent event) {
dNPC npc = DenizenAPI.getDenizenNPC(event.getNPC());
// Do world script event 'On NPC Completes Navigation'
if (NPCNavigationSmartEvent.IsActive()) {
OldEventManager.doEvents(Arrays.asList("npc completes navigation"), new BukkitScriptEntryData(null, npc), null);
}
// Do the assignment script action
if (!event.getNPC().hasTrait(AssignmentTrait.class)) {
return;
}
npc.action("complete navigation", null);
}
Aggregations