mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-04-22 00:33:59 +00:00
Allow specifying compatible OS in plugin manifest (#3192)
This commit is contained in:
parent
df65f1009c
commit
8ec0a4d0d6
@ -24,6 +24,7 @@ declare(strict_types=1);
|
||||
namespace pocketmine\plugin;
|
||||
|
||||
use pocketmine\permission\Permission;
|
||||
use pocketmine\utils\Utils;
|
||||
use function array_map;
|
||||
use function array_values;
|
||||
use function constant;
|
||||
@ -55,6 +56,8 @@ class PluginDescription{
|
||||
private $api;
|
||||
/** @var int[] */
|
||||
private $compatibleMcpeProtocols = [];
|
||||
/** @var string[] */
|
||||
private $compatibleOperatingSystems = [];
|
||||
/**
|
||||
* @var string[][]
|
||||
* @phpstan-var array<string, list<mixed>>
|
||||
@ -114,6 +117,7 @@ class PluginDescription{
|
||||
|
||||
$this->api = array_map("\strval", (array) ($plugin["api"] ?? []));
|
||||
$this->compatibleMcpeProtocols = array_map("\intval", (array) ($plugin["mcpe-protocol"] ?? []));
|
||||
$this->compatibleOperatingSystems = array_map("\strval", (array) ($plugin["os"] ?? []));
|
||||
|
||||
if(isset($plugin["commands"]) and is_array($plugin["commands"])){
|
||||
$this->commands = $plugin["commands"];
|
||||
@ -184,6 +188,13 @@ class PluginDescription{
|
||||
public function getCompatibleMcpeProtocols() : array{
|
||||
return $this->compatibleMcpeProtocols;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string[]
|
||||
*/
|
||||
public function getCompatibleOperatingSystems() : array{
|
||||
return $this->compatibleOperatingSystems;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string[]
|
||||
|
@ -258,6 +258,14 @@ class PluginManager{
|
||||
continue;
|
||||
}
|
||||
|
||||
if(count($description->getCompatibleOperatingSystems()) > 0 and !in_array(Utils::getOS(), $description->getCompatibleOperatingSystems(), true)) {
|
||||
$this->server->getLogger()->error($this->server->getLanguage()->translateString("pocketmine.plugin.loadError", [
|
||||
$name,
|
||||
$this->server->getLanguage()->translateString("%pocketmine.plugin.incompatibleOS", [implode(", ", $description->getCompatibleOperatingSystems())])
|
||||
]));
|
||||
continue;
|
||||
}
|
||||
|
||||
if(count($pluginMcpeProtocols = $description->getCompatibleMcpeProtocols()) > 0){
|
||||
$serverMcpeProtocols = [ProtocolInfo::CURRENT_PROTOCOL];
|
||||
if(count(array_intersect($pluginMcpeProtocols, $serverMcpeProtocols)) === 0){
|
||||
|
Loading…
x
Reference in New Issue
Block a user