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


C# IClient.SendMessage方法代码示例

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


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

示例1: Use

        public void Use(IClient client, string commandName, string[] tokens)
        {
            if (tokens.Length < 1)
            {
                Help(client);
                return;
            }

            var toKick = client.GetServer().GetClients();


            if (toKick.Any() && tokens[0].ToLower() != "all")
            {
                foreach (var client1 in toKick.Where(client1 => !client1.GetOwner().CanUseCommand("chraft.kick.exempt")))
                {
                    client1.Kick(tokens.Length > 1 ? tokens[1] : "Kicked");
                    client.SendMessage("Kicked " + client1.GetOwner().Name);
                }
            }
            else
            {
                foreach (IClient t in toKick.Where(t => t.GetOwner().Name.ToLower() == tokens[0].ToLower()).Where(t => !t.GetOwner().CanUseCommand("chraft.kick.exempt")))
                {
                    t.Kick(tokens.Length > 1 ? tokens[1] : "Kicked");
                    client.SendMessage("Kicked " + t.GetOwner().Name);
                }
            }
        }
开发者ID:TheaP,项目名称:c-raft,代码行数:28,代码来源:CmdKick.cs

示例2: Help

 public void Help(IClient client)
 {
     client.SendMessage("/ban [player] [reason] <duration> ");
     client.SendMessage("e.g. /ban player hax d:30 h:5 m:5 s:5");
     client.SendMessage("ban player for 30 days, 5 hours, 5 minutes and 5 seconds");
     
 }
开发者ID:TheaP,项目名称:c-raft,代码行数:7,代码来源:CmdBan.cs

示例3: Use

        public void Use(IClient client, string commandName, string[] tokens)
        {
            if (tokens.Length < 2)
            {
                Help(client);
                return;
            }
            
            try
            {
                client.GetServer().GetBanSystem().AddToBanList(tokens[0], tokens[1], tokens.Length > 2 ? tokens : null);
            }
            catch (FormatException ex)
            {
                client.SendMessage(ex.Message);
                return;
            }

            foreach (var nClient in client.GetServer().GetClients(tokens[0]).ToList())
            {
                nClient.Kick(tokens[1]);
            }

            client.SendMessage(string.Format("{0} has been banned", tokens[0]));
        }
开发者ID:TheaP,项目名称:c-raft,代码行数:25,代码来源:CmdBan.cs

示例4: Use

        public void Use(IClient client, string commandName, string[] tokens)
        {
            if (client.Point2 == null || client.Point1 == null)
            {
                client.SendMessage("§cPlease select a cuboid first.");
                return;
            }

            UniversalCoords start = client.SelectionStart.Value;
            UniversalCoords end = client.SelectionEnd.Value;

            IItemStack item = client.GetOwner().GetServer().GetItemDb().GetItemStack(tokens[0]);
            if (item == null || item.IsVoid())
            {
                client.SendMessage("§cUnknown item.");
                return;
            }

            if (item.Type > 255)
            {
                client.SendMessage("§cInvalid item.");
            }

            for (int x = start.WorldX; x <= end.WorldX; x++)
            {
                for (int y = start.WorldY; y <= end.WorldY; y++)
                {
                    for (int z = start.WorldZ; z <= end.WorldZ; z++)
                    {
                        client.GetOwner().GetWorld().SetBlockAndData(UniversalCoords.FromWorld(x, y, z), (byte)item.Type, (byte)item.Durability);
                    }
                }
            }
        }
开发者ID:Nirad,项目名称:c-raft,代码行数:34,代码来源:CmdSet.cs

示例5: Use

 public void Use(IClient client, string commandName, string[] tokens)
 {
     if (tokens.Length < 1)
     {
         Help(client);
         return;
     }
     client.GetServer().GetBanSystem().RemoveFromBanList(tokens[0]);
     client.SendMessage(string.Format("{0} has been unbanned", tokens[0]));
 }
开发者ID:TheaP,项目名称:c-raft,代码行数:10,代码来源:CmdUnban.cs

