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


C# IClient.GetOwner方法代码示例

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


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

示例1: DoInteraction

        protected override void DoInteraction(IClient client, IItemInventory item)
        {
            base.DoInteraction(client, item);

            if (client != null && item != null && !ItemHelper.IsVoid(item))
            {
                if (item.Type == (short)BlockData.Items.Shears && !Data.Sheared)
                {
                    // Drop Red mushroom when sheared
                    sbyte count = 5;

                    var drop = ItemHelper.GetInstance(BlockData.Blocks.Red_Mushroom);
                    drop.Count = count;
                    Server.DropItem(World, UniversalCoords.FromAbsWorld(Position.X, Position.Y, Position.Z), drop);

                    Data.Sheared = true;

                    SendMetadataUpdate();
                }
                else if (item.Type == (short)BlockData.Items.Bowl)
                {
                    short slot = (short)item.Slot;
                    client.GetOwner().GetInventory().RemoveItem(slot);
                    client.GetOwner().GetInventory().AddItem((short)BlockData.Items.Mushroom_Soup, 1, 0);
                }
                else if (item.Type == (short)BlockData.Items.Bucket)
                {
                    short slot = (short)item.Slot;
                    client.GetOwner().GetInventory().RemoveItem(slot);
                    client.GetOwner().GetInventory().AddItem((short)BlockData.Items.Milk_Bucket, 1, 0);
                }
            }
        }
开发者ID:TheaP,项目名称:c-raft,代码行数:33,代码来源:Mooshroom.cs

示例2: Use

        public void Use(IClient client, string commandName, string[] tokens)
        {
            MobType type = MobType.Sheep;
            int amount = 1;
            bool validMob = false;

            if (tokens.Length > 1)
                Int32.TryParse(tokens[1], out amount);

            if (tokens.Length > 0)
            {
                int mobId;
                Int32.TryParse(tokens[0], out mobId);
                string mobName = Enum.GetName(typeof(MobType), mobId);
                if (mobId == 0)
                {
                    if (mobId.ToString() != tokens[0])
                    {
                        Enum.TryParse(tokens[0], true, out type);
                        validMob = true;
                    }
                }
                else if (!string.IsNullOrEmpty(mobName))
                {
                    type = (MobType)Enum.Parse(typeof(MobType), mobName);
                    validMob = true;
                }
            }
            else
                validMob = true;

            if (amount < 1 || !validMob)
            {
                Help(client);
                return;
            }

            IServer server = client.GetServer();
            AbsWorldCoords position = client.GetOwner().Position;
            IMobFactory mobFactory = server.GetMobFactory();
            for (int i = 0; i < amount; i++)
            {
                var mob = mobFactory.CreateMob(client.GetOwner().GetWorld(), server, type, null);
                mob.Position = position;

                //Event
                EntitySpawnEventArgs e = new EntitySpawnEventArgs(mob, mob.Position);
                server.GetPluginManager().CallEvent(Event.EntitySpawn, e);
                if (e.EventCanceled)
                    continue;
                mob.Position = e.Location;
                //End Event

                server.AddEntity(mob);
            }
        }
开发者ID:chraft,项目名称:c-raft-plugins,代码行数:56,代码来源:CmdSpawnMob.cs

示例3: Undo

        protected void Undo(IClient client)
        {
            if (!_plugin.Actions.ContainsKey(client.Username))
            {
                client.SendMessage("No changes were made by you");
                return;
            }
            SchematicAction action;
            if (!_plugin.Actions.TryGetValue(client.Username, out action))
            {
                client.SendMessage("Can not revert the changes");
                return;
            }

            UniversalCoords coords = action.StartingPoint;
            bool rotateByX = action.RotateByX;
            bool rotateByZ = action.RotateByZ;
            bool rotateByXZ = action.RotateByXZ;
            int width = ((rotateByX || rotateByXZ) ? -1 * action.Width : action.Width);
            int length = ((rotateByZ || rotateByXZ) ? -1 * action.Length : action.Length);

            if (!RequiredChunksExist(client.GetOwner().GetWorld(), coords, width, action.Height, length))
            {
                client.SendMessage("Can not revert the changes - required chunks are not loaded");
                return;
            }

            UniversalCoords blockCoords;
            IChunk chunk;
            for (int dx = 0; dx < action.Width; dx++)
                for (int dy = 0; dy < action.Height; dy++)
                    for (int dz = 0; dz < action.Length; dz++)
                    {
                        int x = coords.WorldX + ((rotateByX || rotateByXZ) ? -dx : dx);
                        int y = coords.WorldY + dy;
                        int z = coords.WorldZ + ((rotateByZ || rotateByXZ) ? -dz : dz);
                        blockCoords = UniversalCoords.FromWorld(x, y, z);
                        chunk = client.GetOwner().GetWorld().GetChunk(blockCoords);
                        if (chunk == null)
                            continue;
                        int index = action.Width*(dy*action.Length + dz) + dx;
                        chunk.SetBlockAndData(blockCoords, action.BlockIds[index], action.BlockMetas[index]);
                    }
            client.SendMessage(string.Format("Schematic placement has been successfully reverted ({0} blocks)", action.Width * action.Height * action.Length));
            _plugin.Actions.TryRemove(client.Username, out action);
        }
开发者ID:chraft,项目名称:c-raft-plugins,代码行数:46,代码来源:CmdSchematic.cs

示例4: Place

        protected void Place(IClient client, string[] tokens)
        {
            string schematicName = tokens[1];
            Schematic schematic = new Schematic(schematicName);

            bool loaded;
            try
            {
                loaded = schematic.LoadFromFile();
            }
            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;
            }

            bool rotateByX = false;
            bool rotateByZ = false;
            bool rotateByXZ = false;

            if (tokens.Length >= 3)
            {
                string rotation = tokens[2].Trim().ToLower();
                if (rotation == "x")
                    rotateByX = true;
                else if (rotation == "z")
                    rotateByZ = true;
                else if (rotation == "xz")
                    rotateByXZ = true;
            }

            UniversalCoords coords = UniversalCoords.FromAbsWorld(client.GetOwner().Position);
            int width = ((rotateByX || rotateByXZ) ? -1 * schematic.Width : schematic.Width);
            int length = ((rotateByZ || rotateByXZ) ? -1 * schematic.Length : schematic.Length);

            if (!RequiredChunksExist(client.GetOwner().GetWorld(), coords, width, schematic.Height, length))
            {
                client.SendMessage("The schematic is too big - required chunks are not loaded/created yet");
                return;
            }

            int blockAmount = schematic.Width * schematic.Height * schematic.Length;
            byte[] blockIds = new byte[blockAmount];
            byte[] blockMetas = new byte[blockAmount];
            UniversalCoords blockCoords;
            IChunk chunk;
            int index;

            for (int dx = 0; dx < schematic.Width; dx++)
                for (int dy = 0; dy < schematic.Height; dy++)
                    for (int dz = 0; dz < schematic.Length; dz++)
                    {
                        int x = coords.WorldX + ((rotateByX || rotateByXZ) ? -dx : dx);
                        int y = coords.WorldY + dy;
                        int z = coords.WorldZ + ((rotateByZ || rotateByXZ) ? -dz : dz);
                        blockCoords = UniversalCoords.FromWorld(x, y, z);
                        chunk = client.GetOwner().GetWorld().GetChunk(blockCoords, false, false);
                        if (chunk == null)
                            continue;
                        index = schematic.ToIndex(dx, dy, dz);
                        blockIds[index] = (byte)chunk.GetType(blockCoords);
                        blockMetas[index] = chunk.GetData(blockCoords);
                        chunk.SetBlockAndData(blockCoords, schematic.BlockIds[index], schematic.BlockMetas[index]);
                    }

            SchematicAction action;
            if (_plugin.Actions.ContainsKey(client.Username))
                _plugin.Actions.TryRemove(client.Username, out action);

            action = new SchematicAction
                         {
                             StartingPoint = coords,
                             BlockIds = blockIds,
                             BlockMetas = blockMetas,
                             RotateByX = rotateByX,
                             RotateByZ = rotateByZ,
                             RotateByXZ = rotateByXZ,
                             Width = schematic.Width,
                             Height = schematic.Height,
                             Length = schematic.Length
                         };
            _plugin.Actions.TryAdd(client.Username, action);
            client.SendMessage(string.Format("Schematic {0} ({1} blocks) has been placed", schematic.SchematicName, blockAmount));
        }
开发者ID:chraft,项目名称:c-raft-plugins,代码行数:100,代码来源:CmdSchematic.cs

示例5: 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:chraft,项目名称:c-raft-plugins,代码行数:34,代码来源:CmdSet.cs

示例6: Use

        public void Use(IClient client, string commandName, string[] tokens)
        {
            short amount;
            IClient target;

            if (tokens.Length == 1)
            {
                if (short.TryParse(tokens[0], out amount))
                {
                    client.GetOwner().AddExperience(amount);
                    client.SendMessage(string.Format("{0}You has been granted with {1} exp", ChatColor.Red, amount));
                    return;
                }
                Help(client);
                return;
            }

            if (tokens.Length == 2)
            {
                IClient[] matchedClients = client.GetServer().GetClients(tokens[0]).ToArray();
                if (matchedClients.Length < 1)
                {
                    client.SendMessage("Unknown Player");
                    return;
                }
                if (matchedClients.Length == 1)
                {
                    target = matchedClients[0];
                }
                else
                {
                    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)
                    {
                        target = 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;
                    }
                }

                if (short.TryParse(tokens[1], out amount))
                {
                    target.GetOwner().AddExperience(amount);
                    target.SendMessage(string.Format("{0}{1} has been granted with {2} exp", ChatColor.Red, target.GetOwner().DisplayName, amount));
                }
                else
                {
                    Help(client);
                }
                return;
            }

            Help(client);
        }
开发者ID:chraft,项目名称:c-raft-plugins,代码行数:65,代码来源:CmdGiveXP.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: Use

 public void Use(IClient client, string commandName, string[] tokens)
 {
     short newHealth = 20;
     if (tokens.Length > 0)
     {
         if (!short.TryParse(tokens[0], out newHealth))
             newHealth = 20;
     }
     client.GetOwner().SetHealth(newHealth);
 }
开发者ID:chraft,项目名称:c-raft-plugins,代码行数:10,代码来源:CmdSetHealth.cs

示例9: ClientLeftEventArgs

 public ClientLeftEventArgs(IClient c)
     : base(c)
 {
     BrodcastMessage = ChatColor.Yellow + c.GetOwner().DisplayName + " has left the game"; //Like the Notchian server.
 }
开发者ID:TheaP,项目名称:c-raft,代码行数:5,代码来源:PlayerEventArgs.cs

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