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


C# ISender.SendMessage方法代码示例

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


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

示例1: ChangePassword

        void ChangePassword(ISender sender, string password)
        {
            if (!Storage.IsAvailable)
                throw new CommandError("No permissions plugin or data plugin is attached");

            var player = sender as Player;
            if (player == null)
            {
                sender.SendMessage("This is a player command", G: 0, B: 0);
                return;
            }
            else if (!player.IsAuthenticated())
            {
                sender.SendMessage("You are not authenticated.", G: 0, B: 0);
                return;
            }
            else if (password == null || password.Trim().Length < MinPasswordLength)
            {
                sender.SendMessage("Please specify a password longer than 5 characters.", G: 0, B: 0);
                return;
            }

            var auth = player.GetAuthenticatedAs();

            if (Authentication.UpdatePlayer(auth, password))
            {
                sender.SendMessage("Your password is now updated.", R: 0, B: 0);
            }
            else
            {
                sender.SendMessage("Failed to update your password.", G: 0, B: 0);
            }
        }
开发者ID:DeathCradle,项目名称:Terraria-s-Dedicated-Server-Mod,代码行数:33,代码来源:ChangePasswordCommand.cs

示例2: AddAccount

        void AddAccount(ISender sender, ArgumentList args)
        {
            if (!Storage.IsAvailable)
                throw new CommandError("No permissions plugin or data plugin is attached");

            var a = 0;
            string name, pass;
            APIAccount acc = null;

            //api addaccount "username" "password"
            if (!args.TryGetString(a++, out name))
                throw new CommandError("Expected username after addaccount");

            if (!args.TryGetString(a++, out pass))
                throw new CommandError("Expected password after username");

            acc = APIAccountManager.FindByName(name);
            if (acc == null)
            {
                acc = APIAccountManager.Create(name, pass);
                if (acc.Id > 0)
                {
                    sender.SendMessage("Successfully created account.", R: 0, B: 0);
                }
                else
                {
                    sender.SendMessage("Failed to create account.", G: 0, B: 0);
                }
            }
            else
            {
                throw new CommandError("Existing API account found by " + name);
            }
        }
开发者ID:DeathCradle,项目名称:Terraria-s-Dedicated-Server-Mod,代码行数:34,代码来源:ApiCommand.cs

示例3: PrivateMessageReply

        public void PrivateMessageReply(ISender sender, string message)
        {
            var playerFrom = sender as Player;
            if (playerFrom == null)
            {
                sender.SendMessage("This is a player command.", G: 0, B: 0);
                return;
            }

            if (String.IsNullOrEmpty(message))
            {
                sender.SendMessage("Invalid message", G: 0, B: 0);
                return;
            }

            var lastPlayerName = playerFrom.GetPluginData("LastPM", String.Empty);
            if(String.IsNullOrEmpty(lastPlayerName))
            {
                sender.SendMessage("You are required to have started a conversation.", G: 0, B: 0);
                return;
            }

            var playerTo = Tools.GetPlayerByName(lastPlayerName);
            if(playerTo == null || !playerTo.active)
            {
                sender.SendMessage($"Last PM'd user ({lastPlayerName}) is no longer online.", G: 0, B: 0);
                return;
            }

            playerTo.Message(255, Color.Orange, $"[PM] {playerFrom.SenderName}: {message}");
        }
开发者ID:DeathCradle,项目名称:Terraria-s-Dedicated-Server-Mod,代码行数:31,代码来源:PrivateMessageCommand.cs

示例4: PreviousCommandHandle

 private void PreviousCommandHandle(ISender sender, ArgumentList args)
 {
     var player = sender as Player;
     if (player != null)
     {
         if (Core.CommandDictionary.ContainsKey(player.name))
         {
             Entry.CommandParser.ParsePlayerCommand(player, Core.CommandDictionary[player.name]);
             ProgramLog.Log("Executed {0}'s previous command: {1}", player.name, Core.CommandDictionary[player.name]);
         }
         else
             sender.SendMessage("No Previous Command", 255, 255, 20, 20);
         //ProgramLog.Log("{0}", ctx.Player.name); //, args.Prefix + " " + args.ArgumentString);
     }
     if (sender is ConsoleSender)
     {
         if (Core.CommandDictionary.ContainsKey("CONSOLE"))
             Entry.CommandParser.ParseConsoleCommand(Core.CommandDictionary["CONSOLE"]);
         else
             sender.SendMessage("No Previous Command", 255, 255, 20, 20);
     }
 }
开发者ID:carriercomm,项目名称:Terraria-s-Dedicated-Server-Mod,代码行数:22,代码来源:PreviousCommand.cs

示例5: Action

 /// <summary>
 /// 3rd person talking.
 /// </summary>
 /// <param name="sender">Sending player</param>
 /// <param name="message">Message to send</param>
 public void Action(ISender sender, string message)
 {
     if (!String.IsNullOrEmpty(message))
     {
         ProgramLog.Log("* " + sender.SenderName + " " + message);
         if (sender is Player)
             NetMessage.SendData(25, -1, -1, "* " + sender.SenderName + " " + message, 255, 200, 100, 0);
         else
             NetMessage.SendData(25, -1, -1, "* " + sender.SenderName + " " + message, 255, 238, 130, 238);
     }
     else
     {
         sender.SendMessage("Expected message");
     }
 }
开发者ID:carriercomm,项目名称:Terraria-s-Dedicated-Server-Mod,代码行数:20,代码来源:ThirdPersonCommand.cs

示例6: PrivateMessageSend

        public void PrivateMessageSend(ISender sender, ArgumentList args)
        {
            var playerFrom = sender as Player;
            if (playerFrom == null)
            {
                sender.SendMessage("This is a player command.", G: 0, B: 0);
                return;
            }

            var playerTo = args.GetOnlinePlayer(0);
            var msg = string.Join(" ", args.Skip(1).ToArray());

            playerTo.Message(255, Color.Orange, $"[PM] {sender.SenderName}: {msg}");

            playerFrom.SetPluginData("LastPM", playerTo.name);
        }
开发者ID:DeathCradle,项目名称:Terraria-s-Dedicated-Server-Mod,代码行数:16,代码来源:PrivateMessageCommand.cs

示例7: Say

        /// <summary>
        /// Sends a Server Message to all online Players.
        /// </summary>
        /// <param name="sender">Sending player</param>
        /// <param name="message">Message to send</param>
        public void Say(ISender sender, string message)
        {
            /*ProgramLog.Log("<" + sender.SenderName + "> " + message);
            if (sender is Player)
                NewNetMessage.SendData(25, -1, -1, "<" + sender.SenderName + "> " + message, 255, 255, 255, 255);
            else
                NewNetMessage.SendData(25, -1, -1, "<" + sender.SenderName + "> " + message, 255, 238, 180, 238);*/

            // 'Say' should be used for Server Messages, OP's only. This is used on many large servers to notify
            // Users for a quick restart (example), So the OP will most likely be in game, unless it's major.

            if (!String.IsNullOrEmpty(message))
            {
                ProgramLog.Log("<" + sender.SenderName + "> " + ((sender is ConsoleSender) ? String.Empty : "SERVER: ") + message);
                NetMessage.SendData(25, -1, -1, "SERVER: " + message, 255, 238, 130, 238);
            }
            else
            {
                sender.SendMessage("Expected message");
            }
        }
开发者ID:DeathCradle,项目名称:Terraria-s-Dedicated-Server-Mod,代码行数:26,代码来源:SayCommand.cs

