1: <?php
2: namespace aliuly\common;
3:
4: use pocketmine\utils\TextFormat;
5: use aliuly\common\mc;
6:
7: 8: 9:
10: abstract class mc2 {
11: 12: 13: 14: 15: 16: 17:
18: public static function plugin_init_alt($plugin,$path) {
19: $lang = $plugin->getServer()->getProperty("settings.language");
20: if (mc::plugin_init($plugin,$path) === false && $lang != "eng") {
21: list($fp,$fill) = [$plugin->getResource("messages/eng.ini"),"English"];
22: if ($fp === null) list($fp,$fill) = [ $plugin->getResource("messages/messages.ini"),"EMPTY"];
23: if ($fp === null) return false;
24: file_put_contents($plugin->getDataFolder()."messages.ini",stream_get_contents($fp)."\n\"<nagme>\"=\"yes\"\n");
25: mc::plugin_init($plugin,$path);
26: $plugin->getLogger()->error(TextFormat::RED."Your selected language \"".$lang."\" is not supported");
27: $plugin->getLogger()->error(TextFormat::YELLOW."Creating a custom \"messages.ini\" with ".$fill." strings");
28: $plugin->getLogger()->error(TextFormat::AQUA."Please consider translating and submitting a translation");
29: $plugin->getLogger()->error(TextFormat::AQUA."to the developer");
30: $plugin->getLogger()->error(TextFormat::YELLOW."If you later change your language in \"pocketmine.yml\"");
31: $plugin->getLogger()->error(TextFormat::YELLOW."make sure you delete this \"messages.ini\"");
32: $plugin->getLogger()->error(TextFormat::YELLOW."otherwise your changes will not be recognized");
33: return;
34: }
35: if (mc::_("<nagme>") !== "yes") return;
36:
37:
38: $fp = $plugin->getResource("messages/".$lang.".ini");
39: if($fp === null && $lang != "eng"){
40: $plugin->getLogger()->error(TextFormat::RED."Your selected language \"".$lang."\" is not supported");
41: $plugin->getLogger()->error(TextFormat::AQUA."Please consider translating \"messages.ini\"");
42: $plugin->getLogger()->error(TextFormat::AQUA."and submitting a translation to the developer");
43: return;
44: }
45: if ($fp !== null) fclose($fp);
46:
47: $plugin->getLogger()->error(TextFormat::RED."Using a supported language: \"".$lang."\"");
48: $plugin->getLogger()->error(TextFormat::YELLOW."Saving/Fixing \"messages.ini\" as");
49: $plugin->getLogger()->error(TextFormat::YELLOW."\"messages.bak\"...");
50: $orig = file_get_contents($plugin->getDataFolder()."messages.ini");
51: file_put_contents($plugin->getDataFolder()."messages.bak",strtr($orig,["<nagme>"=>"<don't nagme>"]));
52: unlink($plugin->getDataFolder()."messages.ini");
53: }
54: }
55: