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


C# ISender.sendMessage方法代码示例

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


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

示例1: OptionsCommand

        void OptionsCommand(ISender sender, ArgumentList argz)
        {
            try
            {
                var ms = mysqlserver2;
                var md = mysqldatabase2;
                var mu = mysqluser2;
                var mp = mysqlpassword2;
                var pp = pcpinprefix;
                var wc = web2chat;
                var ah = addhours;
                var reload = false;

                var options = new OptionSet ()
                {
                    { "L|reload", v => reload = true },
                };

                var args = options.Parse (argz);

                if (args.Count > 0)
                    throw new CommandError ("");

                if (reload)
                {
                    sender.sendMessage ("webchat: Reloaded settings database, entries: " + properties.Count, 255, 238, 130, 238);
                    properties.Load ();
                }
                if(mysqlenabled)
                {
                var msg2 = string.Concat (
                    "Connection: mysql-server=", ms,
                    ", mysql-database=", md,
                    ", mysql-user=", mu,
                    ", pcpin-prefix=", pp,
                        ", web2chat=", wc,
                        ", addhours=", ah);

                ProgramLog.Admin.Log ("<webchat> " + msg2);

                sender.sendMessage ("webchat: " + msg2, 255, 238, 130, 238);
                }
                else
                {
                    var msg2 = string.Concat (
                    "Mysql connection not set up");

                ProgramLog.Admin.Log ("<webchat> " + msg2);
                sender.sendMessage ("webchat: " + msg2, 255, 238, 130, 238);
                }
            }
            catch (OptionException)
            {
                throw new CommandError ("");
            }
        }
开发者ID:elevatorguy,项目名称:TDSM_WebChat,代码行数:56,代码来源:WebChatPlugin_Commands.cs

示例2: ExampleCommand

        public static void ExampleCommand(ISender sender, ArgumentList args)
        {
            TDSM_Plugin MyPlugin = (TDSM_Plugin)args.Plugin; //Get the plugin object who's assigned to the "tdsmpluginexample"

            //if the user enters /tdsmpluginexample -test 1, it will retreive the next value '1' and put into 'arg' as an integer.
            int arg;
            if (args.TryParseOne<int>("-test", out arg))
                sender.sendMessage(sender.Name + " Argument: " + arg);
            else
            {
                //For new people to .NET, I would not really expect you to understand everything just yet.
                string platform = Platform.Type.ToString();
                switch (Platform.Type)
                {
                    case Platform.PlatformType.LINUX:
                        platform = "Linux";
                        break;
                    case Platform.PlatformType.MAC:
                        platform = "Mac";
                        break;
                    case Platform.PlatformType.WINDOWS:
                        platform = "Windows";
                        break;
                }

                (sender as Player).sendMessage("TDSM Plugin Example, Running OS: " + platform, ChatColor.DarkGreen);
            }
        }
开发者ID:jason14747,项目名称:Terraria-s-Dedicated-Server-Mod,代码行数:28,代码来源:PluginCommands.cs

示例3: ExampleCommand

 public static void ExampleCommand(ISender sender, ArgumentList args)
 {
     TDSM_Plugin MyPlugin = (TDSM_Plugin)args.Plugin; //Get the plugin object who's assigned to the "tdsmpluginexample"
     int arg;
     //if the user enters /tdsmpluginexample -test 1, it will retreive the next value '1' and put into 'arg' as an integer.
     if (args.TryParseOne<int>("-test", out arg))
     {
         sender.sendMessage(sender.Name + " Argument: " + arg);
     }
     else
     {
         //For new people, I would not really expect you to understand the following.
         //If needed I can simplify this down...
         string Platform = Terraria_Server.Definitions.Platform.Type.ToString();
         switch (Terraria_Server.Definitions.Platform.Type)
         {
             case Terraria_Server.Definitions.Platform.PlatformType.LINUX:
                 Platform = "Linux";
                 break;
             case Terraria_Server.Definitions.Platform.PlatformType.MAC:
                 Platform = "Mac";
                 break;
             case Terraria_Server.Definitions.Platform.PlatformType.WINDOWS:
                 Platform = "Windows";
                 break;
         }
         (sender as Player).sendMessage("TDSM Plugin Example, Running OS: " + Platform, ChatColor.DarkGreen);
     }
 }
开发者ID:Skiles,项目名称:Terraria-s-Dedicated-Server-Mod,代码行数:29,代码来源:PluginCommands.cs

