Ejemplo n.º 1
0
 /**
  * Handles the event.
  *
  * @param array $matches
  *
  * @return void
  */
 public function handle($matches)
 {
     list(, $sender, $message) = $matches;
     $handle = ['Round_Spawn', 'Round_Start', 'Round_End'];
     $key = array_search($message, $handle);
     if ($key !== false) {
         $func = 'handle';
         $func .= ucwords(camel_case($handle[$key]));
         $this->{$func}();
     } else {
         Logger::log("{$message} is not a handled event", Logger::LEVEL_DEBUG);
     }
 }
Ejemplo n.º 2
0
 /**
  * Handles the event.
  *
  * @param array $matches
  *
  * @return void
  */
 public function handle($matches)
 {
     $message = $matches[5];
     $handle = ['ready' => 'handleReady', 'r' => 'handleReady', 'unready' => 'handleUnready', 'pause' => 'handlePause', 'unpause' => 'handleUnpause', 'stay' => 'handleStay', 'switch' => 'handleSwitch', 'abort' => 'handleAbort'];
     $prefixes = ['.', '!'];
     if (array_search($message[0], $prefixes) === false) {
         Logger::log('prefix ' . $message[0] . ' does not match any of the specified prefixes', Logger::LEVEL_DEBUG);
         return;
     }
     if (isset($handle[substr($message, 1)])) {
         $this->{$handle[substr($message, 1)]}($matches);
     }
 }
Ejemplo n.º 3
0
 /**
  * Attempts to match a Regex pattern.
  *
  * @param string  $data
  * @param Handler $handler
  *
  * @return void
  */
 public function match($data, $handler)
 {
     $this->map = $this->map->fresh();
     foreach ($this->patterns as $regex) {
         if (isset($regex['ignore']) && $regex['ignore']) {
             continue;
         }
         if (isset($regex['in_game']) && $regex['in_game'] && !$this->map->inGame()) {
             continue;
         }
         if (preg_match($regex['pattern'], $data, $matches)) {
             (new $regex['class']($this->map, $this->rcon, $handler))->handle($matches);
             return;
         }
     }
     Logger::log("could not match data: {$data}", Logger::LEVEL_DEBUG);
 }
Ejemplo n.º 4
0
 /**
  * Runs the migrations.
  *
  * @return bool
  * @return void
  */
 public function run()
 {
     foreach ($this->migrations as $table => $migration) {
         Logger::log("Migrating `{$table}`");
         try {
             $migration = new $migration();
             Capsule::schema()->create($table, function ($table) use($migration) {
                 $migration->up($table);
             });
         } catch (FatalThrowableError $e) {
             Logger::log("Error migrating table `{$table}`: {$e->getMessage()}", Logger::LEVEL_ERROR);
         } catch (\PDOException $e) {
             Logger::log("Error migrating table `{$table}`: {$e->getMessage()}", Logger::LEVEL_ERROR);
         }
     }
     Logger::log('Finished migrating.');
     return true;
 }
Ejemplo n.º 5
0
 /**
  * Kills the timer to say !ready.
  *
  * @return void
  */
 public function killSayReady()
 {
     Logger::log('killing !ready timer', Logger::LEVEL_DEBUG);
     $this->loop->cancelTimer($this->timers['ready']);
 }