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


C# IRemoteClient.SendMessage方法代码示例

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


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

示例1: Handle

        public override void Handle(IRemoteClient client, string alias, string[] arguments)
        {
            switch (arguments.Length)
            {
                case 0:
                    client.SendMessage(client.World.Time.ToString());
                    break;
                case 2:
                    if (!arguments[0].Equals("set"))
                        Help(client, alias, arguments);

                    int newTime;

                    if(!Int32.TryParse(arguments[1], out newTime))
                        Help(client, alias, arguments);

                    client.World.Time = newTime;

                    client.SendMessage(string.Format("Setting time to {0}", arguments[1]));

                    foreach (var remoteClient in client.Server.Clients.Where(c => c.World.Equals(client.World)))
                        remoteClient.QueuePacket(new TimeUpdatePacket(newTime));
                    
                    break;
                default:
                    Help(client, alias, arguments);
                    break;
            }
        }
开发者ID:Zoxive,项目名称:TrueCraft,代码行数:29,代码来源:TimeCommand.cs

示例2: Handle

        public override void Handle(IRemoteClient client, string alias, string[] arguments)
        {
            if (arguments.Length < 2)
            {
                Help(client, alias, arguments);
                return;
            }
            
            string username = arguments[0];
            var messageBuilder = new System.Text.StringBuilder();

            for (int i = 1; i < arguments.Length; i++)
                messageBuilder.Append(arguments[i] + " ");
            var message = messageBuilder.ToString();

            var receivingPlayer = GetPlayerByName(client, username);

            if (receivingPlayer == null)
            {
                client.SendMessage("No client with the username \"" + username + "\" was found.");
                return;
            }
            if (receivingPlayer == client)
            {
                client.SendMessage(ChatColor.Red + "You can't send a private message to yourself!");
                return;
            }

            receivingPlayer.SendMessage(ChatColor.Gray + "<"+ client.Username + " -> You> " + message);
        }
开发者ID:Zoxive,项目名称:TrueCraft,代码行数:30,代码来源:TellCommand.cs

示例3: Handle

 public override void Handle(IRemoteClient client, string alias, string[] arguments)
 {
     StringBuilder listMessage = new StringBuilder("Currently connected players: ");
     foreach (IRemoteClient c in client.Server.Clients)
     {
         if (listMessage.Length + c.Username.Length + 2 >= 120)
         {
             client.SendMessage(listMessage.ToString());
             listMessage.Clear();
         }
         listMessage.AppendFormat("{0}, ", c.Username);
     }
     listMessage.Remove(listMessage.Length - 2, 2);
     client.SendMessage(listMessage.ToString());
 }
开发者ID:Zoxive,项目名称:TrueCraft,代码行数:15,代码来源:ListCommand.cs

示例4: Handle

        public override void Handle(IRemoteClient client, string alias, string[] arguments)
        {
            if (arguments.Length != 1)
            {
                Help(client, alias, arguments);
                return;
            }

            int id;
            if (!int.TryParse(arguments[0], out id))
            {
                Help(client, alias, arguments);
                return;
            }

            var manager = client.Server.GetEntityManagerForWorld(client.World);
            var entity = manager.GetEntityByID(id) as MobEntity;
            if (entity == null)
            {
                client.SendMessage(ChatColor.Red + "An entity with that ID does not exist in this world.");
                return;
            }

            manager.DespawnEntity(entity);
        }
开发者ID:ac682,项目名称:TrueCraft,代码行数:25,代码来源:DebugCommands.cs

示例5: Handle

        public override void Handle(IRemoteClient client, string alias, string[] arguments)
        {
            if (arguments.Length < 2)
            {
                Help(client, alias, arguments);
                return;
            }

            string  username    = arguments[0],
                    itemid      = arguments[1],
                    amount      = "1";

            if(arguments.Length >= 3)
                    amount = arguments[2];
            
            var receivingPlayer = GetPlayerByName(client, username);

            if (receivingPlayer == null)
            {
                client.SendMessage("No client with the username \"" + username + "\" was found.");
                return;
            }

            if (!GiveItem(receivingPlayer, itemid, amount, client))
            {
                Help(client, alias, arguments);
            }
        }
开发者ID:Zoxive,项目名称:TrueCraft,代码行数:28,代码来源:GiveCommand.cs

示例6: Handle

 public override void Handle(IRemoteClient client, string alias, string[] arguments)
 {
     if (arguments.Length != 0)
     {
         Help(client, alias, arguments);
         return;
     }
     client.SendMessage(client.Entity.Position.ToString());
 }
开发者ID:Zoxive,项目名称:TrueCraft,代码行数:9,代码来源:DebugCommands.cs

