getServer() public method

public getServer ( ) : Server
return pocketmine\Server
コード例 #1
1
 public function __construct(Plugin $plugin)
 {
     $this->plugin = $plugin;
     $config = $this->plugin->getConfig()->get("dataProviderSettings");
     if (!isset($config["host"]) or !isset($config["user"]) or !isset($config["password"]) or !isset($config["database"])) {
         $this->plugin->getLogger()->critical("Invalid MySQL settings");
         $this->plugin->setDataProvider(new DummyDataProvider($this->plugin));
         return;
     }
     $this->database = new \mysqli($config["host"], $config["user"], $config["password"], $config["database"], isset($config["port"]) ? $config["port"] : 3306);
     if ($this->database->connect_error) {
         $this->plugin->getLogger()->critical("Couldn't connect to MySQL: " . $this->database->connect_error);
         $this->plugin->setDataProvider(new DummyDataProvider($this->plugin));
         return;
     }
     $resource = $this->plugin->getResource("mysql.sql");
     $this->database->query(stream_get_contents($resource));
     fclose($resource);
     $this->plugin->getServer()->getScheduler()->scheduleRepeatingTask(new MySQLPingTask($this->plugin, $this->database), 600);
     // Each 30 seconds
     $this->plugin->getLogger()->info("Connected to MySQL server");
 }
コード例 #2
0
 static function Execute(Plugin $owner, $callback, $delay = 1, $mode = 0)
 {
     switch ($mode) {
         case 0:
             return $owner->getServer()->getScheduler()->scheduleDelayedTask(new ExecuteTask($owner, $callback), $delay);
             break;
         case 1:
             return $owner->getServer()->getScheduler()->scheduleRepeatingTask(new ExecuteTask($owner, $callback), $delay);
             break;
     }
 }
コード例 #3
0
ファイル: EventListener.php プロジェクト: pid011/SimpleLogin
 public function onLogin(PlayerLoginEvent $event)
 {
     $player = $event->getPlayer()->getName();
     $this->plugin->getServer()->getScheduler()->scheduleDelayedTask(new timeoutKickTask($this->plugin, $this, $event->getPlayer()), 20 * $this->db->config["kick-time"]);
     if (strtolower($player) == "config") {
         $event->setKickMessage(TextFormat::RED . $this->db->get("cant-use-this-name"));
         $event->setCancelled();
     }
     if ($this->isLogin($this->getServer()->getPlayer($player))) {
         $event->setKickMessage(TextFormat::RED . $this->db->get("already-login"));
         $event->setCancelled();
         return true;
     }
     if ($this->db->db["config"]["allowsubaccount"] == false) {
         $puuid = $event->getPlayer()->getClientId();
         foreach ($this->db->db as $playername => $key) {
             if (!isset($this->db->db[$playername]["uuid"])) {
                 continue;
             }
             if ($this->db->db[$playername]["uuid"] == $puuid && strtolower($playername) != strtolower($player)) {
                 $event->setKickMessage(TextFormat::RED . str_replace("%player%", $playername, $this->db->get("already-have-account")));
                 $event->setCancelled();
                 break;
             }
         }
     }
 }
コード例 #4
0
ファイル: OutEventListner.php プロジェクト: EmreTr1/rtr
 public function __construct(Plugin $plugin)
 {
     $this->plugin = $plugin;
     if ($plugin->getServer()->getPluginManager()->getPlugin("SimpleArea") != null) {
         $plugin->getServer()->getPluginManager()->registerEvents($this, $plugin);
     }
 }
コード例 #5
0
 public function __construct(Plugin $plugin)
 {
     if ($this->getResultType() !== self::TYPE_RAW and $this->getExpectedColumns() === null) {
         echo "Fatal: Plugin error. ", static::class . " must override getExpectedColumns(), but it didn't. Committing suicide.";
         sleep(604800);
         die;
     }
     $plugin->getServer()->getScheduler()->scheduleAsyncTask($this);
 }
コード例 #6
0
 public function __construct(Plugin $plugin)
 {
     $this->plugin = $plugin;
     if ($plugin->getServer()->getPluginManager()->getPlugin("EDGE") != null) {
         $plugin->getServer()->getPluginManager()->registerEvents($this, $plugin);
         // $this->edge = EDGE::getInstance ();
         $this->edge = $plugin->getServer()->getPluginManager()->getPlugin("EDGE");
         $this->callback = $this->plugin->getServer()->getScheduler()->scheduleRepeatingTask(new EDGEControlTask($this), 20);
     }
 }
コード例 #7
0
 /**
  * If GrabBag is available, try to get a single shared instance of
  * ExpandVars
  */
 public static function getCommonVars(Plugin $owner)
 {
     $pm = $owner->getServer()->getPluginManager();
     if (($gb = $pm->getPlugin("GrabBag")) !== null) {
         if ($gb->isEnabled() && MPMU::apiCheck($gb->getDescription()->getVersion(), "2.3")) {
             $vars = $gb->api->getVars();
             if ($vars instanceof ExpandVars) {
                 return $vars;
             }
         }
     }
     return new ExpandVars($owner);
 }
コード例 #8
0
ファイル: PopupInfo.php プロジェクト: SuperAdam47/BedWarsPE
 public function __construct(Plugin $owner, $Level, $Mode)
 {
     $this->Task = new PopupInfoTask($owner, $Level, $this, $Mode);
     $owner->getServer()->getScheduler()->scheduleRepeatingTask($this->Task, 7);
 }
コード例 #9
0
ファイル: TPTask.php プロジェクト: SuperAdam47/BedWarsPE
 static function TP(Plugin $owner, Player $Target, Position $Position, $delay = 1)
 {
     return $owner->getServer()->getScheduler()->scheduleDelayedTask(new TPTask($owner, $Target, $Position), $delay);
 }
コード例 #10
0
 public static function breakSignLater(Plugin $plugin, Sign $tile, $ticks = 5)
 {
     $plugin->getServer()->getScheduler()->scheduleDelayedTask(new PluginCallbackTask($this, [self::class, "breakSign"], [$tile]), $ticks);
 }
コード例 #11
0
ファイル: PermUtils.php プロジェクト: DWWf/pocketmine-plugins
 /**
  * Register a permission on the fly...
  * @param Plugin $plugin - owning plugin
  * @param str $name - permission name
  * @param str $desc - permission description
  * @param str $default - one of true,false,op,notop
  */
 public static function add(Plugin $plugin, $name, $desc, $default)
 {
     $perm = new Permission($name, $desc, $default);
     $plugin->getServer()->getPluginManager()->addPermission($perm);
 }