Advertisement
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

PreLogin and Login event

Comments in 'Plugin Development' started by Creeperface, Sep 28, 2015.

  1. Creeperface
    Offline

    Creeperface Notable Member Plugin Developer

    Joined:
    Nov 8, 2014
    Posts:
    1,346
    Plugins:
    4
    Minecraft User:
    CreeperFace
    why when i cancel PreLogin event so server calls login avent after that?
  2. Svile
    Offline

    Svile Active Member

    Joined:
    Mar 30, 2015
    Posts:
    239
    Minecraft User:
    svile
    IDK ... why you need to cancel this event?
  3. Creeperface
    Offline

    Creeperface Notable Member Plugin Developer

    Joined:
    Nov 8, 2014
    Posts:
    1,346
    Plugins:
    4
    Minecraft User:
    CreeperFace
    if player with the same name already playing
  4. Svile
    Offline

    Svile Active Member

    Joined:
    Mar 30, 2015
    Posts:
    239
    Minecraft User:
    svile
    PHP:
    Public function onPreLogin(PlayerPreLoginEvent $event){$event->getPlayer()->close();}
  5. Gamecrafter
    Offline

    Gamecrafter

    Joined:
    Nov 20, 2014
    Posts:
    978
    Plugins:
    9
    I don't understand what you're trying to say. Please speak(or in this case, type) more clearly.
    That isn't enough, that will kick all players when before they login. You need a condition:
    PHP:
    public function onPlayerPreLogin(PlayerPreLoginEvent $event){
        if(
    $server->getPlayer($event->getPlayer()) !== null){
            
    $event->getPlayer()->close("""Already logged in"); //kicks the player that is trying to login
        
    }
    }
    EDIT: DO NOT USE THE CODE, IT IS INCORRECT.
    Last edited: Sep 29, 2015
  6. Creeperface
    Offline

    Creeperface Notable Member Plugin Developer

    Joined:
    Nov 8, 2014
    Posts:
    1,346
    Plugins:
    4
    Minecraft User:
    CreeperFace
    hm i should use $player->kick();
  7. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,294
    Plugins:
    11
    Minecraft User:
    PEMapModder
    What are you even trying to do? Server::getPlayer(Player)? :screams:

    BTW, you should simply cancel the event and the player will be kicked. You do not need to explicitly kick the player.
  8. Kvetinac97
    Offline

    Kvetinac97 Active Member Plugin Developer

    Joined:
    Nov 17, 2014
    Posts:
    276
    Plugins:
    1
    Minecraft User:
    Kvetinac97
    Use
    PHP:
    $server->getPlayerExact($player);
    PianoPlayer38 likes this.
  9. Creeperface
    Offline

    Creeperface Notable Member Plugin Developer

    Joined:
    Nov 8, 2014
    Posts:
    1,346
    Plugins:
    4
    Minecraft User:
    CreeperFace
    but in simpleAuth is not just $e->setCancelled() but $player->kick(); too :D
    PianoPlayer38 likes this.
  10. Kvetinac97
    Offline

    Kvetinac97 Active Member Plugin Developer

    Joined:
    Nov 17, 2014
    Posts:
    276
    Plugins:
    1
    Minecraft User:
    Kvetinac97
    I think shighicp is better than PEMapModder (#blameshoghi), so I think using $p->kick(); should be better
    PianoPlayer38 likes this.
  11. Gamecrafter
    Offline

    Gamecrafter

    Joined:
    Nov 20, 2014
    Posts:
    978
    Plugins:
    9
    Oops, I didn't check the code. Anyways I'm too lazy to fix it, I'll just label it as wrong.
  12. Kvetinac97
    Offline

    Kvetinac97 Active Member Plugin Developer

    Joined:
    Nov 17, 2014
    Posts:
    276
    Plugins:
    1
    Minecraft User:
    Kvetinac97
    Everybody makes this stupid errors.
    PianoPlayer38 likes this.
  13. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,294
    Plugins:
    11
    Minecraft User:
    PEMapModder
    But SimpleAuth cancels the event too :p
    PianoPlayer38 likes this.
  14. Creeperface
    Offline

    Creeperface Notable Member Plugin Developer

    Joined:
    Nov 8, 2014
    Posts:
    1,346
    Plugins:
    4
    Minecraft User:
    CreeperFace
    Yes me too but when i cancel it so it kicks player but calls login Event too

Share This Page

Advertisement