示例4: AddUser

        public static void AddUser(Server server, ISender sender, ArgumentList args)
        {
            String User = "", IP = "";
            Int32 Slot;

            args.TryParseOne<String>("-ip", out IP); //Optional

            //IP or name?
            if (args.TryParseTwo<String, Int32>("-name", out User, "-slot", out Slot))
            {
                String[] exceptions = new String[2];
                if (User.Length > 0)
                {
                    exceptions[0] = User;
                }
                if (IP.Length > 0)
                {
                    exceptions[1] = IP;
                }

                Region.Region region = null;
                for (int i = 0; i < Regions.regionManager.Regions.Count; i++)
                {
                    if (Slot == i)
                        region = Regions.regionManager.Regions[i];
                    break;
                }

                if (region == null)
                    throw new CommandError("Specified Region Slot was incorrect.");

                //List<String> users = new List<String>();
                int usersAdded = 0;
                foreach (String toInflate in exceptions)
                {
                    if (toInflate != null)
                        foreach (String inflatee in toInflate.Split(','))
                        {
                            region.UserList.Add(inflatee);
                            usersAdded++;
                        }
                }

                if (usersAdded > 0)
                {
                    sender.sendMessage(string.Format("{0} users were added to {1}", usersAdded, region.Name),
                        255, 0, 255, 0);
                    Regions.Log(sender.Name + " created region {0} with {1} user/s", region.Name, usersAdded);
                }
                else
                    throw new CommandError("A user was not able to be added to a Region.");
            }
            else
                throw new CommandError("Invalid arguments, Please review your command.");
        }
开发者ID:Dyrian,项目名称:Terraria-s-Dedicated-Server-Mod,代码行数:55,代码来源:Commands.cs

示例5: LastSeenCommand

        void LastSeenCommand(ISender sender, ArgumentList args)
        {
            try {
                if (args.Count != 1)
                    throw new CommandError ("");

                    string playername = args[0].Trim ();
                    string lasttimeonline = getLastPlayerTimeOnline(playername);

                    if(lasttimeonline!="")
                    {
                        sender.sendMessage (playername+" last logged in at: "+lasttimeonline);
                    }
                    else
                    {
                        sender.sendMessage ("ERROR: '"+playername+"' not found");
                    }

            } catch (OptionException) {
                throw new CommandError ("");
            }
        }
开发者ID:elevatorguy,项目名称:TDSM_mysql,代码行数:22,代码来源:MysqlPlugin_Commands.cs

示例6: GroupPermissions

        public void GroupPermissions(ISender sender, ArgumentList args)
        {
            var addPerms = args.TryPop("addperms");
            var denyPerms = args.TryPop("denyperms");
            var removePerms = args.TryPop("removeperms");
            var removeDeniedPerms = args.TryPop("removedenied");
            var save = args.TryPop("-save");

            if (addPerms || denyPerms || removePerms || removeDeniedPerms)
            {
                string group, permission;
                if (args.TryParseTwo<String, String>(out group, out permission))
                {
                    if (!XmlParser.HasGroup(group)) throw new CommandError("{1} `{0}`", group,Languages.NoGroup);

                    var permissions = permission.Split(',');
                    var add = addPerms || denyPerms;

                    int added = 0, failed = 0;
                    foreach (var node in permissions)
                    {
                        var res = false;

                        if (add)
                        {
                            if (addPerms) res = XmlParser.AddNodeToGroup(group, node);
                            else res = XmlParser.AddDeniedNodeToGroup(group, node);
                        }
                        else
                        {
                            if (removePerms) res = XmlParser.RemovePermissionFromGroup(group, node);
                            else res = XmlParser.RemoveDeniedPermissionFromGroup(group, node);
                        }

                        if (res) added++;
                        else failed++;
                    }

                    if (save) XmlParser.Save();

                    sender.sendMessage(
                        String.Format("{2} {0} {3} {1} {4}",
                        added, failed, add ? Languages.Added : Languages.Removed, Languages.NodesWhere, Languages.Failed
                        )
                    );
                }
                else throw new CommandError(Languages.GrpAndNodeExpected);
            }
                else throw new CommandError(Languages.ArgumentsExpected);
        }
开发者ID:emreuyls,项目名称:Terraria-s-Dedicated-Server-Mod,代码行数:50,代码来源:Commands.cs

