Created
April 26, 2020 15:55
-
-
Save PJZ9n/614198b41734cbdab1a8405bd60929ed to your computer and use it in GitHub Desktop.
PluginBaseでConfigを使用する
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
declare(strict_types=1); | |
namespace sample; | |
use pocketmine\plugin\PluginBase; | |
class Main extends PluginBase | |
{ | |
public function onEnable(): void | |
{ | |
//あらかじめ、resources/config.ymlとしてファイルを置いておく(置かないこともできる) | |
$this->saveDefaultConfig();//$this->getConfig()でConfigを取得できるようにする | |
} | |
public function onDisable(): void | |
{ | |
$this->saveConfig();//Configをセーブする(必要に応じて) | |
} | |
public function foo(): void | |
{ | |
//適当な処理 | |
echo $this->getConfig()->get("key1") . PHP_EOL; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment