public static void Initialize()
 {
     Banned.Initialized  = false;
     Banned.SaveFilePath = Path.Combine(Core.SavePath, Banned.string_0);
     Banned.Database     = new Dictionary <ulong, UserBanned>();
     if (Core.DatabaseType.Contains("FILE"))
     {
         Banned.Initialized = Banned.LoadAsTextFile();
     }
     if (Core.DatabaseType.Contains("MYSQL"))
     {
         Banned.Initialized = Banned.LoadAsDatabaseSQL();
     }
 }
        public static bool Add(ulong steam_id, string reason = "", DateTime period = default(DateTime), string details = "")
        {
            bool result;

            if (!Users.Database.ContainsKey(steam_id))
            {
                result = false;
            }
            else
            {
                Users.SetFlags(steam_id, UserFlags.banned, true);
                if (Banned.Database.ContainsKey(steam_id))
                {
                    result = true;
                }
                else
                {
                    if (reason == "")
                    {
                        reason = "No reason.";
                    }
                    if (details == "")
                    {
                        details = "No details.";
                    }
                    UserBanned userBanned = new UserBanned(Users.Database[steam_id].LastConnectIP, DateTime.Now, period, reason, details);
                    Banned.Database.Add(steam_id, userBanned);
                    if (Core.DatabaseType.Equals("FILE"))
                    {
                        Banned.SaveAsTextFile();
                    }
                    if (Core.DatabaseType.Equals("MYSQL"))
                    {
                        MySQL.Update(string.Format(Banned.SQL_INSERT_USER_BANNED, new object[]
                        {
                            steam_id,
                            userBanned.IP,
                            userBanned.Time.ToString("yyyy-MM-dd HH:mm:ss"),
                            userBanned.Period.ToString("yyyy-MM-dd HH:mm:ss"),
                            MySQL.QuoteString(userBanned.Reason),
                            MySQL.QuoteString(userBanned.Details)
                        }));
                    }
                    result = true;
                }
            }
            return(result);
        }
 public static bool Remove(ulong steam_id)
 {
     if (Users.Database.ContainsKey(steam_id))
     {
         Users.SetFlags(steam_id, UserFlags.banned, false);
         Blocklist.Remove(Users.Database[steam_id].LastConnectIP);
     }
     if (Banned.Database.ContainsKey(steam_id))
     {
         Banned.Database.Remove(steam_id);
     }
     if (Core.DatabaseType.Equals("FILE"))
     {
         Banned.SaveAsTextFile();
     }
     if (Core.DatabaseType.Equals("MYSQL"))
     {
         MySQL.Update(string.Format(Banned.SQL_DELETE_USER_BANNED, steam_id));
     }
     return(true);
 }
 public static bool Clear()
 {
     foreach (ulong current in Users.Database.Keys)
     {
         if (Users.HasFlag(current, UserFlags.banned))
         {
             Users.Database[current].SetFlag(UserFlags.banned, false);
         }
         if (Banned.Database.ContainsKey(current))
         {
             Banned.Database.Remove(current);
             Blocklist.Remove(Users.Database[current].LastConnectIP);
         }
     }
     if (Core.DatabaseType.Equals("FILE"))
     {
         Banned.SaveAsTextFile();
     }
     if (Core.DatabaseType.Equals("MYSQL"))
     {
         MySQL.Update(Banned.SQL_CLEAR_USER_BANLIST);
     }
     return(true);
 }
