当前位置: 首页>>代码示例>>C#>>正文


C# HookContext.SetResult方法代码示例

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


在下文中一共展示了HookContext.SetResult方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: CheckState

 /// <summary>
 /// Handles the connection state when receiving a packet
 /// </summary>
 public static void CheckState(ref HookContext ctx, ref HookArgs.CheckBufferState args)
 {
     if (Terraria.Netplay.Clients[args.BufferId].State == (int)ConnectionState.AwaitingUserPassword)
     {
         //Since this is a custom state, we accept it [true to kick the connection, false to accept]
         ctx.SetResult(HookResult.RECTIFY, true, false /* TODO validate packets */);
     }
 }
开发者ID:carriercomm,项目名称:Terraria-s-Dedicated-Server-Mod,代码行数:11,代码来源:PacketProcessor.cs

示例2: OnChat

        void OnChat(ref HookContext ctx, ref TDSMHookArgs.PlayerChat args)
        {
            if (args.Message.Length > 0 && args.Message.Substring(0, 1).Equals("/"))
            {
                ProgramLog.Log(ctx.Player.name + " sent command: " + args.Message);
                ctx.SetResult(HookResult.IGNORE);

                CommandParser.ParsePlayerCommand(ctx.Player, args.Message);
            }
        }
开发者ID:carriercomm,项目名称:Terraria-s-Dedicated-Server-Mod,代码行数:10,代码来源:Events.cs

示例3: HandlePacket

 /// <summary>
 /// Handles packets received from OTA
 /// </summary>
 public static void HandlePacket(ref HookContext ctx, ref HookArgs.ReceiveNetMessage args)
 {
     if (_packetHandlers != null)
     {
         if (_packetHandlers[args.PacketId] != null)
         {
             if (_packetHandlers[args.PacketId].Read(args.BufferId, args.Start, args.Length))
             {
                 //Packet informed us that it was read, let OTA know we consumed the packet
                 ctx.SetResult(HookResult.IGNORE, true);
             }
         }
     }
 }
开发者ID:carriercomm,项目名称:Terraria-s-Dedicated-Server-Mod,代码行数:17,代码来源:PacketProcessor.cs

示例4: 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:DeathCradle,项目名称:Terraria-s-Dedicated-Server-Mod,代码行数:21,代码来源:Events.cs

示例5: OnDefaultServerStart

        void OnDefaultServerStart(ref HookContext ctx, ref HookArgs.StartDefaultServer args)
        {
            if (RunServerCore)
            {
            ProgramLog.Log("Starting TDSM's slot server...");
            ctx.SetResult(HookResult.IGNORE);

            ServerCore.Server.StartServer();
            } else
            ProgramLog.Log("Vanilla only specified, continuing on with Re-Logic code...");
        }
开发者ID:DeathCradle,项目名称:Terraria-s-Dedicated-Server-Mod,代码行数:11,代码来源:Events.cs

示例6: OnSetTitle

 private void OnSetTitle(ref HookContext ctx, ref HookArgs.SetWindowTitle args)
 {
     ctx.SetResult(HookResult.RECTIFY, resultParam: $"{args.Title} | TDSM ({Entry.CoreVersion}) , OTAPI ({Globals.BuildInfo})");
 }
开发者ID:DeathCradle,项目名称:Terraria-s-Dedicated-Server-Mod,代码行数:4,代码来源:Events.cs

示例7: OnPlayerKilled

        void OnPlayerKilled(ref HookContext ctx, ref HookArgs.PlayerKilled args)
        {
            if (_likeABoss)
            {
                if (Terraria.Main.rand == null) Terraria.Main.rand = new Random();

                if (ctx.Player.talkNPC > -1 && Terraria.Main.rand.Next(_labDeathMessages.Count - 1) == 1)
                {
                    args.DeathText = " was too busy talking";
                }
                //                else if (Terraria.Main.rand.Next(_labDeathMessages.Count - 1) == 1)
                //                {
                //
                //                }
                // forgot [NPC]'s birthday
                // tried to hit on [NPC]

                else
                {
                    args.DeathText = _labDeathMessages.Next();
                }
                args.DeathText = ctx.Player.name + args.DeathText;
                ctx.SetResult(HookResult.CONTINUE);
                Loggers.Death.Log(args.DeathText);
            }
            else
            {
                //Standard death log
                Loggers.Death.Log(ctx.Player.name + args.DeathText);
            }
        }
开发者ID:DeathCradle,项目名称:Terraria-s-Dedicated-Server-Mod,代码行数:31,代码来源:Events.cs

示例8: OnNPCSpawned

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

