示例#1
0
        static void AddBuildPlayer(Player p, string name)
        {
            string[] zoneArgs = name.Split(' ');
            name = zoneArgs[0];
            string reason = zoneArgs.Length > 1 ? zoneArgs[1] : "";

            name = CmdZone.FindZoneOwner(p, "os zone add", name, ref reason);
            if (name == null)
            {
                return;
            }

            CmdZone.ZoneAll(p.level, name);
            Player.Message(p, "Added zone for &b" + name);

            LevelAccessController access = p.level.BuildAccess;

            if (access.Blacklisted.CaselessRemove(name))
            {
                access.OnListChanged(p, name, true, true);
            }
            if (!access.Whitelisted.CaselessContains(name))
            {
                access.Whitelisted.Add(name);
                access.OnListChanged(p, name, true, false);
            }
        }
示例#2
0
        static void PrintRanks(Player p, LevelAccessController access, string initial)
        {
            StringBuilder perms = new StringBuilder(initial);

            perms.Append(Group.GetColoredName(access.Min) + "%S+");
            if (access.Max != LevelPermission.Nobody)
            {
                perms.Append(" up to " + Group.GetColoredName(access.Max));
            }

            List <string> whitelist = access.Whitelisted;

            foreach (string name in whitelist)
            {
                perms.Append(", " + PlayerInfo.GetColoredName(p, name));
            }

            List <string> blacklist = access.Blacklisted;

            if (blacklist.Count == 0)
            {
                Player.Message(p, perms.ToString()); return;
            }

            perms.Append(" %S(except ");
            foreach (string name in blacklist)
            {
                perms.Append(PlayerInfo.GetColoredName(p, name) + ", ");
            }
            perms.Remove(perms.Length - 2, 2);
            perms.Append("%S)");
            Player.Message(p, perms.ToString());
        }
示例#3
0
            public void FromOnlineLevel(Level lvl)
            {
                Name           = lvl.name; MapName = lvl.MapName;
                Width          = lvl.Width; Height = lvl.Height; Length = lvl.Length;
                BlockDBEntries = lvl.BlockDB.TotalEntries();
                Config         = lvl.Config;

                Visit = lvl.VisitAccess;
                Build = lvl.BuildAccess;
            }
        static void CopyAllHandler(Player p, string[] parts, CommandData data, bool global, string cmd)
        {
            if (parts.Length < 2)
            {
                Help(p, cmd); return;
            }
            string map = Matcher.FindMaps(p, parts[1]);

            if (map == null)
            {
                return;
            }

            Level            lvl   = null;
            LevelConfig      cfg   = LevelInfo.GetConfig(map, out lvl);
            AccessController visit = new LevelAccessController(cfg, map, true);

            if (!visit.CheckDetailed(p, data.Rank))
            {
                p.Message("Hence, you cannot copy custom blocks from that level"); return;
            }

            int copied = 0;

            BlockDefinition[] defs = BlockDefinition.Load(false, map);
            for (int i = 0; i < defs.Length; i++)
            {
                if (defs[i] == null)
                {
                    continue;
                }

                BlockID b = (BlockID)i;
                if (!DoCopy(p, global, cmd, true, defs[i], b, b))
                {
                    continue;
                }
                copied++;

                string scope = global ? "global" : "level";
                p.Message("Copied the {0} custom block with id \"{1}\".", scope, Block.ToRaw(b));
            }

            string prefix = copied > 0 ? copied.ToString() : "No";

            p.Message("{0} custom blocks were copied from level {1}",
                      prefix, cfg.Color + map);
        }
示例#5
0
 static void DeleteBuildPlayer(Player p, string name)
 {
     if (name.CaselessEq("all"))
     {
         CmdZone.DeleteAll(p);
     }
     else if (Formatter.ValidName(p, name, "player"))
     {
         CmdZone.DeleteWhere(p, zone => zone.Owner.CaselessEq(name));
         LevelAccessController access = p.level.BuildAccess;
         if (access.Whitelisted.CaselessRemove(name))
         {
             access.OnListChanged(p, name, false, true);
         }
     }
 }
示例#6
0
            public void FromMap(string map)
            {
                this.Name = map; MapName = map;
                string  path = LevelInfo.MapPath(map);
                Vec3U16 dims = IMapImporter.GetFor(path).ReadDimensions(path);

                Width          = dims.X; Height = dims.Y; Length = dims.Z;
                BlockDBEntries = BlockDBFile.CountEntries(map);

                path = LevelInfo.PropsPath(map);
                LevelConfig cfg = new LevelConfig();

                cfg.Load(path);

                Config = cfg;
                Visit  = new LevelAccessController(cfg, map, true);
                Build  = new LevelAccessController(cfg, map, false);
            }
示例#7
0
    private void Update()
    {
        if (prefs.level >= levelTarget)
        {
            LAC = ControllerGameObject.GetComponent <LevelAccessController>();

            colorBlock.normalColor      = LAC.ActiveColor;
            colorBlock.disabledColor    = LAC.InActiveColor;
            colorBlock.highlightedColor = LAC.HighLightColor;
            colorBlock.pressedColor     = LAC.PressedColor;
            colorBlock.colorMultiplier  = LAC.colorMultiplier;
            colorBlock.fadeDuration     = LAC.fadeDuration;

            GetComponent <Button>().colors = colorBlock;

            GetComponent <Button>().interactable = prefs.level >= levelTarget;
        }
    }
