Beispiel #1
0
 public function onEnable()
 {
     mc::plugin_init($this, $this->getFile());
     $this->auth = $this->getServer()->getPluginManager()->getPlugin("SimpleAuth");
     if (!$this->auth) {
         $this->getLogger()->error(TextFormat::RED . mc::_("Unable to find SimpleAuth"));
         throw new \RuntimeException("Missing Dependancy");
         return;
     }
     if (!is_dir($this->getDataFolder())) {
         mkdir($this->getDataFolder());
     }
     $defaults = ["version" => $this->getDescription()->getVersion(), "# max-attemps" => "kick player after this many login attempts. ", "max-attempts" => 5, "# login-timeout" => "must authenticate within this number of seconds", "login-timeout" => 60, "# leet-mode" => "lets players use also /login and /register", "leet-mode" => true, "# chat-protect" => "prevent player to display their password in chat", "chat-protect" => false, "# hide-unauth" => "EXPERIMENTAL, hide unauthenticated players", "hide-unauth" => false, "# event-fixer" => "EXPERIMENTAL, cancels additional events", "event-fixer" => false, "# hack-login-perms" => "EXPERIMENTAL, overrides login permisions", "hack-login-perms" => false, "# hack-register-perms" => "EXPERIMENTAL, overrides register permisions", "hack-register-perms" => false, "# db-monitor" => "EXPERIMENTAL, enable database server monitoring", "db-monitor" => false, "# monitor-settings" => "Configure database monitor settings", "monitor-settings" => DbMonitorTask::defaults()];
     $this->cfg = (new Config($this->getDataFolder() . "config.yml", Config::YAML, $defaults))->getAll();
     $this->getServer()->getPluginManager()->registerEvents($this, $this);
     if ($this->cfg["event-fixer"]) {
         $this->listener = new EventListener($this);
     }
     if ($this->cfg["hack-login-perms"] || $this->cfg["hack-register-perms"]) {
         $this->permshacker = new PermsHacker($this, $this->cfg["hack-login-perms"], $this->cfg["hack-register-perms"]);
     }
     if ($this->cfg["db-monitor"]) {
         $this->monitor = new DbMonitorTask($this, $this->cfg["monitor-settings"]);
     }
     $this->pwds = [];
 }
Beispiel #2
0
 public function onEnable()
 {
     if (!is_dir($this->getDataFolder())) {
         mkdir($this->getDataFolder());
     }
     if (mc::plugin_init($this, $this->getFile()) === false) {
         file_put_contents($this->getDataFolder() . "messages.ini", MPMU::getResourceContents($this, "messages/eng.ini") . "\n\"<nagme>\"=\"yes\"\n");
         mc::plugin_init($this, $this->getFile());
         $this->getLogger()->error(TextFormat::RED . "Your selected language \"" . $this->getServer()->getProperty("settings.language") . "\" is not supported");
         $this->getLogger()->error(TextFormat::YELLOW . "Creating a custom \"messages.ini\" with English strings");
         $this->getLogger()->error(TextFormat::AQUA . "Please consider translating and submitting a translation");
         $this->getLogger()->error(TextFormat::AQUA . "to the developer");
         $this->getLogger()->error(TextFormat::YELLOW . "If you later change your language in \"pocketmine.yml\"");
         $this->getLogger()->error(TextFormat::YELLOW . "make sure you delete this \"messages.ini\"");
         $this->getLogger()->error(TextFormat::YELLOW . "otherwise your changes will not be recognized");
     } else {
         if (mc::_("<nagme>") === "yes") {
             // Potentially the language may exists since this was created...
             $ln = $this->getServer()->getProperty("settings.language");
             $fp = $this->getResource("messages/" . $ln . ".ini");
             if ($fp === null) {
                 $this->getLogger()->error(TextFormat::RED . "Your selected language \"" . $ln . "\" is not supported");
                 $this->getLogger()->error(TextFormat::AQUA . "Please consider translating \"messages.ini\"");
                 $this->getLogger()->error(TextFormat::AQUA . "and submitting a translation to the  developer");
             } else {
                 fclose($fp);
                 // This language is actually supported...
                 $this->getLogger()->error(TextFormat::RED . "Using a supported language: \"" . $ln . "\"");
                 $this->getLogger()->error(TextFormat::YELLOW . "Saving/Fixing \"messages.ini\" as");
                 $this->getLogger()->error(TextFormat::YELLOW . "\"messages.bak\"...");
                 $orig = file_get_contents($this->getDataFolder() . "messages.ini");
                 file_put_contents($this->getDataFolder() . "messages.bak", strtr($orig, ["<nagme>" => "<don't nagme>"]));
                 unlink($this->getDataFolder() . "messages.ini");
             }
         }
     }
     $this->auth = $this->getServer()->getPluginManager()->getPlugin("SimpleAuth");
     if (!$this->auth) {
         $this->getLogger()->error(TextFormat::RED . mc::_("Unable to find SimpleAuth"));
         throw new \RuntimeException("Missing Dependancy");
         return;
     }
     $defaults = ["version" => $this->getDescription()->getVersion(), "# max-attemps" => "kick player after this many login attempts. ", "max-attempts" => 5, "# login-timeout" => "must authenticate within this number of seconds", "login-timeout" => 60, "# leet-mode" => "lets players use also /login and /register", "leet-mode" => true, "# chat-protect" => "prevent player to display their password in chat", "chat-protect" => false, "# hide-unauth" => "EXPERIMENTAL, hide unauthenticated players", "hide-unauth" => false, "# event-fixer" => "EXPERIMENTAL, cancels additional events", "event-fixer" => false, "# hack-login-perms" => "EXPERIMENTAL, overrides login permisions", "hack-login-perms" => false, "# hack-register-perms" => "EXPERIMENTAL, overrides register permisions", "hack-register-perms" => false, "# db-monitor" => "EXPERIMENTAL, enable database server monitoring", "db-monitor" => false, "# monitor-settings" => "Configure database monitor settings", "monitor-settings" => DbMonitorTask::defaults()];
     $this->cfg = (new Config($this->getDataFolder() . "config.yml", Config::YAML, $defaults))->getAll();
     $this->getServer()->getPluginManager()->registerEvents($this, $this);
     if ($this->cfg["event-fixer"]) {
         $this->listener = new EventListener($this);
     }
     if ($this->cfg["hack-login-perms"] || $this->cfg["hack-register-perms"]) {
         $this->permshacker = new PermsHacker($this, $this->cfg["hack-login-perms"], $this->cfg["hack-register-perms"]);
     }
     if ($this->cfg["db-monitor"]) {
         $this->monitor = new DbMonitorTask($this, $this->cfg["monitor-settings"]);
     }
     $this->pwds = [];
 }
Beispiel #3
0
 public function onEnable()
 {
     mc::plugin_init($this, $this->getFile());
     $this->auth = $this->getServer()->getPluginManager()->getPlugin("SimpleAuth");
     if (!$this->auth) {
         $this->getLogger()->error(TextFormat::RED . mc::_("Unable to find SimpleAuth"));
         throw new \RuntimeException("Missinge Dependancy");
         return;
     }
     if (!is_dir($this->getDataFolder())) {
         mkdir($this->getDataFolder());
     }
     $defaults = ["version" => $this->getDescription()->getVersion(), "max-attempts" => 5, "login-timeout" => 60, "leet-mode" => true, "chat-protect" => true, "hide-unauth" => false];
     $this->cfg = (new Config($this->getDataFolder() . "config.yml", Config::YAML, $defaults))->getAll();
     $this->getServer()->getPluginManager()->registerEvents($this, $this);
     $this->pwds = [];
 }