|
39 | 39 | use pocketmine\utils\TextFormat;
|
40 | 40 | use pocketmine\utils\VersionString;
|
41 | 41 | use function array_key_last;
|
42 |
| -use function class_exists; |
43 | 42 | use function explode;
|
44 | 43 | use function file_exists;
|
45 | 44 | use function glob;
|
46 |
| -use function implode; |
| 45 | +use function is_dir; |
47 | 46 | use function mkdir;
|
48 | 47 | use function str_starts_with;
|
49 | 48 |
|
@@ -205,42 +204,18 @@ public function compareVersion(bool $success, ?VersionString $latest = null, str
|
205 | 204 | }
|
206 | 205 |
|
207 | 206 | private function checkPackaged(): bool {
|
208 |
| - if (str_starts_with($this->getFile(), self::PHAR_HEADER)) { |
209 |
| - if (class_exists(Dependencies::PACKAGED_LIBRARY_NAMESPACE . Dependencies::PMFORMS)) { |
210 |
| - return true;// PoggitCI |
211 |
| - }elseif (Main::canLoadDependencyFromComposer()) { |
212 |
| - Main::loadDependency(); |
213 |
| - return true;// GitHubActions |
214 |
| - }else { |
215 |
| - $message = $this->lang->translateString("error.on.enable.not.packaged"); |
216 |
| - $this->getLogger()->critical($message); |
217 |
| - return false; |
218 |
| - } |
219 |
| - }else { |
220 |
| - $plugins = $this->getServer()->getPluginManager()->getPlugins(); |
221 |
| - if (isset($plugins["DEVirion"])) { |
222 |
| - if (class_exists(Dependencies::PMFORMS)) { |
223 |
| - return true;// developer |
224 |
| - } else { |
225 |
| - $message = $this->lang->translateString("error.on.enable.not.found.virions", [implode(", ", ["pmforms"])]); |
226 |
| - $this->getLogger()->critical($message); |
227 |
| - return false; |
228 |
| - } |
229 |
| - }elseif (Main::canLoadDependencyFromComposer()) { |
230 |
| - Main::loadDependency(); |
231 |
| - if (class_exists(Dependencies::PMFORMS)) { |
232 |
| - return true;// developer |
233 |
| - } else { |
234 |
| - $message = $this->lang->translateString("error.on.enable.not.found.virions", [implode(", ", ["pmforms"])]); |
235 |
| - $this->getLogger()->critical($message); |
236 |
| - return false; |
237 |
| - } |
238 |
| - }else { |
239 |
| - $message = $this->lang->translateString("error.on.enable.not.packaged"); |
240 |
| - $this->getLogger()->critical($message); |
241 |
| - return false; |
| 207 | + if ($this->isPhar() && $this->isPackagedByPharynx()) { |
| 208 | + return true; // pharynx |
| 209 | + }elseif (Main::canLoadDependencyFromComposer()) { |
| 210 | + Main::loadDependency(); |
| 211 | + if (class_exists(Dependencies::PMFORMS)) { |
| 212 | + return true; // developer |
242 | 213 | }
|
243 | 214 | }
|
| 215 | + |
| 216 | + $message = $this->lang->translateString("error.on.enable.not.packaged"); |
| 217 | + $this->getLogger()->critical($message); |
| 218 | + return false; |
244 | 219 | }
|
245 | 220 |
|
246 | 221 | private function unlinkRecursive(string $dir): bool {
|
@@ -270,6 +245,14 @@ private function findWorldsPath(): array {
|
270 | 245 | return glob($this->getWorldsPath() . "*");
|
271 | 246 | }
|
272 | 247 |
|
| 248 | + private function isPhar(): bool { |
| 249 | + return str_starts_with($this->getFile(), self::PHAR_HEADER); |
| 250 | + } |
| 251 | + |
| 252 | + private function isPackagedByPharynx(): bool { |
| 253 | + return is_dir($this->getFile() . Dependencies::PHARYNX_LIBRARY_DIR); |
| 254 | + } |
| 255 | + |
273 | 256 | public static function prefix(): string {
|
274 | 257 | return self::$prefix;
|
275 | 258 | }
|
|
0 commit comments