Skip to content

Commit

Permalink
Merge pull request #21 from EvoEsports/dev
Browse files Browse the repository at this point in the history
fixing the plugins loader
  • Loading branch information
reaby authored Jun 16, 2024
2 parents 6c47e37 + d96188d commit 483ddda
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 7 deletions.
12 changes: 8 additions & 4 deletions core/commandmanager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -169,14 +169,18 @@ export default class CommandManager {
let out = [];
let all = [];
let diff = [];
let plugins = fs.readdirSync("./core/plugins", { withFileTypes: true, recursive: true });
plugins = plugins.concat(fs.readdirSync("./userdata/plugins", { withFileTypes: true, recursive: true }));
let plugins = fs.readdirSync(process.cwd() +"/core/plugins", { withFileTypes: true, recursive: true });
plugins = plugins.concat(fs.readdirSync(process.cwd() + "/userdata/plugins", { withFileTypes: true, recursive: true }));

for (const i in plugins) {
const plugin = plugins[i];
if (plugin && plugin.isDirectory()) {
const name = plugin.name.replaceAll("\\", "/");
all.push(name);
const path = plugin.path.replace(process.cwd() + "/core/plugins", "").replace(process.cwd() + "/userdata/plugins", "");
let pluginName = plugin.name.replaceAll("\\", "/");
if (path != "") {
pluginName = (path.substring(1) +"/"+ plugin.name).replaceAll("\\", "/");
}
all.push(pluginName);
}
}

Expand Down
14 changes: 11 additions & 3 deletions core/minicontrol.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class MiniControl {
* The version of MiniControl.
*/
readonly brand: string = "$n$o$eeeMINI$o$z$s$abccontrol$z$s¤white¤";
readonly version: string = "0.3.6";
readonly version: string = "0.3.7";
/**
* The start time of MiniControl.
*/
Expand Down Expand Up @@ -356,17 +356,25 @@ class MiniControl {
let include = false;
const plugin = plugins[i];
include = plugin && plugin.isDirectory();
const path = plugin.path.replace(process.cwd() + "/core/plugins", "").replace(process.cwd() + "/userdata/plugins", "");
let pluginName = plugin.name.replaceAll("\\", "/");
if (path != "") {
pluginName = (path.substring(1) +"/"+ plugin.name).replaceAll("\\", "/");
}

for (const excludeName of exclude) {
if (excludeName == "") continue;
if (plugin.name.replaceAll("\\", "/").startsWith(excludeName.trim())) {
if (pluginName.replaceAll("\\", "/").startsWith(excludeName.trim())) {
include = false;
break;
}
}

if (include) {
loadList.push(plugin.name.replaceAll("\\", "/"));
loadList.push(pluginName);
}
}

// load metadata
for (const name of loadList) {
const pluginName = process.cwd() + "/" + this.findPlugin(name)
Expand Down

0 comments on commit 483ddda

Please sign in to comment.