EntityPlayer - how does it work really ?

Discussion in 'Plugin Development' started by Sammy, May 13, 2011.

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

    Sammy

    Hey everyone, I need a bit of a help ^^
    I'm trying to create a fake player to act as a bot so I'm using this src from EdwardHand (I think)
    Code:
            CraftServer cServer = (CraftServer) plugin.getServer();
            CraftWorld cWorld = (CraftWorld) p.getWorld();
            EntityPlayer fakeEntityPlayer = new EntityPlayer(cServer.getHandle().server,
                    cWorld.getHandle(), "tcmdsbot", new ItemInWorldManager(cWorld.getHandle()));
            fakeEntityPlayer.netServerHandler = ((CraftPlayer) p).getHandle().netServerHandler;
            Player TcmdsBot = (Player) fakeEntityPlayer.getBukkitEntity();
            TcmdsBot.setDisplayName("tcmdsbot");
    I changed it a bit but the problem is that it doesn't create a new player it gets the info from the "p" variable and transport it to the new "shell"

    I have a feeling that the problem is here:
    Code:
    fakeEntityPlayer.netServerHandler = ((CraftPlayer) p).getHandle().netServerHandler;
    I really need help =/
     
  2. Offline

    RazorFlint

    Hmmm, Iv only started programming a couple of weeks ago and i really don't know... Sorry. :(
     
  3. Offline

    Sammy

    I really need help so I can continue with my plugin :(
     
  4. Isn't the NPC api broken, if that's what your using?
     
  5. Offline

    Sammy

    No, I'm using craftbukkit to make a fake Entity with no physical representation
     
  6. Offline

    nisovin

    So... you're just creating a text bot? Why create an entity then?
     
  7. Offline

    Sammy

    No, I'm creating a bot that passes commands !
    Similar to the one on CommandSigns
     
  8. Offline

    nisovin

    But you said you're creating a bot with no physical representation. So why are you trying to create an entity, which is a physical item in the world? There shouldn't be any need to create an entity at all.
     
  9. Offline

    Crash

    Where did he say that ?
    He said he wanted to create a fake player to act as a bot.
     
  10. Offline

    nisovin

    Did you even read the thread?

     
  11. Offline

    Crash

    He's contradicting himself...
     
  12. Offline

    Sammy

    @Crash
    Can you tell me on my code were am I giving a physical representation to the entity ? I'm not spawning nothing I'm just making and entity so no I'm not contradicting myself...

    How can I pass a chat events without making a entity that pass them ? an no I don't want to be the players passing them, I suggest having a look at the CommandSings src
     
  13. Offline

    oliverw92

    I think what you are looking for is ConsoleCommandSender. You can create a new instance of it, check the constructor.
     
  14. Offline

    Sammy

    Every time I use a plugin to get ideas I just complicate things ^^
    This week I can't tackle it but maybe on the weekend (this one or the next)...
    Thanks @oliverw92 :p
     
  15. Offline

    oliverw92

    No worries :)
     
Thread Status:
Not open for further replies.

Share This Page