.kickPlayer errors

Discussion in 'Plugin Development' started by Danza, Mar 11, 2011.

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

    Danza

    Code:
    @Override
        public void onPlayerJoin(PlayerEvent event){
    
            if (plugin.isBanned(event.getPlayer())==true){
    
                event.getPlayer().kickPlayer("You are banned from this server!");
            }
        }
    in first time when player trying to connect - everything is normal, but if he try it more times, i see this in console(+100500 times):
    what im doing wrong?

    PS sry for my english
     
  2. Offline

    AnjoCaido

    I really wanted to know that too :(

    It can slow down the server a bit if the player tries to come back thousand times.
     
  3. Offline

    Edward Hand

    Ah. I've investigated this error before. It happens because the onPlayerJoin event is called before the player is actually added into the game world. When you kick the player it tries to remove them from the game world and if they're not there it gets upset.

    What you need to do is use the onPlayerLogin event and set:
    Code:
    theLoginEvent.setResult(Result.KICK_BANNED);
    and it should work fine.
     
  4. Offline

    AnjoCaido

    Damn. That's bad. Because when PlayerLoginEvent is called, there is no enough data(IP address) for me to kick the guy. Is there any other thing I can do?

    ---
    Maybe I schedule the kick to around 100 ticks after the Join. That could fix it. It's an horrible workaround. But if anyone have other idea.
     
Thread Status:
Not open for further replies.

Share This Page