Search in sources :

Example 6 with NPCTag

use of com.denizenscript.denizen.objects.NPCTag in project Denizen-For-Bukkit by DenizenScript.

the class SittingTrait method sit.

// <--[action]
// @Actions
// sit
// 
// @Triggers when the NPC sits down.
// 
// @Context
// None
// 
// -->
/**
 * Makes the NPC sit
 */
public void sit() {
    if (!npc.isSpawned()) {
        return;
    }
    new NPCTag(npc).action("sit", null);
    sit(npc.getStoredLocation());
}
Also used : NPCTag(com.denizenscript.denizen.objects.NPCTag)

Example 7 with NPCTag

use of com.denizenscript.denizen.objects.NPCTag in project Denizen-For-Bukkit by DenizenScript.

the class SneakingTrait method sneak.

// <--[action]
// @Actions
// sneak
// 
// @Triggers when the NPC starts sneaking.
// 
// @Context
// None
// 
// -->
/**
 * Makes the NPC sneak
 */
public void sneak() {
    new NPCTag(npc).action("sneak", null);
    if (npc.getEntity().getType() != EntityType.PLAYER) {
        return;
    }
    NMSHandler.getEntityHelper().setSneaking(npc.getEntity(), true);
    sneaking = true;
}
Also used : NPCTag(com.denizenscript.denizen.objects.NPCTag)

Example 8 with NPCTag

use of com.denizenscript.denizen.objects.NPCTag in project Denizen-For-Bukkit by DenizenScript.

the class SneakingTrait method stand.

/**
 * Makes the NPC stand
 */
public void stand() {
    // Notated in SittingTrait
    new NPCTag(npc).action("stand", null);
    NMSHandler.getEntityHelper().setSneaking(npc.getEntity(), false);
    sneaking = false;
}
Also used : NPCTag(com.denizenscript.denizen.objects.NPCTag)

Example 9 with NPCTag

use of com.denizenscript.denizen.objects.NPCTag in project Denizen-For-Bukkit by DenizenScript.

the class DenizenNPCHelper method onInventoryClick.

@EventHandler
public void onInventoryClick(InventoryClickEvent event) {
    Inventory inventory = event.getInventory();
    if (inventory.getHolder() instanceof NPCTag) {
        NPCTag npc = (NPCTag) inventory.getHolder();
        npc.getInventory().setContents(inventory.getContents());
        Equipment equipment = npc.getEquipmentTrait();
        for (int i = 0; i < 5; i++) {
            equipment.set(i, inventory.getItem(i));
        }
    }
}
Also used : Equipment(net.citizensnpcs.api.trait.trait.Equipment) NPCTag(com.denizenscript.denizen.objects.NPCTag) Inventory(org.bukkit.inventory.Inventory) EventHandler(org.bukkit.event.EventHandler)

Example 10 with NPCTag

use of com.denizenscript.denizen.objects.NPCTag in project Denizen-For-Bukkit by DenizenScript.

the class DenizenNPCHelper method despawn.

// <--[action]
// @Actions
// despawn
// @Triggers when the NPC is despawned.
// This can be because a command was issued, or a chunk has been unloaded.
// 
// @Context
// None
// -->
/**
 * Fires a world script event and then NPC action when the NPC despawns.
 *
 * @param event NPCDespawnEvent
 */
@EventHandler
public void despawn(NPCDespawnEvent event) {
    NPCTag npc = new NPCTag(event.getNPC());
    if (npc.isValid()) {
        EntityDespawnScriptEvent.instance.entity = new EntityTag(event.getNPC().getEntity());
        EntityDespawnScriptEvent.instance.cause = new ElementTag("CITIZENS");
        EntityDespawnScriptEvent.instance.fire(event);
        npc.action("despawn", null);
    }
}
Also used : NPCTag(com.denizenscript.denizen.objects.NPCTag) EntityTag(com.denizenscript.denizen.objects.EntityTag) ElementTag(com.denizenscript.denizencore.objects.core.ElementTag) EventHandler(org.bukkit.event.EventHandler)

Aggregations

NPCTag (com.denizenscript.denizen.objects.NPCTag)72 ElementTag (com.denizenscript.denizencore.objects.core.ElementTag)24 EventHandler (org.bukkit.event.EventHandler)22 PlayerTag (com.denizenscript.denizen.objects.PlayerTag)21 Player (org.bukkit.entity.Player)15 LocationTag (com.denizenscript.denizen.objects.LocationTag)12 EntityTag (com.denizenscript.denizen.objects.EntityTag)10 ListTag (com.denizenscript.denizencore.objects.core.ListTag)9 ScriptEntry (com.denizenscript.denizencore.scripts.ScriptEntry)8 HashMap (java.util.HashMap)8 NPC (net.citizensnpcs.api.npc.NPC)8 ObjectTag (com.denizenscript.denizencore.objects.ObjectTag)7 AssignmentTrait (com.denizenscript.denizen.npc.traits.AssignmentTrait)6 Location (org.bukkit.Location)6 TriggerTrait (com.denizenscript.denizen.npc.traits.TriggerTrait)5 BukkitScriptEntryData (com.denizenscript.denizen.utilities.implementation.BukkitScriptEntryData)5 DurationTag (com.denizenscript.denizencore.objects.core.DurationTag)5 ArrayList (java.util.ArrayList)5 List (java.util.List)5 Entity (org.bukkit.entity.Entity)5