Пример #1
0
        void OnClaimDeleteCommand(User user, string[] args)
        {
            if (args.Length == 0)
            {
                user.SendChatMessage(Messages.Usage, "/claim delete XY [XY XY...]");
                return;
            }

            if (!user.HasPermission(Permission.AdminClaims))
            {
                user.SendChatMessage(Messages.NoPermission);
                return;
            }

            var areas = new List <Area>();

            foreach (string arg in args)
            {
                Area area = Areas.Get(Util.NormalizeAreaId(arg));

                if (area.Type == AreaType.Badlands)
                {
                    user.SendChatMessage(Messages.AreaIsBadlands, area.Id);
                    return;
                }

                if (area.Type == AreaType.Wilderness)
                {
                    user.SendChatMessage(Messages.AreaIsWilderness, area.Id);
                    return;
                }

                areas.Add(area);
            }

            foreach (Area area in areas)
            {
                PrintToChat(Messages.AreaClaimDeletedAnnouncement, area.FactionId, area.Id);
                Log($"{Util.Format(user)} deleted {area.FactionId}'s claim on {area.Id}");
            }

            Areas.Unclaim(areas);
        }
Пример #2
0
        void OnClaimRenameCommand(User user, string[] args)
        {
            Faction faction = Factions.GetByMember(user);

            if (!EnsureUserCanChangeFactionClaims(user, faction))
            {
                return;
            }

            if (args.Length != 2)
            {
                user.SendChatMessage(Messages.Usage, "/claim rename XY \"NAME\"");
                return;
            }

            var areaId = Util.NormalizeAreaId(args[0]);
            var name   = Util.NormalizeAreaName(args[1]);

            if (name == null || name.Length < Options.Claims.MinAreaNameLength || name.Length > Options.Claims.MaxAreaNameLength)
            {
                user.SendChatMessage(Messages.InvalidAreaName, Options.Claims.MinAreaNameLength, Options.Claims.MaxAreaNameLength);
                return;
            }

            Area area = Areas.Get(areaId);

            if (area == null)
            {
                user.SendChatMessage(Messages.UnknownArea, areaId);
                return;
            }

            if (area.FactionId != faction.Id)
            {
                user.SendChatMessage(Messages.AreaNotOwnedByYourFaction, area.Id);
                return;
            }

            user.SendChatMessage(Messages.AreaRenamed, area.Id, name);
            Log($"{Util.Format(user)} renamed {area.Id} to {name}");

            area.Name = name;
        }