Citizens API Help.

Discussion in 'Spigot Plugin Development' started by PistoFrancoPuumm, May 11, 2016.

  1. hello, i'm searching in all types of sources, how i can spawn a NPC and Despawn him with /NPCcontrol spawn
    and /NPCcontrol despawn

    guys, can you help me, im searching in CitizensAPI and Javadoc but i don't search nothing...
    now i have this
    Code (Text):

    package me.PistoFranco;

    import org.bukkit.command.Command;
    import org.bukkit.command.CommandSender;
    import org.bukkit.entity.EntityType;
    import org.bukkit.entity.Player;
    import org.bukkit.plugin.java.JavaPlugin;

    import net.citizensnpcs.api.CitizensAPI;
    import net.citizensnpcs.api.npc.NPC;
    import net.citizensnpcs.npc.CitizensNPC;

    public class Main extends JavaPlugin{
        public void onEnable(){

        }
        public void onDisable(){

        }

        public boolean onCommand(CommandSender sender, Command cmd, String lbl, String[] args){
            Player player = (Player) sender;
            if(lbl.equalsIgnoreCase("NPCcontrol")){
                if(args[0].equalsIgnoreCase("spawn")){
                        NPC npc = CitizensAPI.getNPCRegistry().createNPC(EntityType.PLAYER, player.getName());
                        npc.spawn(player.getLocation());
                        }
                if(args[0].equalsIgnoreCase("despawn")){
                }
            }
            return true;}
    }

     
    i hope you can help me, i know Citizens is a little bit difficult but, i hope you can help me <3
     
    #1 PistoFrancoPuumm, May 11, 2016
    Last edited: May 11, 2016
  2. I think i need to comunicate beetween methods... sorry about this NOOB question but, how i do that (im so sad) :c
     
  3. I'm not sure how to answer your question, but if you want the NPC to be destroyed later, you can store it to a HashMap or something and then restore it and despawn it.
     
    • Useful Useful x 1
  4. i go to try it, thank you for you help!
     
    • Friendly Friendly x 1