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


C# ArgumentList.ParseOne方法代码示例

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


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

示例1: Kick

        /// <summary>
        /// Kicks a given Player from the server
        /// </summary>
        /// <param name="sender">Sending player</param>
        /// <param name="args">Arguments sent with command</param>
        public void Kick(ISender sender, ArgumentList args)
        {
            if (args.TryPop("-s"))
            {
                int s;
                args.ParseOne(out s);

                var slot = Terraria.Netplay.Clients[s];

                #if TDSMServer
                if (slot.State() != SlotState.VACANT)
                {
                slot.Kick("You have been kicked by " + sender.SenderName + ".");

                var player = Main.player[s];
                if (player != null && player.name != null)
                NewNetMessage.SendData(25, -1, -1, player.name + " has been kicked by " + sender.SenderName + ".", 255);
                }
                else
                {
                sender.Message("Kick slot is empty");
                }
                #else
                NetMessage.SendData(2, slot.Id, -1, "Kicked from server.", 0, 0f, 0f, 0f, 0, 0, 0);
                #endif
            }
            else
            {
                Player player;
                args.ParseOne<Player>(out player);

                if (player.name == null)
                {
                    sender.Message("Kick player name is not set.");
                    return;
                }

                player.Kick("You have been kicked by " + sender.SenderName + ".");
                NetMessage.SendData(25, -1, -1, player.name + " has been kicked by " + sender.SenderName + ".", 255);
            }
        }
开发者ID:DeathCradle,项目名称:Terraria-s-Dedicated-Server-Mod,代码行数:46,代码来源:KickCommand.cs

示例2: Kick

        /// <summary>
        /// Kicks a given Player from the server
        /// </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 Kick(Server server, ISender sender, ArgumentList args)
        {
            if (args.TryPop("-s"))
            {
                int s;
                args.ParseOne(out s);

                var slot = Netplay.slots[s];

                if (slot.state != SlotState.VACANT)
                {
                    slot.Kick("You have been kicked by " + sender.Name + ".");

                    var player = Main.players[s];
                    if (player != null && player.Name != null)
                        NetMessage.SendData(25, -1, -1, player.Name + " has been kicked by " + sender.Name + ".", 255);
                }
                else
                {
                    sender.sendMessage("kick: Slot is vacant.");
                }
            }
            else
            {
                Player player;
                args.ParseOne<Player>(out player);

                if (player.Name == null)
                {
                    sender.sendMessage("kick: Error, player has null name.");
                    return;
                }

                player.Kick("You have been kicked by " + sender.Name + ".");
                NetMessage.SendData(25, -1, -1, player.Name + " has been kicked by " + sender.Name + ".", 255);
            }
        }
开发者ID:Dyrian,项目名称:Terraria-s-Dedicated-Server-Mod,代码行数:43,代码来源:Commands.cs

示例3: Kick

        /// <summary>
        /// Kicks a given Player from the server
        /// </summary>
        /// <param name="sender">Sending player</param>
        /// <param name="args">Arguments sent with command</param>
        public static void Kick(ISender sender, ArgumentList args)
        {
            if (args.TryPop("-s"))
            {
                int s;
                args.ParseOne(out s);

                var slot = NetPlay.slots[s];

                if (slot.state != SlotState.VACANT)
                {
                    slot.Kick(Languages.YouHaveBeenKickedBy + sender.Name + ".");

                    var player = Main.players[s];
                    if (player != null && player.Name != null)
                        NetMessage.SendData(25, -1, -1, player.Name + Languages.HasBeenKickedBy + sender.Name + ".", 255);
                }
                else
                {
                    sender.sendMessage(Languages.KickSlotIsEmpty);
                }
            }
            else
            {
                Player player;
                args.ParseOne<Player>(out player);

                if (player.Name == null)
                {
                    sender.sendMessage(Languages.KickPlayerNameNull);
                    return;
                }

                player.Kick(Languages.YouHaveBeenKickedBy + sender.Name + ".");
                NetMessage.SendData(25, -1, -1, player.Name + Languages.HasBeenKickedBy + sender.Name + ".", 255);
            }
        }
开发者ID:jason14747,项目名称:Terraria-s-Dedicated-Server-Mod,代码行数:42,代码来源:Commands.cs

示例4: PluginManage

        public void PluginManage(ISender sender, ArgumentList args)
        {
            /*
             * Commands:
             *      list    - shows all plugins
             *      info    - shows a plugin's author & description etc
             *      disable - disables a plugin
             *      enable  - enables a plugin
             *      reload
             *      unload
             *      status
             *      load
             */

            if (args.Count == 0)
                throw new CommandError("Subcommand expected.");

            string command = args[0];
            args.RemoveAt(0); //Allow the commands to use any additional arguments without also getting the command

            lock (PluginManager._plugins)
                switch (command)
                {
                    case "-l":
                    case "ls":
                    case "list":
                        {
                            if (PluginManager.PluginCount == 0)
                            {
                                sender.Message(255, "No plugins loaded.");
                                return;
                            }

                            var msg = new StringBuilder();
                            msg.Append("Plugins: ");

                            int i = 0;
                            foreach (var plugin in PluginManager.EnumeratePlugins)
                            {
                                if (i > 0)
                                    msg.Append(", ");
                                msg.Append(plugin.Name);

                                if (!String.IsNullOrEmpty(plugin.Version))
                                {
                                    msg.Append(" (");
                                    msg.Append(plugin.Version);
                                    msg.Append(")");
                                }

                                if (!plugin.IsEnabled)
                                    msg.Append("[OFF]");
                                i++;
                            }
                            msg.Append(".");

                            sender.Message(255, Color.DodgerBlue, msg.ToString());

                            break;
                        }

                    case "-s":
                    case "stat":
                    case "status":
                        {
                            if (PluginManager.PluginCount == 0)
                            {
                                sender.Message(255, "No plugins loaded.");
                                return;
                            }

                            var msg = new StringBuilder();

                            foreach (var plugin in PluginManager.EnumeratePlugins)
                            {
                                msg.Clear();
                                msg.Append(plugin.IsDisposed ? "[DISPOSED] " : (plugin.IsEnabled ? "[ON]  " : "[OFF] "));
                                msg.Append(plugin.Name);
                                msg.Append(" ");
                                msg.Append(plugin.Version);
                                if (plugin.Status != null && plugin.Status.Length > 0)
                                {
                                    msg.Append(" : ");
                                    msg.Append(plugin.Status);
                                }
                                sender.Message(255, Color.DodgerBlue, msg.ToString());
                            }

                            break;
                        }

                    case "-i":
                    case "info":
                        {
                            string name;
                            args.ParseOne(out name);

                            var fplugin = PluginManager.GetPlugin(name);
                            if (fplugin != null)
                            {
//.........这里部分代码省略.........
开发者ID:carriercomm,项目名称:Terraria-s-Dedicated-Server-Mod,代码行数:101,代码来源:PluginCommand.cs


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