Example #1
0
        internal void GetData(GetDataEventArgs e)
        {
            PacketTypes type   = e.MsgID;
            var         player = TShock.Players[e.Msg.whoAmI];

            if (player == null)
            {
                e.Handled = true;
                return;
            }

            if (!player.ConnectionAlive)
            {
                e.Handled = true;
                return;
            }

            using (var data = new MemoryStream(e.Msg.readBuffer, e.Index, e.Length))
            {
                try
                {
                    if (GetDataHandlers.HandlerGetData(type, player, data))
                    {
                        e.Handled = true;
                    }
                }
                catch (Exception ex)
                {
                    Log.Error(ex.ToString());
                }
            }
        }
Example #2
0
        public override void Initialize()
        {
            C3Tools.SetupConfig();

            if (C3Config.CTFEnabled)
            {
                GameHooks.Update += CTF.OnUpdate;
            }
            if (C3Config.DuelsEnabled)
            {
                GameHooks.Update += Duel.OnUpdate;
            }
            if (C3Config.OneFlagEnabled)
            {
                GameHooks.Update += OneFlagCTF.OnUpdate;
            }
            if (C3Config.TeamDeathmatchEnabled)
            {
                GameHooks.Update += TDM.OnUpdate;
            }
            if (C3Config.MonsterApocalypseEnabled)
            {
                GameHooks.Update += Apocalypse.OnUpdate;
            }
            if (C3Config.FreeForAllEnabled)
            {
                GameHooks.Update += FFA.OnUpdate;
            }

            GameHooks.Update     += OnUpdate;
            GameHooks.Initialize += OnInitialize;
            NetHooks.GreetPlayer += OnGreetPlayer;
            ServerHooks.Leave    += OnLeave;
            NetHooks.GetData     += GetData;

            GetDataHandlers.InitGetDataHandler();
        }
Example #3
0
        public override void Initialize()
        {
            C3Tools.SetupConfig();

            if (C3Config.CTFEnabled)
            {
                ServerApi.Hooks.GameUpdate.Register(this, CTF.OnUpdate);
            }
            if (C3Config.DuelsEnabled)
            {
                ServerApi.Hooks.GameUpdate.Register(this, Duel.OnUpdate);
            }
            if (C3Config.OneFlagEnabled)
            {
                ServerApi.Hooks.GameUpdate.Register(this, OneFlagCTF.OnUpdate);
            }
            if (C3Config.TeamDeathmatchEnabled)
            {
                ServerApi.Hooks.GameUpdate.Register(this, TDM.OnUpdate);
            }
            if (C3Config.MonsterApocalypseEnabled)
            {
                ServerApi.Hooks.GameUpdate.Register(this, Apocalypse.OnUpdate);
            }
            if (C3Config.FreeForAllEnabled)
            {
                ServerApi.Hooks.GameUpdate.Register(this, FFA.OnUpdate);
            }

            ServerApi.Hooks.GameUpdate.Register(this, OnUpdate);
            ServerApi.Hooks.GameInitialize.Register(this, OnInitialize);
            ServerApi.Hooks.NetGreetPlayer.Register(this, OnGreetPlayer);
            ServerApi.Hooks.ServerLeave.Register(this, OnLeave);
            ServerApi.Hooks.NetGetData.Register(this, GetData);

            GetDataHandlers.InitGetDataHandler();
        }