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


C# Client.Admin方法代码示例

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


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

示例1: Spawner

        static void Spawner(Client player, string[] cmd, int iarg)
        {
            if (!player.Admin())
                throw new ErrorException("Spawn does no longer work");

            VanillaSession rs = player.Session as VanillaSession;
            if (rs.Spawners.Count == 0)
            {
                player.TellSystem(Chat.Purple, "No spawners yet detected");
                return;
            }
            CoordInt nearby = rs.Spawners [0];
            double dist = nearby.DistanceTo(rs.Position);
            foreach (CoordInt c in rs.Spawners)
            {
                double cdist = c.DistanceTo(rs.Position);
                if (cdist < 10)
                    continue;
                if (cdist < dist)
                {
                    dist = cdist;
                    nearby = c;
                }
            }   
            player.Warp(nearby.CloneDouble(), rs.Dimension, player.Session.World);
        }
开发者ID:mctraveler,项目名称:MineSharp,代码行数:26,代码来源:VanillaWorldCommands.cs

示例2: Translate

        static void Translate(Client p, string[] cmd, int offset)
        {
            if (!p.Donor && !p.Admin())
                throw new ErrorException("Only for donors, /donate");

            if (cmd.Length == offset)
            {
                lock (senderTranslate)
                {
                    if (senderTranslate.Remove(p.MinecraftUsername))
                        p.TellSystem(Chat.Aqua, "Removed translation");
                }
                throw new ShowHelpException();
            }

            if (cmd.Length == offset + 1)
            {
                if (cmd [offset].Length == 2)
                    TranslateNext(p, new Languages(cmd [offset]));
                else
                    TranslatePrev(p, new Languages(p.Language), cmd [offset]);
                return;
            }


            Languages lang;
            if (cmd [offset].Length == 2 && cmd [offset + 1].Length == 2)
            {
                lang = new Languages(cmd [offset], cmd [offset + 1]);
                offset += 2;
            } else
            {
                lang = new Languages(cmd [offset]);
                offset += 1;
            }

            if (cmd.Length == offset)
            {
                TranslateNext(p, lang);
                return;
            }
            
            if (cmd.Length == offset + 1)
            {
                TranslatePrev(p, lang, cmd [offset]);
                return;
            }

            TranslateText(p, lang, cmd.JoinFrom(offset));
        }
开发者ID:mctraveler,项目名称:MineSharp,代码行数:50,代码来源:Translate.cs

示例3: FindShowHelp

        static bool FindShowHelp(Client player, string path, string command)
        {
            if (command == "" || command == null)
                return false;

            if (player.Admin())
            {
                string apath = Path.Combine(Path.Combine(path, "admin"), Path.GetFileName(command));
                if (Chat.ReadFile(apath, Chat.Pink, player))
                    return true;
            }
            
            string filepath = Path.Combine(path, Path.GetFileName(command));
            if (Chat.ReadFile(filepath, Chat.Green, player))
                return true;

            //Try with one argument less
            int pos = command.LastIndexOf(' ');
            if (pos < 0)
                return false;
            return FindShowHelp(player, path, command.Substring(0, pos));
        }
开发者ID:mctraveler,项目名称:MineSharp,代码行数:22,代码来源:Help.cs

示例4: ParseClientTab

        public static void ParseClientTab(Client player, TabCompleteClient tab)
        {
            string[] cmd = tab.Command.Substring(1).Replace("  ", " ").Split(' ');
            cmd [0] = cmd [0].Trim().Trim('/');

            var tc = new TabComplete();
                
            var commander = player.Session.World.Commands;
            if (commander != null)
            {
                player.Session.World.Commands.ParseTab(player, cmd, 1, tc);
                if (tc.Alternatives.Count > 0)
                {
                    player.Queue.Queue(tc);
                    return;
                }
            }
            
            Instance.ParseTab(player, cmd, 1, tc);
            if (tc.Alternatives.Count > 0)
            {
                player.Queue.Queue(tc);
                return;
            }

            if (cmd.Length > 1)
            {
                Client p;
                if (player.Admin())
                    p = PlayerList.GetPlayerByUsernameOrName(cmd [cmd.Length - 1]);
                else
                    p = PlayerList.GetPlayerByName(cmd [cmd.Length - 1]);
                if (p != null)
                {
                    player.Queue.Queue(TabComplete.Single(p.Name));
                }
            }
        }
