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));
75 $serverMcpeProtocols = [ProtocolInfo::CURRENT_PROTOCOL];
76 if(count(array_intersect($pluginMcpeProtocols, $serverMcpeProtocols)) === 0){
77 return KnownTranslationFactory::pocketmine_plugin_incompatibleProtocol(implode(
", ", $pluginMcpeProtocols));
81 foreach(Utils::stringifyKeys($description->
getRequiredExtensions()) as $extensionName => $versionConstrs){
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);