• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# Plugin.HookContext类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中TDSM.API.Plugin.HookContext的典型用法代码示例。如果您正苦于以下问题:C# HookContext类的具体用法?C# HookContext怎么用?C# HookContext使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



HookContext类属于TDSM.API.Plugin命名空间,在下文中一共展示了HookContext类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: LeftHook

 void LeftHook(ref HookContext ctx, ref HookArgs.PlayerLeftGame args)
 {
     // If player has a last command stored, remove it now.
     if ( history.ContainsKey(ctx.Sender.SenderName) ) {
         history.Remove(ctx.Sender.SenderName);
     }
 }
开发者ID:D1G1T4L3CH0,项目名称:TDSM-Plugin_LastCommand,代码行数:7,代码来源:lcmd.cs


示例2: ClientConnection

        public ClientConnection(Socket sock)
            : base(sock)
        {
            if (SlotId == 0)
                SlotId = -1;

            var remoteEndPoint = (IPEndPoint)sock.RemoteEndPoint;
            _remoteAddress = new TcpAddress(remoteEndPoint.Address, remoteEndPoint.Port);

            sock.LingerState = new LingerOption(true, 10);
            sock.NoDelay = true;

            var ctx = new HookContext
            {
                Connection = this
            };

            var args = new HookArgs.NewConnection();

            HookPoints.NewConnection.Invoke(ref ctx, ref args);

            if (ctx.CheckForKick())
                return;

            _isReceiving = true; //The connection was established, so we can begin reading
        }
开发者ID:Narkun,项目名称:Terraria-s-Dedicated-Server-Mod,代码行数:26,代码来源:ClientConnection.cs


示例3: SendData

 public static bool SendData(int msgType, int remoteClient = -1, int ignoreClient = -1, string text = "", int number = 0, float number2 = 0f, float number3 = 0f, float number4 = 0f, int number5 = 0)
 {
     #if Full_API
     var ctx = new HookContext()
     {
         Sender = HookContext.ConsoleSender
     };
     var args = new HookArgs.SendNetData()
     {
         MsgType = msgType,
         RemoteClient = remoteClient,
         IgnoreClient = ignoreClient,
         Text = text,
         Number = number,
         Number2 = number2,
         Number3 = number3,
         Number4 = number4,
         Number5 = number5
     };
     HookPoints.SendNetData.Invoke(ref ctx, ref args);
     return ctx.Result == HookResult.DEFAULT;
     #else
     return false;
     #endif
 }
开发者ID:skylord123,项目名称:Terraria-s-Dedicated-Server-Mod,代码行数:25,代码来源:NetMessageCallback.cs


示例4: SetAuthentication

        public void SetAuthentication(string auth, string by)
        {
            #if Full_API
            var ctx = new Plugin.HookContext()
            {
                Player = this as Terraria.Player,
                Connection = this.Connection.Socket
            };
            var changing = new Plugin.HookArgs.PlayerAuthenticationChanging()
            {
                AuthenticatedAs = auth,
                AuthenticatedBy = by
            };

            Plugin.HookPoints.PlayerAuthenticationChanging.Invoke(ref ctx, ref changing);
            if (ctx.Result != Plugin.HookResult.DEFAULT)
                return;

            this.AuthenticatedAs = auth;
            this.AuthenticatedBy = by;

            ctx = new Plugin.HookContext()
            {
                Player = this as Terraria.Player,
                Connection = this.Connection.Socket
            };
            var changed = new Plugin.HookArgs.PlayerAuthenticationChanged()
            {
                AuthenticatedAs = this.AuthenticatedAs,
                AuthenticatedBy = this.AuthenticatedBy
            };

            Plugin.HookPoints.PlayerAuthenticationChanged.Invoke(ref ctx, ref changed);
            #endif
        }
开发者ID:skylord123,项目名称:Terraria-s-Dedicated-Server-Mod,代码行数:35,代码来源:BasePlayer.cs


示例5: OnProgramStarted

        public static bool OnProgramStarted(string[] cmd)
        {
            System.Threading.Thread.CurrentThread.Name = "Run";
            Console.OutputEncoding = System.Text.Encoding.UTF8;

            ProgramStart();
            #pragma warning disable 0162
            if (!Globals.FullAPIDefined)
            {
                Console.WriteLine("Your TDSM.API.dll is incorrect, and does not expose all methods.");
                return false;
            }
            #pragma warning restore 0162

            var ctx = new HookContext()
            {
                Sender = HookContext.ConsoleSender
            };
            var args = new HookArgs.ProgramStart()
            {
                Arguments = cmd
            };
            HookPoints.ProgramStart.Invoke(ref ctx, ref args);

            return ctx.Result == HookResult.DEFAULT;
        }
开发者ID:apemanzilla,项目名称:Terraria-s-Dedicated-Server-Mod,代码行数:26,代码来源:MainCallback.cs


