本文整理汇总了PHP中pocketmine\plugin\Plugin::getServer方法的典型用法代码示例。如果您正苦于以下问题:PHP Plugin::getServer方法的具体用法?PHP Plugin::getServer怎么用?PHP Plugin::getServer使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pocketmine\plugin\Plugin
的用法示例。
在下文中一共展示了Plugin::getServer方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __construct
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: Execute
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: onLogin
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: __construct
public function __construct(Plugin $plugin)
{
$this->plugin = $plugin;
if ($plugin->getServer()->getPluginManager()->getPlugin("SimpleArea") != null) {
$plugin->getServer()->getPluginManager()->registerEvents($this, $plugin);
}
}
示例5: __construct
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: __construct
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: getCommonVars
/**
* 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: __construct
public function __construct(Plugin $owner, $Level, $Mode)
{
$this->Task = new PopupInfoTask($owner, $Level, $this, $Mode);
$owner->getServer()->getScheduler()->scheduleRepeatingTask($this->Task, 7);
}
示例9: TP
static function TP(Plugin $owner, Player $Target, Position $Position, $delay = 1)
{
return $owner->getServer()->getScheduler()->scheduleDelayedTask(new TPTask($owner, $Target, $Position), $delay);
}
示例10: breakSignLater
public static function breakSignLater(Plugin $plugin, Sign $tile, $ticks = 5)
{
$plugin->getServer()->getScheduler()->scheduleDelayedTask(new PluginCallbackTask($this, [self::class, "breakSign"], [$tile]), $ticks);
}
示例11: add
/**
* 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);
}