From 27148053ae603118157262ec7a6af84fd020edef Mon Sep 17 00:00:00 2001 From: Danielv123 Date: Sun, 29 Jan 2017 23:34:56 +0100 Subject: [PATCH] Basic plugin implementation --- client.js | 59 ++++++++++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 54 insertions(+), 5 deletions(-) diff --git a/client.js b/client.js index 25eaccb8..e1c1f44a 100644 --- a/client.js +++ b/client.js @@ -11,8 +11,9 @@ var hashFiles = require('hash-files'); // require config.json var config = require('./config'); + // Functions -var deleteFolderRecursive = function (path) { +function deleteFolderRecursive(path) { if (fs.existsSync(path)) { fs.readdirSync(path).forEach(function (file, index) { var curPath = path + "/" + file; @@ -26,11 +27,50 @@ var deleteFolderRecursive = function (path) { } }; -function getDirectories(srcpath) { - return fs.readdirSync(srcpath).filter(function (file) { - return fs.statSync(path.join(srcpath, file)).isDirectory(); - }); +// function to handle sending commands into the game +function messageInterface(command, callback) { + if(client && client.exec && typeof client.exec == "function") { + try { + client.exec(command, callback); + } catch (err) { + console.log(err); + callback(err); + } + } } + +// load plugins and execute onLoad event +let pluginDirectories = getDirectories("./sharedPlugins/"); +let plugins = []; +for(i=0; i