internal static List <EffectSpawner> ReadAll(string json) { List <EffectSpawner> spawners = new List <EffectSpawner>(); if (elems == null) { elems = ConfigElement.GetAll(typeof(EffectSpawner)); } //JsonContext ctx = new JsonContext(); ctx.Val = json; //JsonArray array = (JsonArray)Json.ParseStream(ctx); JsonReader reader = new JsonReader(json); JsonArray array = (JsonArray)reader.Parse(); if (array == null) { return(spawners); } foreach (object raw in array) { JsonObject obj = (JsonObject)raw; if (obj == null) { continue; } EffectSpawner data = new EffectSpawner(); obj.Deserialise(elems, data); spawners.Add(data); } return(spawners); }
public override void Use(Player p, string message, CommandData data) { if (message.Length == 0) { if (p.IsSuper) { SuperRequiresArgs(p, "player name or IP"); return; } message = p.name; } string name, ip = ModActionCmd.FindIP(p, message, "Location", out name); if (ip == null) return; if (HttpUtil.IsPrivateIP(ip)) { p.Message("%WPlayer has an internal IP, cannot trace"); return; } JsonContext ctx = new JsonContext(); using (WebClient client = HttpUtil.CreateWebClient()) { ctx.Val = client.DownloadString(https://geoip.pw/" + ip); } JsonObject obj = (JsonObject)Json.ParseStream(ctx); GeoInfo info = new GeoInfo(); if (obj == null || !ctx.Success) { p.Message("%WError parsing GeoIP info"); return; } if (elems == null) elems = ConfigElement.GetAll(typeof(GeoInfo)); obj.Deserialise(elems, info); string target = name == null ? ip : "of " + PlayerInfo.GetColoredName(p, name); p.Message("The IP {0} %Shas been traced to: &b{1}%S/&b{2}", target, info.region, info.country); }
public void Retrieve(string mapName) { if (elems == null) { elems = ConfigElement.GetAll(typeof(CTFConfig)); } PropertiesFile.Read("CTF/" + mapName + ".config", LineProcessor); }
public override void Save(string map) { if (cfg == null) { cfg = ConfigElement.GetAll(typeof(TWMapConfig)); } SaveTo(cfg, propsDir, map); }
public override void Load(string map) { if (cfg == null) { cfg = ConfigElement.GetAll(typeof(TWMapConfig)); } LoadFrom(cfg, propsDir, map); }
public void Load(string map) { if (cfg == null) { cfg = ConfigElement.GetAll(typeof(TWMapConfig)); } ConfigElement.ParseFile(cfg, Path(map), this); }
public void Save(string map) { if (cfg == null) { cfg = ConfigElement.GetAll(typeof(NOGMapConfig)); } ConfigElement.SerialiseSimple(cfg, Path(map), this); }
public override void Load() { if (cfg == null) { cfg = ConfigElement.GetAll(typeof(ZSConfig)); } PropertiesFile.Read(PropsPath, ProcessConfigLine); }
public void Save() { if (cfg == null) { cfg = ConfigElement.GetAll(typeof(DiscordConfig)); } ConfigElement.SerialiseSimple(cfg, file, this); }
public virtual void Load() { if (cfg == null) { cfg = ConfigElement.GetAll(GetType()); } ConfigElement.ParseFile(cfg, PropsPath, this); }
public virtual void Save() { if (cfg == null) { cfg = ConfigElement.GetAll(GetType()); } ConfigElement.SerialiseSimple(cfg, PropsPath, this); }
public void Save(string effectName) { if (cfg == null) { cfg = ConfigElement.GetAll(typeof(EffectConfig)); } ConfigElement.SerialiseSimple(cfg, "effects/" + effectName + ".properties", this); }
public void Load(string effectName) { if (cfg == null) { cfg = ConfigElement.GetAll(typeof(EffectConfig)); } ConfigElement.ParseFile(cfg, "effects/" + effectName + ".properties", this); }
public override void Use(Player p, string message, CommandData data) { if (message.Length == 0) { if (p.IsSuper) { SuperRequiresArgs(p, "player name or IP"); return; } message = p.name; } string name, ip = ModActionCmd.FindIP(p, message, "Location", out name); if (ip == null) { return; } if (HttpUtil.IsPrivateIP(ip)) { p.Message("%WPlayer has an internal IP, cannot trace"); return; } JsonContext ctx = new JsonContext(); using (WebClient client = HttpUtil.CreateWebClient()) { ctx.Val = client.DownloadString("http://geoip.pw/api/" + ip); } JsonObject obj = (JsonObject)Json.ParseStream(ctx); GeoInfo info = new GeoInfo(); if (obj == null || !ctx.Success) { p.Message("%WError parsing GeoIP info"); return; } if (elems == null) { elems = ConfigElement.GetAll(typeof(GeoInfo)); } obj.Deserialise(elems, info); string target = name == null ? ip : "of " + PlayerInfo.GetColoredName(p, name); p.Message("The IP {0} %Shas been traced to: ", target); p.Message(" Continent: &f{1}&S ({0})", info.continent_abbr, info.continent); p.Message(" Country: &f{1}&S ({0})", info.country_abbr, info.country); p.Message(" Region/State: &f{0}", info.subdivision); p.Message(" City: &f{0}", info.city); p.Message(" Time Zone: &f{0}", info.timezone); p.Message(" Hostname: &f{0}", info.host); p.Message(" Is using proxy: &f{0}", info.proxy); p.Message("Geoip information by: &9http://geoip.pw/"); }
internal static void WriteAll(TextWriter dst, List <BotProperties> props) { if (elems == null) { elems = ConfigElement.GetAll(typeof(BotProperties)); } JsonConfigWriter w = new JsonConfigWriter(dst, elems); w.WriteArray(props); }
public virtual void Save() { if (cfg == null) { cfg = ConfigElement.GetAll(GetType()); } using (StreamWriter w = new StreamWriter(PropsPath)) { w.WriteLine("#" + GameName + " configuration"); ConfigElement.SerialiseElements(cfg, w, this); } }
public void Save(string map) { if (!Directory.Exists(propsDir)) { Directory.CreateDirectory(propsDir); } if (cfg == null) { cfg = ConfigElement.GetAll(typeof(TWMapConfig)); } ConfigElement.SerialiseSimple(cfg, Path(map), this); }
public void Save() { if (cfg == null) { cfg = ConfigElement.GetAll(typeof(DiscordConfig)); } using (StreamWriter w = new StreamWriter(PROPS_PATH)) { w.WriteLine("# Discord relay bot configuration"); w.WriteLine("# See " + Updater.SourceURL + "/wiki/Discord-relay-bot/"); w.WriteLine(); ConfigElement.SerialiseElements(cfg, w, this); } }
public void Load() { // create default config file if (!File.Exists(file)) { Save(); } if (cfg == null) { cfg = ConfigElement.GetAll(typeof(DiscordConfig)); } ConfigElement.ParseFile(cfg, file, this); }
public override void Save() { if (cfg == null) { cfg = ConfigElement.GetAll(typeof(ZSConfig)); } using (StreamWriter w = new StreamWriter(PropsPath)) { w.WriteLine("# no-pillaring-during-zombie = Disables pillaring while Zombie Survival is activated."); w.WriteLine("# zombie-name-while-infected = Sets the zombies name while actived if there is a value."); w.WriteLine(); ConfigElement.Serialise(cfg, w, this); } }
public override void Use(Player p, string message, CommandData data) { if (message.Length == 0) { if (p.IsSuper) { SuperRequiresArgs(p, "player name or IP"); return; } message = p.name; } string name, ip = ModActionCmd.FindIP(p, message, "Location", out name); if (ip == null) { return; } if (HttpUtil.IsPrivateIP(ip)) { p.Message("%WPlayer has an internal IP, cannot trace"); return; } bool success; string ipInfo; using (WebClient client = HttpUtil.CreateWebClient()) { ipInfo = client.DownloadString("http://ipinfo.io/" + ip + "/geo"); } JsonObject obj = (JsonObject)Json.Parse(ipInfo, out success); GeoInfo info = new GeoInfo(); if (obj == null || !success) { p.Message("%WError parsing GeoIP info"); return; } if (elems == null) { elems = ConfigElement.GetAll(typeof(GeoInfo)); } obj.Deserialise(elems, info); string suffix = HasExtraPerm(p, data.Rank, 1) ? "&b{1}%S/&b{2}" : "&b{2}"; string nick = name == null ? ip : "of " + p.FormatNick(name); p.Message("The IP {0} %Straces to: " + suffix, nick, info.region, info.country); }
public override void Load(bool startup) { if (!File.Exists(SETTINGS_FILE)) { SaveDefault(); } SSLConfig settings = new SSLConfig(); ConfigElement[] cfg = ConfigElement.GetAll(typeof(SSLConfig)); ConfigElement.ParseFile(cfg, SETTINGS_FILE, settings); // UGLY HACK I don't know what this file should even contain??? seems you need public and private key Cert = new X509Certificate2(settings.CertPath, settings.CertPath); INetSocket.Protocols[0x16] = ConstructSecureWebsocket; }
internal static void WriteAll(StreamWriter w, List <EffectSpawner> props) { w.WriteLine("["); if (elems == null) { elems = ConfigElement.GetAll(typeof(EffectSpawner)); } string separator = null; for (int i = 0; i < props.Count; i++) { w.Write(separator); Json.Serialise(w, elems, props[i]); separator = ",\r\n"; } w.WriteLine("]"); }
internal static void WriteAll(TextWriter w, List <BotProperties> props) { w.WriteLine("["); if (elems == null) { elems = ConfigElement.GetAll(typeof(BotProperties)); } string separator = null; for (int i = 0; i < props.Count; i++) { w.Write(separator); Json.Serialise(w, elems, props[i]); separator = ",\r\n"; } w.WriteLine("]"); }
internal static List <BotProperties> ReadAll(string path) { List <BotProperties> props = new List <BotProperties>(); if (elems == null) { elems = ConfigElement.GetAll(typeof(BotProperties)); } string json = File.ReadAllText(path); JsonReader reader = new JsonReader(json); reader.OnMember = (obj, key, value) => { if (obj.Meta == null) { obj.Meta = new BotProperties(); } ConfigElement.Parse(elems, obj.Meta, key, (string)value); }; JsonArray array = (JsonArray)reader.Parse(); if (array == null) { return(props); } foreach (object raw in array) { JsonObject obj = (JsonObject)raw; if (obj == null || obj.Meta == null) { continue; } BotProperties data = (BotProperties)obj.Meta; if (String.IsNullOrEmpty(data.DisplayName)) { data.DisplayName = data.Name; } props.Add(data); } return(props); }
internal static List <BotProperties> ReadAll(string path) { List <BotProperties> props = new List <BotProperties>(); if (elems == null) { elems = ConfigElement.GetAll(typeof(BotProperties)); } string json = File.ReadAllText(path); bool success; JsonArray array = (JsonArray)Json.Parse(json, out success); if (array == null) { return(props); } foreach (object raw in array) { JsonObject obj = (JsonObject)raw; if (obj == null) { continue; } BotProperties data = new BotProperties(); obj.Deserialise(elems, data); if (String.IsNullOrEmpty(data.DisplayName)) { data.DisplayName = data.Name; } props.Add(data); } return(props); }
internal static List <BotProperties> ReadAll(string json) { List <BotProperties> props = new List <BotProperties>(); if (elems == null) { elems = ConfigElement.GetAll(typeof(BotProperties)); } JsonContext ctx = new JsonContext(); ctx.Val = json; JsonArray array = (JsonArray)Json.ParseStream(ctx); if (array == null) { return(props); } foreach (object raw in array) { JsonObject obj = (JsonObject)raw; if (obj == null) { continue; } BotProperties data = new BotProperties(); obj.Deserialise(elems, data); if (String.IsNullOrEmpty(data.DisplayName)) { data.DisplayName = data.Name; } props.Add(data); } return(props); }