开发者ID:mctraveler,项目名称:MineSharp,代码行数:38,代码来源:MainCommands.cs

示例5: RegionCommand

        void RegionCommand(Client player, string[] cmd, int iarg)
        {
            if (cmd.Length == iarg)
            {
                //Single /reg, no arguments
                WorldRegion region = player.Session.CurrentRegion;
                if (region == null)
                    throw new ErrorException("No region here");

                    
                player.TellSystem(Chat.Aqua, "Region: " + region.ColorName);
                if (player.Admin())
                {
                    player.TellSystem(Chat.Gray, region.Type + ": " + region);
                }   
                player.TellSystem(Chat.DarkAqua + "Residents: ", region.GetResidents());
                player.TellSystem(Chat.DarkAqua + "Last visited by resident: ", (DateTime.UtcNow - region.Stats.LastVisitResident).TotalDays.ToString("0.0") + " days ago");
                return;
            }

            if (base.ParseCommand(player, cmd, iarg + 1) == false)
                throw new ShowHelpException();
        }
开发者ID:mctraveler,项目名称:MineSharp,代码行数:23,代码来源:RegionCommands.cs

示例6: Delete

        void Delete(Client player, string[] cmd, int iarg)
        {
            if (player.Admin() == false)
                throw new ErrorException("Disabled");
            WorldRegion region = player.Session.CurrentRegion;
            if (region == null)
                throw new ErrorException("No region here");

            if (cmd.Length <= iarg)
                throw new ShowHelpException(); //Need more arguments

            RegionList regions = player.Session.World.Regions;

            string subdel = cmd [iarg].ToLowerInvariant();
            switch (subdel)
            {
                case "single":
                    DeleteSingle(region, regions);
                    player.TellSystem(Chat.Purple, region.Name + " removed");
                    player.Session.CurrentRegion = null;
                    break;
                case "recursive":
                    DeleteRecursive(region);
                    player.TellSystem(Chat.Purple, region.Name + " and subregions removed");
                    region.Deleted = true;
                    player.Session.CurrentRegion = null;
                    break;
                case "subonly":
                    DeleteSubregions(region);
                    player.TellSystem(Chat.Purple, "Subregions of " + region.Name + " removed");                        
                    break;
                default:
                    throw new ShowHelpException();
            }
            RegionLoader.Save(regions);
            
            //Update all players regions
            foreach (var p in PlayerList.List)
                RegionCrossing.SetRegion(p.Session);
            
            ScoreboardRegionManager.UpdateAllPlayersRegion();
        }
开发者ID:mctraveler,项目名称:MineSharp,代码行数:42,代码来源:RegionCommands.cs