示例9: OnInvasionWarning

        void OnInvasionWarning(ref HookContext ctx, ref HookArgs.InvasionWarning args)
        {
            if (Main.invasionType == Core._assignedInvasionType && Core._invasion != null)
            {
                if (Main.invasionSize > 0)
                {
                    string message = null;
                    if (Main.invasionX < (double)Main.spawnTileX)
                    {
                        //West
                        if (!Core._notfInbound)
                        {
                            Core._notfInbound = true;
                            message = "An invasion is approaching from the west!";
                        }
                    }
                    else if (Main.invasionX > (double)Main.spawnTileX)
                    {
                        //East
                        if (!Core._notfInbound)
                        {
                            Core._notfInbound = true;
                            message = "An invasion is approaching from the east!";
                        }
                    }
                    else
                    {
                        //Arrived
                        message = "The invasion has arrived!";
                    }

                    if (null != message)
                        NetMessage.SendData(25, -1, -1, message, 255, 175f, 75f, 255f);
                }

                ctx.SetResult(HookResult.IGNORE);
            }
        }
开发者ID:carriercomm,项目名称:Terraria-s-Dedicated-Server-Mod,代码行数:38,代码来源:InvasionCommand.cs

示例10: OnStatusTextChanged

        void OnStatusTextChanged(ref HookContext ctx, ref HookArgs.StatusTextChange args)
        {
            ctx.SetResult(HookResult.IGNORE);
            //There's no locking and two seperate threads, so we must use local variables incase of changes
            var statusText = Terraria.Main.statusText;
            var oldStatusText = Terraria.Main.oldStatusText;

            if (oldStatusText != statusText)
            {
                if (!String.IsNullOrEmpty(statusText))
                {
                    string previousProgress, currentProgress;

                    string keyA = GetProgressKey(oldStatusText, out previousProgress);
                    string keyB = GetProgressKey(statusText, out currentProgress);

                    if (keyA != null && keyB != null)
                    {
                        keyA = keyA.Trim();
                        keyB = keyB.Trim();
                        if (keyA.Length > 0 && keyB.Length > 0)
                        {
                            if (keyA == keyB)
                            {
                                if (lastWritten > 0)
                                {
                                    for (var x = 0; x < lastWritten; x++)
                                        Console.Write("\b");
                                }

                                Console.Write(currentProgress);
                                lastWritten += currentProgress.Length - lastWritten;
                            }
                            else
                            {
                                Console.WriteLine();
                                lastWritten = 0;
                                Console.Write(statusText);

                                lastWritten += currentProgress.Length;

                                if (currentProgress.Length == 0)
                                    Console.WriteLine();
                            }
                        }
                        else
                        {
                            if (lastWritten > 0)//!String.IsNullOrEmpty(oldStatusText)) //There was existing text
                            {
                                Console.WriteLine();
                                lastWritten = 0;
                            }

                            Console.Write(statusText);
                            lastWritten += currentProgress.Length;
                        }
                    }
                    else if (keyA == null && keyB != null)
                    {
                        Console.Write(statusText);
                        lastWritten += currentProgress.Length;
                    }
                }
                else
                {
                    if (lastWritten > 0)//!String.IsNullOrEmpty(oldStatusText)) //There was existing text
                    {
                        Console.WriteLine();
                        lastWritten = 0;
                    }
                }
            }
            else if (statusText == String.Empty)
            {
                if (lastWritten > 0)//!String.IsNullOrEmpty(Terraria.Main.oldStatusText)) //There was existing text
                {
                    Console.WriteLine();
                    lastWritten = 0;
                }
            }
            Terraria.Main.oldStatusText = statusText;
        }
开发者ID:DeathCradle,项目名称:Terraria-s-Dedicated-Server-Mod,代码行数:82,代码来源:ProgressText.cs

示例11: OnNetMessageReceived

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

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

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