示例7: Buff

        public static void Buff(ISender sender, ArgumentList args)
        {
            Player target;
            int type;
            int length;
            int maxBuffs = 40;

            if (args.Count == 2)
            {
                target = sender as Player;
                try
                {
                    type = Essentials.GetBuffID(args[0]);
                    length = (Int32.Parse(args[1])) * 60;
                    if (type >= 0 && type <= maxBuffs && length >=0)
                    {
                        target.AddBuff(type,length,false);
                        NetMessage.SendData (55, target.whoAmi, -1, "", target.whoAmi, type, length, 0f, 0);
                        Server.notifyOps("Buffed " + target.Name + " with " + args[0] + " for " + args[1] + " second(s).", true);
                    }
                    else sender.sendMessage ("Invalid parameters specified. Maybe the item name was not found?");
                }
                catch
                {
                    throw new CommandError("Command error.");
                }
            }
            else if (args.Count == 3)
            {
                target = Server.GetPlayerByName(args[0].Trim());
                try
                {
                    type = Essentials.GetBuffID(args[1]);
                    length = (Int32.Parse(args[2])) * 60;
                    if (type >= 0 && type <= maxBuffs && length >= 0)
                    {
                        target.AddBuff(type, length, false);
                        NetMessage.SendData(55, target.whoAmi, -1, "", target.whoAmi, type, length, 0f, 0);
                        Server.notifyOps("Buffed " + target.Name + " with " + args[1] + " for " + args[2] + " second(s).", true);
                    }
                    else sender.sendMessage("Invalid parameters specified. Maybe the item name was not found?");
                }
                catch
                {
                    throw new CommandError("Command error.");
                }
            }
            else
                throw new CommandError("No parameters specified.");
        }
开发者ID:TimeBomb,项目名称:Essentials-TDSM,代码行数:50,代码来源:Commands.cs

示例8: Backups

        /// <summary>
        /// Allows a user to take backups and purge old data
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="args"></param>
        public static void Backups(ISender sender, ArgumentList args)
        {
            var perform = args.TryPop("now");
            var purge = args.TryPop("purge");

            if (perform)
                BackupManager.PerformBackup();
            else if (purge)
            {
                int minutes;
                if (args.TryParseOne<Int32>(out minutes))
                {
                    var backups = BackupManager.GetBackupsBefore(Main.worldName, DateTime.Now.AddMinutes(-minutes));

                    var failCount = 0;
                    foreach (var backup in backups)
                        try
                        {
                            File.Delete(backup);
                        }
                        catch { failCount++; }

                    if (failCount > 0)
                        sender.sendMessage(
                            String.Format("Failed to deleted {0} backup(s).", failCount)
                        );
                    else
                        sender.sendMessage(
                            String.Format("Deleted {0} backup(s).", backups.Length - failCount)
                        );
                }
                else
                    throw new CommandError("Please specify a time frame.");
            }
            else
                throw new CommandError("Argument expected.");
        }
开发者ID:jason14747,项目名称:Terraria-s-Dedicated-Server-Mod,代码行数:42,代码来源:Commands.cs

示例9: Perms_Add

        void Perms_Add(ISender sender, ArgumentList args)
        {
            //permsadd -group <group> -node <node>
            //permsadd -user <user> -group <group>
            //permsadd -user <user> -node <node>
            var Name = "";
            var Secondary = "";

            if (args.TryParseTwo("-group", out Name, "-node", out Secondary))
            {
                Group grp = Permissions.GetGroup(Name);
                if (grp == null)
                    throw new CommandError("Group not found.");

                var token = Secondary.Substring(0, 1) == "-"; //Allowed or not?.
                grp.permissions.Add(Secondary, token);
            }
            else if (args.TryParseTwo("-user", out Name, "-group", out Secondary))
            {
                Group grp = Permissions.GetGroup(Secondary);
                if (grp == null)
                    throw new CommandError("Group not found.");

                User usr = Permissions.GetUser(Name);
                if (usr == null)
                    throw new CommandError("User not found.");

                usr.group.Add(Secondary);
            }
            else if (args.TryParseTwo("-user", out Name, "-node", out Secondary))
            {
                User usr = Permissions.GetUser(Name);
                if (usr == null)
                    throw new CommandError("User not found.");

                usr.hasPerm.Add(Secondary);
            }
            else
                throw new CommandError("Unknown command.");

            sender.sendMessage(
                String.Format("`{0}` successfully added to `{1}`", Secondary, Name)
            );
        }
