Пример #1
0
        public Task(ICoreServerAPI api) : base(api)
        {
            _api = api;
            var conf = _api.LoadOrCreateConf <Config>(_automessageFilename);

            if (conf.messages.Count == 0)
            {
                api.Logger.Warning($"Oh, i don't see any messages in automessages file. Generating default...");
                var defaultMessages = new List <string> {
                    "First message! Set messages in automessage.json!",
                    "Second message! Plugin repository <a href='http://github.com/kiriharu/kessentials'>is here</a>",
                    "Third message! I can use <font size='5' " +
                    "color='green'" +
                    " weight='bold'" + ">VTML</font>"
                };
                conf.messages = defaultMessages;
                api.StoreModConfig(conf, _automessageFilename);
            }
            else
            {
                _messages = conf.messages;
            }
            _prefix = conf.prefix;
            Timer   = conf.timer;
            _minPlayersCountToPost = conf.minPlayersCountToPost;
        }
Пример #2
0
 /// <summary>
 /// Save cooldowns to file and update kits on reload and shutdown
 /// </summary>
 public override void Dispose()
 {
     base.Dispose();
     // Save cooldowns
     KitsCooldownManagerStorage.Save();
     // Kits loading
     LoadedKitsStorageClass = _coreServerApi.LoadOrCreateConf <KitsStorageClass>(KitsConfigName);
 }
Пример #3
0
        public override void StartServerSide(ICoreServerAPI api)
        {
            base.StartServerSide(api);

            // Load main config
            var conf = api.LoadOrCreateConf <Config>("kessentials.json");

            // TODO: Сначала смотреть, есть ли вообще либа. Если её нет - просто писать варнинг, что её нет
            // KEssentials Automessage
            if (conf.EnableAutomessage)
            {
                api.ModLoader.GetModSystem <KEssentialsAutomessage>();
            }
        }
Пример #4
0
        public override void StartServerSide(ICoreServerAPI api)
        {
            base.StartServerSide(api);
            _coreServerApi = api;

            // Kit Config register
            LoadedKitsStorageClass = api.LoadOrCreateConf <KitsStorageClass>(KitsConfigName);

            // Kit Cooldown manager
            KitsCooldownManagerStorage = new KitCooldownManagerStorage(_coreServerApi, CooldownsConfigName);
            KitsCooldownManagerStorage.Load();
            KitsCooldownManager = KitsCooldownManagerStorage.CooldownManager;

            var kitsInstance = new Api.DefaultKits();

            if (LoadedKitsStorageClass.kits.Count == 0)
            {
                var defaultKit = kitsInstance.GetDefaultKit();
                LoadedKitsStorageClass.kits.Add(defaultKit);
                api.StoreModConfig(kitsInstance.GetLoadedKits(), KitsConfigName);
            }

            // Register commands
            api.RegisterCommand(new Commands.Kit(api, kitsInstance));
            api.RegisterCommand(new Commands.Kits(api, kitsInstance));

            // Register priveleges
            api.RegisterPrivilegeClass(typeof(Privilege));
            foreach (var kit in LoadedKitsStorageClass.kits)
            {
                api.Logger.Event($"Register {Privilege.kit}.{kit.name} kit-based permission");
                api
                .Permissions
                .RegisterPrivilege($"{Privilege.kit}.{kit.name}", $"Kit {kit.name}", true);
            }

            // Give kits on first join
            api.Event.PlayerCreate += kitsInstance.GiveFirstJoinKits;

            // Saving cooldowns to file
            api.Event.Timer(CooldownSaveTimer, 3600);
        }
Пример #5
0
 public void Load()
 {
     StorageClass = _serverApi.LoadOrCreateConf <T>(_configStorage);
 }