Plugin Is Not Sending Message To Player

Discussion in 'Development' started by ethaniccc, Mar 14, 2020.

  1. ethaniccc

    ethaniccc Baby Zombie

    Messages:
    136
    GitHub:
    ethaniccc
    So, this is my function:
    PHP:
    public function onJoin(PlayerJoinEvent $event){
        
        
    $player $event->getPlayer();
        
    $name $player->getName();
        
            if(
    $player->hasPlayedBefore() == true){
                
    $player->sendMessage(TextFormat::BOLD TextFormat::GOLD "=======================");
                
    $player->sendMessage(TextFormat::BOLD TextFormat::GOLD "           Welcome back to " TextFormat::AQUA "Sky" TextFormat::WHITE "line" TextFormat::GOLD ", " TextFormat::WHITE $name TextFormat::GOLD "!");
                
    $player->sendMessage(TextFormat::BOLD TextFormat::GOLD "=======================");
            } else {
                
    $player->sendMessage(TextFormat::BOLD TextFormat::GOLD "=======================");
                
    $player->sendMessage(TextFormat::BOLD TextFormat::GOLD "           Welcome to " TextFormat::AQUA "Sky" TextFormat::WHITE "line" TextFormat::GOLD ", " TextFormat::WHITE $name TextFormat::GOLD "!");
                
    $player->sendMessage(TextFormat::BOLD TextFormat::GOLD "           Since this is your first time here, we recommend reading the rules of the server!");
                
    $player->sendMessage(TextFormat::BOLD TextFormat::GOLD "=======================");
            }       
        }
    I thought that would work, but for some reason it didn't do anything...
    Can anyone help me? Thanks!
     
  2. HimbeersaftLP

    HimbeersaftLP Fish

    Messages:
    2,362
    GitHub:
    HimbeersaftLP
    Did you forget to register your event listener?

    (btw if (sth == true) { do stuff } is kinda stupid most of the time, because you already have a boolean right there, just use if (sth) { do stuff })
     
    ethaniccc likes this.
  3. ethaniccc

    ethaniccc Baby Zombie

    Messages:
    136
    GitHub:
    ethaniccc
    Apparently I didn't, thanks for your help!
     
    HimbeersaftLP likes this.
  4. HimbeersaftLP

    HimbeersaftLP Fish

    Messages:
    2,362
    GitHub:
    HimbeersaftLP
    No problem, not registering the listener is probably the top PMMP pluhin development mistake that even pros make haha
     
    Invy55 likes this.

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.