Beispiel #1
0
        // MC World Management

        public ActionResult ManageWorlds()
        {
            var serverPath = WebConfig.AppSettings["McServerPath"];
            var backupsDir = Path.Combine(serverPath, "Backups");

            if (!Directory.Exists(backupsDir))
            {
                Directory.CreateDirectory(backupsDir);
            }

            ViewBag.Backups =
                new DirectoryInfo(backupsDir)
                .EnumerateFiles("*.zip")
                .OrderByDescending(fi => fi.LastWriteTimeUtc)
                .Select(fi =>
            {
                var s = fi.Name.Split('.');
                return(Tuple.Create(s[0],
                                    DateTime.ParseExact(s[1], "yyyy-MM-dd-hh-mm-ss-tt", null)));
            })
                .ToList();

            ViewBag.Worlds =
                Directory.EnumerateDirectories(serverPath)
                .Where(d => FileIO.Exists(d + "\\level.dat"))
                .Select(d => Path.GetFileName(d))
                .ToList();

            ViewBag.SelWorld = McProperties.GetValue("level-name");

            return(View());
        }
        public ActionResult StartMapper(string world)
        {
            var serverPath = WebConfig.AppSettings["McServerPath"];

            if (world == null)
            {
                world = McProperties.GetValue("level-name");
            }

            var mapsDir = Path.Combine(serverPath, "Map");

            if (!Directory.Exists(mapsDir))
            {
                Directory.CreateDirectory(mapsDir);
            }

            try
            {
                ProcHttpClient.StartProc("Mapper",
                                         Path.Combine(serverPath, "Overviewer\\overviewer.exe"),
                                         "-p 4 --rendermodes=smooth_lighting,smooth_night \""
                                         + world + "\" \"" + Path.Combine("Map", world) + "\"",
                                         serverPath);
            }
            catch (Exception ex)
            {
                Response.StatusCode = 500;
                return(Content(ex.ToString()));
            }

            return(Content("OK " + DateTime.Now.Ticks));
        }
        public ActionResult Properties(List <McProperty> props)
        {
            props.RemoveAll(p => string.IsNullOrEmpty(p.Name));

            McProperties.SetAll(props);

            return(RedirectToAction("Properties"));
        }
        public ActionResult Map(string world)
        {
            var serverPath = WebConfig.AppSettings["McServerPath"];

            ViewBag.Worlds =
                Directory.EnumerateDirectories(serverPath)
                .Where(d => FileIO.Exists(d + "\\level.dat"))
                .Select(d => Path.GetFileName(d))
                .ToList();

            ViewBag.SelWorld = world ?? McProperties.GetValue("level-name");

            return(View());
        }
        public ActionResult RestoreProperties()
        {
            McProperties.RestoreBackup();

            return(RedirectToAction("Properties"));
        }
 public ActionResult Properties()
 {
     return(View(McProperties.GetAll()));
 }
Beispiel #7
0
        public ActionResult SelectWorld(string world)
        {
            McProperties.SetValue("level-name", world);

            return(RedirectToAction("ManageWorlds"));
        }