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


C# Client.SendMessage方法代码示例

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


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

示例1: Use

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

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

            ItemStack item = client.Owner.Server.Items[tokens[1]];
            if (ItemStack.IsVoid(item))
            {
                client.SendMessage("§cUnknown item.");
                return;
            }

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

            for (int x = start.X; x <= end.X; x++)
            {
                for (int y = start.Y; y <= end.Y; y++)
                {
                    for (int z = start.Z; z <= end.Z; z++)
                    {
                        client.Owner.World.SetBlockAndData(x, y, z, (byte)item.Type, (byte)item.Durability);
                    }
                }
            }
        }
开发者ID:AVATAR-Phoenix,项目名称:c-raft,代码行数:34,代码来源:CmdSet.cs

示例2: Use

 public void Use(Client client, string[] tokens)
 {
     int newTime = -1;
     if (tokens.Length < 2)
     {
         client.SendMessage("You must specify an explicit time, day, or night.");
         return;
     }
     if (int.TryParse(tokens[1], out newTime) && newTime >= 0 && newTime <= 24000)
     {
         client.Owner.World.Time = newTime;
     }
     else if (tokens[1].ToLower() == "day")
     {
         client.Owner.World.Time = 0;
     }
     else if (tokens[1].ToLower() == "night")
     {
         client.Owner.World.Time = 12000;
     }
     else
     {
         client.SendMessage("You must specify a time value between 0 and 24000");
         return;
     }
     client.Owner.Server.Broadcast(new TimeUpdatePacket { Time = client.Owner.World.Time });
 }
开发者ID:AVATAR-Phoenix,项目名称:c-raft,代码行数:27,代码来源:CmdTime.cs

示例3: Use

 public void Use(Client client, string[] tokens)
 {
     if (tokens.Length < 2)
     {
         client.SendMessage("§cUsage <player> <mode>");
         return;
     }
     Client c = client.Owner.Server.GetClients(tokens[1]).FirstOrDefault();
     if (c != null)
     {
         if (c.Owner.GameMode == Convert.ToByte(tokens[2]))
         {
             client.SendMessage("§7You are already in that mode");
             return;
         }
         c.SendPacket(new NewInvalidStatePacket
         {
             GameMode = c.Owner.GameMode = Convert.ToByte(tokens[2]),
             Reason = NewInvalidStatePacket.NewInvalidReason.ChangeGameMode
         });
     }
     else
     {
         client.SendMessage(string.Format("§cPlayer {0} not found", tokens[1]));
     }
 }
开发者ID:AVATAR-Phoenix,项目名称:c-raft,代码行数:26,代码来源:CmdGameMode.cs

示例4: Use

        public void Use(Client client, string commandName, string[] tokens)
        {
            if (tokens.Length == 0)
            {
                client.SendMessage(String.Format("§7Your position: X={0:0.00},Y={1:0.00},Z={2:0.00}, Yaw={3:0.00}, Pitch={4:0.00}", client.Owner.Position.X, client.Owner.Position.Y, client.Owner.Position.Z, client.Owner.Yaw, client.Owner.Pitch));
            }
            else if (tokens[0] == "yaw")
            {
                Vector3 z1 = client.Owner.Position.ToVector() + Vector3.ZAxis;
                Vector3 posToZ1 = (client.Owner.Position.ToVector() - z1);

                client.SendMessage(String.Format("§7Player.Position.Yaw {0:0.00}, vector computed yaw (SignedAngle) {1:0.00}", client.Owner.Yaw % 360, Vector3.ZAxis.SignedAngle(Vector3.ZAxis.Yaw(client.Owner.Yaw.ToRadians()), Vector3.ZAxis.Yaw(client.Owner.Yaw.ToRadians()).Yaw(90.0.ToRadians())).ToDegrees()));
                client.SendMessage(String.Format("§7Normalised facing Yaw: " + new Vector3(client.Owner.Position.X, client.Owner.Position.Y, client.Owner.Position.Z).Normalize().Yaw(client.Owner.Yaw % 360).ToString()));
            }
        }
