Skip to content

Commit

Permalink
Don't add songs/images.xml if there are none
Browse files Browse the repository at this point in the history
  • Loading branch information
mon committed Dec 10, 2022
1 parent 969b68f commit 293c434
Showing 1 changed file with 14 additions and 10 deletions.
24 changes: 14 additions & 10 deletions src/js/ResourcePack.ts
Original file line number Diff line number Diff line change
Expand Up @@ -963,19 +963,23 @@ export class Respack {
async generateZIP() {
const zipWriter = new zip.ZipWriter(new zip.BlobWriter("application/zip"));

const songXml = xmlbuilder.create('songs');
for(const song of this.songs) {
song.generateXML(songXml);
await song.addZipAssets(zipWriter);
if(this.songs.length > 0) {
const songXml = xmlbuilder.create('songs');
for(const song of this.songs) {
song.generateXML(songXml);
await song.addZipAssets(zipWriter);
}
await this.addXML("songs.xml", zipWriter, songXml);
}
await this.addXML("songs.xml", zipWriter, songXml);

const imageXml = xmlbuilder.create('images');
for(const image of this.images) {
image.generateXML(imageXml);
await image.addZipAssets(zipWriter);
if(this.images.length > 0) {
const imageXml = xmlbuilder.create('images');
for(const image of this.images) {
image.generateXML(imageXml);
await image.addZipAssets(zipWriter);
}
await this.addXML("images.xml", zipWriter, imageXml);
}
await this.addXML("images.xml", zipWriter, imageXml);

const infoXml = xmlbuilder.create('info');
infoXml.ele("name", this.name);
Expand Down

0 comments on commit 293c434

Please sign in to comment.