How come my custom NPC code doesn't work

Discussion in 'Spigot Plugin Help' started by BossCode, Jul 1, 2021.

  1. So, I am trying to create some custom NPCs for a plugin I am working on, but for some reason this code is buggy and the npc will not spawn every time, just some times - if I disconnect then reconnect sometimes it spawns.

    Code (Java):

            MinecraftServer server = ((CraftServer)Bukkit.getServer()).getServer();
            WorldServer world = ((CraftWorld) Bukkit.getWorld("Lobby")).getHandle();

            GameProfile gameProfile = new GameProfile(UUID.fromString("28bba6d2-7dbb-489b-aed5-500768c9c185"), "DBoss45");
            selectNPC = new EntityPlayer(server, world, gameProfile, new PlayerInteractManager(world));

            selectNPC.setLocation(0.5, 1, 1.5, 180, 0);
     

    'npc' is just because it is a function, when it is called on player join 'npc' is just 'selectNPC' from before.
    Code (Java):

        MinecraftServer server = ((CraftServer)Bukkit.getServer()).getServer();
        WorldServer world = ((CraftWorld) Bukkit.getWorld("Lobby")).getHandle();

        GameProfile gameProfile = new GameProfile(UUID.fromString("28bba6d2-7dbb-489b-aed5-500768c9c185"), "DBoss45");
        selectNPC = new EntityPlayer(server, world, gameProfile, new PlayerInteractManager(world));

        selectNPC.setLocation(0.5, 1, 1.5, 180, 0);
     

    This is made for 1.8.9 (although I am using spigot 1.8.8) and I have watched some tutorials and that is where the code is from. I would like to be able to program this all myself with the help of tutorials and anyone who answers - and not have to use and API such as citizens.
     
  2. Please provide console log
     
  3. There are no messages appearing in the log.
    Just no NPC is visible, is visible in tab though.
     
  4. i think you need try debug
     
  5. What and where should the debug be?
     
  6. Code (Text):
    System.out.print(debug message);
     
  7. Yeah but where should I put that?
    And what should the message be?