本文整理汇总了PHP中pocketmine\plugin\Plugin::getResource方法的典型用法代码示例。如果您正苦于以下问题:PHP Plugin::getResource方法的具体用法?PHP Plugin::getResource怎么用?PHP Plugin::getResource使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pocketmine\plugin\Plugin
的用法示例。
在下文中一共展示了Plugin::getResource方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: getResourceToReadable
/**
* resources 폴더 안에 있는 파일을 읽어서 문자열로 가져옵니다.
*
* @param string $filename
* @return string
*/
public function getResourceToReadable($filename)
{
$string = "";
$resource = $this->plugin->getResource($filename);
if ($resource === null) {
return null;
}
while (!feof($resource)) {
$string .= fgets($resource, 1024);
}
fclose($resource);
return $string;
}