示例6: OnStateChange

 void OnStateChange(ref HookContext ctx, ref HookArgs.ServerStateChange args)
 {
     if (args.ServerChangeState == TDSM.API.ServerState.Initialising)
     {
         ProgramLog.Plugin.Log("SQLite connector is: " + (_connector == null ? "disabled" : "enabled"));
     }
 }
开发者ID:apemanzilla,项目名称:Terraria-s-Dedicated-Server-Mod,代码行数:7,代码来源:Plugin.cs


示例7: OnGreetPlayer

        public static bool OnGreetPlayer(int playerId)
        {
            #if Full_API
            var player = Main.player[playerId];

            var ctx = new HookContext
            {
                Connection = player.Connection.Socket,
                Player = player,
                Sender = player
            };

            var args = new HookArgs.PlayerPreGreeting
            {
                Slot = playerId,
                Motd = String.IsNullOrEmpty(Main.motd) ? (Lang.mp[18] + " " + Main.worldName) : Main.motd,
                MotdColour = new Microsoft.Xna.Framework.Color(255, 240, 20)
            };

            HookPoints.PlayerPreGreeting.Invoke(ref ctx, ref args);

            if (ctx.CheckForKick())
            {
                return false;
            }

            if (ctx.Result == HookResult.DEFAULT)
            {
                player.SendMessage(args.Motd, 255, args.MotdColour.R, args.MotdColour.G, args.MotdColour.B);

                string list = "";
                for (int i = 0; i < 255; i++)
                {
                    if (Main.player[i].active)
                    {
                        if (list == "")
                            list += Main.player[i].name;
                        else
                            list = list + ", " + Main.player[i].Name;
                    }
                }

                player.SendMessage("Current players: " + list + ".", 255, 255, 240, 20);
            }

            ProgramLog.Users.Log("{0} @ {1}: ENTER {2}", Netplay.Clients[playerId].Socket.GetRemoteAddress(), playerId, player.name);

            var args2 = new HookArgs.PlayerEnteredGame
            {
                Slot = playerId
            };

            ctx.SetResult(HookResult.DEFAULT, false);
            HookPoints.PlayerEnteredGame.Invoke(ref ctx, ref args2);
            ctx.CheckForKick();
            #endif

            return false; //We implemented our own, so do not continue on with vanilla
        }
开发者ID:Narkun,项目名称:Terraria-s-Dedicated-Server-Mod,代码行数:59,代码来源:VanillaHooks.cs


示例8: OnStateChange

 void OnStateChange(ref HookContext ctx, ref HookArgs.ServerStateChange args)
 {
     if (args.ServerChangeState == TDSM.API.ServerState.Initialising)
     {
         //Data connectors must have loaded by now
         //Get TDSM to swap the current permission handler to our own
         TDSM.API.Permissions.PermissionsManager.SetHandler(_instance);
     }
 }
开发者ID:skylord123,项目名称:TDSM_SQLPermissions,代码行数:9,代码来源:SQLPermissions.cs


示例9: OnNPCKilled

        public static void OnNPCKilled(Terraria.NPC npc)
        {
            var ctx = new HookContext();
            var args = new HookArgs.NPCKilled()
            {
                Type = npc.type,
                NetId = npc.netID
            };

            HookPoints.NPCKilled.Invoke(ref ctx, ref args);
        }
开发者ID:Narkun,项目名称:Terraria-s-Dedicated-Server-Mod,代码行数:11,代码来源:NPCCallback.cs


示例10: OnInvasionNPCSpawn

        public static void OnInvasionNPCSpawn(int x, int y)
        {
            var ctx = new HookContext();
            var args = new HookArgs.InvasionNPCSpawn()
            {
                X = x,
                Y = y
            };

            HookPoints.InvasionNPCSpawn.Invoke(ref ctx, ref args);
        }
开发者ID:skylord123,项目名称:Terraria-s-Dedicated-Server-Mod,代码行数:11,代码来源:NPCCallback.cs


示例11: CommmandHook

 void CommmandHook(ref HookContext ctx, ref HookArgs.Command args)
 {
     // If the command issued is not !...
     if ( args.Prefix != "!" ) {
         string WhoCalled = ctx.Sender.SenderName; // get the name of the sender
         // If there is a command saved for the sender already...
         if ( history.ContainsKey( WhoCalled ) ) {
             history[WhoCalled] = args.Prefix + " " + args.ArgumentString; // Replace the sender's last command.
         } else {
             history.Add( WhoCalled, args.Prefix + " " + args.ArgumentString ); // Record the sender's command for the first time.
         }
     }
 }
开发者ID:D1G1T4L3CH0,项目名称:TDSM-Plugin_LastCommand,代码行数:13,代码来源:lcmd.cs


