Ejemplo n.º 1
0
 public function onEnable()
 {
     if (\pocketmine\DEBUG <= 1) {
         return;
     }
     echo __METHOD__ . "," . __LINE__ . "\n";
     //##DEBUG
     // Create example folders
     if (!is_dir($this->getDataFolder())) {
         mkdir($this->getDataFolder());
     }
     $mft = explode("\n", trim($this->getResourceContents("manifest.txt")));
     foreach ($mft as $f) {
         if (file_exists($this->getDataFolder() . $f)) {
             continue;
         }
         $txt = $this->getResourceContents("examples/" . $f);
         file_put_contents($this->getDataFolder() . $f, $txt);
     }
     echo __METHOD__ . "," . __LINE__ . "\n";
     //##DEBUG
     mc::plugin_init($this, $this->getFile());
     MPMU::addCommand($this, $this, "libcommon", ["description" => "LibCommon Command Line interface", "usage" => "/libcommon <subcommand> [options]", "aliases" => ["lc"], "permission" => "libcommon.debug.command"]);
     $this->modules = [];
     foreach (["Version", "DumpMsgs"] as $mod) {
         echo __METHOD__ . "," . __LINE__ . " - {$mod}\n";
         //##DEBUG
         $mod = __NAMESPACE__ . "\\" . $mod;
         $this->modules[] = new $mod($this);
     }
     $this->modules[] = new BasicHelp($this);
 }
Ejemplo n.º 2
0
 /**
  * Checks message files and nags the user to submit translations...
  *
  * @param Plugin $plugin - owning plugin
  * @param str $path - output of $plugin->getFile()
  * @return int|false - false on error or the number of messages loaded
  */
 public static function plugin_init_alt($plugin, $path)
 {
     $lang = $plugin->getServer()->getProperty("settings.language");
     if (mc::plugin_init($plugin, $path) === false && $lang != "eng") {
         list($fp, $fill) = [$plugin->getResource("messages/eng.ini"), "English"];
         if ($fp === null) {
             list($fp, $fill) = [$plugin->getResource("messages/messages.ini"), "EMPTY"];
         }
         if ($fp === null) {
             return false;
         }
         file_put_contents($plugin->getDataFolder() . "messages.ini", stream_get_contents($fp) . "\n\"<nagme>\"=\"yes\"\n");
         mc::plugin_init($plugin, $path);
         $plugin->getLogger()->error(TextFormat::RED . "Your selected language \"" . $lang . "\" is not supported");
         $plugin->getLogger()->error(TextFormat::YELLOW . "Creating a custom \"messages.ini\" with " . $fill . " strings");
         $plugin->getLogger()->error(TextFormat::AQUA . "Please consider translating and submitting a translation");
         $plugin->getLogger()->error(TextFormat::AQUA . "to the developer");
         $plugin->getLogger()->error(TextFormat::YELLOW . "If you later change your language in \"pocketmine.yml\"");
         $plugin->getLogger()->error(TextFormat::YELLOW . "make sure you delete this \"messages.ini\"");
         $plugin->getLogger()->error(TextFormat::YELLOW . "otherwise your changes will not be recognized");
         return;
     }
     if (mc::_("<nagme>") !== "yes") {
         return;
     }
     // Potentially the language may exists since this was created...
     $fp = $plugin->getResource("messages/" . $lang . ".ini");
     if ($fp === null && $lang != "eng") {
         $plugin->getLogger()->error(TextFormat::RED . "Your selected language \"" . $lang . "\" is not supported");
         $plugin->getLogger()->error(TextFormat::AQUA . "Please consider translating \"messages.ini\"");
         $plugin->getLogger()->error(TextFormat::AQUA . "and submitting a translation to the  developer");
         return;
     }
     if ($fp !== null) {
         fclose($fp);
     }
     // This language is actually supported...
     $plugin->getLogger()->error(TextFormat::RED . "Using a supported language: \"" . $lang . "\"");
     $plugin->getLogger()->error(TextFormat::YELLOW . "Saving/Fixing \"messages.ini\" as");
     $plugin->getLogger()->error(TextFormat::YELLOW . "\"messages.bak\"...");
     $orig = file_get_contents($plugin->getDataFolder() . "messages.ini");
     file_put_contents($plugin->getDataFolder() . "messages.bak", strtr($orig, ["<nagme>" => "<don't nagme>"]));
     unlink($plugin->getDataFolder() . "messages.ini");
 }
