jsdatapack
Version:
Make minecraft datapacks in javascript.
61 lines (51 loc) • 1.4 kB
JavaScript
const utils = require("./utils/generator");
const fs = require('fs');
const path = require('path');
class Base {
name = "";
description = "";
/**
* @private
*/
datapack;
/**
* Create a new Datapack
* @param {String} name
* @param {String} description
*/
constructor(name, description) {
this.name = name;
this.description = description;
this.generate();
}
/**
* @private
*/
generate() {
this.datapack = utils.createMainFolder(this.name, this.description);
}
save() {
utils.save(this.name);
}
/**
* Save a datapack to a path,
* Like .minecraft
* @param {String} path
* @deprecated
*/
saveLocation(currentPath, newPath) {
while(utils.exists(currentPath + "\\" + this.name + "-datapack.zip")) {
if(utils.exists(currentPath + "\\" + this.name + "-datapack.zip")) {
const cp = path.join(currentPath, this.name + "-datapack.zip");
const np = path.join(newPath, this.name + "-datapack.zip");
try {
fs.renameSync(cp, np);
} catch(err) {
throw err;
}
break;
}
}
}
}
module.exports = Base;