/**
  * @param int $currentTick
  */
 public function onRun($currentTick)
 {
     if (!$this->plugin->isTimerPaused()) {
         if (Utils::isOverloaded($this->plugin->getMemoryLimit())) {
             $this->plugin->initiateRestart(RestartMe::OVERLOADED);
         }
     }
 }
 /** 
  * @param string $message
  * @param string $messageType
  */
 public function broadcastTime($message, $messageType)
 {
     $time = Utils::toArray($this->getTime());
     $outMessage = str_replace(["{RESTART_FORMAT_TIME}", "{RESTART_HOUR}", "{RESTART_MINUTE}", "{RESTART_SECOND}", "{RESTART_TIME}"], [$this->getFormattedTime(), $time[0], $time[1], $time[2], $this->getTime()], $message);
     switch (strtolower($messageType)) {
         case "chat":
             $this->getServer()->broadcastMessage($outMessage);
             break;
         case "popup":
             foreach ($this->getServer()->getOnlinePlayers() as $player) {
                 $player->sendPopup($outMessage);
             }
             break;
         case "tip":
             foreach ($this->getServer()->getOnlinePlayers() as $player) {
                 $player->sendTip($outMessage);
             }
             break;
     }
 }
 /**
  * @param CommandSender $sender
  * @param string $label
  * @param string[] $args
  * @return bool
  */
 public function execute(CommandSender $sender, $label, array $args)
 {
     if (!$this->testPermission($sender)) {
         return false;
     }
     if (isset($args[0])) {
         switch (strtolower($args[0])) {
             case "a":
             case "add":
                 if (isset($args[1])) {
                     if (is_numeric($args[1])) {
                         $time = (int) $args[1];
                         $this->plugin->addTime($time);
                         $sender->sendMessage(TextFormat::GREEN . "Added " . $time . " to restart timer.");
                     } else {
                         $sender->sendMessage(TextFormat::RED . "Time value must be numeric.");
                     }
                 } else {
                     $sender->sendMessage(TextFormat::RED . "Please specify a time value.");
                 }
                 return true;
             case "help":
                 $this->sendCommandHelp($sender);
                 return true;
             case "m":
             case "memory":
                 $memLimit = $this->plugin->getMemoryLimit();
                 $sender->sendMessage("Bytes: " . memory_get_usage(true) . "/" . Utils::calculateBytes($memLimit));
                 $sender->sendMessage("Memory-limit: " . $memLimit);
                 $sender->sendMessage("Overloaded: " . (Utils::isOverloaded($memLimit) ? TextFormat::GREEN . "yes" : TextFormat::RED . "no"));
                 return true;
             case "set":
                 if (isset($args[1])) {
                     if (is_numeric($args[1])) {
                         $time = (int) $args[1];
                         $this->plugin->setTime($time);
                         $sender->sendMessage(TextFormat::GREEN . "Set restart timer to " . $time . ".");
                     } else {
                         $sender->sendMessage(TextFormat::RED . "Time value must be numeric.");
                     }
                 } else {
                     $sender->sendMessage(TextFormat::RED . "Please specify a time value.");
                 }
                 return true;
             case "start":
                 if ($this->plugin->isTimerPaused()) {
                     $this->plugin->setPaused(false);
                     $sender->sendMessage(TextFormat::YELLOW . "Timer is no longer paused.");
                 } else {
                     $sender->sendMessage(TextFormat::RED . "Timer is not paused.");
                 }
                 return true;
             case "stop":
                 if ($this->plugin->isTimerPaused()) {
                     $sender->sendMessage(TextFormat::RED . "Timer is already paused.");
                 } else {
                     $this->plugin->setPaused(true);
                     $sender->sendMessage(TextFormat::YELLOW . "Timer has been paused.");
                 }
                 return true;
             case "s":
             case "subtract":
                 if (isset($args[1])) {
                     if (is_numeric($args[1])) {
                         $time = (int) $args[1];
                         $this->plugin->subtractTime($time);
                         $sender->sendMessage(TextFormat::GREEN . "Subtracted " . $time . " from restart timer.");
                     } else {
                         $sender->sendMessage(TextFormat::RED . "Time value must be numeric.");
                     }
                 } else {
                     $sender->sendMessage(TextFormat::RED . "Please specify a time value.");
                 }
                 return true;
             case "t":
             case "time":
                 $sender->sendMessage(TextFormat::YELLOW . "Time remaining: " . $this->plugin->getFormattedTime());
                 return true;
             default:
                 $sender->sendMessage("Usage: /restartme <sub-command> [parameters]");
                 return false;
         }
     } else {
         $this->sendCommandHelp($sender);
         return false;
     }
 }