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);
        }
Beispiel #2
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));
        }