예제 #1
0
        static bool LoadOfflineLevel(Player p, string map)
        {
            string      propsPath = LevelInfo.PropsPath(map);
            LevelConfig cfg       = new LevelConfig();

            cfg.Load(propsPath);

            if (!cfg.LoadOnGoto)
            {
                p.Message("Level \"{0}\" cannot be loaded using %T/Goto.", map);
                return(false);
            }

            AccessController visitAccess = new LevelAccessController(cfg, map, true);
            bool             skip        = p.summonedMap != null && p.summonedMap.CaselessEq(map);
            LevelPermission  plRank      = skip ? LevelPermission.Nobody : p.Rank;

            if (!visitAccess.CheckDetailed(p, plRank))
            {
                return(false);
            }

            LevelActions.Load(p, map, false);
            Level lvl = LevelInfo.FindExact(map);

            if (lvl != null)
            {
                return(GotoLevel(p, lvl));
            }

            p.Message("Level \"{0}\" failed to be auto-loaded.", map);
            return(false);
        }
예제 #2
0
        static bool LoadOfflineLevel(Player p, string name)
        {
            string      propsPath = LevelInfo.PropertiesPath(name);
            LevelConfig cfg       = new LevelConfig();

            LevelConfig.Load(propsPath, cfg);

            if (!cfg.LoadOnGoto)
            {
                Player.Message(p, "Level \"{0}\" cannot be loaded using %T/Goto.", name);
                return(false);
            }

            LevelAccessController visitAccess = new LevelAccessController(cfg, name, true);
            bool ignorePerms = p.summonedMap != null && p.summonedMap.CaselessEq(name);

            if (!visitAccess.CheckDetailed(p, ignorePerms))
            {
                return(false);
            }

            CmdLoad.LoadLevel(p, name, true);
            Level lvl = LevelInfo.FindExact(name);

            if (lvl != null)
            {
                return(GotoLevel(p, lvl));
            }

            Player.Message(p, "Level \"{0}\" failed to be auto-loaded.", name);
            return(false);
        }
예제 #3
0
        public static LevelConfig GetConfig(string map, out Level lvl)
        {
            lvl = FindExact(map);
            if (lvl != null)
            {
                return(lvl.Config);
            }

            string      propsPath = PropsPath(map);
            LevelConfig cfg       = new LevelConfig();

            cfg.Load(propsPath);
            return(cfg);
        }
예제 #4
0
파일: Level.cs 프로젝트: ProtheanGod/KingMC
        public static void LoadMetadata(Level lvl)
        {
            try {
                string propsPath    = LevelInfo.PropertiesPath(lvl.MapName);
                bool   propsExisted = LevelConfig.Load(propsPath, lvl.Config);

                if (propsExisted)
                {
                    lvl.setPhysics(lvl.Config.Physics);
                }
                else
                {
                    Logger.Log(LogType.ConsoleMessage, ".properties file for level {0} was not found.", lvl.MapName);
                }

                // Backwards compatibility for older levels which had .env files.
                string envPath = "levels/level properties/" + lvl.MapName + ".env";
                LevelConfig.Load(envPath, lvl.Config);
            } catch (Exception e) {
                Logger.LogError(e);
            }
            lvl.BlockDB.Cache.Enabled = lvl.Config.UseBlockDB;

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

            lvl.UpdateBlockProps();
            lvl.UpdateBlockHandlers();
        }