开发者ID:dekema2,项目名称:c-raft,代码行数:15,代码来源:DbgPos.cs

示例5: Use

        public void Use(Client 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;

            ItemStack item = client.Owner.Server.Items[tokens[0]];
            if (ItemStack.IsVoid(item))
            {
                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.Owner.World.SetBlockAndData(UniversalCoords.FromWorld(x, y, z), (byte)item.Type, (byte)item.Durability);
                    }
                }
            }
        }
开发者ID:dekema2,项目名称:c-raft,代码行数:34,代码来源:CmdSet.cs

示例6: Use

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

            Client[] matchedClients = client.Owner.Server.GetClients(tokens[1]).ToArray();
            Client 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].Owner.DisplayName.ToLower() == tokens[1].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.Owner.IsMuted;
            clientToMute.Owner.IsMuted = !clientMuted;
            clientToMute.SendMessage(clientMuted ? "You have been unmuted" : "You have been muted");
            client.SendMessage(clientMuted ? clientToMute.Owner.DisplayName + " has been unmuted" : clientToMute.Owner.DisplayName + " has been muted");
        }
开发者ID:AVATAR-Phoenix,项目名称:c-raft,代码行数:46,代码来源:CmdMute.cs

示例7: Use

 public void Use(Client client, string[] tokens)
 {
     if (tokens.Length < 2)
     {
         client.SendMessage("§cPlease specify a target.");
         return;
     }
     Client[] targets = client.Owner.Server.GetClients(tokens[1]).ToArray();
     if (targets.Length < 1)
     {
         client.SendMessage("§cUnknown payer.");
         return;
     }
     foreach (Client c in targets)
     {
         c.Owner.World = client.Owner.World;
         c.Owner.TeleportTo(new AbsWorldCoords(client.Owner.Position.X, client.Owner.Position.Y, client.Owner.Position.Z));
     }
 }
开发者ID:Smjert,项目名称:c-raft,代码行数:19,代码来源:CmdTp.cs

示例8: Use

        public void Use(Client 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.Owner.World.Time = newTime;
            }
            else if (tokens[0].ToLower() == "sunrise")
            {
                client.Owner.World.Time = 0;
            }
            else if (tokens[0].ToLower() == "day")
            {
                client.Owner.World.Time = 6000;
            }
            else if (tokens[0].ToLower() == "sunset")
            {
                client.Owner.World.Time = 12000;
            }

            else if (tokens[0].ToLower() == "night")
            {
                client.Owner.World.Time = 18000;
            }
            else
            {
                client.SendMessage("You must specify a time value between 0 and 24000 or <sunrise|day|sunset|night>");
                return;
            }
            client.Owner.Server.Broadcast(new TimeUpdatePacket { Time = client.Owner.World.Time });
        }
开发者ID:dekema2,项目名称:c-raft,代码行数:36,代码来源:CmdTime.cs

示例9: HandlePacketPlayerDigging

        public static void HandlePacketPlayerDigging(Client client, PlayerDiggingPacket packet)
        {
            Player player = client.Owner;

            UniversalCoords coords = UniversalCoords.FromWorld(packet.X, packet.Y, packet.Z);

            Chunk chunk = player.World.GetChunk(coords);

            if (chunk == null)
                return;

            byte type = (byte)chunk.GetType(coords);
            byte data = chunk.GetData(coords);

            switch (packet.Action)
            {
                case PlayerDiggingPacket.DigAction.StartDigging:
            #if DEBUG
                    UniversalCoords oneUp = UniversalCoords.FromWorld(coords.WorldX, coords.WorldY + 1, coords.WorldZ);
                    client.SendMessage(String.Format("SkyLight: {0}", player.World.GetSkyLight(oneUp)));
                    client.SendMessage(String.Format("BlockLight: {0}", player.World.GetBlockLight(oneUp)));
                    client.SendMessage(String.Format("Opacity: {0}", player.World.GetChunk(oneUp, false, false).GetOpacity(oneUp)));
                    client.SendMessage(String.Format("Height: {0}", player.World.GetHeight(oneUp)));
                    client.SendMessage(String.Format("Data: {0}", player.World.GetBlockData(oneUp)));
                    //this.SendMessage()
            #endif
                    if (BlockHelper.IsSingleHit(type))
                        goto case PlayerDiggingPacket.DigAction.FinishDigging;
                    if (BlockHelper.Instance(type) is BlockLeaves && player.Inventory.ActiveItem.Type == (short)BlockData.Items.Shears)
                        goto case PlayerDiggingPacket.DigAction.FinishDigging;
                    if (player.GameMode == 1)
                        goto case PlayerDiggingPacket.DigAction.FinishDigging;
                    break;

                case PlayerDiggingPacket.DigAction.FinishDigging:
                    StructBlock block = new StructBlock(coords, type, data, player.World);
                    BlockHelper.Instance(type).Destroy(player, block);
                    break;

                case PlayerDiggingPacket.DigAction.DropItem:
                    player.DropItem();
                    break;
            }
        }
开发者ID:dekema2,项目名称:c-raft,代码行数:44,代码来源:Client.Recv.cs

示例10: Use

        public void Use(Client client, string commandName, string[] tokens)
        {
            Vector3 facing = new Vector3(client.Owner.Yaw, client.Owner.Pitch);

            Vector3 start = new Vector3(client.Owner.Position.X, client.Owner.Position.Y + client.Owner.EyeHeight, client.Owner.Position.Z);
            Vector3 end = facing * 100 + start;
            if (end.Y < 0)
            {
                end = end * (Math.Abs(end.Y) / start.Y);
                end.Y = 0;
            }

            RayTraceHitBlock hit = client.Owner.World.RayTraceBlocks(new AbsWorldCoords(start), new AbsWorldCoords(end));

            if (hit != null)
            {
                if (tokens.Length == 0)
                {
                }
                else
                {
                    MobType mobType;
                    if (Enum.TryParse<MobType>(tokens[0], true, out mobType))
                    {
                        Mob theMob = MobFactory.CreateMob(client.Owner.World, client.Server.AllocateEntity(), mobType, null);
                        theMob.Position = new AbsWorldCoords(client.Owner.World.FromFace(hit.TargetBlock, hit.FaceHit));
                        client.Server.AddEntity(theMob);
                    }
                    else if (tokens[0] == "update")
                    {
                        foreach (var entity in client.Server.GetNearbyEntities(client.Owner.World, client.Owner.Position))
                        {
                            entity.TeleportTo(entity.Position);
                        }
                    }
                    else
                    {
                        client.SendMessage(String.Format("Unrecognised mob type: '{0}'", tokens[0]));
                    }
                }
            }
        }
开发者ID:dekema2,项目名称:c-raft,代码行数:42,代码来源:DbgMob.cs

示例11: Use

 public void Use(Client client, string[] tokens)
 {
     client.SendMessage("Online Players: " + client.Owner.Server.Clients.Count);
     foreach (Client c in client.Owner.Server.GetAuthenticatedClients())
         client.SendMessage(c.Owner.EntityId + " : " + c.Owner.DisplayName);
 }
开发者ID:AVATAR-Phoenix,项目名称:c-raft,代码行数:6,代码来源:CmdPlayers.cs

示例12: Help

 public void Help(Client client)
 {
     client.SendMessage("/players - Shows a list of online players.");
 }
开发者ID:AVATAR-Phoenix,项目名称:c-raft,代码行数:4,代码来源:CmdPlayers.cs

示例13: Use

        public void Use(Client client, string[] tokens)
        {
            ItemStack item;
            string itemName = string.Empty;
            short metaData = 0;
            uint amount = 0;
            List<Client> who = new List<Client>();

            if (tokens.Length < 2)
            {
                client.SendMessage("§cPlease specify a target and an item or just an item to give it to yourself.");
                return;
            }

            if (tokens[1].Contains(':'))
            {
                itemName = tokens[1].Split(':')[0].Trim();
                short.TryParse(tokens[1].Split(':')[1].Trim(), out metaData);
                item = client.Owner.Server.Items[itemName];
                item.Durability = metaData;
            }
            else
            {
                item = client.Owner.Server.Items[tokens[1]];
            }

            if (tokens.Length == 2)
            {
                // Trying to give something to yourself
                who.Add(client);
            }
            else if (tokens.Length == 3)
            {
                // Trying to give yourself an item with amount specified
                if (uint.TryParse(tokens[2], out amount))
                {
                    if (!ItemStack.IsVoid(item))
                        who.Add(client);
                    else
                    {
                        if (tokens[2].Contains(':'))
                        {
                            itemName = tokens[2].Split(':')[0].Trim();
                            short.TryParse(tokens[2].Split(':')[1].Trim(), out metaData);
                            item = client.Owner.Server.Items[itemName];
                            item.Durability = metaData;
                        }

                        else
                        {
                            item = client.Owner.Server.Items[tokens[2]];
                        }
                        who.AddRange(client.Owner.Server.GetClients(tokens[1]));
                    }

                }
                else
                {
                    // OR trying to give something to a player(s)
                    who.AddRange(client.Owner.Server.GetClients(tokens[1]));
                    if (tokens[2].Contains(':'))
                    {
                        itemName = tokens[2].Split(':')[0].Trim();
                        short.TryParse(tokens[2].Split(':')[1].Trim(), out metaData);
                        item = client.Owner.Server.Items[itemName];
                        item.Durability = metaData;
                    }
                    else
                    {
                        item = client.Owner.Server.Items[tokens[2]];
                    }
                }
            }
            else
            {
                // Trying to give item to other player with amount specified
                if (uint.TryParse(tokens[3], out amount))
                {
                    who.AddRange(client.Owner.Server.GetClients(tokens[1]));
                    if (tokens[2].Contains(':'))
                    {
                        itemName = tokens[2].Split(':')[0].Trim();
                        short.TryParse(tokens[2].Split(':')[1].Trim(), out metaData);
                        item = client.Owner.Server.Items[itemName];
                        item.Durability = metaData;
                    }
                    else
                    {
                        item = client.Owner.Server.Items[tokens[2]];
                    }
                }

            }

            if (ItemStack.IsVoid(item))
            {
                client.SendMessage("§cUnknown item.");
                return;
            }

//.........这里部分代码省略.........
开发者ID:Smjert,项目名称:c-raft,代码行数:101,代码来源:CmdGive.cs

示例14: Help

 public void Help(Client 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:Smjert,项目名称:c-raft,代码行数:5,代码来源:CmdGive.cs

示例15: Use

 public void Use(Client client, string commandName, string[] tokens)
 {
     switch (tokens.Length)
     {
         case 0:
             ChangeGameMode(client, client.Owner.GameMode == 0 ? 1 : 0);
             break;
         case 2:
             if (Int32.Parse(tokens[1]) != 0)
             {
                 if (Int32.Parse(tokens[1]) != 1)
                 {
                     Help(client);
                     break;
                 }
             }
             Client c = client.Owner.Server.GetClients(tokens[0]).FirstOrDefault();
             if (c != null)
             {
                 if (c.Owner.GameMode == Convert.ToByte(tokens[1]))
                 {
                     client.SendMessage(ChatColor.Red + "Player is already in that mode");
                     break;
                 }
                 ChangeGameMode(client, Int32.Parse(tokens[1]));
                 break;
             }
             client.SendMessage(string.Format(ChatColor.Red + "Player {0} not found", tokens[0]));
             break;
         default:
             Help(client);
             break;
     }
 }
开发者ID:dekema2,项目名称:c-raft,代码行数:34,代码来源:CmdGameMode.cs


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