Example #1
0
        public override void RenderMap()
        {
            EMMServer Server = Manager.Server;

            if (Server.CurrentStatus != Status.Stopped)
            {
                Server.RaiseServerMessage("BiomeExtractor cannot run - server is running");
                return;
            }

            string exeFile = Server.Settings.ReadConfigPath("biomeextractor_exe");

            if (exeFile.StartsWith("."))
            {
                exeFile = Path.Combine(Server.Settings.ServerManagerRoot, exeFile);
                exeFile = Path.GetFullPath(exeFile);
            }
            if (!File.Exists(exeFile))
            {
                Server.RaiseServerMessage("BiomeExtractor not found.  Expected in {0}", exeFile);
                return;
            }

            // Check the world exists
            string WorldPath = Server.MinecraftSettings.WorldPath;

            if (!Directory.Exists(WorldPath))
            {
                throw new DirectoryNotFoundException("World path missing: " + WorldPath);
            }

            Server.RaiseServerMessage("BiomeExtractor: Updating hints...");

            string cmd = string.Format(
                "-jar \"$EXEPATH\" " +
                "-nogui " +
                "\"$WORLD\" "
                );

            cmd = cmd.Replace("$EXEPATH", exeFile);
            cmd = cmd.Replace("$WORLD", WorldPath);

            Process p = new Process();

            p.StartInfo.FileName        = "java.exe";
            p.StartInfo.UseShellExecute = false;
            p.StartInfo.CreateNoWindow  = false;
            p.StartInfo.Arguments       = cmd;
            p.Start();
            p.PriorityClass = ProcessPriorityClass.BelowNormal;
            p.WaitForExit();

            Server.RaiseServerMessage("BiomeExtractor: Done.");
        }
Example #2
0
 private void ExecuteTask(ScheduleTask task)
 {
     task.CalculateNextRunTime();
     if (mServer != null)
     {
         mServer.RaiseServerMessage(string.Format("Running scheduled task '{0}'.  Next run will be {1}.", task.Name, task.NextRun));
         mServer.Execute(task.Command);
     }
 }
Example #3
0
        /// <summary>
        /// Perform environment checks to make sure backups are reaady to run.
        /// </summary>
        /// <returns>True if system is ready; else false.</returns>
        private bool CheckRequirements()
        {
            EMMServer server = Manager.Server;
            bool      status = true;

            if (!Directory.Exists(server.Settings.BackupRoot))
            {
                server.RaiseServerMessage(string.Format("ERROR: Specified backup location doesn't exist! {0}", server.Settings.BackupRoot));
                status = false;
            }
            return(status);
        }
