/// <summary> /// Creates a new ScheduleManager with default values, linked to the /// specified <see cref="EMMServer"/>. /// </summary> /// <param name="server">The EMMServer to use for executing commands.</param> public SchedulerManager(EMMServer server) { mServer = server; mTasks = new List <ScheduleTask>(); mTimer = new Timer(); mTimer.Elapsed += onTimerEvent; }
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."); }
/// <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); }
private void Initialise() { // Setup the log viewer mLogItemLock = new object(); mLogItems = new InvokeOC <LogListItem>(uxLogListView.Dispatcher); uxLogListView.ItemsSource = mLogItems; // Setup the server manager mMinecraft = Manager.Server; mMinecraft.ServerMessage += HandleServerMessage; mMinecraft.StatusChanged += HandleServerMessage; }
public void FixtureSetup() { mPersistentServer = new EMMServer(); mSettingsFilename = Path.Combine(Path.GetTempPath(), Path.GetTempFileName()); using (TextWriter tw = new StreamWriter(mSettingsFilename)) { tw.WriteLine(@"SimpleValue=Banana"); tw.WriteLine(@"TestSimpleValue=Strawberry"); tw.WriteLine(string.Format(@"AbsolutePath={0}", mSettingsFilename)); tw.WriteLine(string.Format(@"RelativePath=.\{0}", Path.GetFileName(mSettingsFilename))); tw.Close(); } mSettings = new SettingsFile(mPersistentServer, mSettingsFilename, '='); mSettings.LookForNewSettings(); }
private void RotateFiles() { // Get a list of current backups, sorted by created-date EMMServer server = Manager.Server; string[] fileNames = Directory.GetFiles(server.Settings.BackupRoot, "*.zip"); DateTime[] creationTimes = new DateTime[fileNames.Length]; for (int i = 0; i < fileNames.Length; i++) { creationTimes[i] = new FileInfo(fileNames[i]).CreationTime; } Array.Sort(creationTimes, fileNames); // Delete any older ones needed to keep the number to the configured value for (int i = 0; i < fileNames.Length - (mBackupsToKeep - 1); i++) { File.Delete(fileNames[i]); } }
public void FixtureSetup() { // Reflection within the server will yield the incorrect directory for settings, so we need to set it here. string testRoot = Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().CodeBase.Substring(8)); string settingsFile = Path.Combine(testRoot, "settings.conf"); using (TextWriter tw = new StreamWriter(settingsFile)) { tw.WriteLine(@"ServerJar=.\MinecraftSimulator.exe"); tw.Close(); } Console.WriteLine("Settings File is: " + settingsFile); mPersistentServer = new EMMServer(); //mPersistentServer = new EMMServer(settingsFile); //Assert.That(mPersistentServer.Settings.Filename, Is.EqualTo(settingsFile)); mPersistentServer.StartServer(); WaitForServerStatus(Status.Running); }
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)); } } }
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."); }
public void FixtureTeardown() { mPersistentServer.StopServer(false, 0, true); WaitForServerStatus(Status.Stopped); mPersistentServer = null; }
public Config(EMMServer server) { mServer = server; mServerManagerRoot = Path.Combine(Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().CodeBase.Substring(8))); // strip the "file:///" from the front of the codebase }
public SettingsFile(EMMServer server, string fileName, char separator) { mServer = server; mSettingsFile = fileName; mSeparator = separator; }
public MCServerProperties(EMMServer server) : base(server, Path.Combine(server.Settings.MinecraftRoot, "server.properties"), '=') { }
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."); }