mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-06-10 05:34:54 +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;
|
namespace pocketmine\plugin;
|
||||||
|
|
||||||
use pocketmine\permission\Permission;
|
use pocketmine\permission\Permission;
|
||||||
|
use pocketmine\utils\Utils;
|
||||||
use function array_map;
|
use function array_map;
|
||||||
use function array_values;
|
use function array_values;
|
||||||
use function constant;
|
use function constant;
|
||||||
@ -55,6 +56,8 @@ class PluginDescription{
|
|||||||
private $api;
|
private $api;
|
||||||
/** @var int[] */
|
/** @var int[] */
|
||||||
private $compatibleMcpeProtocols = [];
|
private $compatibleMcpeProtocols = [];
|
||||||
|
/** @var string[] */
|
||||||
|
private $compatibleOperatingSystems = [];
|
||||||
/**
|
/**
|
||||||
* @var string[][]
|
* @var string[][]
|
||||||
* @phpstan-var array<string, list<mixed>>
|
* @phpstan-var array<string, list<mixed>>
|
||||||
@ -114,6 +117,7 @@ class PluginDescription{
|
|||||||
|
|
||||||
$this->api = array_map("\strval", (array) ($plugin["api"] ?? []));
|
$this->api = array_map("\strval", (array) ($plugin["api"] ?? []));
|
||||||
$this->compatibleMcpeProtocols = array_map("\intval", (array) ($plugin["mcpe-protocol"] ?? []));
|
$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"])){
|
if(isset($plugin["commands"]) and is_array($plugin["commands"])){
|
||||||
$this->commands = $plugin["commands"];
|
$this->commands = $plugin["commands"];
|
||||||
@ -184,6 +188,13 @@ class PluginDescription{
|
|||||||
public function getCompatibleMcpeProtocols() : array{
|
public function getCompatibleMcpeProtocols() : array{
|
||||||
return $this->compatibleMcpeProtocols;
|
return $this->compatibleMcpeProtocols;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return string[]
|
||||||
|
*/
|
||||||
|
public function getCompatibleOperatingSystems() : array{
|
||||||
|
return $this->compatibleOperatingSystems;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return string[]
|
* @return string[]
|
||||||
|
@ -258,6 +258,14 @@ class PluginManager{
|
|||||||
continue;
|
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){
|
if(count($pluginMcpeProtocols = $description->getCompatibleMcpeProtocols()) > 0){
|
||||||
$serverMcpeProtocols = [ProtocolInfo::CURRENT_PROTOCOL];
|
$serverMcpeProtocols = [ProtocolInfo::CURRENT_PROTOCOL];
|
||||||
if(count(array_intersect($pluginMcpeProtocols, $serverMcpeProtocols)) === 0){
|
if(count(array_intersect($pluginMcpeProtocols, $serverMcpeProtocols)) === 0){
|
||||||
|
Loading…
x
Reference in New Issue
Block a user