示例8: Time

        /////// <summary>
        /////// Adds or removes specified player to/from the white list.
        /////// </summary>
        /////// <param name="sender">Sending player</param>
        /////// <param name="args">Arguments sent with command</param>
        ////public static void WhiteList(ISender sender, ArgumentList args)
        ////{
        ////    // /whitelist <add:remove> <player>
        ////    string Exception, Type = String.Empty;
        ////    if (args.TryParseOne<String>(Languages.Add, out Exception))
        ////    {
        ////        Server.WhiteList.addException(Exception);
        ////        Type = Languages.Added;
        ////    }
        ////    else if (args.TryParseOne<String>(Languages.Remove, out Exception))
        ////    {
        ////        Server.WhiteList.removeException(Exception);
        ////        Type = Languages.RemovedFrom;
        ////    }
        ////    else
        ////    {
        ////        sender.Message(Languages.PleaseReview);
        ////        return;
        ////    }
        ////    Tools.NotifyAllOps(Exception + " was " + Type + " the Whitelist [" + sender.SenderName + "]", true);
        ////    if (!Server.WhiteList.Save())
        ////    {
        ////        Tools.NotifyAllOps(Languages.WhilelistFailedSave + sender.SenderName + "'s " + Languages.Command, true);
        ////    }
        ////}
        ///// <summary>
        ///// Adds a player or ip (Exception) to the ban list.
        ///// </summary>
        ///// <param name="sender">Sending player</param>
        ///// <param name="args">Arguments sent with command</param>
        //public static void Ban(ISender sender, ArgumentList args)
        //{
        //    Player banee;
        //    string playerName = null;
        //    if (args.TryGetOnlinePlayer(0, out banee))
        //    {
        //        playerName = banee.Name;
        //        banee.Kick(Languages.Ban_You);
        //        Server.BanList.addException(Netplay.slots[banee.whoAmi].
        //                remoteAddress.Split(':')[0]);
        //    }
        //    else if (!args.TryGetString(0, out playerName))
        //    {
        //        throw new CommandError(Languages.IPExpected);
        //    }
        //    Server.BanList.addException(playerName);
        //    Tools.NotifyAllOps(playerName + Languages.Ban_Banned + " [" + sender.SenderName + "]", true);
        //    if (!Server.BanList.Save())
        //    {
        //        Tools.NotifyAllOps(Languages.Ban_FailedToSave + sender.SenderName + "'s " + Languages.Command, true);
        //    }
        //}
        ///// <summary>
        ///// Removes an exception from the ban list.
        ///// </summary>
        ///// <param name="sender">Sending player</param>
        ///// <param name="args">Arguments sent with command</param>
        //public static void UnBan(ISender sender, ArgumentList args)
        //{
        //    string playerName;
        //    if (!args.TryGetString(0, out playerName))
        //    {
        //        throw new CommandError(Languages.IPExpected);
        //    }
        //    Server.BanList.removeException(playerName);
        //    Tools.NotifyAllOps(playerName + Languages.Ban_UnBanned + " [" + sender.SenderName + "]", true);
        //    if (!Server.BanList.Save())
        //    {
        //        Tools.NotifyAllOps(Languages.Ban_FailedToSave + sender.SenderName + "'s " + Languages.Command, true);
        //    }
        //}
        /// <summary>
        /// Sets the time in the game.
        /// </summary>
        /// <param name="sender">Sending player</param>
        /// <param name="args">Arguments sent with command</param>
        public void Time(ISender sender, ArgumentList args)
        {
            double time;
            WorldTime text;
            if (args.TryParseOne<Double>("-set", out time) || args.TryParseOne<Double>("set", out time))
            {
                if (time >= WorldTime.TimeMin && time <= WorldTime.TimeMax)
                {
                    World.SetTime(time);
                }
                else
                {
                    sender.SendMessage(String.Format("Invalid time specified, must be from {0} to {1}", WorldTime.TimeMin, WorldTime.TimeMax));
                    return;
                }
            }
            else if (args.TryParseOne<WorldTime>("-set", out text) || args.TryParseOne<WorldTime>("set", out text))
            {
                time = text.GameTime;
//.........这里部分代码省略.........
开发者ID:Stickiler,项目名称:Terraria-s-Dedicated-Server-Mod,代码行数:101,代码来源:Commands.cs

示例9: ColorCommand

        void ColorCommand(ISender sender, ArgumentList args)
        {
            try
            {
                // Using a predefined color / reset color
                if (args.Count == 2)
                {
                    if (DEBUG)
                        ProgramLog.Admin.Log("PlayerChat.color: Recieved arguments name[" + args[0] + "] color[" + args[1] + "]");

                    var name = args[0];
                    var player = Tools.GetPlayerByName(name);

                    var color = args[1];
                    bool remove_color = false;
                    if (color == "-r")
                        remove_color = true;

                    // Player not online
                    if (player == null)
                    {
                        ProgramLog.Admin.Log("PlayerChat.color: [" + name + "] is not online.");
                        return;
                    }

                    // Player online
                    name = player.Name;
                    if (DEBUG)
                        ProgramLog.Admin.Log("PlayerChat.color: [" + name + "] is online.");

                    if (Storage.IsAvailable)
                    {
                        if (DEBUG)
                            ProgramLog.Admin.Log("PlayerChat.color: Storage is available");

                        var player_group = Storage.GetInheritedGroupForUser(name);
                        if (DEBUG)
                            ProgramLog.Admin.Log("before change - R[" + player_group.Chat_Red + "] G[" + player_group.Chat_Green + "] B[" + player_group.Chat_Blue + "]");

                        if (remove_color)
                        {
                            player_group.Chat_Red = 255;
                            player_group.Chat_Green = 255;
                            player_group.Chat_Blue = 255;
                        }
                        else
                        {
                            // TODO: match player color to Microsoft.Xna.Framework.Color
                        }
                        if (DEBUG)
                            ProgramLog.Admin.Log("after change - R[" + player_group.Chat_Red + "] G[" + player_group.Chat_Green + "] B[" + player_group.Chat_Blue + "]");
                        AuthenticatedUsers.UpdateUser(name, null, false);
                    }
                    else
                    {
                        ProgramLog.Admin.Log("PlayerChat.color: Storage is not available");
                    }
                }
                // Using a custom color
                else if (args.Count == 4)
                {
                    if (DEBUG)
                        ProgramLog.Admin.Log("PlayerChat.color: Recieved arguments name[" + args[0] + "] r[" + args[1] + "] g[" + args[2] + "] b[" + args[3] + "]");

                    var name = args[0];
                    var player = Tools.GetPlayerByName(name);

                    Color color = new Color(ConvertStringToInt(args[1]), ConvertStringToInt(args[2]), ConvertStringToInt(args[3]));
                    var r = color.R;
                    var g = color.G;
                    var b = color.B;

                    // Player not online
                    if (player == null)
                        return; //sender.SendMessage("PlayerChat.color: Player is not online.");
                    else
                        name = player.Name;

                    if (Storage.IsAvailable)
                    {
                        if (DEBUG)
                            ProgramLog.Admin.Log("PlayerChat.color: Storage is available");

                        var player_group = Storage.GetInheritedGroupForUser(name);
                        if (DEBUG)
                            ProgramLog.Admin.Log("before change - R[" + player_group.Chat_Red + "] G[" + player_group.Chat_Green + "] B[" + player_group.Chat_Blue + "]");

                        if (DEBUG)
                            ProgramLog.Admin.Log("PlayerChat.color: Attempting to update color for [" + name + "] to color R[" + r + "] G[" + g + "] B[" + b + "]");
                        player_group.Chat_Red = r;
                        player_group.Chat_Green = g;
                        player_group.Chat_Blue = b;

                        if (DEBUG)
                            ProgramLog.Admin.Log("after change - R[" + player_group.Chat_Red + "] G[" + player_group.Chat_Green + "] B[" + player_group.Chat_Blue + "]");
                        AuthenticatedUsers.UpdateUser(name, null, false);
                    }
                    else
                    {
                        ProgramLog.Admin.Log("PlayerChat.color: Storage is not available");
//.........这里部分代码省略.........
开发者ID:i2c2-caj,项目名称:PlayerChat,代码行数:101,代码来源:PlayerChatPlugin_Commands.cs

示例10: ManageApi

        void ManageApi(ISender sender, ArgumentList args)
        {
            if (!Storage.IsAvailable)
                throw new CommandError("No permissions plugin or data plugin is attached");

            var a = 0;
            string name, pass, type, value;
            APIAccount acc = null;
            var cmd = args.GetString(a++);

            switch (cmd)
            {
                case "addaccount":
                    //api addaccount "username" "password"
                    if (!args.TryGetString(a++, out name))
                        throw new CommandError("Expected username after [" + cmd + "]");

                    if (!args.TryGetString(a++, out pass))
                        throw new CommandError("Expected password after username");

                    acc = APIAccountManager.FindByName(name);
                    if (acc == null)
                    {
                        acc = APIAccountManager.Create(name, pass);
                        if (acc.Id > 0)
                        {
                            sender.SendMessage("Successfully created account.", R: 0, B: 0);
                        }
                        else
                        {
                            sender.SendMessage("Failed to create account.", G: 0, B: 0);
                        }
                    }
                    else
                    {
                        throw new CommandError("Existing API account found by " + name);
                    }
                    break;
                case "removeaccount":
                    //api removeaccount "username"
                    if (!args.TryGetString(a++, out name))
                        throw new CommandError("Expected username after [" + cmd + "]");

                    acc = APIAccountManager.FindByName(name);
                    if (acc != null)
                    {
                        if (APIAccountManager.DeleteAccount(acc.Id))
                        {
                            sender.SendMessage("Successfully removed account.", R: 0, B: 0);
                        }
                        else
                        {
                            sender.SendMessage("Failed to remove account.", G: 0, B: 0);
                        }
                    }
                    else
                    {
                        throw new CommandError("No API account found by " + name);
                    }
                    break;
                case "addrole":
                    //api addrole "account" "type" "value"
                    if (!args.TryGetString(a++, out name))
                        throw new CommandError("Expected username after [" + cmd + "]");

                    if (!args.TryGetString(a++, out type))
                        throw new CommandError("Expected type after username");

                    if (!args.TryGetString(a++, out value))
                        throw new CommandError("Expected value after type");

                    acc = APIAccountManager.FindByName(name);
                    if (acc != null)
                    {
                        var role = APIAccountManager.AddType(acc.Id, type, value);
                        if (role != null && role.Id > 0)
                        {
                            sender.SendMessage("Successfully added role account.", R: 0, B: 0);
                        }
                        else
                        {
                            sender.SendMessage("Failed to add role to account.", G: 0, B: 0);
                        }
                    }
                    else
                    {
                        throw new CommandError("No API account found by " + name);
                    }
                    break;
                case "removerole":
                    //api removerole "account" "type" "value"
                    if (!args.TryGetString(a++, out name))
                        throw new CommandError("Expected username after [" + cmd + "]");

                    if (!args.TryGetString(a++, out type))
                        throw new CommandError("Expected type after username");

                    if (!args.TryGetString(a++, out value))
                        throw new CommandError("Expected value after type");

//.........这里部分代码省略.........
开发者ID:DeathCradle,项目名称:Terraria-s-Dedicated-Server-Mod,代码行数:101,代码来源:ApiCommand.cs

示例11: DeopPlayer

        /// <summary>
        /// De-OPs a given Player.
        /// </summary>
        /// <param name="sender">Sending player</param>
        /// <param name="args">Arguments sent with command</param>
        public void DeopPlayer(ISender sender, ArgumentList args)
        {
            var playerName = args.GetString(0);
            //Player player;
            //if (args.TryGetOnlinePlayer(0, out player))
            //{
            //    playerName = player.Name;

            //    if (Server.Ops.Contains(playerName, true))
            //    {
            //        player.SendMessage("Your OP privledges have been revoked.", Color.Green);
            //    }

            //    player.Op = false;
            //}

            if (Storage.IsAvailable)
            {
                var existing = AuthenticatedUsers.GetUser(playerName);
                if (existing != null)
                {
                    if (!existing.Value.Operator)
                        throw new CommandError("Player is not an operator");

                    var player = Tools.GetPlayerByName(playerName);
                    if (player != null)
                    {
                        player.SendMessage("Your server operator privledges have been revoked.", Color.DarkRed);
                        player.Op = false;
                    }

                    if (AuthenticatedUsers.UpdateUser(playerName, false))
                    {
                        sender.Message("Deop success", Color.DarkGreen);
                    }
                    else
                    {
                        sender.Message("Failed to deop player", Color.DarkRed);
                    }
                }
                else
                {
                    sender.SendMessage("No user found by " + playerName);
                }
            }
            else
            {
                if (Ops.Contains(playerName))
                {
                    var player = Tools.GetPlayerByName(playerName);
                    if (player != null)
                    {
                        player.SendMessage("Your server operator privledges have been revoked.", Color.Green);
                        player.Op = false;
                    }

                    Tools.NotifyAllOps("De-Opping " + playerName + " [" + sender.SenderName + "]", true);
                    Ops.Remove(playerName, true);

                    if (!Ops.Save())
                    {
                        Tools.NotifyAllOps("Failed to save op list [" + sender.SenderName + "]", true);
                    }
                }
                else
                    sender.SendMessage("No user found by " + playerName);
            }
        }
开发者ID:CJKay,项目名称:Terraria-s-Dedicated-Server-Mod,代码行数:73,代码来源:Commands.cs

示例12: SuffixCommand

        void SuffixCommand(ISender sender, ArgumentList args)
        {
            try
            {
                if (args.Count == 2)
                {
                    if (DEBUG)
                        ProgramLog.Admin.Log("PlayerChat.suffix: Recieved arguments name[" + args[0] + "] suffix[" + args[1] + "]");

                    var name = args[0];
                    var player = Tools.GetPlayerByName(name);
                    var suffix = args[1];
                    bool remove_suffix = false;
                    if (suffix == "-r")
                        remove_suffix = true;

                    // Player offline
                    if (player == null)
                    {
                        ProgramLog.Admin.Log("PlayerChat.suffix: [" + name + "] is not online.");
                        return;
                    }

                    // Player online
                    name = player.Name;
                    if (DEBUG)
                        ProgramLog.Admin.Log("PlayerChat.suffix: [" + name + "] is online.");

                    if (Storage.IsAvailable)
                    {
                        if (DEBUG)
                            ProgramLog.Admin.Log("PlayerChat.suffix: Storage is available");

                        var player_group = Storage.GetInheritedGroupForUser(name);
                        if (DEBUG)
                            ProgramLog.Admin.Log("before change - suffix[" + player_group.Chat_Suffix + "]");

                        if (remove_suffix)
                        {
                            if (DEBUG)
                                ProgramLog.Admin.Log("PlayerChat.suffix: Attempting to remove suffix for [" + name + "]");
                            player_group.Chat_Suffix = "";
                        }
                        else
                        {
                            if (DEBUG)
                                ProgramLog.Admin.Log("PlayerChat.suffix: Attempting to update suffix for [" + name + "] to suffix [" + suffix + "]");
                            player_group.Chat_Suffix = suffix;

                        }
                        if (DEBUG)
                            ProgramLog.Admin.Log("after change - suffix[" + player_group.Chat_Suffix + "]");
                        AuthenticatedUsers.UpdateUser(name, null, false);
                    }
                    else
                    {
                        ProgramLog.Admin.Log("PlayerChat.suffix: Storage is not available");
                    }
                }
                else
                {
                    sender.SendMessage("Type 'help suffix' for usage");
                }
            }
            catch (OptionException)
            {
                throw new CommandError("");
            }
        }
开发者ID:i2c2-caj,项目名称:PlayerChat,代码行数:69,代码来源:PlayerChatPlugin_Commands.cs

示例13: ServerList

 /// <summary>
 /// Manages the server list
 /// </summary>
 /// <param name="sender">Sending player</param>
 /// <param name="args">Arguments sent with command</param>
 public void ServerList(ISender sender, ArgumentList args)
 {
     string first;
     args.TryPopOne(out first);
     switch (first)
     {
         case "enable":
             if (!Heartbeat.Enabled)
             {
                 Heartbeat.Begin(Entry.CoreBuild);
                 sender.SendMessage("Heartbeat enabled to the TDSM server.");
             }
             else
             {
                 sender.SendMessage("Heartbeat is already enabled.");
             }
             break;
         case "disable":
             if (Heartbeat.Enabled)
             {
                 Heartbeat.End();
                 sender.SendMessage("Heartbeat disabled to the TDSM server.");
             }
             else
             {
                 sender.SendMessage("Heartbeat is not enabled.");
             }
             break;
         case "public":
             Heartbeat.PublishToList = args.GetBool(0);
             if (!ConfigUpdater.IsAvailable || ConfigUpdater.Set("server-list", Heartbeat.PublishToList))
                 sender.SendMessage("Server list is now " + (Heartbeat.PublishToList ? "public" : "private"));
             else sender.Message("Failed to update visibility");
             break;
         case "desc":
             string d;
             if (args.TryPopOne(out d))
             {
                 Heartbeat.ServerDescription = d;
                 if (!ConfigUpdater.IsAvailable || ConfigUpdater.Set("server-list-desc", d))
                     sender.SendMessage("Description set to: " + Heartbeat.ServerDescription);
                 else sender.Message("Failed to update description");
             }
             else
                 sender.SendMessage("Current description: " + Heartbeat.ServerDescription);
             break;
         case "name":
             string n;
             if (args.TryPopOne(out n))
             {
                 Heartbeat.ServerName = n;
                 if (!ConfigUpdater.IsAvailable || ConfigUpdater.Set("server-list-name", n))
                     sender.SendMessage("Name set to: " + Heartbeat.ServerName);
                 else sender.Message("Failed to update name");
             }
             else
                 sender.SendMessage("Current name: " + Heartbeat.ServerName);
             break;
         case "domain":
             string h;
             if (args.TryPopOne(out h))
             {
                 Heartbeat.ServerDomain = h;
                 if (!ConfigUpdater.IsAvailable || ConfigUpdater.Set("server-list-domain", h))
                     sender.SendMessage("Domain set to: " + Heartbeat.ServerDomain);
                 else sender.Message("Failed to update domain");
             }
             else
                 sender.SendMessage("Current domain: " + Heartbeat.ServerDomain);
             break;
         case "?":
         case "print":
             sender.SendMessage("Heartbeat is " + (Heartbeat.Enabled ? "enabled" : "disabled"));
             if (Heartbeat.LastBeat.HasValue)
                 sender.SendMessage("Last beat: " + Heartbeat.LastBeat);
             else
                 sender.SendMessage("Last beat: n/a");
             sender.SendMessage("Server list is " + (Heartbeat.PublishToList ? "public" : "private"));
             sender.SendMessage("Current name: " + Heartbeat.ServerName);
             sender.SendMessage("Current domain: " + Heartbeat.ServerDomain);
             sender.SendMessage("Current description: " + Heartbeat.ServerDescription);
             break;
         default:
             throw new CommandError("Not a supported serverlist command " + first);
     }
 }
开发者ID:DeathCradle,项目名称:Terraria-s-Dedicated-Server-Mod,代码行数:91,代码来源:ServerListCommand.cs

示例14: ParseAndProcess

        public void ParseAndProcess(ISender sender, string line)
        {
            var ctx = new HookContext
            {
                Sender = sender,
            #if Full_API
                Player = sender as Player
            #endif
            };

            #if Full_API
            ctx.Connection = ctx.Player != null ? ctx.Player.Connection.Socket : null;
            #endif

            var hargs = new HookArgs.Command();

            try
            {
                CommandInfo info;

                var firstSpace = line.IndexOf(' ');

                if (firstSpace < 0) firstSpace = line.Length;

                var prefix = line.Substring(0, firstSpace);

                hargs.Prefix = prefix;

                if (FindStringCommand(prefix, out info))
                {
                    hargs.ArgumentString = (firstSpace < line.Length - 1 ? line.Substring(firstSpace + 1, line.Length - firstSpace - 1) : "").Trim();

                    HookPoints.Command.Invoke(ref ctx, ref hargs);

                    if (ctx.CheckForKick() || ctx.Result == HookResult.IGNORE)
                        return;

                    if (ctx.Result != HookResult.CONTINUE && !CheckAccessLevel(info, sender))
                    {
                        sender.SendMessage("Permissions error", 255, 238, 130, 238);
                        return;
                    }

                    try
                    {
                        info.Run(sender, hargs.ArgumentString);
                    }
                    catch (NLua.Exceptions.LuaScriptException e)
                    {
                        if (e.IsNetException)
                        {
                            var ex = e.GetBaseException();
                            if (ex != null)
                            {
                                if (ex is CommandError)
                                {
                                    sender.SendMessage(prefix + ": " + ex.Message);
                                    info.ShowHelp(sender);
                                }
                            }
                        }
                    }
                    catch (ExitException e)
                    {
                        throw e;
                    }
                    catch (CommandError e)
                    {
                        sender.SendMessage(prefix + ": " + e.Message);
                        info.ShowHelp(sender);
                    }
                    return;
                }

                var args = new ArgumentList();
                var command = Tokenize(line, args);

                if (command != null)
                {
                    if (FindTokenCommand(command, out info))
                    {
                        hargs.Arguments = args;

                        foreach (BasePlugin plg in PluginManager._plugins.Values)
                        {
                            if (plg.commands.ContainsKey(command))
                            {
                                args.Plugin = plg;
                            }
                        }

                        HookPoints.Command.Invoke(ref ctx, ref hargs);

                        if (ctx.CheckForKick() || ctx.Result == HookResult.IGNORE)
                            return;

                        if (ctx.Result != HookResult.CONTINUE && !CheckAccessLevel(info, sender))
                        {
                            sender.SendMessage("Permissions error", 255, 238, 130, 238);
                            return;
//.........这里部分代码省略.........
开发者ID:apemanzilla,项目名称:Terraria-s-Dedicated-Server-Mod,代码行数:101,代码来源:CommandParser.cs

示例15: ShowHelp

        public void ShowHelp(ISender sender, bool noHelp = false)
        {
            if (helpText.Count == 0 && noHelp)
            {
                // Disabled this since it's not needed. There will usually be a description. But there should be some checks on if these are actually set, especially for plugins.
                //sender.SendMessage("No help text specified.");
                return;
            }

            #if Full_API
            if (!_oldHelpStyle)
            {
                const String Push = "       ";
                string command = (sender is Player ? "/" : String.Empty) + _prefix;
                if (_defaultHelp)
                    sender.SendMessage("Usage: " + command);

                bool first = !_defaultHelp;
                foreach (var line in helpText)
                {
                    if (first)
                    {
                        first = false;
                        sender.SendMessage("Usage: " + command + " " + line);
                    }
                    else sender.SendMessage(Push + command + " " + line);
                }
            }
            else
            {
                foreach (var line in helpText)
                    sender.SendMessage(line);
            }
            #endif
        }
开发者ID:apemanzilla,项目名称:Terraria-s-Dedicated-Server-Mod,代码行数:35,代码来源:CommandParser.cs


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