public void onLoad(string ServerDirectory)
        {
            PluginDirectory = ServerDirectory + "ServerModifier";
            Console.WriteLine(PluginDirectory);
            UserDirectory = PluginDirectory + "\\" + "Users";
            Console.WriteLine(UserDirectory);

            if (!Directory.Exists(UserDirectory))
            {
                Directory.CreateDirectory(UserDirectory);
            }

            //Updates the Users list for the directories located. It is assumed you checked from UserDirectory if the user exist and is login.
            UpdateLocalData();

            //To dispose of the list of servers
            AppDomain.CurrentDomain.ProcessExit += new EventHandler(CurrentDomain_ProcessExit);

            //Initializing servers
            foreach (string user in Users)
            {
                DirectoryInfo[] servers = new DirectoryInfo(UserDirectory + "\\" + user).GetDirectories();
                foreach (DirectoryInfo server in servers)
                {
                    serverControlObject serverControl = new serverControlObject();
                    serverControl.Username = user;

                    string serverdirectory = GetServerDirectory(user, server.Name);

                    serverControl.serverController = new ServerController(server.Name, serverdirectory);
                    Console.WriteLine("Initialized " + server.Name + " controller for " + user);
                }
            }
        }
        public void Invoke(ClientSocketWorkload workload, ClientContext context, int port, List <string> Args, string ServerDirectory)
        {
            //ServerModifier [Command] [Username] [Server]
            string Command     = Args[1].ToUpper();
            string UserProfile = Args[2];
            string ServerUI    = Args[3];

            if (Command == "GETSERVERDIRECTORY")
            {
                List <string> UserServers = GetUserServers(UserProfile);

                bool s = false; foreach (string file in UserServers)
                {
                    if (file == ServerUI)
                    {
                        workload.SendMessage(context, UserDirectory + "\\" + UserProfile + "\\" + file); s = true; break;
                    }
                }
                if (s == false)
                {
                    workload.SendMessage(context, "invalid");
                }
            }
            if (Command == "CHANGEENDDATE")
            {
            }
            if (Command == "STARTSERVER")
            {
                ServerController userServerController = GetServerController(UserProfile, ServerUI);
                if (userServerController != null)
                {
                    string startFile       = Args[4];
                    string serverdirectory = GetServerDirectory(UserProfile, ServerUI);
                    string serverStartArgs = Args[5];
                    userServerController.StartServer(startFile, serverdirectory, serverStartArgs);
                    workload.SendMessage(context, "true");
                }
                else
                {
                    workload.SendMessage(context, "invalid");
                }
            }
            if (Command == "GETCONSOLEINFO")
            {
                ServerController userServerController = GetServerController(UserProfile, ServerUI);

                if (userServerController != null)
                {
                    workload.SendMessage(context, userServerController.GetServerOutput());
                }
                else
                {
                    workload.SendMessage(context, "invalid");
                }
            }
            if (Command == "SENDCONSOLECOMMAND")
            {
                ServerController userServerController = GetServerController(UserProfile, ServerUI);

                string consoleCommand = Args[4];
                if (userServerController != null)
                {
                    userServerController.InputCommand(consoleCommand);
                    workload.SendMessage(context, "true");
                }
                else
                {
                    workload.SendMessage(context, "invalid");
                }
            }
            if (Command == "STOPSERVER")
            {
                ServerController userServerController = GetServerController(UserProfile, ServerUI);

                if (userServerController != null)
                {
                    userServerController.StopServer();
                    workload.SendMessage(context, "true");
                }
                else
                {
                    workload.SendMessage(context, "invalid");
                }
            }
            if (Command == "CREATESERVER")
            {
                string UserDirectory = GetPersonalUserDirectory(UserProfile);

                if (Directory.Exists(UserDirectory + "\\" + ServerUI))
                {
                    workload.SendMessage(context, "invalid");
                }
                else
                {
                    string serverdirectory = GetServerDirectory(UserProfile, ServerUI);

                    Directory.CreateDirectory(UserDirectory + "\\" + ServerUI);
                    serverControlObject controllerObject = new serverControlObject();
                    ServerController    controller       = new ServerController(ServerUI, serverdirectory);
                    controllerObject.serverController = controller;
                    controllerObject.Username         = UserProfile;
                    controllers.Add(controllerObject);
                    workload.SendMessage(context, "true");
                }
            }
            if (Command == "DELETESERVER")
            {
                string UserDirectory = GetPersonalUserDirectory(UserProfile);

                if (Directory.Exists(UserDirectory + "\\" + ServerUI))
                {
                    Directory.Delete(UserDirectory + "\\" + ServerUI, true);
                    workload.SendMessage(context, "true");
                }
                else
                {
                    workload.SendMessage(context, "invalid");
                }
            }
            if (Command == "ISONLINE")
            {
                ServerController controller = GetServerController(UserProfile, ServerUI);

                if (controller != null)
                {
                    bool isOn = controller.IsOnline();
                    if (isOn == true)
                    {
                        workload.SendMessage(context, "yes");
                    }
                    if (isOn == false)
                    {
                        workload.SendMessage(context, "no");
                    }
                }
                else
                {
                    workload.SendMessage(context, "invalid");
                }
            }
            if (Command == "GETUSERSERVERS")
            {
                workload.SendMessage(context, string.Join("%20%", GetUserServers(UserProfile)));
            }
            if (Command == "CHANGEEXPIREDATE")
            {
                string   dateString   = Args[4];
                DateTime incomingDate = DateTime.Today;
                try { incomingDate = DateTime.Parse(dateString); }
                catch { workload.SendMessage(context, "Failed to parse DateString"); }

                ServerController controller = GetServerController(UserProfile, ServerUI);

                if (controller != null)
                {
                    if (controller.ChangeExpireTime(incomingDate) == true)
                    {
                        workload.SendMessage(context, "true");
                    }
                    else
                    {
                        workload.SendMessage(context, "falsec");
                    }
                }
                else
                {
                    workload.SendMessage(context, "invalid");
                }
            }
            if (Command == "GETEXPIREDATE")
            {
                ServerController controller = GetServerController(UserProfile, ServerUI);

                if (controller != null)
                {
                    workload.SendMessage(context, controller.GetExpireTime().ToString());
                }
                else
                {
                    workload.SendMessage(context, "invalid");
                }
            }
            if (Command == "CHANGEIMAGEURL")
            {
                string           ImageURL   = Args[4];
                ServerController controller = GetServerController(UserProfile, ServerUI);

                if (controller != null)
                {
                    if (controller.ChangeImageURL(ImageURL))
                    {
                        workload.SendMessage(context, "true");
                    }
                    else
                    {
                        workload.SendMessage(context, "falsec");
                    }
                }
                else
                {
                    workload.SendMessage(context, "invalid");
                }
            }
            if (Command == "GETIMAGEURL")
            {
                ServerController controller = GetServerController(UserProfile, ServerUI);

                if (controller != null)
                {
                    workload.SendMessage(context, controller.GetImageURL());
                }
                else
                {
                    workload.SendMessage(context, "invalid");
                }
            }
            if (Command == "WRITESETTING")
            {
                string           SettingName  = Args[4];
                string           SettingValue = Args[5];
                ServerController controller   = GetServerController(UserProfile, ServerUI);

                if (controller != null)
                {
                    if (controller.WriteSetting(SettingName, SettingValue))
                    {
                        workload.SendMessage(context, "true");
                    }
                    else
                    {
                        workload.SendMessage(context, "falsec");
                    }
                }
                else
                {
                    workload.SendMessage(context, "invalid");
                }
            }
            if (Command == "READSETTING")
            {
                string SettingName = Args[4];

                ServerController controller = GetServerController(UserProfile, ServerUI);

                if (controller != null)
                {
                    workload.SendMessage(context, controller.ReadSetting(SettingName));
                }
                else
                {
                    workload.SendMessage(context, "invalid");
                }
            }
            if (Command == "CHECKSETTING")
            {
                string SettingName = Args[4];

                ServerController controller = GetServerController(UserProfile, ServerUI);

                if (controller != null)
                {
                    if (controller.CheckSetting(SettingName))
                    {
                        workload.SendMessage(context, "true");
                    }
                    else
                    {
                        workload.SendMessage(context, "false");
                    }
                }
                else
                {
                    workload.SendMessage(context, "invalid");
                }
            }
        }