开发者ID:jason14747,项目名称:Terraria-s-Dedicated-Server-Mod,代码行数:44,代码来源:PluginCommands.cs

示例10: LocationCommand

        void LocationCommand(ISender sender, ArgumentList args)
        {
            try {
                if (args.Count > 0)
                    throw new CommandError ("");
                var msg2 = "";
                if (s.isEnabled(sender.Name)) {
                    msg2 = string.Concat ("show block history disabled for "+sender.Name);
                    s.disable(sender.Name);

                } else {
                    msg2 = string.Concat ("show block history enabled for "+sender.Name);
                    s.enable(sender.Name);
                }

                ProgramLog.Admin.Log ("<mysql> " + msg2);
                sender.sendMessage ("mysql: " + msg2);

            } catch (OptionException) {
                throw new CommandError ("");
            }
        }
开发者ID:elevatorguy,项目名称:TDSM_mysql,代码行数:22,代码来源:MysqlPlugin_Commands.cs

示例11: GroupAttributes

        public void GroupAttributes(ISender sender, ArgumentList args)
        {
            var save = args.TryPop("-save");
            var requestedGroup = args.GetString(0);
            var attribute = args.GetString(1);
            var value = args.GetString(2);

            if (!XmlParser.HasGroup(requestedGroup))
                throw new CommandError("{1} `{0}`", requestedGroup, Languages.NoGroup);

            IPermission group = XmlParser.GetGroup(requestedGroup);

            SetAttribute(ref group, attribute, value);

            var res = XmlParser.UpdateDefiniton(group);

            if (save) XmlParser.Save();

            sender.sendMessage(
                String.Format("{0} {1}", res ? Languages.Success : Languages.Failure, Languages.UpdatingAttribute)
            );
        }
开发者ID:emreuyls,项目名称:Terraria-s-Dedicated-Server-Mod,代码行数:22,代码来源:Commands.cs

示例12: Ban

        /// <summary>
        /// Adds a player or ip (Exception) to the ban list.
        /// </summary>
        /// <param name="server">Current Server instance</param>
        /// <param name="sender">Sending player</param>
        /// <param name="args">Arguments sent with command</param>
        public static void Ban(Server server, ISender sender, ArgumentList args)
        {
            if (args != null && args.Count > 0)
            {
                //We now should check to make sure they are off the server...
                Player banee = Program.server.GetPlayerByName(args[0]);

                if (banee == null)
                {
                    foreach (Player player in Program.server.PlayerList)
                    {
                        var ip = Netplay.slots[player.whoAmi].remoteAddress.Split(':')[0];
                        if (ip == args[0])
                        {
                            banee = player;
                        }
                    }
                }

                Program.server.BanList.addException(args[0]);

                if (banee != null)
                {
                    banee.Kick("You have been banned from this Server.");
                    Program.server.BanList.addException(Netplay.slots[banee.whoAmi].
                        remoteAddress.Split(':')[0]);
                }

                Program.server.notifyOps(args[0] + " has been banned {" + sender.Name + "}", true);
                if (!Program.server.BanList.Save())
                {
                    Program.server.notifyOps("BanList Failed to Save due to " + sender.Name + "'s command", true);
                }
            }
            else
            {
                sender.sendMessage("Please review that command");
            }
        }
开发者ID:Dyrian,项目名称:Terraria-s-Dedicated-Server-Mod,代码行数:45,代码来源:Commands.cs

示例13: ProtectMap

        public void ProtectMap(ISender sender, ArgumentList args)
        {
            Vector2 Start = new Vector2(0, 0);
            Vector2 End = new Vector2(Main.maxTilesX, Main.maxTilesY);

            bool Restrict = args.TryPop("-res");
            bool RestrictNPC = args.TryPop("-npcres");

            string rgnName = "all";
            int count = 0;

            while (regionManager.ContainsRegion(rgnName))
            {
                //if(regionManager.ContainsRegion(rgnName))
                //{
                rgnName = "all" + count.ToString();
                count++;
                //}
                //else
                //    break;
            }

            Region rgn = new Region();
            rgn.Name = rgnName;
            rgn.Description = "A Region that protects the entire map";
            rgn.Point1 = Start;
            rgn.Point2 = End;
            rgn.Restricted = Restrict;
            rgn.RestrictedNPCs = RestrictNPC;

            if (rgn.IsValidRegion())
            {
                regionManager.Regions.Add(rgn);
                if (regionManager.SaveRegion(rgn))
                    sender.sendMessage("Region '" + rgnName + "' was successfully created.");
                else
                    sender.sendMessage("There was an issue while saving the region");
            }
            else
            {
                sender.sendMessage("There was an issue while creating the region");
            }
        }
