Skip to content

Instantly share code, notes, and snippets.

@PJZ9n
Created September 17, 2020 12:29
Show Gist options
  • Save PJZ9n/c2ca0870ca09efdef0896cd687b9f12b to your computer and use it in GitHub Desktop.
Save PJZ9n/c2ca0870ca09efdef0896cd687b9f12b to your computer and use it in GitHub Desktop.
API/プロトコルバージョンチェック無効化
<?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