22declare(strict_types=1);
31use
function array_intersect;
33use
function extension_loaded;
36use
function phpversion;
37use
function str_starts_with;
41use
function version_compare;
45 public function __construct(
46 private string $apiVersion
50 $name = $description->getName();
51 if(stripos($name,
"pocketmine") !==
false || stripos($name,
"minecraft") !==
false || stripos($name,
"mojang") !==
false){
52 return KnownTranslationFactory::pocketmine_plugin_restrictedName();
56 if(!VersionString::isValidBaseVersion($api)){
57 return KnownTranslationFactory::pocketmine_plugin_invalidAPI($api);
62 return KnownTranslationFactory::pocketmine_plugin_incompatibleAPI(implode(
", ", $description->
getCompatibleApis()));
66 if(count($ambiguousVersions) > 0){
67 return KnownTranslationFactory::pocketmine_plugin_ambiguousMinAPI(implode(
", ", $ambiguousVersions));
76 if(count(array_intersect($pluginMcpeProtocols, $serverMcpeProtocols)) === 0){
77 return KnownTranslationFactory::pocketmine_plugin_incompatibleProtocol(implode(
", ", $pluginMcpeProtocols));
82 if(!extension_loaded($extensionName)){
83 return KnownTranslationFactory::pocketmine_plugin_extensionNotLoaded($extensionName);
85 $gotVersion = phpversion($extensionName);
86 if($gotVersion ===
false){
88 $gotVersion =
"**UNKNOWN**";
91 foreach($versionConstrs as $k => $constr){
96 return KnownTranslationFactory::pocketmine_plugin_emptyExtensionVersionConstraint(extensionName: $extensionName, constraintIndex:
"$k");
98 foreach([
"<=",
"le",
"<>",
"!=",
"ne",
"<",
"lt",
"==",
"=",
"eq",
">=",
"ge",
">",
"gt"] as $comparator){
100 if(str_starts_with($constr, $comparator)){
101 $version = substr($constr, strlen($comparator));
102 if(!version_compare($gotVersion, $version, $comparator)){
103 return KnownTranslationFactory::pocketmine_plugin_incompatibleExtensionVersion(extensionName: $extensionName, extensionVersion: $gotVersion, pluginRequirement: $constr);
108 return KnownTranslationFactory::pocketmine_plugin_invalidExtensionVersionConstraint(extensionName: $extensionName, versionConstraint: $constr);
static isCompatible(string $myVersionStr, array $wantVersionsStr)
static checkAmbiguousVersions(array $versions)
getCompatibleOperatingSystems()
getCompatibleMcpeProtocols()
static stringifyKeys(array $array)
static getOS(bool $recalculate=false)