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

SimpleAuth LoggedIn API?

Comments in 'Plugin Development' started by deot, Oct 13, 2015.

  1. deot
    Offline

    deot Active Member Plugin Developer

    Joined:
    Apr 22, 2015
    Posts:
    219
    Plugins:
    1
    Minecraft User:
    deot
    Hi, I would like to make PlayerChatEvent for logged in (SimpleAuth logged in) players only.
    Because for players didn't logged in, they need to type in password etc (Using SimpleAuthHelper)

    If I run PlayerChatEvent for players who haven't logged in yet will block thier message being sent to SimpleAuth Auth System :)

    So... Any solution?
    PHP:
    //Only run this PlayerChatEvent for SimpleAuth LoggedIn user only
    public function onChat(PlayerChatEvent $event){
            
    //CODE
    }
    Taha_The_Hacker likes this.
  2. Creeperface
    Offline

    Creeperface Notable Member Plugin Developer

    Joined:
    Nov 8, 2014
    Posts:
    1,346
    Plugins:
    4
    Minecraft User:
    CreeperFace
    PHP:
    //e.g. onEnable()
    $auth $this->getServer()->getPluginManager()->getPlugin("SimpleAuth");
    if(
    $auth instanceof Plugin && $auth->isEnabled()) $this->simpleAuth $auth;

    //in chat event
    if(!$this->simpleAuth->isPlayerAuthenticated($event->getPlayer()){
        
    $event->setCancelled();
    }
    jojoe77777, deot and AndrewBit like this.
  3. deot
    Offline

    deot Active Member Plugin Developer

    Joined:
    Apr 22, 2015
    Posts:
    219
    Plugins:
    1
    Minecraft User:
    deot
  4. AndrewBit
    Offline

    AndrewBit Notable Member

    Joined:
    Jun 18, 2015
    Posts:
    435
    Minecraft User:
    AndrewBit4
    Can you change the title to solved? :)
    Taha_The_Hacker likes this.
  5. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,294
    Plugins:
    11
    Minecraft User:
    PEMapModder
    SimpleAuth would cancel PlayerCommandPreprocessEvent, then PlayerChatEvent would not even be fired at all. Make sure your players don't have the simpleauth.chat permission when they are not logged in.
    Creeperface likes this.

Share This Page

Advertisement