ChestControl.Commands.Load C# (CSharp) Метод

Load() публичный статический Метод

public static Load ( ) : void
Результат void
        public static void Load()
        {
            //Get ready to update to new Commands when TShock releases the next version
            TShockAPI.Commands.ChatCommands.Add(new Command("protectchest", Set, "cset", "setchest"));
            TShockAPI.Commands.ChatCommands.Add(new Command("protectchest", UnSet, "cunset", "unsetchest"));
            TShockAPI.Commands.ChatCommands.Add(new Command("protectchest", CancelSet, "ccset", "ccunset", "cancelsetchest", "cancelunsetchest"));

            TShockAPI.Commands.ChatCommands.Add(new Command("protectchest", SetRegionChest, "crset", "rchest", "regionsharechest"));
            TShockAPI.Commands.ChatCommands.Add(new Command("protectchest", SetPublicChest, "cpset", "pchest", "setpublicchest"));
            TShockAPI.Commands.ChatCommands.Add(new Command("protectchest", SetPasswordChest, "clock", "lockchest", "chestlock") {DoLog = false});
            TShockAPI.Commands.ChatCommands.Add(new Command("refillchest", SetRefillChest, "crefill", "refillchest", "chestrefill"));

            //everyone can unlock
            TShockAPI.Commands.ChatCommands.Add(new Command(UnLockChest, "cunlock", "unlockchest", "chestunlock") {DoLog = false});

            //add permissions to db if not exists
            bool perm = TShock.Groups.groups.Where(@group => @group.Name != "superadmin").Any(@group => group.HasPermission("protectchest"));
            if (!perm)
            {
                var permissions = new List<string>
                                      {
                                          "protectchest",
                                          "openallchests",
                                          "removechestprotection",
                                          "showchestinfo",
                                          "refillchest"
                                      };
                TShock.Groups.AddPermissions("trustedadmin", permissions);
            }
        }

Usage Example

Пример #1
0
        private void OnUpdate()
        {
            if ((DateTime.UtcNow - LastSave).TotalMinutes >= 5)
            {
                try
                {
                    ChestManager.Save(); //save chests
                }
                catch (Exception ex)     //we don't want the world to fail to save.
                {
                    Log.Write(ex.ToString(), LogLevel.Error);
                }
                finally
                {
                    LastSave = DateTime.UtcNow;
                }
            }
            if (Init)
            {
                return;
            }
            Log.Initialize(ChestManager.ChestLogPath, false);
            Log.Write("Initiating ChestControl...", LogLevel.Info);
            ChestManager.Load();
            Commands.Load();

            for (int i = 0; i < Players.Length; i++)
            {
                Players[i] = new CPlayer(i);
            }
            Init = true;
        }