Added capability to specify compatible protocol versions in plugin.yml (#1247)

Protocol-dependent plugins may specify the `mcpe-protocol` attribute in plugin.yml to disallow plugin loading when the protocol changes.
This commit is contained in:
Dylan K. Taylor
2017-09-01 17:57:40 +01:00
committed by GitHub
parent 138d85307b
commit 6e8631347d
3 changed files with 32 additions and 1 deletions

View File

@ -32,6 +32,7 @@ use pocketmine\event\HandlerList;
use pocketmine\event\Listener;
use pocketmine\event\Timings;
use pocketmine\event\TimingsHandler;
use pocketmine\network\mcpe\protocol\ProtocolInfo;
use pocketmine\permission\Permissible;
use pocketmine\permission\Permission;
use pocketmine\Server;
@ -258,6 +259,24 @@ class PluginManager{
continue;
}
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;
}
}
$plugins[$name] = $file;
$softDependencies[$name] = $description->getSoftDepend();