最終更新: hitoshi0929 2015年05月26日(火) 17:43:24履歴
こちらのページではConfigを使用して、Pluginを作る際にどのようなコードを使用すればよいのか、そして細かく説明を書いていきます
コマンドを実行すると、configファイル内の設定されたコメントが返されるプラグインです
コマンドを実行すると、configファイル内の設定されたコメントが返されるプラグインです
public function onEnable(){ $this->config = new Config($this->getDataFolder()."config.yml", Config::YAML); if(!file_exists($this->getDataFolder())){ mkdir($this->getDataFolder(), 0744, true); } if(file_exists($this->getDataFolder() . "config.yml")){ $this->config = new Config($this->getDataFolder()."config.yml", Config::YAML, array()); }else{ $this->config = new Config($this->getDataFolder()."config.yml", Config::YAML, array()); } if($this->config->exists("コメント")){ $comment = $this->config->get("コメント"); $this->getLogger()->info("コメント読み込み完了", $comment); }else{ $this->config->set("コメント", "お前がな"); $this->getLogger()->info("コメント書き込み完了"); $this->config->save(); } } public function onCommand(CommandSender $sender, Command $command, $label, array $args){ if($this->config->exists("コメント")){ $message = $this->config->get("コメント"); $sender->sendMessage($message); }else{ $this->getLogger()->info("configファイルが正しく書き込み、または読み込みされていません"); } } }
コメントをかく