示例7: HandleCommand

 /// <summary>
 ///     Tries to find the specified command by first performing a
 ///     case-insensitive search on the command names, then a
 ///     case-sensitive search on the aliases.
 /// </summary>
 /// <param name="client">Client which called the command</param>
 /// <param name="alias">Case-insensitive name or case-sensitive alias of the command</param>
 /// <param name="arguments"></param>
 public void HandleCommand(IRemoteClient client, string alias, string[] arguments)
 {
     ICommand foundCommand = FindByName(alias) ?? FindByAlias(alias);
     if (foundCommand == null)
     {
         client.SendMessage("Invalid command \"" + alias + "\".");
         return;
     }
     foundCommand.Handle(client, alias, arguments);
 }
开发者ID:Zoxive,项目名称:TrueCraft,代码行数:18,代码来源:CommandManager.cs

示例8: HelpPage

        public void HelpPage(IRemoteClient client, int page)
        {
            const int perPage = 5;
            int numPages = (int)Math.Floor(((double)Program.CommandManager.Commands.Count / perPage));
            if ((Program.CommandManager.Commands.Count % perPage) > 0)
                numPages++;

            if (page < 1 || page > numPages)
                page = 1;

            int startingIndex = (page - 1) * perPage;
            client.SendMessage("--Help page " + page + " of " + numPages + "--");
            for (int i = 0; i < perPage; i++)
            {
                int index = startingIndex + i;
                if (index > Program.CommandManager.Commands.Count - 1)
                {
                    break;
                }
                var command = Program.CommandManager.Commands[index];
                client.SendMessage("/" + command.Name + " - " + command.Description);
            }
        }
开发者ID:Zoxive,项目名称:TrueCraft,代码行数:23,代码来源:HelpCommand.cs

示例9: GiveItem

        protected static bool GiveItem(IRemoteClient receivingPlayer, string itemid, string amount, IRemoteClient client)
        {
            short id;
            short metadata = 0;
            int count;

            if (itemid.Contains(":"))
            {
                var parts = itemid.Split(':');
                if (!short.TryParse(parts[0], out id) || !short.TryParse(parts[1], out metadata) || !Int32.TryParse(amount, out count)) return false;
            }
            else
            {
                if (!short.TryParse(itemid, out id) || !Int32.TryParse(amount, out count)) return false;
            }

            if (client.Server.ItemRepository.GetItemProvider(id) == null)
            {
                client.SendMessage("Invalid item id \"" + id + "\".");
                return true;
            }

            string username = receivingPlayer.Username;
            var inventory = receivingPlayer.Inventory as InventoryWindow;
            if (inventory == null) return false;

            while (count > 0)
            {
                sbyte amountToGive;
                if (count >= 64)
                    amountToGive = 64;
                else
                    amountToGive = (sbyte) count;

                count -= amountToGive;

                inventory.PickUpStack(new ItemStack(id, amountToGive, metadata));
            }

            return true;
        }
开发者ID:Zoxive,项目名称:TrueCraft,代码行数:41,代码来源:GiveCommand.cs

示例10: Help

 public override void Help(IRemoteClient client, string alias, string[] arguments)
 {
     client.SendMessage("Correct usage is /" + alias + " <User> <Item ID> [Amount]");
 }
开发者ID:Zoxive,项目名称:TrueCraft,代码行数:4,代码来源:GiveCommand.cs

示例11: Help

 public override void Help(IRemoteClient client, string alias, string[] arguments)
 {
     client.SendMessage("/what: Tells you what you're holding.");
 }
开发者ID:ac682,项目名称:TrueCraft,代码行数:4,代码来源:DebugCommands.cs

示例12: Help

 public override void Help(IRemoteClient client, string alias, string[] arguments)
 {
     client.SendMessage("/time: Shows the current time.");
 }
开发者ID:Zoxive,项目名称:TrueCraft,代码行数:4,代码来源:TimeCommand.cs

示例13: Help

 public virtual void Help(IRemoteClient client, string alias, string[] arguments) { client.SendMessage("Command \"" + alias + "\" is not functional!"); }
开发者ID:ricucremop,项目名称:TrueCraft,代码行数:1,代码来源:Command.cs

示例14: Handle

 public override void Handle(IRemoteClient client, string alias, string[] arguments)
 {
     client.SendMessage("Pong!");
 }
开发者ID:Zoxive,项目名称:TrueCraft,代码行数:4,代码来源:PingCommand.cs

示例15: Help

 public override void Help(IRemoteClient client, string alias, string[] arguments)
 {
     client.SendMessage("Correct usage is /" + alias);
 }
开发者ID:Zoxive,项目名称:TrueCraft,代码行数:4,代码来源:ListCommand.cs


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