/**
  * @param string $key
  * @param string $lang
  *
  * @return Phrase|null
  */
 public function get($key, $lang)
 {
     if (isset($this->langs[$key])) {
         if (isset($this->langs[$key][$lang])) {
             return $this->langs[$key][$lang];
         }
         if (isset($this->langs[$key]["en"])) {
             return $this->langs[$key]["en"];
         }
     }
     $this->main->getLogger()->warning("Returning null for unknown translation string ID '{$key}'");
     return null;
 }
 public function execute(CommandSender $issuer, $lbl, array $args)
 {
     if (count($args) === 0) {
         $args = ["help"];
     }
     if (is_string($lbl) and substr($lbl, 0, 1) === "/" and strlen($lbl) > 1) {
         $cmd = substr($lbl, 1);
     } else {
         $cmd = array_shift($args);
     }
     if (isset($this->subcmds[$cmd = strtolower(trim($cmd))]) and $this->subcmds[$cmd]->valid() and $cmd !== "help") {
         if ($this->subcmds[$cmd]->get()->hasPermission($issuer)) {
             if (!IS_DEBUGGING) {
                 try {
                     $this->subcmds[$cmd]->get()->run($this, $args, $issuer);
                 } catch (\Exception $exception) {
                     $issuer->sendMessage("Uh-oh. Something went wrong! An exception has been caught during executing your command.");
                     $issuer->sendMessage("Error caught: " . ($class = array_slice(explode("\\", get_class($exception)), -1)[0]));
                     $issuer->sendMessage("Error message: " . $exception->getMessage());
                     $issuer->sendMessage("The error has been reported to console.");
                     $this->main->getLogger()->notice("An exception has been caught. Exception name: '{$class}'. Exception message: " . $exception->getMessage());
                 }
             } else {
                 $this->subcmds[$cmd]->get()->run($this, $args, $issuer);
                 // let the error fly
             }
         } else {
             $issuer->sendMessage("You either have to select an anchor / make a selection first, don't have permission to do this, or you have to run this command in-game/on-console.");
         }
     } else {
         $help = $this->getFullHelp($issuer);
         $page = 1;
         $max = (int) ceil(count($help) / 5);
         if (isset($args[0])) {
             $page = max(1, (int) $args[0]);
             $page = min($max, $page);
         }
         $output = "Commands available for you currently: (page {$page} of {$max})\n";
         for ($i = ($page - 1) * 5; $i < $page * 5 and isset($help[$i]); $i++) {
             $output .= $help[$i] . "\n";
         }
         $issuer->sendMessage($output);
     }
     return true;
 }
 /**
  * @param object $object
  *
  * @return int
  */
 public function store($object)
 {
     $this->objects[$id = $this->nextId()] = $object;
     if (count($this->objects) >= $this->main->getConfig()->getNested("advanced.objectPool.warningSize")) {
         $this->main->getLogger()->warning("OrderedObjectPool size reached " . count($this->objects) . "! Object summary:");
         $summary = [];
         foreach ($this->objects as $obj) {
             $class = get_class($obj);
             if (isset($summary[$class])) {
                 $summary[$class]++;
             } else {
                 $summary[$class] = 1;
             }
         }
         foreach ($summary as $class => $cnt) {
             $this->main->getLogger()->warning($class . ": {$cnt} entries");
         }
         $this->main->getLogger()->warning("The above is most likely caused by a mistake in code that results in a memory leak. Please report the above to the issue tracker on GitHub at " . TextFormat::LIGHT_PURPLE . "http://lgpe.co/weai/");
     }
     return $id;
 }