コード例 #1
0
ファイル: Main.php プロジェクト: DWWf/pocketmine-plugins
 public function onEnable()
 {
     if (!is_dir($this->getDataFolder())) {
         mkdir($this->getDataFolder());
     }
     mc::plugin_init($this, $this->getFile());
     $defaults = ["version" => $this->getDescription()->getVersion(), "modules" => ["treecapitator" => true, "compasstp" => true, "trampoline" => true, "powertool" => true, "cloakclock" => true, "floating-torch" => true, "magic-carpet" => true, "veinminer" => true], "floating-torch" => ["item" => "TORCH", "block" => "TORCH"], "compasstp" => ["item" => "COMPASS"], "cloakclock" => ["item" => "CLOCK"], "powertool" => ["ItemIDs" => ["IRON_PICKAXE", "WOODEN_PICKAXE", "STONE_PICKAXE", "DIAMOND_PICKAXE", "GOLD_PICKAXE"], "need-item" => true, "item-wear" => 1, "creative" => true], "veinminer" => ["ItemIDs" => ["IRON_PICKAXE", "WOODEN_PICKAXE", "STONE_PICKAXE", "DIAMOND_PICKAXE", "GOLD_PICKAXE"], "need-item" => true, "item-wear" => 1, "creative" => true, "max-blocks" => 10, "broadcast-use" => true], "treecapitator" => ["ItemIDs" => ["IRON_AXE", "WOODEN_AXE", "STONE_AXE", "DIAMOND_AXE", "GOLD_AXE"], "need-item" => true, "break-leaves" => true, "item-wear" => 1, "broadcast-use" => true, "creative" => true], "trampoline" => ["blocks" => ["SPONGE"]], "magic-carpet" => ["block" => "GLASS"]];
     $cnt = 0;
     $cfg = (new Config($this->getDataFolder() . "config.yml", Config::YAML, $defaults))->getAll();
     if ($cfg["modules"]["treecapitator"]) {
         $this->modules[] = new TreeCapitator($this, $cfg["treecapitator"]);
     }
     if ($cfg["modules"]["powertool"]) {
         $this->modules[] = new PowerTool($this, $cfg["powertool"]);
     }
     if ($cfg["modules"]["trampoline"]) {
         $this->modules[] = new Trampoline($this, $cfg["trampoline"]);
     }
     if ($cfg["modules"]["compasstp"]) {
         $this->modules[] = new CompassTp($this, $cfg["compasstp"]["item"]);
     }
     if ($cfg["modules"]["cloakclock"]) {
         $this->modules[] = new CloakClock($this, $cfg["cloakclock"]["item"]);
     }
     if ($cfg["modules"]["floating-torch"]) {
         $this->modules[] = new TorchMgr($this, $cfg["floating-torch"]);
     }
     if ($cfg["modules"]["magic-carpet"]) {
         $this->modules[] = new MagicCarpet($this, $cfg["magic-carpet"]["block"]);
     }
     if ($cfg["modules"]["veinminer"]) {
         $this->modules[] = new VeinMiner($this, $cfg["veinminer"]);
     }
     if (count($this->modules)) {
         $this->state = [];
         $this->getServer()->getPluginManager()->registerEvents($this, $this);
     }
     $this->getLogger()->info(mc::_("enabled %1% modules", count($this->modules)));
 }