public string getCustomSetting(string settingname)
        {
            JSONWriter writer = new JSONWriter();

            writer.WriteStartArray();
            foreach (CustomSetting setting in CustomSettings)
            {
                if (setting.SettingName == settingname.ToLower())
                {
                    writer.WriteStartObject();
                    writer.WritePropertyName("Name");
                    writer.WriteValue(setting.SettingName);
                    writer.WritePropertyName("Private");
                    writer.WriteValue(setting.Private);
                    writer.WritePropertyName("Value");
                    writer.WriteValue(setting.Value);
                    writer.WriteEndObject();

                    break;
                }
            }
            writer.WriteEndArray();

            return(writer.GetString());
        }
        public string getSettings()
        {
            JSONWriter writer = new JSONWriter();

            writer.WriteStartObject();
            foreach (FieldInfo field in Settings.GetType().GetFields())
            {
                writer.WritePropertyName(field.Name);
                writer.WriteValue(field.GetValue(Settings));
            }
            writer.WriteEndObject();

            return(writer.GetString());
        }
        public string getCustomSettings()
        {
            JSONWriter writer = new JSONWriter();

            writer.WriteStartArray();
            foreach (CustomSetting setting in CustomSettings)
            {
                writer.WriteRaw(getCustomSetting(setting.SettingName));
            }

            writer.WriteEndArray();

            return(writer.GetString());
        }
        public string getPlugins()
        {
            JSONWriter writer = new JSONWriter();

            writer.WriteStartArray();

            foreach (PluginJS plugin in tmch.Plugins)
            {
                writer.WriteRaw(getPlugin(plugin.PluginName) + ',');
            }

            writer.WriteEndArray();

            return(writer.GetString());
        }
        public string getExtensions()
        {
            JSONWriter writer = new JSONWriter();

            writer.WriteStartArray();

            foreach (PluginNET plugin in extloader.Plugins)
            {
                writer.WriteRaw(getExtension(plugin.PluginName) + ',');
            }

            writer.WriteEndArray();

            return(writer.GetString());
        }
        public string getClients()
        {
            JSONWriter writer = new JSONWriter();

            writer.WriteStartArray();

            foreach (Client client in Clients)
            {
                writer.WriteRaw(getClient((int)client.ID) + ',');
            }

            writer.WriteEndArray();

            return(writer.GetString());
        }
        public string getExtension(string filenamewithoutextension)
        {
            foreach (PluginNET plugin in extloader.Plugins)
            {
                if (plugin.PluginName == filenamewithoutextension)
                {
                    JSONWriter writer = new JSONWriter();

                    writer.WriteStartObject();
                    writer.WritePropertyName("PluginName");
                    writer.WriteValue(plugin.PluginName);
                    writer.WriteEndObject();

                    return(writer.GetString());
                }
            }

            return(string.Empty);
        }
        public string getPlugin(string filenamewithoutextension)
        {
            foreach (PluginJS plugin in tmch.Plugins)
            {
                if (plugin.PluginName == filenamewithoutextension)
                {
                    JSONWriter writer = new JSONWriter();

                    writer.WriteStartObject();
                    writer.WritePropertyName("PluginName");
                    writer.WriteValue(plugin.PluginName);

                    writer.WritePropertyName("AddedCommands");
                    writer.WriteStartArray();

                    foreach (string addedcommand in plugin.AddedCommands)
                    {
                        writer.WriteValue(addedcommand);
                    }

                    writer.WriteEndArray();

                    writer.WritePropertyName("HandledEvents");
                    writer.WriteStartArray();

                    foreach (string handledevent in plugin.HandledEvents)
                    {
                        writer.WriteValue(handledevent);
                    }

                    writer.WriteEndArray();
                    writer.WriteEndObject();

                    return(writer.GetString());
                }
            }

            return(string.Empty);
        }
        public string getClient(int playerid)
        {
            foreach (Client client in Clients)
            {
                if (client.ID == playerid)
                {
                    JSONWriter writer = new JSONWriter();

                    writer.WriteStartObject();
                    writer.WritePropertyName("ID");
                    writer.WriteValue(client.ID);
                    writer.WritePropertyName("AvgCosts");
                    writer.WriteValue(client.AvgCosts);
                    writer.WritePropertyName("AvgIncome");
                    writer.WriteValue(client.AvgIncome);
                    writer.WritePropertyName("AvgScore");
                    writer.WriteValue(client.AvgScore);
                    writer.WritePropertyName("Boss");
                    writer.WriteValue(client.Boss);
                    writer.WritePropertyName("Cash");
                    writer.WriteValue(client.Cash);
                    writer.WritePropertyName("Code");
                    writer.WriteValue(client.Code);
                    writer.WritePropertyName("CurrentWeek");
                    writer.WriteValue(client.CurrentWeek);
                    writer.WritePropertyName("Employees");
                    writer.WriteValue(client.Employees);
                    writer.WritePropertyName("Fans");
                    writer.WriteValue(client.Fans);
                    writer.WritePropertyName("FavouriteGenre");
                    writer.WriteValue(client.FavouriteGenre);
                    writer.WritePropertyName("GameCount");
                    writer.WriteValue(client.GameCount);
                    writer.WritePropertyName("HighScore");
                    writer.WriteValue(client.HighScore);
                    writer.WritePropertyName("IP");
                    writer.WriteValue(client.Context.ConnectionInfo.ClientIpAddress);

                    writer.WritePropertyName("Mods");
                    writer.WriteStartArray();
                    foreach (ClientMod mod in client.Mods)
                    {
                        writer.WriteStartObject();
                        writer.WritePropertyName("ID");
                        writer.WriteValue(mod.ID);
                        writer.WritePropertyName("Name");
                        writer.WriteValue(mod.Name);
                        writer.WriteEndObject();
                    }
                    writer.WriteEndArray();

                    writer.WritePropertyName("Name");
                    writer.WriteValue(client.Name);
                    writer.WritePropertyName("Op");
                    writer.WriteValue(client.Op);
                    writer.WritePropertyName("PlatformCount");
                    writer.WriteValue(client.PlatformCount);
                    writer.WritePropertyName("Port");
                    writer.WriteValue(client.Context.ConnectionInfo.ClientPort);
                    writer.WritePropertyName("ResearchPoints");
                    writer.WriteValue(client.ResearchPoints);
                    writer.WriteEndObject();

                    return(writer.GetString());
                }
            }

            return(string.Empty);
        }