示例#1
0
 public function __construct(Server $server)
 {
     $this->server = $server;
     $this->identifiers = [];
     $this->rakLib = new RakLibServer($this->server->getLogger(), $this->server->getLoader(), $this->server->getPort(), $this->server->getIp() === "" ? "0.0.0.0" : $this->server->getIp());
     $this->interface = new ServerHandler($this->rakLib, $this);
     for ($i = 0; $i < 256; ++$i) {
         $this->channelCounts[$i] = 0;
     }
 }
示例#2
0
 public function increaseSize($newSize)
 {
     $newSize = (int) $newSize;
     if ($newSize > $this->size) {
         for ($i = $this->size; $i < $newSize; ++$i) {
             $this->workerUsage[$i] = 0;
             $this->workers[$i] = new AsyncWorker();
             $this->workers[$i]->setClassLoader($this->server->getLoader());
             $this->workers[$i]->start();
         }
         $this->size = $newSize;
     }
 }
示例#3
0
 /**
  * Loads the plugin contained in $file
  *
  * @param string $file
  *
  * @return Plugin
  *
  * @throws \Exception
  */
 public function loadPlugin($file)
 {
     if (($description = $this->getPluginDescription($file)) instanceof PluginDescription) {
         $this->server->getLogger()->info($this->server->getLanguage()->translateString("BukkitPE.plugin.load", [$description->getFullName()]));
         $dataFolder = dirname($file) . DIRECTORY_SEPARATOR . $description->getName();
         if (file_exists($dataFolder) and !is_dir($dataFolder)) {
             throw new \InvalidStateException("Projected dataFolder '" . $dataFolder . "' for " . $description->getName() . " exists and is not a directory");
         }
         $file = "phar://{$file}";
         $className = $description->getMain();
         $this->server->getLoader()->addPath("{$file}/src");
         if (class_exists($className, true)) {
             $plugin = new $className();
             $this->initPlugin($plugin, $description, $dataFolder, $file);
             return $plugin;
         } else {
             throw new PluginException("Couldn't load plugin " . $description->getName() . ": main class not found");
         }
     }
     return null;
 }