Examples of NPC


Examples of net.citizensnpcs.api.npc.NPC

        // Report to dB
        dB.report(scriptEntry, getName(),
                aH.debugObj("NPC", ((BukkitScriptEntryData)scriptEntry.entryData).getNPC().toString()) +
                        aH.debugObj("Toggle", toggle.toString()));

        NPC npc = ((BukkitScriptEntryData)scriptEntry.entryData).getNPC().getCitizen();

        boolean vulnerable;

        if (toggle == Toggle.TOGGLE)
            vulnerable = !npc.data().get(NPC.DEFAULT_PROTECTED_METADATA, true);

        else vulnerable = Boolean.valueOf(toggle.toString());

        npc.data().set(NPC.DEFAULT_PROTECTED_METADATA, !vulnerable);
    }
View Full Code Here

Examples of net.citizensnpcs.api.npc.NPC

        Element name = (Element) scriptEntry.getObject("name");

        dB.report(scriptEntry, getName(), name.debug());

        NPC npc = ((BukkitScriptEntryData)scriptEntry.entryData).getNPC().getCitizen();

        Location prev = npc.isSpawned() ? npc.getEntity().getLocation() : null;
        npc.despawn(DespawnReason.PENDING_RESPAWN);
        npc.setName(name.asString().length() > 100 ? name.asString().substring(0, 100): name.asString());
        if (prev != null)
            npc.spawn(prev);

    }
View Full Code Here

Examples of net.citizensnpcs.api.npc.NPC

        // Report to dB
        dB.report(scriptEntry, getName(), state.debug() + target.debug());

        if (target.isNPC()) {
            NPC npc = target.getDenizenNPC().getCitizen();
            if (!npc.hasTrait(InvisibleTrait.class))
                npc.addTrait(InvisibleTrait.class);
            InvisibleTrait trait = npc.getTrait(InvisibleTrait.class);
            switch (Action.valueOf(state.asString().toUpperCase())) {
                case FALSE:
                    trait.setInvisible(false);
                    break;
                case TRUE:
View Full Code Here

Examples of net.citizensnpcs.api.npc.NPC

    @Override
    public void execute(ScriptEntry scriptEntry) throws CommandExecutionException {

        Element toggle = scriptEntry.getElement("state");
        Element traitName = scriptEntry.getElement("trait");
        NPC npc = ((BukkitScriptEntryData)scriptEntry.entryData).getNPC().getCitizen();

        dB.report(scriptEntry, getName(),
                    traitName.debug() +
                    toggle.debug() +
                    ((BukkitScriptEntryData)scriptEntry.entryData).getNPC().debug());

        Class<? extends Trait> trait = CitizensAPI.getTraitFactory().getTraitClass(traitName.asString());

        if (trait == null) {
            dB.echoError(scriptEntry.getResidingQueue(), "Trait not found: " + traitName.asString());
            return;
        }

        switch (Toggle.valueOf(toggle.asString())) {

            case TRUE:
            case ON:
                if (npc.hasTrait(trait))
                    dB.echoError(scriptEntry.getResidingQueue(), "NPC already has trait '" + traitName.asString() + "'");
                else
                    npc.addTrait(trait);
                break;

            case FALSE:
            case OFF:
                if (!npc.hasTrait(trait))
                    dB.echoError(scriptEntry.getResidingQueue(), "NPC does not have trait '" + traitName.asString() + "'");
                else
                    npc.removeTrait(trait);
                break;

            case TOGGLE:
                if (npc.hasTrait(trait))
                    npc.removeTrait(trait);
                else
                    npc.addTrait(trait);
                break;

        }

    }
View Full Code Here

Examples of net.citizensnpcs.api.npc.NPC

     *
     * @param event NPCRemoveEvent
     */
    @EventHandler
    public void onRemove(NPCRemoveEvent event) {
        NPC npc = event.getNPC();
        getDenizen(npc).action("remove", null);
        if (_isRegistered(npc)) {
            denizenNPCs.remove(npc.getId());
            npcInventories.remove(npc.getId());
        }
        dB.log(ChatColor.RED + "Deconstructing Denizen NPC " + npc.getName() + "/" + npc.getId());
        FlagManager.clearNPCFlags(npc.getId());
    }
View Full Code Here

Examples of net.citizensnpcs.api.npc.NPC

    public Set<NPC> getActiveNPCsWithinRangeWithTrigger (Location location, int maxRange) {
        Set<NPC> closestNPCs = new HashSet<NPC> ();

        Iterator<NPC>    it = CitizensAPI.getNPCRegistry().iterator();
        while (it.hasNext ()) {
            NPC    npc = it.next ();
            if (npc.isSpawned()
                    && npc.getEntity().getLocation().getWorld().equals(location.getWorld())
                    && npc.getEntity().getLocation().distance(location) < maxRange
                    && npc.hasTrait(TriggerTrait.class)
                    && npc.getTrait(TriggerTrait.class).isEnabled(name)) {
                closestNPCs.add (npc);
            }
        }

        return closestNPCs;
View Full Code Here

Examples of net.citizensnpcs.api.npc.NPC

    public void setInfected(boolean bool) {

        if (bool) {
            if (infected.isNPC()) {
                NPC infected_npc = infected.getDenizenNPC().getCitizen();
                infected_npc.setBukkitEntityType(EntityType.ZOMBIE);
                if (!infected_npc.getTrait(ZombieModifier.class).toggleVillager())
                    infected_npc.getTrait(ZombieModifier.class).toggleVillager();
            }

            // If it's a Villager, we need to spawn a Zombie instead.
            // This is kind of messy, and can be improved upon.
            // TODO: Improve upon.
View Full Code Here

Examples of net.citizensnpcs.api.npc.NPC

    }

    public void setBaby(boolean bool) {
        if (ageable.isNPC()) {
            NPC ageable_npc = ageable.getDenizenNPC().getCitizen();
            if (!ageable_npc.hasTrait(Age.class))
                ageable_npc.addTrait(Age.class);
            ageable_npc.getTrait(Age.class).setAge(bool ? -24000 : 0);
        }
        else {
            if (ageable.getBukkitEntity().getType() == EntityType.ZOMBIE)
                ((Zombie) ageable.getBukkitEntity()).setBaby(bool);
View Full Code Here

Examples of net.citizensnpcs.api.npc.NPC

        }
    }

    public void setAge(int val) {
        if (ageable.isNPC()) {
            NPC ageable_npc = ageable.getDenizenNPC().getCitizen();
            ageable_npc.getTrait(Age.class).setAge(val);
        }
        else {
            if (ageable.getBukkitEntity().getType() == EntityType.ZOMBIE)
                ((Zombie) ageable.getBukkitEntity()).setBaby(val >= 0);
            else
View Full Code Here

Examples of net.citizensnpcs.api.npc.NPC

        ////////
        // Match NPC id

        string = string.toUpperCase().replace("N@", "");
        NPC npc;
        if (aH.matchesInteger(string)) {
            int id = aH.getIntegerFrom(string);

            if (dNPCRegistry._isRegistered(id))
                return dNPCRegistry.getDenizen(id);
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.