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


C# Server.SendChatToGroup方法代码示例

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


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

示例1: Execute

 public override void Execute(Server server, RemoteClient user, string text, params string[] parameters)
 {
     if (parameters.Length != 1)
     {
         user.SendChat(ChatColors.Red + "Incorrect usage. Use /help difficulty for more information.");
         return;
     }
     Difficulty value;
     int num;
     if (int.TryParse(text, out num))
     {
         if (num < 0 || num > 3)
         {
             user.SendChat(ChatColors.Red + "Invalid difficulty specified.");
             return;
         }
         value = (Difficulty)num;
     }
     else
     {
         if (!Enum.TryParse<Difficulty>(text, true, out value))
         {
             user.SendChat(ChatColors.Red + "Invalid difficulty specified.");
             return;
         }
     }
     //user.World.Difficulty = value; // TODO
     server.SendChatToGroup("server.op", ChatColors.Gray + user.Username + " sets difficulty of " + user.World.Name + " to " + value.ToString());
 }
开发者ID:SirCmpwn,项目名称:PartyCraft,代码行数:29,代码来源:DifficultyCommand.cs

示例2: Execute

 public override void Execute(Server server, MinecraftClient user, string text, params string[] parameters)
 {
     if (parameters.Length != 1)
     {
         user.SendChat(ChatColors.Red + "Invalid parameters. Use /help op for more information.");
         return;
     }
     var groups = server.GetUserGroups(parameters[0]);
     if (groups.Contains("server.op"))
     {
         user.SendChat(ChatColors.Red + "User is already an op.");
         return;
     }
     groups.Add("server.op");
     server.SetUserGroups(parameters[0], groups);
     server.SendChatToGroup("server.op", ChatColors.Gray + user.Username + " adds " + parameters[0] + " to server.op group.");
 }
开发者ID:NiLSPACE,项目名称:PartyCraft,代码行数:17,代码来源:OpCommand.cs

示例3: Execute

 public override void Execute(Server server, RemoteClient user, string text, params string[] parameters)
 {
     if (parameters.Length != 1)
     {
         user.SendChat(ChatColors.Red + "Invalid parameters. Use /help op for more information.");
         return;
     }
     var groups = server.GetUserGroups(parameters[0]);
     if (!groups.Contains("server.op"))
     {
         user.SendChat(ChatColors.Red + "User is not an op.");
         return;
     }
     groups.Remove("server.op");
     server.SendChatToGroup("server.op", ChatColors.Gray + user.Username + " removes " + parameters[0] + " from server.op group.");
     server.SetUserGroups(parameters[0], groups);
 }
开发者ID:SirCmpwn,项目名称:PartyCraft,代码行数:17,代码来源:DeopCommand.cs

示例4: Execute

 public override void Execute(Server server, MinecraftClient user, string text, params string[] parameters)
 {
     string player = user.Username;
     GameMode gameMode;
     if (parameters.Length == 0 || parameters.Length > 2)
     {
         user.SendChat(ChatColors.Red + "Incorrect usage. Use /help gamemode for more information.");
         return;
     }
     int value;
     if (int.TryParse(parameters[0], out value))
     {
         if (value < 0 || value > 2)
         {
             user.SendChat(ChatColors.Red + "Incorrect usage. Use /help gamemode for more information.");
             return;
         }
         gameMode = (GameMode)value;
     }
     else
     {
         if (!Enum.TryParse<GameMode>(parameters[0], true, out gameMode))
         {
             user.SendChat(ChatColors.Red + "Incorrect usage. Use /help gamemode for more information.");
             return;
         }
     }
     if (parameters.Length == 2)
         player = parameters[1];
     var client = server.MinecraftServer.GetClient(player);
     if (client == null)
     {
         user.SendChat(ChatColors.Red + player + " is not online."); // TODO: Set it anyway
         return;
     }
     client.Entity.GameMode = gameMode;
     server.SendChatToGroup("server.op", ChatColors.Gray + user.Username + " sets " + player + " to " + gameMode + " mode.");
 }
开发者ID:NiLSPACE,项目名称:PartyCraft,代码行数:38,代码来源:GameModeCommand.cs

示例5: Execute

 public override void Execute(Server server, MinecraftClient user, string text, params string[] parameters)
 {
     string player = user.Username;
     int x = (int)user.Entity.Position.X;
     int y = (int)user.Entity.Position.Y;
     int z = (int)user.Entity.Position.Z;
     if (parameters.Length == 1)
         player = parameters[0];
     else if (parameters.Length == 3)
     {
         if (!int.TryParse(parameters[0], out x) &&
             !int.TryParse(parameters[1], out y) &&
             !int.TryParse(parameters[2], out z))
         {
             user.SendChat(ChatColors.Red + "Incorrect usage. Use /help spawnpoint for more information.");
             return;
         }
     }
     else if (parameters.Length == 4)
     {
         player = parameters[0];
         if (!int.TryParse(parameters[1], out x) &&
             !int.TryParse(parameters[2], out y) &&
             !int.TryParse(parameters[3], out z))
         {
             user.SendChat(ChatColors.Red + "Incorrect usage. Use /help spawnpoint for more information.");
             return;
         }
     }
     var client = server.MinecraftServer.GetClient(player);
     if (player == null)
     {
         user.SendChat(ChatColors.Red + player + " is not online."); // TODO: Set it anyway
         return;
     }
     client.Entity.SpawnPoint = new Vector3(x, y, z);
     server.SendChatToGroup("server.op", user.Username + " set " + player + " spawn point to " + client.Entity.SpawnPoint);
 }
开发者ID:NiLSPACE,项目名称:PartyCraft,代码行数:38,代码来源:SpawnPointCommand.cs

示例6: Execute

        public override void Execute(Server server, MinecraftClient user, string text, params string[] parameters)
        {
            bool add = false;
            var current = server.MinecraftServer.GetLevel(user).Time;
            long? time = null;
            if (parameters.Length == 0)
            {
                user.SendChat("The current time is " + current + ", or " + LongToTimeString(current));
                return;
            }
            if (parameters[0].ToLower() == "day")
                time = 0;
            else if (parameters[0].ToLower() == "night")
                time = 12000;
            else if (parameters[0].ToLower() == "noon")
                time = 6000;
            else if (parameters[0].ToLower() == "midnight")
                time = 18000;
            else
            {
                string timeString;
                if (parameters[0].ToLower() == "set" && parameters.Length > 1)
                    timeString = parameters[1];
                else if (parameters[0].ToLower() == "add" && parameters.Length > 1)
                {
                    timeString = parameters[1];
                    add = true;
                }
                else
                    timeString = parameters[0];
                if (timeString.Contains(":"))
                {
                    try
                    {
                        time = TimeStringToLong(timeString);
                    }
                    catch { }
                }
                else
                {
                    long _time;
                    if (long.TryParse(timeString, out _time))
                        time = _time;
                }
                if (add)
                    time += current;
            }

            if (time == null)
            {
                user.SendChat(ChatColors.Red + "Invalid time specified.");
                return;
            }

            time = time.Value % 24000;

            server.MinecraftServer.GetLevel(user).Time = time.Value; // TODO: Add event listener in Craft.Net
            server.SendChatToGroup("server.op", ChatColors.Gray + user.Username + " set the time in " + user.World.Name +
                " to " + time.Value + ", or " + LongToTimeString(time.Value));
        }
开发者ID:NiLSPACE,项目名称:PartyCraft,代码行数:60,代码来源:TimeCommand.cs


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