示例#8
0
        static void DeleteBuildPlayer(Player p, string name)
        {
            if (!Formatter.ValidName(p, name, "player"))
            {
                return;
            }

            LevelAccessController access = p.level.BuildAccess;

            if (access.Whitelisted.CaselessRemove(name))
            {
                access.OnListChanged(p, name, false, true);
            }
            else
            {
                Player.Message(p, name + " was not whitelisted.");
            }
        }
示例#9
0
            public void FromOfflineLevel(string name)
            {
                this.Name = name; MapName = name;
                string  path = LevelInfo.MapPath(name);
                Vec3U16 dims = IMapImporter.Formats[0].ReadDimensions(path);

                Width          = dims.X; Height = dims.Y; Length = dims.Z;
                BlockDBEntries = BlockDBFile.CountEntries(name);

                path = LevelInfo.PropsPath(name);
                LevelConfig cfg = new LevelConfig();

                cfg.SetDefaults(Height);
                cfg.Load(path);

                Config = cfg;
                Visit  = new LevelAccessController(cfg, name, true);
                Build  = new LevelAccessController(cfg, name, false);
            }
示例#10
0
        protected void DoLevel(Player p, string message, CommandData data, bool visit)
        {
            const string maxPrefix = "-max ";
            bool         max       = message.CaselessStarts(maxPrefix);

            if (max)
            {
                message = message.Substring(maxPrefix.Length);
            }

            string[] args = message.SplitSpaces();
            if (message.Length == 0 || args.Length > 2)
            {
                Help(p); return;
            }
            if (args.Length == 1 && p.IsSuper)
            {
                Command.SuperRequiresArgs(name, p, "level"); return;
            }

            string map = args.Length == 1 ? p.level.name : Matcher.FindMaps(p, args[0]);

            if (map == null)
            {
                return;
            }
            Level       lvl;
            LevelConfig cfg    = LevelInfo.GetConfig(map, out lvl);
            int         offset = args.Length == 1 ? 0 : 1;

            AccessController access;

            if (lvl == null)
            {
                access = new LevelAccessController(cfg, map, visit);
            }
            else
            {
                access = visit ? lvl.VisitAccess : lvl.BuildAccess;
            }
            Do(p, args, offset, max, access, data, lvl);
        }
示例#11
0
        static BlockDefinition[] GetDefs(Player p, CommandData data, string map, ref string coloredMap)
        {
            map = Matcher.FindMaps(p, map);
            if (map == null)
            {
                return(null);
            }

            Level            lvl   = null;
            LevelConfig      cfg   = LevelInfo.GetConfig(map, out lvl);
            AccessController visit = new LevelAccessController(cfg, map, true);

            if (!visit.CheckDetailed(p, data.Rank))
            {
                p.Message("Hence, you cannot copy custom blocks from that level");
                return(null);
            }

            coloredMap = cfg.Color + map;
            return(BlockDefinition.Load(false, map));
        }
示例#12
0
        protected void UseList(Player p, string[] args, bool isVisit)
        {
            string target = isVisit ? "pervisit" : "perbuild";

            if (args.Length == 1 && Player.IsSuper(p))
            {
                Command.SuperRequiresArgs(target, p, "level"); return;
            }
            Level level = args.Length == 1 ? p.level : LevelInfo.FindMatches(p, args[0]);

            if (level == null)
            {
                return;
            }
            LevelAccessController access = isVisit ? level.VisitAccess : level.BuildAccess;

            string name    = args.Length == 1 ? args[0] : args[1];
            bool   include = name[0] == '+';
            string mode    = include ? "whitelist" : "blacklist";

            name = name.Substring(1);

            if (name == "")
            {
                Player.Message(p, "You must provide a player name to {0}.", mode); return;
            }
            if (p != null && name.CaselessEq(p.name))
            {
                Player.Message(p, "You cannot {0} yourself.", mode); return;
            }

            if (include)
            {
                access.Whitelist(p, name);
            }
            else
            {
                access.Blacklist(p, name);
            }
        }
示例#13
0
        static void AddBuildPlayer(Player p, string rawArgs)
        {
            string[] args   = rawArgs.SplitSpaces();
            string   reason = args.Length > 1 ? args[1] : "";
            string   name   = ModActionCmd.FindName(p, "zone", "os zone add", "", args[0], ref reason);

            if (name == null)
            {
                return;
            }

            Player.Message(p, "Added zone for &b" + name);
            LevelAccessController access = p.level.BuildAccess;

            if (access.Blacklisted.CaselessRemove(name))
            {
                access.OnListChanged(p, name, true, true);
            }
            if (!access.Whitelisted.CaselessContains(name))
            {
                access.Whitelisted.Add(name);
                access.OnListChanged(p, name, true, false);
            }
        }