public static void Replace(Level old, Level lvl) { LevelDB.SaveBlockDB(old); LevelInfo.Remove(old); LevelInfo.Add(lvl); old.SetPhysics(0); old.ClearPhysics(); lvl.StartPhysics(); Player[] players = PlayerInfo.Online.Items; foreach (Player pl in players) { if (pl.level != old) { continue; } pl.level = lvl; ReloadFor(Player.Console, pl, false); } old.Unload(true, false); if (old == Server.mainLevel) { Server.mainLevel = lvl; } }
public static void LoadMetadata(Level lvl) { try { string propsPath = LevelInfo.PropsPath(lvl.MapName); if (lvl.Config.Load(propsPath)) { lvl.SetPhysics(lvl.Config.Physics); } else { Logger.Log(LogType.ConsoleMessage, ".properties file for level {0} was not found.", lvl.MapName); } } catch (Exception e) { Logger.LogError(e); } lvl.BlockDB.Cache.Enabled = lvl.Config.UseBlockDB; string blockDefsPath = Paths.MapBlockDefs(lvl.MapName); BlockDefinition[] defs = BlockDefinition.Load(blockDefsPath); for (int b = 0; b < defs.Length; b++) { if (defs[b] == null) { continue; } lvl.UpdateCustomBlock((BlockID)b, defs[b]); } lvl.UpdateBlockProps(); lvl.UpdateAllBlockHandlers(); }
public static void LoadMetadata(Level lvl) { lvl.Config.JailX = (ushort)(lvl.spawnx * 32); lvl.Config.JailY = (ushort)(lvl.spawny * 32); lvl.Config.JailZ = (ushort)(lvl.spawnz * 32); lvl.Config.jailrotx = lvl.rotx; lvl.Config.jailroty = lvl.roty; try { string propsPath = LevelInfo.PropsPath(lvl.MapName); bool propsExisted = lvl.Config.Load(propsPath); 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"; lvl.Config.Load(envPath); } catch (Exception e) { Logger.LogError(e); } lvl.BlockDB.Cache.Enabled = lvl.Config.UseBlockDB; BlockDefinition[] defs = BlockDefinition.Load(false, lvl.MapName); for (int b = 0; b < defs.Length; b++) { if (defs[b] == null) { continue; } lvl.UpdateCustomBlock((BlockID)b, defs[b]); } lvl.UpdateBlockProps(); lvl.UpdateBlockHandlers(); }