From b678740d9f50a907423123ee792f238e83b24e77 Mon Sep 17 00:00:00 2001 From: retroluxfilm Date: Wed, 3 Jan 2024 15:09:14 +0100 Subject: [PATCH 1/5] Renamed tags to conform OMM 1.2.x compatibility for the repository descriptor --- src/Repository/RemotePackageDescriptor.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Repository/RemotePackageDescriptor.php b/src/Repository/RemotePackageDescriptor.php index 106f9fd..f36c6b6 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_REMOTE = "mod", + TAG_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"; /** From 4fd3f4acb5aa9c2867b730dfb7711118bdd74983 Mon Sep 17 00:00:00 2001 From: retroluxfilm Date: Wed, 3 Jan 2024 15:28:17 +0100 Subject: [PATCH 2/5] Renamed tags to conform OMM 1.2.x compatibility for the repository descriptor --- src/Package/Package.php | 4 ++-- src/Repository/RemotePackageDescriptor.php | 6 +++--- src/Repository/RemoteRepositoryXML.php | 6 +++--- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/Package/Package.php b/src/Package/Package.php index c5fcebd..2bd9b3b 100644 --- a/src/Package/Package.php +++ b/src/Package/Package.php @@ -92,7 +92,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 +119,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); } diff --git a/src/Repository/RemotePackageDescriptor.php b/src/Repository/RemotePackageDescriptor.php index f36c6b6..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 = "mod", - TAG_PICTURE = "thumbnail", + TAG_MOD = "mod", + TAG_MOD_PICTURE = "thumbnail", TAG_DESCRIPTION = "description", TAG_URL = "url"; /** @@ -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); From 944158010e497371a1e689d1d8e891d55936cf33 Mon Sep 17 00:00:00 2001 From: retroluxfilm Date: Wed, 3 Jan 2024 15:55:48 +0100 Subject: [PATCH 3/5] Includes *.ozd as possible archive extension --- src/Task/GenerateFolderRepositoryTask.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/Task/GenerateFolderRepositoryTask.php b/src/Task/GenerateFolderRepositoryTask.php index 8ff3e73..7717f10 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("ozd", pathinfo($fileEntry, PATHINFO_EXTENSION)) != 0) { continue; } From cd869680b1d98b8258c0a0dd13010ccedb432043 Mon Sep 17 00:00:00 2001 From: retroluxfilm Date: Wed, 3 Jan 2024 15:57:21 +0100 Subject: [PATCH 4/5] Includes *.ozp as possible archive extension --- src/Task/GenerateFolderRepositoryTask.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Task/GenerateFolderRepositoryTask.php b/src/Task/GenerateFolderRepositoryTask.php index 7717f10..199683a 100644 --- a/src/Task/GenerateFolderRepositoryTask.php +++ b/src/Task/GenerateFolderRepositoryTask.php @@ -230,7 +230,7 @@ private static function getAvailableArchives($searchDir, bool $recursive): array { // skip non zip archives or ozd archives if (strcasecmp("zip", pathinfo($fileEntry, PATHINFO_EXTENSION)) != 0 - && strcasecmp("ozd", pathinfo($fileEntry, PATHINFO_EXTENSION)) != 0) { + && strcasecmp("ozp", pathinfo($fileEntry, PATHINFO_EXTENSION)) != 0) { continue; } From 089ae8c02f1760ad4e5cfc77da8660df12638f3f Mon Sep 17 00:00:00 2001 From: retroluxfilm Date: Wed, 3 Jan 2024 16:04:10 +0100 Subject: [PATCH 5/5] Updated OMM 1.2.x mod package descriptor XML name --- src/Package/Package.php | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/Package/Package.php b/src/Package/Package.php index 2bd9b3b..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; @@ -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