示例6: Use

        public void Use(IClient client, string commandName, string[] tokens)
        {
            if (tokens.Length < 1)
            {
                client.SendMessage("You must specify a player to mute");
                return;
            }

            IClient[] matchedClients = client.GetServer().GetClients(tokens[0]).ToArray();
            IClient clientToMute = null;
            if (matchedClients.Length < 1)
            {
                client.SendMessage("Unknown Player");
                return;
            }
            else if (matchedClients.Length == 1)
            {
                clientToMute = matchedClients[0];
            }
            else if (matchedClients.Length > 1)
            {
                // We've got more than 1 client. I.e. "Test" and "Test123" for the "test" pattern.
                // Looking for exact name match.
                int exactMatchClient = -1;
                for (int i = 0; i < matchedClients.Length; i++)
                {
                    if (matchedClients[i].GetOwner().DisplayName.ToLower() == tokens[0].ToLower())
                        exactMatchClient = i;
                }

                // If we found the player with the exactly same name - he is our target
                if (exactMatchClient != -1)
                {
                    clientToMute = matchedClients[exactMatchClient];
                } else
                {
                    // We do not found a proper target and aren't going to randomly punish anyone
                    client.SendMessage("More than one player found. Provide the exact name.");
                    return;
                }
            }
            bool clientMuted = clientToMute.GetOwner().IsMuted;
            clientToMute.GetOwner().IsMuted = !clientMuted;
            clientToMute.SendMessage(clientMuted ? "You have been unmuted" : "You have been muted");
            client.SendMessage(clientMuted ? clientToMute.GetOwner().DisplayName + " has been unmuted" : clientToMute.GetOwner().DisplayName + " has been muted");
        }
开发者ID:Nirad,项目名称:c-raft,代码行数:46,代码来源:CmdMute.cs

示例7: Use

        public void Use(IClient client, string commandName, string[] tokens)
        {
            int newTime = -1;
            if (tokens.Length < 1)
            {
                client.SendMessage("You must specify a time value between 0 and 24000 or <sunrise|day|sunset|night>");
                return;
            }
            if (int.TryParse(tokens[0], out newTime) && newTime >= 0 && newTime <= 24000)
            {
                client.GetOwner().GetWorld().Time = newTime;
            }
            else if (tokens[0].ToLower() == "sunrise")
            {
                client.GetOwner().GetWorld().Time = 0;
            }
            else if (tokens[0].ToLower() == "day")
            {
                client.GetOwner().GetWorld().Time = 6000;
            }
            else if (tokens[0].ToLower() == "sunset")
            {
                client.GetOwner().GetWorld().Time = 12000;
            }

            else if (tokens[0].ToLower() == "night")
            {
                client.GetOwner().GetWorld().Time = 18000;
            }
            else
            {
                client.SendMessage("You must specify a time value between 0 and 24000 or <sunrise|day|sunset|night>");
                return;
            }

            client.GetServer().BroadcastTimeUpdate(client.GetOwner().GetWorld());
        }
开发者ID:Nirad,项目名称:c-raft,代码行数:37,代码来源:CmdTime.cs

示例8: List

        protected void List(IClient client, uint pageNumber)
        {
            int maxPerPage = 9;
            // 10 max
            if (!Directory.Exists(SchematicsPlugin.SchematicsFolder))
            {
                client.SendMessage("Schematics not found");
                return;
            }
            string[] files = Directory.GetFiles(SchematicsPlugin.SchematicsFolder, "*.schematic");

            if (files.Length == 0)
            {
                client.SendMessage("Schematics not found");
                return;
            }

            int totalPages = (files.Length / maxPerPage);
            if (files.Length % maxPerPage != 0)
                totalPages += 1;
            if (pageNumber < 1 || pageNumber > totalPages)
            {
                if (totalPages == 1)
                    client.SendMessage("Only page is available");
                else
                    client.SendMessage("Please specify the page number between 1 and " + totalPages);
                return;
            }

            client.SendMessage(string.Format("Schematics [{0}/{1}]:", pageNumber, totalPages));
            int startIndex = (int)(maxPerPage * (pageNumber - 1));
            int lastIndex = (pageNumber == totalPages ? files.Length : (int)(maxPerPage * pageNumber));
            for (int i = startIndex; i < lastIndex; i++)
            {
                string schematicName = files[i].Replace(".schematic", "").Replace(SchematicsPlugin.SchematicsFolder + Path.DirectorySeparatorChar, "");
                client.SendMessage(string.Format("{0}: {1}", (i + 1), schematicName));
            }
        }
开发者ID:chraft,项目名称:c-raft-plugins,代码行数:38,代码来源:CmdSchematic.cs

示例9: Info

        protected void Info(IClient client, string schematicName)
        {
            Schematic schematic = new Schematic(schematicName);

            bool loaded;
            try
            {
                loaded = schematic.LoadFromFile(true);
            }
            catch (FileNotFoundException)
            {
                client.SendMessage(string.Format("Schematic file is not found: {0}", schematicName));
                return;
            }
            catch (Exception ex)
            {
                loaded = false;
                var sb = new StringBuilder();
                sb.Append("Schematics: error has occured while loading schematic file ");
                sb.Append(schematicName);
                sb.Append(Environment.NewLine);
                sb.Append(ex.ToString());
                client.GetServer().GetLogger().Log(LogLevel.Warning, sb.ToString());
            }

            if (!loaded)
            {
                client.SendMessage("Can not load schematic file");
                return;
            }

            client.SendMessage(string.Format("Width(X) x Height(Y) x Length(Z): {0} x {1} x {2} ({3} blocks)", schematic.Width, schematic.Height, schematic.Length, (schematic.Width * schematic.Height * schematic.Length)));
        }
