Пример #1
0
        /// <summary>
        /// Registers the appropriate hooks, loads the existing config or write one if not, and then starts the one second update timer.
        /// </summary>
        public override void Initialize()
        {
            ServerApi.Hooks.NetGetData.Register(this, GetData);
            ServerApi.Hooks.ServerJoin.Register(this, ServerJoin);
            ServerApi.Hooks.ServerLeave.Register(this, ServerLeave);
            ServerApi.Hooks.ServerChat.Register(this, ServerChat);
            ServerApi.Hooks.NetSendData.Register(this, SendData);
            Commands.ChatCommands.Add(new Command("pvpcontroller.reload", Reload, "pvpcreload"));
            Commands.ChatCommands.Add(new Command("pvpcontroller.spectate", ToggleSpectate, "spectate"));
            SetupConfig();

            foreach (var netID in Config.BannedArmorPieces)
            {
                EquipItems.Add(new EquipItem(netID, true));
            }

            if (Config.UseDatabase)
            {
                SetupDatabase();
            }

            if (Config.UseRedis)
            {
                Synchroniser = new Synchroniser(this);
            }

            GetDataHandler = new GetDataHandlers(this);
            DataSender     = new DataSender();
            SetupUpdateTimer();
            SetupDuplicateEquipPrevention();
        }
Пример #2
0
        /// <summary>
        /// Ensures that this player has non-prefixed armor if the option is enabled
        /// </summary>
        /// <param name="handlers"></param>
        internal void CheckArmorAndEnforce(GetDataHandlers handlers)
        {
            if (TPlayer.armor[0].prefix > 0)
            {
                TPlayer.armor[0].prefix = 0;
                Controller.DataSender.SendSlotUpdate(this, 59, TPlayer.armor[0]);
            }

            if (TPlayer.armor[1].prefix > 0)
            {
                Controller.DataSender.SendSlotUpdate(this, 60, TPlayer.armor[1]);
            }

            if (TPlayer.armor[2].prefix > 0)
            {
                Controller.DataSender.SendSlotUpdate(this, 61, TPlayer.armor[2]);
            }
        }