示例12: CanSpawnNPC

        public static bool CanSpawnNPC(int x, int y, int type, int start = 0)
        {
            var ctx = new HookContext();
            var args = new HookArgs.NPCSpawn()
            {
                X = x,
                Y = y,
                Type = type,
                Start = start
            };

            HookPoints.NPCSpawn.Invoke(ref ctx, ref args);

            return ctx.Result == HookResult.DEFAULT;
        }
开发者ID:Narkun,项目名称:Terraria-s-Dedicated-Server-Mod,代码行数:15,代码来源:NPCCallback.cs


示例13: Initialise

 public static void Initialise()
 {
     #if Full_API
     if (Terraria.Main.dedServ)
     {
         var ctx = new HookContext()
         {
             Sender = HookContext.ConsoleSender
         };
         var args = new HookArgs.ServerStateChange()
         {
             ServerChangeState = ServerState.Initialising
         };
         HookPoints.ServerStateChange.Invoke(ref ctx, ref args);
     }
     #endif
 }
开发者ID:apemanzilla,项目名称:Terraria-s-Dedicated-Server-Mod,代码行数:17,代码来源:MainCallback.cs


示例14: OnReadConfig

        void OnReadConfig(ref HookContext ctx, ref HookArgs.ConfigurationLine args)
        {
            switch (args.Key)
            {
                case "sqlite":
                    if (_connector == null)
                    {
                        var cn = new SQLiteConnector(args.Value);

                        cn.Open();

                        Storage.SetConnector(cn);

                        _connector = cn;
                    }
                    break;
            }
        }
开发者ID:apemanzilla,项目名称:Terraria-s-Dedicated-Server-Mod,代码行数:18,代码来源:Plugin.cs


示例15: OnReadConfig

        void OnReadConfig(ref HookContext ctx, ref HookArgs.ConfigurationLine args)
        {
            switch (args.Key)
            {
                case "mysql":
                    if (!Storage.IsAvailable)
                    {
                        MySQLConnector cn = null;

                        try
                        {
                            cn = new MySQLConnector(args.Value);
                            cn.Open();
                        }
                        catch (Exception e)
                        {
                            ProgramLog.Error.Log("Exception connecting to MySQL database: {0}", e);
                            return;
                        }
                        Storage.SetConnector(_connector = cn);
                    }
                    break;
            }
        }
开发者ID:CJKay,项目名称:Terraria-s-Dedicated-Server-Mod,代码行数:24,代码来源:SqlPermissions.cs


示例16: OnNPCSpawned

 void OnNPCSpawned(ref HookContext ctx, ref HookArgs.NPCSpawn args)
 {
     if (StopNPCSpawning)
         ctx.SetResult(HookResult.IGNORE);
 }
开发者ID:Narkun,项目名称:Terraria-s-Dedicated-Server-Mod,代码行数:5,代码来源:Entry.cs


