1. The forums will be archived and moved to a read only mode in about 2 weeks (mid march).

Server Shutdown

Discussion in 'Facepalm' started by RoyalMCPE, Jul 2, 2017.

  1. RoyalMCPE

    RoyalMCPE Slime

    Messages:
    87
    Question:
    How would I be able to detect when a server is shutting down, and transfer all players to a different server?
     
  2. Kyd

    Kyd Zombie Pigman

    Messages:
    678
    GitHub:
    boi1216
    PHP:
    if($this->getServer()->isRunning() == false){
     
  3. SOFe

    SOFe Administrator Staff Member PMMP Team Poggit Admin

    Messages:
    1,968
    GitHub:
    sof3
    You should do it in onDisable. You should never do anything after your plugin is disabled.
     
  4. Teamblocket

    Teamblocket Zombie

    Messages:
    301
    GitHub:
    teamblocket
    PHP:
        public function onDisable(){
            foreach(
    $this->getServer()->getOnlinePlayers() as $p){
                
    $p->transfer("ip""port""message?");
            }
        }
    will this work to transfer all players?
     
    Defications2po likes this.
  5. Kyd

    Kyd Zombie Pigman

    Messages:
    678
    GitHub:
    boi1216
    PHP:
      public function onDisable(){
            foreach(
    $this->getServer()->getOnlinePlayers() as $p){
            if(
    $this->getServer()->isRunning() == false){
                
    $p->transfer($ip$port$message);
                }
            }
        }
     
  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.