Example #4
0
        private void BackupFiles()
        {
            EMMServer server     = Manager.Server;
            string    backupFile = Path.Combine(server.Settings.BackupRoot, string.Format("backup-{0:yyyyMMdd-HHmmss}.zip", DateTime.Now));

            using (ZipFile zip = new ZipFile())
            {
                zip.AddSelectedFiles("*.txt", server.Settings.MinecraftRoot, @"minecraft");
                zip.AddSelectedFiles("*.jar", server.Settings.MinecraftRoot, @"minecraft");
                zip.AddSelectedFiles("*.properties", server.Settings.MinecraftRoot, @"minecraft");
                zip.AddDirectory(mWorldPath, @"minecraft\" + Path.GetFileName(mWorldPath));
                try
                {
                    zip.Save(backupFile);
                }
                catch (Exception e)
                {
                    server.RaiseServerMessage(string.Format("ERROR: Unable to save backup! {0}", e.Message));
                }
            }
        }
Example #5
0
        public override void RenderMap()
        {
            EMMServer Server = Manager.Server;

            string OutputPath = Server.Settings.MapOutputPath;

            if (OutputPath.StartsWith("."))
            {
                OutputPath = Path.Combine(Server.Settings.ServerManagerRoot, OutputPath);
                OutputPath = Path.GetFullPath(OutputPath);
            }
            OutputPath = Path.Combine(OutputPath, "overviewer");


            string CachePath = Server.Settings.CacheRoot;

            if (CachePath.StartsWith("."))
            {
                CachePath = Path.Combine(Server.Settings.ServerManagerRoot, CachePath);
                CachePath = Path.GetFullPath(CachePath);
            }
            CachePath = Path.Combine(CachePath, "overviewer");


            string exeFile = Server.Settings.ReadConfigPath("overviewer_exe");

            if (exeFile.StartsWith("."))
            {
                exeFile = Path.Combine(Server.Settings.ServerManagerRoot, exeFile);
                exeFile = Path.GetFullPath(exeFile);
                //exeFile = string.Format("cmd");
            }
            if (!File.Exists(exeFile))
            {
                Server.RaiseServerMessage("Overviewer not found.  Expected in {0}", exeFile);
                return;
            }

            // Check the world exists
            string WorldPath = Server.MinecraftSettings.WorldPath;

            if (!Directory.Exists(WorldPath))
            {
                throw new DirectoryNotFoundException("World path missing: " + WorldPath);
            }

            // Check the output path
            if (!Directory.Exists(Path.GetDirectoryName(OutputPath)))
            {
                throw new DirectoryNotFoundException("Output path missing: " + Path.GetDirectoryName(OutputPath));
            }
            if (!Directory.Exists(OutputPath))
            {
                Directory.CreateDirectory(OutputPath);
            }

            Server.RaiseServerMessage("Overviewer: Rendering map...");

            string cmd = string.Format(
                "\"$WORLD\" " +
                "\"$OUTPUTPATH\" "
                );

            cmd = cmd.Replace("$EXEPATH", Path.GetDirectoryName(exeFile));
            cmd = cmd.Replace("$WORLD", WorldPath);
            cmd = cmd.Replace("$OUTPUTPATH", OutputPath);

            Process p = new Process();

            p.StartInfo.FileName        = exeFile;
            p.StartInfo.UseShellExecute = false;
            p.StartInfo.CreateNoWindow  = false;
            p.StartInfo.Arguments       = cmd;
            p.Start();
            p.PriorityClass = ProcessPriorityClass.BelowNormal;
            p.WaitForExit();

            Server.RaiseServerMessage("overviewer: Done.");
        }
Example #6
0
        public override void RenderMap()
        {
            EMMServer Server = Manager.Server;

            string OutputPath = Server.Settings.MapOutputPath;

            OutputPath = Path.Combine(OutputPath, "c10t");

            string CachePath = Server.Settings.CacheRoot;

            CachePath = Path.Combine(CachePath, "c10t");

            string exeFile = Server.Settings.ReadConfigPath("c10t_exe");

            if (!File.Exists(exeFile))
            {
                Server.RaiseServerMessage("c10t not found.  Expected in {0}", exeFile);
                return;
            }

            // Check the world exists
            string WorldPath = Server.MinecraftSettings.WorldPath;

            if (!Directory.Exists(WorldPath))
            {
                throw new DirectoryNotFoundException("World path missing: " + WorldPath);
            }

            // Check the output path
            if (!Directory.Exists(Path.GetDirectoryName(OutputPath)))
            {
                throw new DirectoryNotFoundException("Output path missing: " + Path.GetDirectoryName(OutputPath));
            }
            if (!Directory.Exists(OutputPath))
            {
                Directory.CreateDirectory(OutputPath);
            }

            // Check the core cache path
            if (!Directory.Exists(Path.GetDirectoryName(CachePath)))
            {
                throw new DirectoryNotFoundException("Cache path missing: " + Path.GetDirectoryName(CachePath));
            }
            if (!Directory.Exists(CachePath))
            {
                Directory.CreateDirectory(CachePath);
            }

            Server.RaiseServerMessage("c10t: Rendering map...");

            string OutputFile = Path.Combine(OutputPath, "map.png");
            string cmd        = string.Format(
                "--world \"$WORLD\" " +
                "--ttf-path \"$EXEPATH\\font.ttf\" " +
                "--output \"$OUTPUTFILE\" " +
                "--cache-dir \"$CACHE\" " +
                "--cache-key \"$CACHEKEY\" " +
                "-P \"$PALETTE\" " +
                "--isometric " +
                "--show-signs=^<^< " +
                "--show-players " +
                "-r 270 " +
                "--player-color 255,255,255,255 " +
                "--sign-color 255,255,0,255");

            cmd = cmd.Replace("$EXEPATH", Path.GetDirectoryName(exeFile));
            cmd = cmd.Replace("$PALETTE", Path.Combine(Path.GetDirectoryName(exeFile), "palette.txt"));
            cmd = cmd.Replace("$WORLD", WorldPath);
            cmd = cmd.Replace("$CACHEKEY", Path.GetFileName(WorldPath));
            cmd = cmd.Replace("$CACHE", CachePath);
            cmd = cmd.Replace("$OUTPUTPATH", OutputPath);
            cmd = cmd.Replace("$OUTPUTFILE", OutputFile);

            Server.RaiseServerMessage("c10t: {0} {1}", exeFile, cmd);
            Process p = new Process();

            p.StartInfo.FileName        = exeFile;
            p.StartInfo.UseShellExecute = false;
            p.StartInfo.CreateNoWindow  = true;
            p.StartInfo.Arguments       = cmd;
            p.Start();
            p.PriorityClass = ProcessPriorityClass.BelowNormal;
            p.WaitForExit();

            int smallWidth = 0;

            int.TryParse(Server.Settings.ReadConfigPath("map_small_width"), out smallWidth);
            string smallFile = Path.Combine(OutputPath, "map-small.png");

            Resize(OutputFile, smallFile, smallWidth);

            Server.RaiseServerMessage("c10t: Done.");
        }