开发者ID:jason14747,项目名称:Terraria-s-Dedicated-Server-Mod,代码行数:43,代码来源:Commands.cs

示例14: getBlockHistory

        public string getBlockHistory(float x, float y, ISender sender)
        {
            DateTime timestamp;
            string player;
            string action;
            //bool undone;
            string result = "TileHistory for ("+x+", "+y+")";
            IDbConnection dbcon;
            dbcon = new MySqlConnection (connectionString);
            dbcon.Open();
            IDbCommand dbcmd = dbcon.CreateCommand ();
            string sql = "SELECT * FROM `terraria_tiles` WHERE x = " + (int)x + " and y = " + (int)y + " LIMIT 0, 5";
            dbcmd.CommandText = sql;
            IDataReader reader = dbcmd.ExecuteReader ();
            sender.sendMessage("mysql: " + result);
            while (reader.Read()) {
                timestamp = (DateTime)reader ["timestamp"];
                player = (string)reader ["player"];
                action = (string)reader ["action"];

                var msg = timestamp.ToString() + " " + player + " " + action + " ";
                sender.sendMessage("mysql: " + msg);
                result = result + "\n" + msg + " ";
            }
            // clean up
            reader.Close ();
            reader = null;
            dbcmd.Dispose ();
            dbcmd = null;
            dbcon.Close();
            dbcon = null;
            //end check

            return result;
        }
开发者ID:elevatorguy,项目名称:TDSM_mysql,代码行数:35,代码来源:MysqlPlugin_Mysql.cs

示例15: AddUser

        public void AddUser(ISender sender, ArgumentList args)
        {
            string User = "", IP = "", regionName = "";
            int Slot = -1;

            //args.TryParseOne<String>("-ip", out IP); //Optional

            //IP or name?
            if (args.TryParseTwo<String, Int32>("-name", out User, "-slot", out Slot) ||
                args.TryParseTwo<String, Int32>("-ip", out User, "-slot", out Slot) ||
                args.TryParseTwo<String, String>("-name", out User, "-region", out regionName) ||
                args.TryParseTwo<String, String>("-ip", out User, "-region", out regionName))
            {
                string[] exceptions = new string[2];
                if (User.Length > 0)
                {
                    exceptions[0] = User;
                }
                if (IP.Length > 0)
                {
                    exceptions[1] = IP;
                }

                Region region = null;
                for (int i = 0; i < regionManager.Regions.Count; i++)
                {
                    if (Slot == i)
                    {
                        region = regionManager.Regions[i];
                        break;
                    }
                }

                //[TODO] TEST ME
                if (region == null && regionName.Length > 0)
                {
                    for (int i = 0; i < regionManager.Regions.Count; i++)
                    {
                        if (regionManager.Regions[i].Name.Trim().ToLower().Replace(" ", "").Equals(regionName.ToLower()))
                        {
                            region = regionManager.Regions[i];
                            break;
                        }
                    }
                }

                if (region == null)
                    throw new CommandError("Specified Region Slot was incorrect.");

                int usersAdded = 0;
                foreach (string toInflate in exceptions)
                {
                    if (toInflate != null)
                        foreach (string inflatee in toInflate.Split(','))
                        {
                            region.UserList.Add(inflatee);
                            usersAdded++;
                        }
                }

                if (usersAdded > 0)
                {
                    if (regionManager.SaveRegion(region))
                    {
                        sender.sendMessage(String.Format("{0} users were added to {1}", usersAdded, region.Name),
                        255, 0, 255);
                        RegionsPlugin.Log(sender.Name + " created region {0} with {1} user/s", region.Name, usersAdded);
                    }
                    else
                        sender.sendMessage(String.Format("Failed to save Region '{0}'", region.Name));
                }
                else
                    throw new CommandError("A user was not able to be added to a Region.");
            }
            else
                throw new CommandError("Invalid arguments, Please review your command.");
        }
开发者ID:jason14747,项目名称:Terraria-s-Dedicated-Server-Mod,代码行数:77,代码来源:Commands.cs


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