getServer() final public method

final public getServer ( ) : Server
return pocketmine\Server
Esempio n. 1
0
 public function __construct(PluginBase $owner, $target)
 {
     $this->owner = $owner;
     switch (strtolower($target)) {
         case "emergency":
             $this->level = LogLevel::EMERGENCY;
             break;
         case "alert":
             $this->level = LogLevel::ALERT;
             break;
         case "critical":
             $this->level = LogLevel::CRITICAL;
             break;
         case "error":
             $this->level = LogLevel::ERROR;
             break;
         case "warning":
             $this->level = LogLevel::WARNING;
             break;
         case "notice":
             $this->level = LogLevel::NOTICE;
             break;
         case "info":
             $this->level = LogLevel::INFO;
             break;
         case "debug":
             $this->level = LogLevel::DEBUG;
             break;
         default:
             $owner->getServer()->getLogger()->error(mc::_("Invalid log target %1%", $target));
             $owner->getServer()->getLogger()->error(mc::_("Using \"debug\""));
             $this->level = LogLevel::DEBUG;
     }
 }
Esempio n. 2
0
 /**
  * @param PluginBase $owner - plugin that owns this session
  * @param bool $hard - hard freeze option
  */
 public function __construct(PluginBase $owner, $hard = true)
 {
     $bag = $owner->getServer()->getPluginManager()->getPlugin("GrabBag");
     if ($bag && $bag->isEnabled() && MPMU::apiCheck($bag->getDescription()->getVersion(), "2.3") && $bag->api->getFeature("shield")) {
         $this->api = $bag->api;
         return;
     }
     parent::__construct($owner);
     $this->api = null;
 }
 /**
  * @param PluginBase $owner - plugin that owns this session
  * @param bool $hard - hard freeze option
  */
 public function __construct(PluginBase $owner, $hard = true)
 {
     $bag = $owner->getServer()->getPluginManager()->getPlugin("GrabBag");
     if ($bag && $bag->isEnabled() && MPMU::apiCheck($bag->getDescription()->getVersion(), "2.3") && $bag->api->getFeature("freeze-thaw")) {
         $this->api = $bag->api;
         return;
     }
     parent::__construct($owner);
     // We do it here so to prevent the registration of listeners
     $this->api = null;
     $this->hard = $hard;
 }
Esempio n. 4
0
 public function __construct(PluginBase $owner, $target)
 {
     $this->owner = $owner;
     $fp = @fopen($target, "a");
     if ($fp === false) {
         $owner->getServer()->getLogger()->error(mc::_("Error writing to %1%", $target));
         throw new \RuntimeException("{$target}: unable to open");
         return;
     }
     fclose($fp);
     $this->file = $target;
 }
Esempio n. 5
0
 public function __construct(PluginBase $owner)
 {
     $cf = $owner->getCfg("MySql");
     $this->database = new \mysqli($cf["host"], $cf["user"], $cf["password"], $cf["database"], $cf["port"]);
     if ($this->database->connect_error) {
         throw new \RuntimeException("Invalid MySql settings");
         return;
     }
     $sql = "CREATE TABLE IF NOT EXISTS Scores (\n\t\t\tplayer VARCHAR(16) NOT NULL,\n\t\t\ttype VARCHAR(128) NOT NULL,\n\t\t\tcount INT NOT NULL,\n\t\t\tPRIMARY KEY (player,type)\n\t\t)";
     $this->database->query($sql);
     $owner->getServer()->getScheduler()->scheduleRepeatingTask(new PluginCallbackTask($owner, [$this, "pingMySql"]), 600);
     $owner->getLogger()->info("Connected to MySQL server");
 }
Esempio n. 6
0
 public function __construct(PluginBase $owner, $cf)
 {
     $this->owner = $owner;
     $this->isGlobal = $cf["settings"]["global"];
     $this->database = new \mysqli($cf["MySql"]["host"], $cf["MySql"]["user"], $cf["MySql"]["password"], $cf["MySql"]["database"], $cf["MySql"]["port"]);
     if ($this->database->connect_error) {
         throw new \RuntimeException("Invalid MySql settings");
         return;
     }
     $sql = "CREATE TABLE IF NOT EXISTS NetherChests (\n      player VARCHAR(16) NOT NULL,\n      world VARCHAR(128) NOT NULL,\n      slot INT NOT NULL,\n      id INT NOT NULL,\n      damage INT NOT NULL,\n      count INT NOT NULL,\n      PRIMARY KEY (player,world,slot)\n    )";
     $this->database->query($sql);
     $owner->getServer()->getScheduler()->scheduleRepeatingTask(new PluginCallbackTask($owner, [$this, "pingMySql"]), 600);
     $owner->getLogger()->info("Connected to MySQL server");
 }
Esempio n. 7
0
 /**
  * @param PluginBase $owner - plugin that owns this session
  */
 public function __construct(PluginBase $owner)
 {
     $bag = $owner->getServer()->getPluginManager()->getPlugin("GrabBag");
     $this->apis = [null, null];
     if ($bag && $bag->isEnabled() && MPMU::apiCheck($bag->getDescription()->getVersion(), "2.3")) {
         if ($bag->api->getFeature("chat-utils")) {
             $this->apis[0] = $bag->api;
         }
         if ($bag->api->getFeature("mute-unmute")) {
             $this->apis[1] = $bag->api;
         }
         return;
     }
     parent::__construct($owner);
     $this->chat = true;
 }
Esempio n. 8
0
 /**
  * This will hopefully save someone typing.
  * @param PluginBase $base
  * @return SimpleWarpAPI
  */
 public static function getInstance(PluginBase $base)
 {
     return $base->getServer()->getPluginManager()->getPlugin("SimpleWarp")->getApi();
 }