Created
September 17, 2020 12:29
-
-
Save PJZ9n/c2ca0870ca09efdef0896cd687b9f12b to your computer and use it in GitHub Desktop.
API/プロトコルバージョンチェック無効化
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
declare(strict_types=1); | |
echo "-- PocketMineSourceInstaller --" . PHP_EOL; | |
echo "comment out" . PHP_EOL; | |
//フォルダ入力 | |
folder: | |
echo "folder: "; | |
$folder = trim(fgets(STDIN)); | |
//フォルダ存在確認 | |
echo "check folder..."; | |
if (!file_exists("./$folder/")) { | |
echo "folder ./$folder/ not found." . PHP_EOL; | |
goto folder; | |
} | |
echo "done." . PHP_EOL; | |
//最終確認 | |
echo "comment out ok? (y/N): "; | |
$ok = trim(fgets(STDIN)); | |
if ($ok !== "y") { | |
echo "bye." . PHP_EOL; | |
exit(); | |
} | |
//実行 | |
if (($pluginManagerPhp = file_get_contents("./$folder/src/pocketmine/plugin/PluginManager.php")) === false) goto error; | |
static $compatibleApi = <<< 'EOL' | |
if(!$this->isCompatibleApi(...$description->getCompatibleApis())){ | |
$this->server->getLogger()->error($this->server->getLanguage()->translateString("pocketmine.plugin.loadError", [ | |
$name, | |
$this->server->getLanguage()->translateString("%pocketmine.plugin.incompatibleAPI", [implode(", ", $description->getCompatibleApis())]) | |
])); | |
continue; | |
} | |
EOL; | |
static $compatibleProtocol = <<< 'EOL' | |
if(count($pluginMcpeProtocols = $description->getCompatibleMcpeProtocols()) > 0){ | |
$serverMcpeProtocols = [ProtocolInfo::CURRENT_PROTOCOL]; | |
if(count(array_intersect($pluginMcpeProtocols, $serverMcpeProtocols)) === 0){ | |
$this->server->getLogger()->error($this->server->getLanguage()->translateString("pocketmine.plugin.loadError", [ | |
$name, | |
$this->server->getLanguage()->translateString("%pocketmine.plugin.incompatibleProtocol", [implode(", ", $pluginMcpeProtocols)]) | |
])); | |
continue; | |
} | |
} | |
EOL; | |
$pluginManagerPhp = str_replace([$compatibleApi, $compatibleProtocol], "/* removed */", $pluginManagerPhp); | |
unlink("./$folder/src/pocketmine/plugin/PluginManager.php"); | |
if (file_put_contents("./$folder/src/pocketmine/plugin/PluginManager.php", $pluginManagerPhp) === false) goto error; | |
echo "success!" . PHP_EOL; | |
exit(); | |
error: | |
echo PHP_EOL . "error." . PHP_EOL; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment