Skip to content

Commit 8975544

Browse files
committed
add original file name to export
1 parent 75d0d86 commit 8975544

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

src/datapack.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import JSZip from "jszip";
22
import { ConfigClass } from "./config";
33

44
export interface Datapack {
5+
file_name: string;
56
id: string;
67
name: string | undefined;
78
description:
@@ -53,6 +54,7 @@ export async function loadDatapack(file: File): Promise<Datapack | string> {
5354
pack_id = pack_id + Math.round(Math.random()*100);
5455

5556
let new_pack: Datapack = {
57+
file_name: file.name,
5658
id: pack_id,
5759
name: mcmeta.pack.name,
5860
description: mcmeta.pack.description,

src/datapack_changes.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -120,21 +120,21 @@ export class DatapackModifier {
120120
console.timeEnd("[DatapackModifier] Applied changes to packs");
121121

122122
if (export_settings.combinePacks) {
123-
await this.saveFile(packs[Object.keys(packs)[0]], export_settings);
123+
await this.saveFile(packs[Object.keys(packs)[0]], export_settings, "Combined Pack.zip");
124124
}
125125
else {
126126
for (const pack in packs) {
127127
if (Object.prototype.hasOwnProperty.call(packs, pack)) {
128128
const zip = packs[pack];
129-
await this.saveFile(zip, export_settings);
129+
await this.saveFile(zip, export_settings, datapacks.find((dp) => dp.id === pack)?.file_name!);
130130
}
131131
}
132132
}
133133

134134
this.wipeCache();
135135
}
136136

137-
public async saveFile(zip: JSZip, export_settings: ExportSettings) {
137+
public async saveFile(zip: JSZip, export_settings: ExportSettings, file_name: string) {
138138
console.info(`[DatapackModifier] Saving file... [${zip.name}]`);
139139
await zip.generateAsync({
140140
type: "blob",
@@ -144,7 +144,7 @@ export class DatapackModifier {
144144
}
145145
}).then((content) => {
146146
var link = document.createElement("a"), url = URL.createObjectURL(content);
147-
link.href = url; link.download = `modified datapack test.zip`;
147+
link.href = url; link.download = `Modded copy of ${file_name}`;
148148
link.hidden = true;
149149
document.body.appendChild(link);
150150
link.click();

0 commit comments

Comments
 (0)