コード例 #1
0
        public static bool SetupConfig()
        {
            try
            {
                if (File.Exists(ConfigPath))
                {
                    Config = TimeConfig.Read(ConfigPath);
                }
                else
                {
                    Config.Write(ConfigPath);
                }

                return(true);
            }
            catch (Exception ex)
            {
                Console.ForegroundColor = ConsoleColor.Red;
                Console.WriteLine("Error in TimeCurrency config (Time.json)! Check logs for more details.");
                Console.ResetColor();
                Log.Error("Error in TimeCurrency config (Time.json):");
                Log.Error(ex.ToString());
                return(false);
            }
        }
コード例 #2
0
        public override void Initialize()
        {
            Commands.ChatCommands.Add(new Command(new List <string>()
            {
                "time.*", "time.default"
            }, CheckTime, "checktime"));
            Commands.ChatCommands.Add(new Command(new List <string>()
            {
                "time.*", "time.default"
            }, CMDTime, "timec"));
            Commands.ChatCommands.Add(new Command(new List <string>()
            {
                "time.*", "time.checkplayed"
            }, CheckTimePlayed, "checktimeplayed"));


            ServerHooks.Join  += OnJoin;
            ServerHooks.Leave += OnLeave;
            GameHooks.Update  += OnUpdate;
            ServerHooks.Chat  += OnChat;

            SqlManager.EnsureTableExists(TShock.DB);

            Config = new TimeConfig();
            SetupConfig();

            if (!TShock.Groups.GroupExists("dead"))
            {
                TShock.Groups.AddGroup("dead", TShock.Config.DefaultRegistrationGroupName, "", Config.DeadGroupColor, false);
            }
            TShock.Groups.GetGroupByName("dead").ChatColor = Config.DeadGroupColor;
            TShock.Groups.GetGroupByName("dead").Prefix    = Config.DeadGroupPrefix;
            TShock.Groups.GetGroupByName("dead").Suffix    = Config.DeadGroupSuffix;

            foreach (Group group in TShock.Groups)
            {
                if (group.Name != "superadmin" && group.Name != TShock.Config.DefaultGuestGroupName)
                {
                    TShock.Groups.AddPermissions(group.Name, (new List <string>()
                    {
                        "time.checkplayed", "time.default"
                    }));
                }
            }
        }