Detecting when the server is shutting down from a plugin

Discussion in 'Resources' started by dktapps, Jul 21, 2017.

  1. dktapps

    dktapps Administrator Staff Member PMMP Team

    Messages:
    676
    GitHub:
    dktapps
    This is far easier than most people believe. No need for any events, simply

    Code:
    public function onDisable(){
        if(!$this->getServer()->isRunning()){
            //do things on server shutdown
        }else{
            //reload, plugin disabled or server crashed
        }
    }
    
    in your PluginBase.

    Do note however that this will not work in the event of a server crash, as the server is still judged to be "running" if it did not shut down correctly.
     
  2. Levi

    Levi Zombie Pigman

    Messages:
    615
    GitHub:
    captainleviftw
    how do you get Player on onDisable()?
     
  3. TheDeibo

    TheDeibo Moderator Staff Member Poggit Reviewer Verified

    Messages:
    344
    GitHub:
    thedeibo
    Please explain what you mean, as I am unsure what you mean.
     
  4. Levi

    Levi Zombie Pigman

    Messages:
    615
    GitHub:
    captainleviftw
    so, I want to transfer the player to a different server when my server shut down but I don't know how to get the Player
     
  5. TheDeibo

    TheDeibo Moderator Staff Member Poggit Reviewer Verified

    Messages:
    344
    GitHub:
    thedeibo
    That is a completely different topic to what dktapps has started.
    Please create that topic separately , as it helps for another user to search for the same issue as you.
     
    SOFe, iiFlamiinBlaze and Thunder33345 like 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.