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

PlayerQuitEvent doesn't work correctly

Comments in 'Plugin Development' started by CraftYourBukkit, May 16, 2015.

  1. CraftYourBukkit
    Offline

    CraftYourBukkit Notable Member Plugin Developer

    Joined:
    Jan 20, 2015
    Posts:
    1,022
    Plugins:
    2
    Minecraft User:
    CraftYourBukkit
    I want to set the Quit Message with Permission but it only sets it for Ops, code:
    PHP:
    public function onLeave(PlayerQuitEvent $event){
                
    $player $event->getPlayer();
                if(!
    $player->hasPermission("permission.permission")|| !$player->isOp()){
                    
    $event->setQuitMessage("");
                } else{
                    
    $event->setQuitMessage($player->getName() . " joined the game");
                }
            }
  2. EvolSoft
    Offline

    EvolSoft Notable Member Plugin Developer

    Joined:
    Sep 10, 2014
    Posts:
    821
    Plugins:
    15
    Minecraft User:
    Flavius12
    I don't understand well what you want to do. Do you want to set the message only for OPs?
    RekkuzaRage likes this.
  3. iiDeathStrokeii
    Offline

    iiDeathStrokeii Active Member

    Joined:
    Mar 30, 2015
    Posts:
    111
    Minecraft User:
    iiDeathstrokeii
    If its onLeave why does the else statement say joined, should it not be left
  4. iJoshuaHD
    Offline

    iJoshuaHD Notable Member Plugin Developer

    Joined:
    Nov 7, 2013
    Posts:
    1,196
    Plugins:
    4
    Minecraft User:
    iJoshuaHD
    because the player doesnt have the permission?
  5. CraftYourBukkit
    Offline

    CraftYourBukkit Notable Member Plugin Developer

    Joined:
    Jan 20, 2015
    Posts:
    1,022
    Plugins:
    2
    Minecraft User:
    CraftYourBukkit
    The message is judt an example. I want to set a custom message to players with a permission but if I do so, the permission doesn't work but Ops have the custom message. It works at PlayerJoinEvent tho
  6. EvolSoft
    Offline

    EvolSoft Notable Member Plugin Developer

    Joined:
    Sep 10, 2014
    Posts:
    821
    Plugins:
    15
    Minecraft User:
    Flavius12
    Your code is wrong.
    This should work:
    PHP:
    public function onLeave(PlayerQuitEvent $event){
                
    $player $event->getPlayer();
                if(!
    $player->hasPermission("permission.permission") && !$player->isOp()){
                    
    $event->setQuitMessage("");
                } else{
                    
    $event->setQuitMessage($player->getName() . " joined the game");
                }
            }
    Or better
    PHP:
    public function onLeave(PlayerQuitEvent $event){
                
    $player $event->getPlayer();
                if(
    $player->hasPermission("permission.permission") || $player->isOp()){
                    
    $event->setQuitMessage($player->getName() . " joined the game");
                } else{
                    
    $event->setQuitMessage("");
                }
            }
  7. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,306
    Plugins:
    11
    Minecraft User:
    PEMapModder
    What is the point of checking whether the player is op when you already checked whether the player has the permission?

Share This Page

Advertisement