Plugin Maneger #276

Merged
Sirherobrine23 merged 5 commits from PluginManeger into main 2022-01-04 13:39:34 +00:00
2 changed files with 5 additions and 4 deletions
Showing only changes of commit e3af4b771b - Show all commits

View File

@@ -15,7 +15,7 @@ async function PluginManeger(BdsPlatform = BdsSettings.GetPlatform()) {
if (!pluginName) throw new Error("Plugin name not found");
const RepositoryPlugins = (await GetPluginsPath());
if (RepositoryPlugins[0] === undefined) throw new Error(`Bds Platform ${BdsPlatform} not found`);
const PluginPath = `${BdsPlatform}/${pluginName.charAt(0).toLocaleLowerCase()}/${pluginName}`;
const PluginPath = `${BdsPlatform}/${pluginName.split("").filter(le => /[a-zA-Z0-9]/gi.test(le)).join("").charAt(0).toLocaleLowerCase()}/${pluginName}`;
const PluginArray = RepositoryPlugins.filter(Plugin => Plugin.path.startsWith(PluginPath));
if (PluginArray[0] === undefined) throw new Error(`Plugin ${pluginName} not found`);
const ConfigFile = js_yaml.load(await request.text(`${RawGithubUrl}/${PluginPath}/${path.basename(PluginArray.filter(A => /config\.y[a]ml$/gi.test(A.path))[0].path)}`));
@@ -71,4 +71,4 @@ async function PluginManeger(BdsPlatform = BdsSettings.GetPlatform()) {
module.exports = {
PluginManeger
};
};

View File

@@ -4,12 +4,13 @@ const RawGithubUrl = "https://raw.githubusercontent.com/The-Bds-Maneger/Plugins_
*/
function Parse(RepositoryPath = "", BdsPlatform = "pocketmine", Config = {}) {
for (let KeyArray of Object.keys(Config)) {
if (!(KeyArray === "revision" || KeyArray === "type" || KeyArray === "versions")) console.error(`${KeyArray} is not supported`);
if (!(KeyArray === "revision" || KeyArray === "name" || KeyArray === "type" || KeyArray === "versions")) console.error(`${KeyArray} is not supported`);
}
if (Config.type === undefined) throw new Error("Config Error: type not found");
const NewConfig = {
revision: "v1",
type: String(Config.type).toLowerCase(),
name: String(Config.name||""),
versions: [
{
dependencies: [""],
@@ -81,4 +82,4 @@ function Parse(RepositoryPath = "", BdsPlatform = "pocketmine", Config = {}) {
module.exports = {
Parse
};
};