Example #5
0
        public static bool Initialize()
        {
            Initialized = AssemblyVerifed;
            if (!Initialized)
            {
                return(false);
            }
            Helper.Log("RustExtended Initialization", true);
            World.Initialize();
            Zones.Initialize();
            Economy.Initialize();
            Helper.Log("RustExtended Economy " + (Economy.Enabled ? "Enabled" : "Disabled") + ".", true);
            Helper.Log("RustExtended Shopping " + (Shop.Enabled ? "Enabled" : "Disabled") + ".", true);
            Users.Initialize();
            Banned.Initialize();
            Clans.Initialize();
            Blocklist.Initialize();
            LoadoutInitialized = InitializeLoadout();
            if (Config.Initialized)
            {
                Helper.Log("  - " + PremiumConnections + " Allocated Premium Connection(s)", true);
                Helper.Log("  - " + Commands.Count + " Total Command(s)", true);
                Helper.Log("  - " + Ranks.Count + " Total Rank(s)", true);
                Helper.Log("  - " + Kits.Count + " Total Kit(s)", true);
                Helper.Log("  - " + ForbiddenUsername.Count + " Total Forbidden Name(s)", true);
                Helper.Log("  - " + ForbiddenObscene.Count + " Total Obscene(s)", true);
                Helper.Log("  - " + Events.Motd.Count + " Total Message Event(s)", true);
                Helper.Log("  - " + Clans.Levels.Count + " Total Clan Level(s)", true);
            }
            if (LoadoutInitialized)
            {
                Helper.Log("  - " + Loadout.Count + " Loadout", true);
            }
            if (Zones.Initialized)
            {
                Helper.Log("  - " + Zones.Count + " Total Zone(s)", true);
            }
            if (Users.Initialized)
            {
                Helper.Log("  - " + Users.Count + " Total User(s)", true);
            }
            if (Banned.Initialized)
            {
                Helper.Log("  - " + Banned.Count + " Banned User(s)", true);
            }
            if (Clans.Initialized)
            {
                Helper.Log("  - " + Clans.Count + " Total Clan(s)", true);
            }
            if (Economy.Enabled && Shop.Initialized)
            {
                Helper.Log("  - " + Shop.GroupCount + " Total Shop Group(s)", true);
                Helper.Log("  - " + Shop.ItemCount + " Total Shop Item(s)", true);
            }
            if (Blocklist.Initialized)
            {
                Helper.Log("  - " + Blocklist.Count + " Total Blocked IP", true);
            }
            if (Override.LootsFileCreated)
            {
                Helper.Log(" Loots file has been created.", true);
            }
            else if (OverrideLoots && Override.LootsInitialized)
            {
                Helper.Log("  - " + Override.LootsCount + " Overridden Loot(s)", true);
            }
            if (Override.ItemsFileCreated)
            {
                Helper.Log(" Items file has been created.", true);
            }
            else if (OverrideItems && Override.ItemsInitialized)
            {
                Helper.Log("  - " + Override.ItemsCount + " Overridden Item(s)", true);
            }
            Events.Initialize();
            GenericSpawners = UnityEngine.Object.FindObjectsOfType <GenericSpawner>();
            for (int i = 0; i < GenericSpawners.Length; i++)
            {
                int num2 = 0;
                switch (i)
                {
                case 0x2b:
                    GenericSpawners[i].transform.position = new Vector3(6019f, 428.8f, -2296.3f);
                    break;

                case 0x2c:
                    GenericSpawners[i].transform.position = new Vector3(5819f, 428.8f, -1896.3f);
                    break;
                }
                foreach (GenericSpawnerSpawnList.GenericSpawnInstance instance in GenericSpawners[i]._spawnList)
                {
                    GenericSpawnsTotal += instance.targetPopulation;
                    num2 += instance.targetPopulation;
                }
                Helper.Log(string.Format("[GenericSpawner #{0}] Position={1}, Radius={2}, Spawns={3}({4}), Think Delay={5}", new object[] { i, GenericSpawners[i].transform.position.AsString(), GenericSpawners[i].radius, GenericSpawners[i]._spawnList.Count, num2, GenericSpawners[i].thinkDelay }), false);
            }
            return(Initialized);
        }
Example #6
0
        public static bool Initialize()
        {
            Core.Initialized = Core.AssemblyVerifed;
            bool result;

            if (!Core.Initialized)
            {
                result = false;
            }
            else
            {
                Helper.Log("RustExtended Initialization", true);
                World.Initialize();
                Zones.Initialize();
                Economy.Initialize();
                Users.Initialize();
                Banned.Initialize();
                Clans.Initialize();
                Blocklist.Initialize();
                Core.LoadoutInitialized = Core.InitializeLoadout();
                if (Spawns.Singleton != null)
                {
                    Spawns.Singleton.Initialize();
                }
                if (Config.Initialized)
                {
                    Helper.Log("  - " + Core.PremiumConnections + " Allocated Premium Connection(s)", true);
                    Helper.Log("  - " + Core.Commands.Count + " Total Command(s)", true);
                    Helper.Log("  - " + Core.Ranks.Count + " Total Rank(s)", true);
                    Helper.Log("  - " + Core.Kits.Count + " Total Kit(s)", true);
                    Helper.Log("  - " + Core.ForbiddenUsername.Count + " Total Forbidden Name(s)", true);
                    Helper.Log("  - " + Core.ForbiddenObscene.Count + " Total Obscene(s)", true);
                    Helper.Log("  - " + Events.Motd.Count + " Total Message Event(s)", true);
                    Helper.Log("  - " + Clans.Levels.Count + " Total Clan Level(s)", true);
                }
                if (Core.LoadoutInitialized)
                {
                }
                if (Zones.Initialized)
                {
                }
                if (Users.Initialized)
                {
                }
                if (Banned.Initialized)
                {
                }
                if (Clans.Initialized)
                {
                }
                if (Economy.Enabled && Shop.Initialized)
                {
                    Helper.Log("  - " + Shop.GroupCount + " Total Shop Group(s)", true);
                    Helper.Log("  - " + Shop.ItemCount + " Total Shop Item(s)", true);
                }
                if (Blocklist.Initialized)
                {
                    Helper.Log("  - " + Blocklist.Count + " Total Blocked IP", true);
                }
                if (!Override.LootsFileCreated)
                {
                    if (Core.OverrideLoots && Override.LootsInitialized)
                    {
                    }
                }
                if (!Override.ItemsFileCreated)
                {
                    if (Core.OverrideItems && Override.ItemsInitialized)
                    {
                    }
                }
                if (Spawns.Initialized)
                {
                    Helper.Log("  - " + Spawns.TotalGeneric + " Generic Spawner(s)", true);
                    Helper.Log("  - " + Spawns.TotalLootable + " Lootable Spawner(s)", true);
                }
                Events.Initialize();
                result = Core.Initialized;
            }
            return(result);
        }