示例7: Create

        internal static WorldRegion Create(Dimensions dimension, CoordDouble start, CoordDouble end, string regionName, Client player, string resident, RegionList regions)
        {
            if (regions == null)
                throw new ErrorException("No regions in this world");

            WorldRegion w = new WorldRegion(dimension, start, end, regionName);
            w.Residents.Add(resident);
            w.Type = "protected";

            lock (regions)
            {
                //Test for overlapping regions
                WorldRegion existing = RegionCrossing.GetBaseRegion(regions.List, w, dimension);
                if (existing == null)
                {
                    //New Top level region
                    regions.List.Add(w);
                    RegionLoader.Save(regions);
                    return w;
                } 

                //Make sure you already are a part of the region
                if (existing.ResidentPermissions(player) == false)
                    throw new ErrorException("You can't set a subregion unless you are a resident in the parent region.");

                //All inside, make subregion
                if (existing.Cover(w))
                {
                    if (existing.SubRegions == null)
                        existing.SubRegions = new List<WorldRegion>();
                    existing.SubRegions.Add(w);
                    RegionLoader.Save(regions);
                    return w;
                }
                //Need to make a wrapping region

                //Only admins may create wrapping regions
                if (player != null && player.Admin() == false)
                    throw new ErrorException("New region must be fully inside " + existing);

                //New region covering several old ones?
                var parentList = WorldRegion.GetParentList(regions, existing);
                if (parentList == null)
                    throw new ErrorException("Parent list not found for " + existing);

                //regions to move inside the new one
                var moving = new List<WorldRegion>();

                //Determine if we are breaking any boundaries
                bool breaking = false;
                foreach (var s in parentList)
                {
                    if (w.Cover(s))
                    {
                        moving.Add(s);
                    } else if (w.Overlap(s)) //Overlap but not cover completely
                    {
                        player.TellSystem(Chat.Red, "Breaking boundaries: " + s);
                        breaking = true;
                    }
                }
                if (breaking)
                {
                    player.TellSystem(Chat.Red, "Failed creating: " + w);
                    player.TellSystem(Chat.Red, "Aborting: Broke region boundaries");
                    return null;
                }

                //Move subregions into new region and remove from parentlist
                w.SubRegions = moving;
                foreach (var s in moving)
                {
                    player.TellSystem(Chat.Aqua, "New subregion: " + s);
                    parentList.Remove(s);
                }
                parentList.Add(w);
                RegionLoader.Save(regions);
                return w;
            }
        }
开发者ID:mctraveler,项目名称:MineSharp,代码行数:80,代码来源:RegionCommands.cs

示例8: SetRegionEnd

        void SetRegionEnd(Client player, int ymin, int ymax)
        {
            if (regionStart.ContainsKey(player.MinecraftUsername) == false)
                throw new UsageException("You must type /region start");
            if (ymin > ymax)
                throw new ErrorException(ymin + " must be less than " + ymax);
            if (ymin < 50 && (!player.Admin()) && (!player.Donor))
                throw new ErrorException("Only admins and donors may make regions below Y=50");
            if (player.Session.Position.Y + 1 < ymin)
                throw new ErrorException("You are below the region you tried to create, move up and run the command again");

            if (ymax > 256)
                ymax = 256;

            if (player.Session.Dimension == Dimensions.End)
                throw new ErrorException("No regions in The End");

            CoordDouble start = regionStart [player.MinecraftUsername];
            CoordDouble end = player.Session.Position.Clone();
            
            start.Y = ymin;
            end.Y = ymax;

            CreateRegion(player, start, end);
        }
开发者ID:mctraveler,项目名称:MineSharp,代码行数:25,代码来源:RegionCommands.cs

示例9: SetRegionStart

 void SetRegionStart(Client player, string[] cmd, int iarg)
 {
     if (Donors.IsDonor(player) == false && player.Uptime.TotalDays < 2 && (player.Admin() == false))
     {
         player.TellSystem(Chat.Red, "You must have been playing here at least 48 hours before you can create custom regions");
         player.TellSystem(Chat.Gray, "Use " + Chat.Yellow + "/ticket region" + Chat.Gray + " to create your first region");
         player.TellSystem(Chat.Gold, "See /donate, if you donate you can make one immediately.");
         return;
     }
     
     regionStart.Remove(player.MinecraftUsername);
     regionStart.Add(player.MinecraftUsername, player.Session.Position.Clone());
     player.TellSystem(Chat.Aqua, "Region start set at " + player.Session.Position.CloneInt());
     player.TellSystem(Chat.Aqua, "Go to other corner and type:");
     player.TellSystem("", "    /region set [ymin] [ymax]");
 }
开发者ID:mctraveler,项目名称:MineSharp,代码行数:16,代码来源:RegionCommands.cs

示例10: Pardon

 static void Pardon(Client player, string[] cmd, int iarg)
 {
     if (cmd.Length != 2)
         throw new ErrorException("Missing username");
             
     if (player.Admin() || Donors.IsDonor(player))
     {
         Banned.Pardon(player, cmd [1]);
         return;
     }
             
     Banned.VotePardon(player, cmd [1]);
 }
开发者ID:mctraveler,项目名称:MineSharp,代码行数:13,代码来源:Players.cs


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