NpcSpawner lib - spawn basic NPCs

Discussion in 'Resources' started by Redecouverte, Feb 3, 2011.

Thread Status:
Not open for further replies.
  1. Offline

    Derek Peterson

    I'm getting NullPointerExceptions from the latest from https://github.com/Top-Cat/NPCLib, is that to be expected?

    [edit] I should note that I'm getting them when I try to initialize NPCManager:

    Code:
    16:10:46 [SEVERE] null
    java.lang.NullPointerException
    	at org.martin.bukkit.npclib.BServer.<init>(BServer.java:35)
    	at org.martin.bukkit.npclib.BServer.getInstance(BServer.java:119)
    	at org.martin.bukkit.npclib.NPCManager.<init>(NPCManager.java:37)
    	at com.derekpeterson.Plugin.Plugin.<init>(Plugin.java:37)
    	at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    	at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
    	at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
    	at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
    	at org.bukkit.plugin.java.JavaPluginLoader.loadPlugin(JavaPluginLoader.java:173)
    	at org.bukkit.plugin.SimplePluginManager.loadPlugin(SimplePluginManager.java:213)
    	at org.bukkit.plugin.SimplePluginManager.loadPlugins(SimplePluginManager.java:136)
    	at org.bukkit.craftbukkit.CraftServer.loadPlugins(CraftServer.java:135)
    	at org.bukkit.craftbukkit.CraftServer.<init>(CraftServer.java:102)
    	at net.minecraft.server.ServerConfigurationManager.<init>(ServerConfigurationManager.java:51)
    	at net.minecraft.server.MinecraftServer.init(MinecraftServer.java:133)
    	at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:337)
    	at net.minecraft.server.ThreadServerApplication.run(SourceFile:422)
     
  2. Offline

    Top_Cat

    Only if you're passing it null... can i see your code?
     
  3. Offline

    Derek Peterson

    Aha, I found the problem. I was trying to initialize it up by my listeners, which is before plugin.getServer() will work. I declared it up there, and am now initializing it in onEnable, and it's working great! Thank you!

    Is there any way I can get a LivingEntity out of an NPCEntity so I can change its skin using SpoutAPI?
     
  4. Offline

    Top_Cat

    NPCEntity is a living entity....
     
  5. Offline

    Derek Peterson

    java.lang.ClassCastException: org.martin.bukkit.npclib.NPCEntity cannot be cast to org.bukkit.entity.LivingEntity
    at com.derekpeterson.Plugin.Plugin.spawnNpc(Plugin.java:1288)
    at com.derekpeterson.Plugin.PluginPlayerListener.onPlayerMove(PluginPlayerListener.java:96)
    at org.bukkit.plugin.java.JavaPluginLoader$7.execute(JavaPluginLoader.java:286)
    at org.bukkit.plugin.RegisteredListener.callEvent(RegisteredListener.java:58)
    at org.bukkit.plugin.SimplePluginManager.callEvent(SimplePluginManager.java:338)
    at net.minecraft.server.NetServerHandler.a(NetServerHandler.java:174)
    at org.getspout.spout.SpoutNetServerHandler.a(SpoutNetServerHandler.java:592)
    at net.minecraft.server.Packet10Flying.a(SourceFile:126)
    at net.minecraft.server.NetworkManager.b(NetworkManager.java:226)
    at net.minecraft.server.NetServerHandler.a(NetServerHandler.java:89)
    at org.getspout.spout.SpoutNetServerHandler.a(SpoutNetServerHandler.java:478)
    at net.minecraft.server.NetworkListenThread.a(SourceFile:105)
    at net.minecraft.server.MinecraftServer.h(MinecraftServer.java:453)
    at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:363)
    at net.minecraft.server.ThreadServerApplication.run(SourceFile:422)


    Aha, npcEntity.getBukkitEntity() returns a HumanEntity!

    Ok I do have one final question. Ever since adding this library, I get this message on reloading:

    Code:
    17:44:19 [SEVERE] Nag author: '<derekpeterson>' of 'NightfallMC' about the following: This plugin is not properly shutting down its async tasks when it is being reloaded.  This may cause conflicts with the newly loaded version of the plugin
    I never had this show up before, could it be something is outdated in the library?

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: May 8, 2016
  6. Offline

    tips48

    /me nags @Top_Cat to add Spout support :3
     
  7. Offline

    Top_Cat

    I can only reply as above, if you're sending it your plugin then it'll work fine...
     
  8. Offline

    sddddgjd

    @Top_Cat
    You should know 1.8 broke the npclib :(
    Hope you can fix it!
     
  9. Offline

    Top_Cat

    I know, I have other priorities but it will be fixed :)
     
    sddddgjd likes this.
  10. Offline

    Kekec852

    Lolmewn likes this.
  11. Offline

    mixxit

    ah this is great, i was going to post about

    java.lang.NoSuchMethodError: net.minecraft.server.ItemInWorldManager.<init>(Lnet/minecraft/server/WorldServer;)V
     
  12. Offline

    sddddgjd

    Sometimes this happens:
    Code:
    
    2011-09-16 23:11:46 [SEVERE] java.lang.NullPointerException
    2011-09-16 23:11:46 [SEVERE] 	at net.minecraft.server.AxisAlignedBB.b(SourceFile:27)
    2011-09-16 23:11:46 [SEVERE] 	at net.minecraft.server.Block.e(Block.java:261)
    2011-09-16 23:11:46 [SEVERE] 	at net.minecraft.server.Block.a(Block.java:253)
    2011-09-16 23:11:46 [SEVERE] 	at net.minecraft.server.World.getEntities(World.java:938)
    2011-09-16 23:11:46 [SEVERE] 	at net.minecraft.server.Entity.move(Entity.java:399)
    2011-09-16 23:11:46 [SEVERE] 	at net.minecraft.server.EntityLiving.a(EntityLiving.java:650)
    2011-09-16 23:11:46 [SEVERE] 	at net.minecraft.server.EntityLiving.s(EntityLiving.java:803)
    2011-09-16 23:11:46 [SEVERE] 	at net.minecraft.server.EntityMonster.s(EntityMonster.java:27)
    2011-09-16 23:11:46 [SEVERE] 	at net.minecraft.server.EntityLiving.s_(EntityLiving.java:266)
    2011-09-16 23:11:46 [SEVERE] 	at net.minecraft.server.EntityMonster.s_(EntityMonster.java:31)
    2011-09-16 23:11:46 [SEVERE] 	at net.minecraft.server.EntityCreeper.s_(EntityCreeper.java:68)
    2011-09-16 23:11:46 [SEVERE] 	at net.minecraft.server.World.entityJoinedWorld(World.java:1186)
    2011-09-16 23:11:46 [SEVERE] 	at net.minecraft.server.WorldServer.entityJoinedWorld(WorldServer.java:48)
    2011-09-16 23:11:46 [SEVERE] 	at net.minecraft.server.World.playerJoinedWorld(World.java:1168)
    2011-09-16 23:11:46 [SEVERE] 	at net.minecraft.server.World.cleanUp(World.java:1083)
    2011-09-16 23:11:46 [SEVERE] 	at net.minecraft.server.MinecraftServer.h(MinecraftServer.java:460)
    2011-09-16 23:11:46 [SEVERE] 	at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:374)
    2011-09-16 23:11:46 [SEVERE] 	at net.minecraft.server.ThreadServerApplication.run(SourceFile:417)
    2011-09-16 23:11:46 [SEVERE] Unexpected exception
    java.lang.NullPointerException
    	at net.minecraft.server.AxisAlignedBB.b(SourceFile:27)
    	at net.minecraft.server.Block.e(Block.java:261)
    	at net.minecraft.server.Block.a(Block.java:253)
    	at net.minecraft.server.World.getEntities(World.java:938)
    	at net.minecraft.server.Entity.move(Entity.java:399)
    	at net.minecraft.server.EntityLiving.a(EntityLiving.java:650)
    	at net.minecraft.server.EntityLiving.s(EntityLiving.java:803)
    	at net.minecraft.server.EntityMonster.s(EntityMonster.java:27)
    	at net.minecraft.server.EntityLiving.s_(EntityLiving.java:266)
    	at net.minecraft.server.EntityMonster.s_(EntityMonster.java:31)
    	at net.minecraft.server.EntityCreeper.s_(EntityCreeper.java:68)
    	at net.minecraft.server.World.entityJoinedWorld(World.java:1186)
    	at net.minecraft.server.WorldServer.entityJoinedWorld(WorldServer.java:48)
    	at net.minecraft.server.World.playerJoinedWorld(World.java:1168)
    	at net.minecraft.server.World.cleanUp(World.java:1083)
    	at net.minecraft.server.MinecraftServer.h(MinecraftServer.java:460)
    	at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:374)
    	at net.minecraft.server.ThreadServerApplication.run(SourceFile:417)
    
    
    Followed shortly by tons of errors regarding line 44 of NPCManager,nullpointerexception apparently!
    Could be bukkit bug though...
     
  13. Offline

    sddddgjd

    @Top_Cat
    I know it's not in your priorities,i understand you're busy with Spout and stuff...but is there any way to move npcs right now? I mean,make them move from one location to another...
     
  14. Offline

    Top_Cat

    There are pathfinding methods in the lib using A*
     
  15. Offline

    sddddgjd

    Sorry,never compiled using craftbukkit before...how do i access it? I have the NPCEntity,but the only method with a capital A seems to be A(),which doesn't seem to do anything...
     
  16. Offline

    Top_Cat

    A* is the algorithm not the function name.
    NPCEntity.pathFindTo(location, maxIterations)
     
  17. Offline

    Lolmewn Retired Staff

    how can I check if a Entity that has been hit is a NPC, and not another player?
     
  18. Offline

    Top_Cat

  19. Offline

    Lolmewn Retired Staff

  20. Offline

    Trc202

    Double thanks as this was asked and answered just as I needed it.
     
  21. Offline

    Mariusz

  22. Offline

    Lolmewn Retired Staff

    It seems that whenever an NPC spawns it sais "Read Timed Out".
    The NPC is there, however.
     
  23. Offline

    dralletje

    you know, you are amazing :D
    this is great :)
     
  24. Offline

    ashtheking

    Hey, I have a bug to report / question to ask.

    PHP:
      if(rand.nextInt(10) == 0)
         ((
    Player)npc.getBukkitEntity()).chat("The hive rules all! Kill Kill Kill!");
    Seems to give this exception:
    PHP:
    java.lang.NullPointerException
          at org
    .bukkit.event.player.PlayerChatEvent.<init>(PlayerChatEvent.java:25)
          
    at org.bukkit.event.player.PlayerChatEvent.<init>(PlayerChatEvent.java:20)
          
    at net.minecraft.server.NetServerHandler.chat(NetServerHandler.java:726)
          
    at org.bukkit.craftbukkit.entity.CraftPlayer.chat(CraftPlayer.java:208)
    (I'm using java, but the PHP code tag has proper syntax highlighting, so..)

    @Top_Cat
     
  25. Offline

    ashtheking

    Never Mind, I found a work around.
     
  26. Offline

    kTrn

    Hello, does it make sense to you?
     
  27. Offline

    NeoSilky

    Has anybody had errors in these classes:

    BServer and NPCNetworkManager

    they seem to have errors in the methods?
     
  28. Offline

    Top_Cat

    Care to be more specific?
     
  29. Offline

    NeoSilky


    Sure, here, i think i fixed it by doing the things i say, but i'm not sure it's right?

    NPCNetworkManager:

    Code:
     @Override
        public void a(Packet packet) {
        }
    <<<says it must override or implement a supertype, i removed the @Override and it worked>>>

    BServer:

    Code:
    public void stop() {
            mcServer.a();
        }
    <<<error under the a, and it was referring to the server, to i guessed it stopped it, and i removed the.a for .stop();>>>

    Code:
    public int getSpawnProtationRadius() {
            return mcServer.spawnProtection;
        }
    <<<just says it cant find any reference of spawnprotection, so i just removed it :p>>>


    I wish i knew more about this, I want it to work for myself and others :p

    in the main class, i had

    public final NPCManager npcmanager = new NPCManager(this);

    but i read you should put it in onEnable, so i put itin, and it won't let me have public, only final.

    Any ideas? :p

    PS. you should write a guide to this ;)

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: May 8, 2016
  30. Offline

    Top_Cat

    The first issue is because you have not have the latest version of the lib, do NOT remove @Overrides if they are causing errors, they should be dealt with properly ie the correct method name should be found. Removing the annotation breaks things.

    The second issue is that a field cannot be public inside a function and it cannot be final if not defined in the constructor. Basic java, learn it.
     
Thread Status:
Not open for further replies.

Share This Page