示例12: onPlayerOpenChest

        void onPlayerOpenChest(ref HookContext ctx, ref HookArgs.ChestOpenReceived args)
        {
            ISender sender = ctx.Sender;
            int ChestId = args.ChestIndex;

            if(!(sender is Player))
            {
                return;
            }

            // we only want players ?
            Player player = sender as Player;

            // get the Chest object
            Chest chest = Main.chest[ChestId];

            // the location of the chest
            LocationKey key = new LocationKey(chest.x, chest.y);

            // see if we have a protection attached to the chest
            Protection protection = Cache.Protections.Get(key);
            bool CanAccess = true;

            // if it's a valid protection, ensure they can access it
            if(protection != null)
            {
                CanAccess = protection.CanAccess(player);

                // PASSWORD PROTECTION CHECK
                if(protection.Type == Protection.PASSWORD_PROTECTION)
                {
                    if(!CanAccess)
                    {
                        Pair<Action, Protection> PassTemp = new Pair<Action, Protection>(Action.UNLOCK, protection);
                        ResetActions(player);
                        Cache.Actions.Add(player.Name, PassTemp);

                        player.SendMessage("This chest is locked with a password!", 255, 255, 0, 0);
                        player.SendMessage("Type /cunlock <password> to unlock it.", 150, 255, 0, 0);
                    }
                }

                // Update the chest id if it changed somehow
                if(protection.ChestId != ChestId)
                {
                    protection.ChestId = ChestId;
                }
            }

            // if they can't access it, cancel the event !!
            if(!CanAccess)
            {
                ctx.SetResult (HookResult.IGNORE);
            }

            // is there an action for this player?
            Pair<Action, Protection> pair = Cache.Actions.Get(sender.SenderName);

            if(pair == null)
            {
                // check again if they dont have access and pester them
                if(!CanAccess)
                {
                    sender.SendMessage("That Chest is locked with a magical spell.", 255, 255, 0, 0);
                }

                return;
            }

            // action data
            Action action = pair.First;
            Protection Temp = pair.Second;

            switch(action)
            {
                case Action.INFO:

                    if(protection == null)
                    {
                        player.SendMessage("That chest is not protected!", 255, 255, 0, 0);
                    } else
                    {
                        player.SendMessage("Owner: " + protection.Owner, 255, 255, 0, 0);
                        player.SendMessage("Type: " + protection.TypeToString(), 255, 255, 0, 0);

                        if(CanAccess)
                        {
                            player.SendMessage("Can access: Yes", 255, 0, 255, 0);
                        } else
                        {
                            player.SendMessage("Can access: No", 255, 255, 0, 0);
                        }
                    }

                    ResetActions(player);
                    break;

                case Action.CREATE:
                    if(protection != null)
                    {
//.........这里部分代码省略.........
开发者ID:elevatorguy,项目名称:LWC-Terraria,代码行数:101,代码来源:LWCPlugin.cs

示例13: OnStartCommandProcessing

        void OnStartCommandProcessing(ref HookContext ctx, ref HookArgs.StartCommandProcessing args)
        {
            ctx.SetResult(HookResult.IGNORE);

            if (Console.IsInputRedirected)
            {
                ProgramLog.Admin.Log("Console input redirection has been detected.");
                return;
            }

            (new OTA.Misc.ProgramThread("Command", ListenForCommands)).Start();
        }
开发者ID:carriercomm,项目名称:Terraria-s-Dedicated-Server-Mod,代码行数:12,代码来源:Events.cs

示例14: OnServerStateChange

        void OnServerStateChange(ref HookContext ctx, ref HookArgs.ServerStateChange args)
        {
            ProgramLog.Log("Server state changed to: " + args.ServerChangeState.ToString());

            if (args.ServerChangeState == ServerState.Initialising)
            {
                if (!String.IsNullOrEmpty(RConBindAddress))
                {
                    ProgramLog.Log("Starting RCON Server");
                    RemoteConsole.RConServer.Start(Path.Combine(Globals.DataPath, "rcon_logins.properties"));
                }

                if (Terraria.Main.ServerSideCharacter)
                {
                    CharacterManager.Init();
                }

                if (BackupManager.BackupsEnabled && BackupManager.BackupIntervalMinutes < SaveManager.SaveIntervalMinutes)
                {
                    ProgramLog.Admin.Log("[Warning] Backup interval is smaller than the save interval.");
                }
            }
            if (args.ServerChangeState == ServerState.Stopping)
            {
                RunComponent(ComponentEvent.ServerStopping);
                if (!String.IsNullOrEmpty(RConBindAddress))
                {
                    ProgramLog.Log("Stopping RCON Server");
                    RemoteConsole.RConServer.Stop();
                }
            }
            if (args.ServerChangeState == ServerState.Starting)
            {
                RunComponent(ComponentEvent.ServerStarting);
            }

            //if (args.ServerChangeState == ServerState.Initialising)
            #if TDSMServer
            if (!Server.IsInitialised)
            {
            Server.Init();

            if (!String.IsNullOrEmpty(RConBindAddress))
            {
            ProgramLog.Log("Starting RCON Server");
            RemoteConsole.RConServer.Start(Path.Combine(Globals.DataPath, "rcon_logins.properties"));
            }

            if (!String.IsNullOrEmpty(_webServerAddress))
            {
            ProgramLog.Log("Starting Web Server");
            WebInterface.WebServer.Begin(_webServerAddress, _webServerProvider);

            this.AddCommand("webauth")
            .WithAccessLevel(AccessLevel.OP)
            .Calls(WebInterface.WebServer.WebAuthCommand);
            }
            }

            if (args.ServerChangeState == ServerState.Stopping)
            {
            RemoteConsole.RConServer.Stop();
            WebInterface.WebServer.End();
            //if (properties != null && File.Exists(properties.PIDFile.Trim()))
            //File.Delete(properties.PIDFile.Trim());
            }

            ctx.SetResult(HookResult.IGNORE); //Don't continue on with vanilla code
            #endif
        }
开发者ID:carriercomm,项目名称:Terraria-s-Dedicated-Server-Mod,代码行数:70,代码来源:Events.cs

示例15: OnLoadConfiguration

 void OnLoadConfiguration(ref HookContext ctx, ref HookArgs.LoadConfigurationFile args)
 {
     ctx.SetResult(HookResult.IGNORE);
 }
开发者ID:DeathCradle,项目名称:Terraria-s-Dedicated-Server-Mod,代码行数:4,代码来源:Events.cs


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