diff --git a/src/Package/Package.php b/src/Package/Package.php index c5fcebd..0cfdaf9 100644 --- a/src/Package/Package.php +++ b/src/Package/Package.php @@ -38,7 +38,8 @@ class Package /** * Package descriptor file */ - private const PACKAGE_DESCRIPTOR_FILE = "package.omp"; + private const PACKAGE_DESCRIPTOR_FILE_LEAGACY = "package.omp"; + private const PACKAGE_DESCRIPTOR_FILE = "modpack.xml"; private PackageXML $packageXML; protected string $packageArchiveFile; @@ -92,7 +93,7 @@ public function createRemotePackageDescriptor(): RemotePackageDescriptor $xml->preserveWhiteSpace = false; //create remote root element - $remote = $xml->createElement(RemotePackageDescriptor::TAG_REMOTE); + $remote = $xml->createElement(RemotePackageDescriptor::TAG_MOD); $remote->setAttribute(RemotePackageDescriptor::ATTRIBUTE_IDENT, $this->packageXML->getIdentifier()); $remote->setAttribute(RemotePackageDescriptor::ATTRIBUTE_FILE, $this->packageArchiveFile); $remote->setAttribute(RemotePackageDescriptor::ATTRIBUTE_BYTES, $this->packageByteSize); @@ -119,7 +120,7 @@ public function createRemotePackageDescriptor(): RemotePackageDescriptor // Crop & Resize logo to max 128x128 pixels in size $thumbnail = PackageHelper::createThumbnail($this->logoImageData); - $picture = $xml->createElement(RemotePackageDescriptor::TAG_PICTURE, PackageHelper::encodePackageLogo($thumbnail)); + $picture = $xml->createElement(RemotePackageDescriptor::TAG_MOD_PICTURE, PackageHelper::encodePackageLogo($thumbnail)); $remote->appendChild($picture); } @@ -170,9 +171,14 @@ protected function retrieveInformationFromArchive(string $packageArchiveFilePath // read package descriptor contents $packageDescriptorData = $packageZip->getFromName(self::PACKAGE_DESCRIPTOR_FILE); if ($packageDescriptorData === false) { - throw new Exception( - "OMM Package Descriptor (" . self::PACKAGE_DESCRIPTOR_FILE . ") not found or invalid in" . $packageArchiveFilePath - ); + + // read package descriptor contents (Legacy Mod package below OMM 1.2.x) + $packageDescriptorData = $packageZip->getFromName(self::PACKAGE_DESCRIPTOR_FILE_LEAGACY); + if ($packageDescriptorData === false) { + throw new Exception( + "OMM Package Descriptor (" . self::PACKAGE_DESCRIPTOR_FILE_LEAGACY . " or " . self::PACKAGE_DESCRIPTOR_FILE .") not found or invalid in" . $packageArchiveFilePath + ); + } } // load package XML from the descriptor file diff --git a/src/Repository/RemotePackageDescriptor.php b/src/Repository/RemotePackageDescriptor.php index 106f9fd..fef9e97 100644 --- a/src/Repository/RemotePackageDescriptor.php +++ b/src/Repository/RemotePackageDescriptor.php @@ -34,8 +34,8 @@ class RemotePackageDescriptor * Tags of the remote package descriptor */ public const - TAG_REMOTE = "remote", - TAG_PICTURE = "picture", + TAG_MOD = "mod", + TAG_MOD_PICTURE = "thumbnail", TAG_DESCRIPTION = "description", TAG_URL = "url"; /** @@ -46,7 +46,7 @@ class RemotePackageDescriptor ATTRIBUTE_FILE = "file", ATTRIBUTE_BYTES = "bytes", ATTRIBUTE_MD5 = "md5sum", - ATTRIBUTE_CHECKSUM = "checksum", + ATTRIBUTE_CHECKSUM = "xxhsum", ATTRIBUTE_CATEGORY = "category"; /** @@ -64,7 +64,7 @@ class RemotePackageDescriptor public function __construct(DOMElement $remoteXMLElement) { - if($remoteXMLElement->nodeName != self::TAG_REMOTE){ + if($remoteXMLElement->nodeName != self::TAG_MOD){ throw new InvalidArgumentException("Passed remote xml element is not valid"); } diff --git a/src/Repository/RemoteRepositoryXML.php b/src/Repository/RemoteRepositoryXML.php index c011adc..d2ceb34 100644 --- a/src/Repository/RemoteRepositoryXML.php +++ b/src/Repository/RemoteRepositoryXML.php @@ -41,7 +41,7 @@ class RemoteRepositoryXML TAG_UUID = "uuid", TAG_TITLE = "title", TAG_DOWNPATH = "downpath", - TAG_REMOTES = "remotes"; + TAG_REFERENCES = "references"; /** * Attributes of the remote repository xml @@ -144,9 +144,9 @@ protected function updateRepositoryFromXMLData(string $repositoryTitle, string $ } // add remote package element and store it for later modification - $remotesList = $this->root->getElementsByTagName(self::TAG_REMOTES); + $remotesList = $this->root->getElementsByTagName(self::TAG_REFERENCES); if ($remotesList->length == 0) { - $this->remotes = $this->xml->createElement(self::TAG_REMOTES); + $this->remotes = $this->xml->createElement(self::TAG_REFERENCES); $this->remotes->setAttribute(self::ATTRIBUTE_COUNT, 0); $this->root->appendChild($this->remotes); diff --git a/src/Task/GenerateFolderRepositoryTask.php b/src/Task/GenerateFolderRepositoryTask.php index 8ff3e73..199683a 100644 --- a/src/Task/GenerateFolderRepositoryTask.php +++ b/src/Task/GenerateFolderRepositoryTask.php @@ -228,8 +228,9 @@ private static function getAvailableArchives($searchDir, bool $recursive): array } else { - // skip non zip archives - if (strcasecmp("zip", pathinfo($fileEntry, PATHINFO_EXTENSION)) != 0) { + // skip non zip archives or ozd archives + if (strcasecmp("zip", pathinfo($fileEntry, PATHINFO_EXTENSION)) != 0 + && strcasecmp("ozp", pathinfo($fileEntry, PATHINFO_EXTENSION)) != 0) { continue; }