开发者ID:chraft,项目名称:c-raft-plugins,代码行数:33,代码来源:CmdSchematic.cs

示例10: Help

 public void Help(IClient client)
 {
     client.SendMessage("/schematic list [pageNumber] - display a list of available schematics");
     client.SendMessage("/schematic place <schematic name> [x|z|xz] - place the specified schematic at current position and rotate it by X, Z or X & Z axis (optional)");
     client.SendMessage("/schematic info <schematic name> - display the info about specified schematic");
     client.SendMessage("/schematic undo - revert the changes made by the last schematic");
 }
开发者ID:chraft,项目名称:c-raft-plugins,代码行数:7,代码来源:CmdSchematic.cs

示例11: Help

 public void Help(IClient client)
 {
     client.SendMessage("/set <Block> - Sets the selected cuboid to <Block>");
 }
开发者ID:chraft,项目名称:c-raft-plugins,代码行数:4,代码来源:CmdSet.cs

示例12: Help

 public void Help(IClient client)
 {
     client.SendMessage("/banip [ip] [reason] <duration>");
     client.SendMessage("e.g. /banip 127.0.0.1 hax d:30 h:5 m:5 s:5");
     client.SendMessage("banip 127.0.0.1 for 30 days, 5 hours, 5 minutes and 5 seconds");
 }
开发者ID:TheaP,项目名称:c-raft,代码行数:6,代码来源:CmdBanIp.cs

示例13: Use

        public void Use(IClient client, string commandName, string[] tokens)
        {
            if (tokens.Length < 1)
            {
                Help(client);
                return;
            }

            switch (tokens[0].ToLower())
            {
                
                case "on":
                    ChraftConfig.SetWhitelist(true);
                    foreach (var cl in client.GetServer().GetClients())
                    {
                        if( !cl.GetOwner().CanUseCommand("chraft.whitelist.exempt") &&
                            client.GetServer().GetBanSystem().IsOnWhiteList(cl.GetOwner().Name))
                        {
                            cl.Kick(ChraftConfig.WhiteListMesasge);
                        }
                    }
                    client.SendMessage("Whitelist enabled");
                    break;
                case "off":
                    ChraftConfig.SetWhitelist(false);
                    client.SendMessage("Whitelist disabled");
                    break;
                case "add":
                    if (tokens.Length < 2)
                    {
                        Help(client);
                        return;
                    }
                    client.GetServer().GetBanSystem().AddToWhiteList(tokens[1]);
                    client.SendMessage(tokens[1] + " added to Whitelist");
                    break;
                case "remove":
                    if (tokens.Length < 2)
                    {
                        Help(client);
                        return;
                    }
                    client.GetServer().GetBanSystem().RemoveFromWhiteList(tokens[1]);
                    client.SendMessage(tokens[1] + " removed from Whitelist");
                    break;
                case "list":
                    foreach (var play in client.GetServer().GetBanSystem().ListWhiteList())
                    {
                        client.SendMessage(play);
                    }
                    break;
                case "message":
                    if (tokens.Length < 2)
                    {
                        Help(client);
                        return;
                    }
                    ChraftConfig.SetWhitelistMessage(tokens[1]);
                    client.SendMessage("Whitelist message set");
                    break;

            }
        }
开发者ID:TheaP,项目名称:c-raft,代码行数:63,代码来源:CmdWhitelist.cs

示例14: Help

 public void Help(IClient client)
 {
     client.SendMessage(
         "/give <Player> <Item OR Block>[:MetaData] [Amount] - Gives <Player> [Amount] of <Item OR Block>.");
     client.SendMessage("/give <Item OR Block>[:MetaData] [Amount] - Gives you [Amount] of <Item OR Block>.");
 }
开发者ID:TheaP,项目名称:c-raft,代码行数:6,代码来源:CmdGive.cs

示例15: Use

 public void Use(IClient client, string commandName, string[] tokens)
 {
     client.Point2 = UniversalCoords.FromAbsWorld(client.GetOwner().Position);
     client.SendMessage("§7First position set.");
 }
开发者ID:chraft,项目名称:c-raft-plugins,代码行数:5,代码来源:CmdPos.cs


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