Ejemplo n.º 3
0
 public function onEnable()
 {
     $this->api = new GrabBagAPI($this);
     if (!is_dir($this->getDataFolder())) {
         mkdir($this->getDataFolder());
     }
     mc::plugin_init($this, $this->getFile());
     $this->getLogger()->info(mc::_("LibCommon v%1%", MPMU::version()));
     $features = ["players" => ["CmdPlayers", true], "ops" => ["CmdOps", true], "gm?" => ["CmdGmx", true], "as" => ["CmdAs", true], "slay" => ["CmdSlay", true], "heal" => ["CmdHeal", true], "whois" => ["CmdWhois", true], "mute-unmute" => ["CmdMuteMgr", true], "freeze-thaw" => ["CmdFreezeMgr", true], "showtimings" => ["CmdTimings", true], "seeinv-seearmor" => ["CmdShowInv", true], "clearinv" => ["CmdClearInv", true], "get" => ["CmdGet", true], "shield" => ["CmdShieldMgr", true], "srvmode" => ["CmdSrvModeMgr", true], "opms-rpt" => ["CmdOpMsg", true], "entities" => ["CmdEntities", true], "after-at" => ["CmdAfterAt", true], "summon-dismiss" => ["CmdSummon", true], "pushtp-poptp" => ["CmdTpStack", true], "prefix" => ["CmdPrefixMgr", true], "spawn" => ["CmdSpawn", true], "burn" => ["CmdBurn", true], "blowup" => ["CmdBlowUp", true], "setarmor" => ["CmdSetArmor", true], "spectator" => ["CmdSpectator", false], "followers" => ["CmdFollowMgr", true], "rcon-client" => [["ServerList", "CmdRcon"], true], "join-mgr" => ["JoinMgr", true], "custom-death" => ["CustomDeath", true], "repeater" => ["RepeatMgr", true], "broadcast-tp" => ["BcTpMgr", true], "crash" => ["CmdCrash", true], "pluginmgr" => ["CmdPluginMgr", true], "permmgr" => ["CmdPermMgr", true], "throw" => ["CmdThrow", true], "regmgr" => ["CmdRegMgr", true], "invisible" => ["CmdInvisible", true], "chat-utils" => ["CmdChatMgr", true], "query-hosts" => [["ServerList", "CmdQuery"], true], "cmd-selector" => ["CmdSelMgr", true], "cmd-alias" => ["CmdAlias", true], "reop" => ["CmdReOp", true], "tprequest" => ["CmdTpRequest", false], "homes" => ["CmdHomes", false], "warps" => ["CmdWarp", false], "motd-task" => [["ServerList", "MotdDaemon"], false], "query-task" => [["ServerList", "QueryDaemon"], false], "merge-slots" => [["ServerList", "MegaSlots"], false], "echo" => ["CmdEcho", true], "onevent-cmd" => ["CmdOnEvent", false], "pmscripts" => ["CmdRc", true], "event-tracer" => ["CmdTrace", false], "iteminfo" => ["CmdItemInfo", true], "plenty" => ["CmdPlenty", true], "wall" => [["ServerList", "CmdWall"], true], "afk" => ["CmdAFK", true], "xyz" => ["CmdXyz", true], "tptop" => ["CmdTpTop", true], "tpback" => ["CmdTpBack", true], "near" => ["CmdNear", true], "chat-scribe" => ["CmdSpy", true]];
     if (MPMU::apiVersion("1.12.0")) {
         $features["fly"] = ["CmdFly", true];
         $features["skinner"] = ["CmdSkinner", true];
         $features["blood-particles"] = ["BloodMgr", true];
         $ft = $this->getServer()->getPluginManager()->getPlugin("FastTransfer");
         if ($ft) {
             $features["broadcast-ft"] = ["TransferMgr", true];
             $features["ftservers"] = [["ServerList", "CmdFTServers"], true];
         }
     }
     $cfg = $this->modConfig(__NAMESPACE__, $features, ["version" => $this->getDescription()->getVersion(), "serverlist" => [], "join-mgr" => JoinMgr::defaults(), "broadcast-tp" => BcTpMgr::defaults(), "custom-death" => CustomDeath::defaults(), "freeze-thaw" => CmdFreezeMgr::defaults(), "cmd-selector" => CmdSelMgr::defaults(), "query-task" => QueryDaemon::defaults(), "motd-task" => MotdDaemon::defaults(), "chat-scribe" => CmdSpy::defaults()]);
 }