Example #1
0
 public function commandFormSubmitted(Nette\Application\UI\Form $form)
 {
     $command = $form->getValues()->command;
     $this->serverCmd->issueCommand($command, $this->runtimeHash);
     //TODO make it less ugly and more reliable
     usleep(500000);
     if ($this->isAjax()) {
         $this->redrawControl();
     } else {
         $this->redirect('this');
     }
 }
 /**
  * @param string $filename
  */
 public function handleUseFile($filename)
 {
     if ($this->serverCmd->isServerRunning($this->runtimeHash)) {
         $this->serverCmd->stopServer($this->runtimeHash);
         $this->flashMessage('Server byl vypnut.', 'info');
     }
     $this->serverRepo->setExecutable($this->selectedServerId, $filename);
     $this->flashMessage('Verze nastavena úspěšně.', 'success');
     if ($this->isAjax()) {
         $this->redrawControl();
         $this->redrawControl('runIcon');
     } else {
         $this->redirect('this');
     }
 }
Example #3
0
 /**
  * stops server, delete world/, restore backup, and start server
  * stoping and starting server will be omitted if the server is down
  * @param string $path to minecraft folder ('backup/' will be added automaticaly)
  * @param string $filename name of the backup file
  * @param string $runtimeHash if is server running
  * @param string $jar name of jar file to run, needed only on running server
  * @return boolean TRUE when successful
  */
 public function restore($path, $filename, $runtimeHash = NULL, $jar = NULL)
 {
     if (file_exists($path . 'backups/' . $filename)) {
         if ($runtimeHash !== NULL) {
             //stop server
             $this->serverCmd->stopServer($runtimeHash);
         }
         //delete world/
         $this->removeDir($path . 'world/');
         //extract backup archive
         try {
             $archive = new PharData($path . 'backups/' . $filename);
             $archive->extractTo($path . 'world/', NULL, TRUE);
         } catch (UnexpectedValueException $e) {
             echo $e->getTraceAsString();
             return FALSE;
         }
         if ($runtimeHash !== NULL) {
             //start server again
             $this->serverCmd->startServer($path, $jar, $runtimeHash);
             return TRUE;
         }
         return TRUE;
     } else {
         //no such file
         return FALSE;
     }
 }
Example #4
0
 /**
  * @param string $command 'op' | 'deop'
  * @param int $userId
  * @param string $runhash
  */
 private function callCommand($command, $userId, $runhash)
 {
     $mcname = $this->userRepo->findById($userId)->fetch()->mcname;
     $this->serverComm->issueCommand($command . ' ' . $mcname, $runhash);
 }