示例17: SendData

        public static bool SendData(int msgType, int remoteClient = -1, int ignoreClient = -1, string text = "", int number = 0, float number2 = 0f, float number3 = 0f, float number4 = 0f, int number5 = 0)
        {
            #if Full_API
            if (Main.netMode == 0)
            {
                return false;
            }

            int bufferId = 256;
            if (Main.netMode == 2 && remoteClient >= 0)
            {
                bufferId = remoteClient;
            }

            lock (NetMessage.buffer [bufferId])
            {
                var writer = NetMessage.buffer[bufferId].writer;
                if (writer == null)
                {
                    NetMessage.buffer[bufferId].ResetWriter();
                    writer = NetMessage.buffer[bufferId].writer;
                }

                writer.BaseStream.Position = 0;
                var position = writer.BaseStream.Position;
                writer.BaseStream.Position += 2;
                writer.Write((byte)msgType);

                var ctx = new HookContext()
                {
                    Sender = HookContext.ConsoleSender
                };
                var args = new HookArgs.SendNetMessage()
                {
                    MsgType = msgType,
                    BufferId = bufferId,
                    RemoteClient = remoteClient,
                    IgnoreClient = ignoreClient,
                    Text = text,
                    Number = number,
                    Number2 = number2,
                    Number3 = number3,
                    Number4 = number4,
                    Number5 = number5
                };
                HookPoints.SendNetMessage.Invoke(ref ctx, ref args);

                if (ctx.Result != HookResult.DEFAULT)
                {
                    var endOfMessage = (int)writer.BaseStream.Position;
                    writer.BaseStream.Position = position;
                    writer.Write((short)endOfMessage);
                    writer.BaseStream.Position = (long)endOfMessage;

                    if (remoteClient == -1)
                    {
                        switch ((Packet)msgType)
                        {
                            case Packet.CHEST:
                            case Packet.CHEST_NAME_UPDATE:
                                for (int i = 0; i < 256; i++)
                                {
                                    if (i != ignoreClient && NetMessage.buffer[i].broadcast && Netplay.Clients[i].IsConnected())
                                    {
                                        try
                                        {
                                            NetMessage.buffer[i].spamCount++;
                                            Main.txMsg++;
                                            Main.txData += endOfMessage;
                                            Main.txMsgType[msgType]++;
                                            Main.txDataType[msgType] += endOfMessage;
                                            Netplay.Clients[i].Socket.AsyncSend(NetMessage.buffer[bufferId].writeBuffer, 0, endOfMessage, new SocketSendCallback(Netplay.Clients[i].ServerWriteCallBack), null);
                                        }
                                        catch
                                        {
                                        }
                                    }
                                }
                                break;

                            case Packet.TILE_SQUARE:
                                for (int i = 0; i < 256; i++)
                                {
                                    if (i != ignoreClient && NetMessage.buffer[i].broadcast && Netplay.Clients[i].IsConnected() && Netplay.Clients[i].SectionRange(number, (int)number2, (int)number3))
                                    {
                                        try
                                        {
                                            NetMessage.buffer[i].spamCount++;
                                            Main.txMsg++;
                                            Main.txData += endOfMessage;
                                            Main.txMsgType[msgType]++;
                                            Main.txDataType[msgType] += endOfMessage;
                                            Netplay.Clients[i].Socket.AsyncSend(NetMessage.buffer[bufferId].writeBuffer, 0, endOfMessage, new SocketSendCallback(Netplay.Clients[i].ServerWriteCallBack), null);
                                        }
                                        catch
                                        {
                                        }
                                    }
                                }
                                break;
//.........这里部分代码省略.........
开发者ID:Narkun,项目名称:Terraria-s-Dedicated-Server-Mod,代码行数:101,代码来源:NetMessageCallback.cs


示例18: OnNetMessageReceived

        //        [Hook]
        void OnNetMessageReceived(ref HookContext ctx, ref HookArgs.ReceiveNetMessage args)
        {
            if (Terraria.Main.ServerSideCharacter)
            {
                switch ((Packet)args.PacketId)
                {
                    case Packet.INVENTORY_DATA:
                        if (!AllowSSCGuestInfo && !ctx.Player.IsAuthenticated)
                            ctx.SetResult(HookResult.IGNORE);
                        break;

                    case Packet.PLAYER_MANA_UPDATE:
                        if (!AllowSSCGuestInfo && !ctx.Player.IsAuthenticated)
                            ctx.SetResult(HookResult.IGNORE);
                        break;

                    case Packet.PLAYER_HEALTH_UPDATE:
                        if (!AllowSSCGuestInfo && !ctx.Player.IsAuthenticated)
                            ctx.SetResult(HookResult.IGNORE);
                        break;
                }
            }
        }
开发者ID:Narkun,项目名称:Terraria-s-Dedicated-Server-Mod,代码行数:24,代码来源:Entry.cs


示例19: OnInventoryItemReceived

 void OnInventoryItemReceived(ref HookContext ctx, ref HookArgs.InventoryItemReceived args)
 {
     #if TDSMSever
     if (Server.ItemRejections.Count > 0)
     {
         if (args.Item != null)
         {
             if (Server.ItemRejections.Contains(args.Item.name) || Server.ItemRejections.Contains(args.Item.type.ToString()))
             {
                 if (!String.IsNullOrEmpty(args.Item.name))
                 {
                     ctx.SetKick(args.Item.name + " is not allowed on this server.");
                 }
                 else
                 {
                     ctx.SetKick("Item type " + args.Item.type.ToString() + " is not allowed on this server.");
                 }
             }
         }
     }
     #endif
 }
开发者ID:Narkun,项目名称:Terraria-s-Dedicated-Server-Mod,代码行数:22,代码来源:Entry.cs


示例20: OnGreetPlayer

        void OnGreetPlayer(ref HookContext ctx, ref HookArgs.PlayerPreGreeting args)
        {
            ctx.SetResult(HookResult.IGNORE);
            var lines = args.Motd.Split(new string[]{ "\\0" }, StringSplitOptions.None);
            foreach (var line in lines)
                ctx.Player.SendMessage(line, 255, 0, 0, 255);

            string list = "";
            for (int i = 0; i < 255; i++)
            {
                if (Main.player[i].active)
                {
                    if (list == "")
                        list += Main.player[i].name;
                    else
                        list = list + ", " + Main.player[i].Name;
                }
            }

            ctx.Player.SendMessage("Current players: " + list + ".", 255, 255, 240, 20);
        }
开发者ID:Narkun,项目名称:Terraria-s-Dedicated-Server-Mod,代码行数:21,代码来源:Entry.cs



注:本文中的TDSM.API.Plugin.HookContext类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# TDTK.UnitTower类代码示例发布时间:2022-05-26
下一篇:
C# T4MVC.Dummy类代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap