Permalink
Browse files

Removing unused classes

  • Loading branch information...
Kekec852 committed Mar 12, 2012
1 parent 56eb5fa commit 1a6ceda07f6bb2582ecb8910fbdf7d0c7b5ef07c
@@ -1,106 +0,0 @@
-using System;
-using System.IO;
-using System.Threading;
-using System.Collections.Generic;
-using YAMS;
-
-namespace YAMS.AddOns
-{
- public abstract class App
- {
- //We're usually going to operate on a server
- public MCServer Server;
-
- //Where is the main executable?
- protected string MainExe = @"nowhere.exe";
- protected string FullFolderPath = "";
- protected string FullExePath = "";
-
- //What's it called
- protected string Name = "App";
- protected string BaseName = "app";
-
- //Do we need the client?
- protected bool RequiresClient = false;
-
- //Is it even installed?
- public bool IsInstalled = false;
-
- //How did it all go?
- public bool Complete = false;
- public bool Result = false;
-
- //Are we doing something?
- public bool Running = false;
-
- public Dictionary<string, string> jobParams = new Dictionary<string, string> { };
-
- //Set this class's server
- public App(MCServer s, string strBaseName, string strMainExe, string strName, bool bolRequiresClient, string strParams)
- {
- //set up runtime actions
- this.BaseName = strBaseName;
- this.MainExe = strMainExe;
- this.Name = strName;
- this.RequiresClient = bolRequiresClient;
- this.FullFolderPath = Core.RootFolder + @"\apps\" + this.BaseName;
- this.FullExePath = this.FullFolderPath + @"\" + this.MainExe;
- //have we had any options set?
- if (strParams != "")
- {
- string[] arrKeys = strParams.Split('&');
- foreach (string strKey in arrKeys)
- {
- string[] arrValues = strKey.Split('=');
- if (arrValues.Length == 2)
- {
- this.jobParams.Add(arrValues[0], arrValues[1]);
- }
- else
- {
- Database.AddLog("Params failed on " + this.Name + ". String was " + strParams, this.BaseName, "warn");
- }
- }
- }
- //Is it installed?
- if (File.Exists(this.FullExePath))
- {
- this.IsInstalled = true;
- this.Server = s;
- }
- else
- {
- Database.AddLog(this.Name + " is not installed", "addons", "error");
- }
- }
-
- //Start doing work, can't think of a situation where we *wouldn't* want this in a new thread.
- public void Start()
- {
- if (this.IsInstalled)
- {
- if ((this.RequiresClient && Util.HasMCClientSystem()) || !this.RequiresClient)
- {
- this.Running = true;
- ThreadStart threadDelegate = new ThreadStart(this.DoWork);
- Thread newThread = new Thread(threadDelegate);
- newThread.Start();
- }
- else
- {
- Database.AddLog(this.Name + " requires the MC client installed", "addons", "error");
- }
- }
- }
-
- //When we're done, make sure it's known.
- public virtual void Finish()
- {
- this.Running = false;
- }
-
- //The workhorse of any app should always call Finish() when done.
- public abstract void DoWork();
-
- }
-}
@@ -1,103 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Text;
-using System.Diagnostics;
-using System.IO;
-using System.Threading;
-using YAMS;
-
-namespace YAMS.AddOns
-{
- class BiomeExtractor : App
- {
-
- public BiomeExtractor(MCServer s, string strParams = "")
- : base(s, "biome-extractor", @"MinecraftBiomeExtractor.jar", "Biome Extractor", true, strParams) {}
-
- public override void DoWork()
- {
- bool bolStoppedServer = false;
-
- //We shouldn't run this if the server is online, so check
- if (this.Server.Running)
- {
- //It is running, if it's empty we could stop it
- if (this.Server.Players.Count == 0)
- {
- Database.AddLog("Stopping server for Biome Extractor.", this.BaseName, "info", false, this.Server.ServerID);
- this.Server.Stop();
- bolStoppedServer = true;
- }
- else
- {
- //There are people on, so warn and dump out of here
- Database.AddLog("Couldn't run Biome Extractor as server running and not empty.", this.BaseName, "warn", true, this.Server.ServerID);
- this.Complete = true;
- this.Result = false;
- return;
- }
- }
-
- //First run the biome extractor tool
- Process prcBiomeExtractor = new Process();
- prcBiomeExtractor.StartInfo.UseShellExecute = false;
- prcBiomeExtractor.StartInfo.FileName = YAMS.Util.JavaPath() + "java.exe";
- prcBiomeExtractor.StartInfo.Arguments = "-jar MinecraftBiomeExtractor.jar -nogui \"" + Core.StoragePath + this.Server.ServerID + "\\world\"";
- prcBiomeExtractor.StartInfo.CreateNoWindow = true;
- prcBiomeExtractor.StartInfo.RedirectStandardError = true;
- prcBiomeExtractor.StartInfo.RedirectStandardInput = true;
- prcBiomeExtractor.StartInfo.RedirectStandardOutput = true;
- prcBiomeExtractor.StartInfo.WorkingDirectory = this.FullFolderPath;
-
- //Set up events
- prcBiomeExtractor.OutputDataReceived += new DataReceivedEventHandler(BiomeExtractorOutput);
- prcBiomeExtractor.ErrorDataReceived += new DataReceivedEventHandler(BiomeExtractorError);
- prcBiomeExtractor.EnableRaisingEvents = true;
-
- //Finally start the thing
- prcBiomeExtractor.Start();
- prcBiomeExtractor.BeginOutputReadLine();
- prcBiomeExtractor.BeginErrorReadLine();
-
- Database.AddLog("Biome Extractor Started", this.BaseName);
-
- while (!prcBiomeExtractor.WaitForExit(1000)) ;
-
- if (prcBiomeExtractor.ExitCode == 0)
- {
- Database.AddLog("Biome Extractor Completed", this.BaseName);
- this.Complete = true;
- this.Result = true;
- }
- else
- {
- Database.AddLog("Biome Extractor Failed: " + prcBiomeExtractor.ExitCode, this.BaseName, "error");
- this.Complete = true;
- this.Result = false;
- }
-
- //Did we stop the server earlier?
- if (bolStoppedServer)
- {
- Database.AddLog("Restarting server after Biome Extractor completed.", this.BaseName, "info", false, this.Server.ServerID);
- this.Server.Start();
- }
-
- //Must always call this to let base class know we're done
- this.Finish();
- }
-
- //Catch what the process sends back
- private void BiomeExtractorOutput(object sender, DataReceivedEventArgs e)
- {
- DateTime datTimeStamp = DateTime.Now;
- if (e.Data != null) Database.AddLog(datTimeStamp, e.Data, this.BaseName, "info", false, this.Server.ServerID);
- }
- private void BiomeExtractorError(object sender, DataReceivedEventArgs e)
- {
- DateTime datTimeStamp = DateTime.Now;
- if (e.Data != null) Database.AddLog(datTimeStamp, e.Data, this.BaseName, "error", false, this.Server.ServerID);
- }
-
- }
-}
@@ -1,106 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Text;
-using System.Diagnostics;
-using System.IO;
-using System.Threading;
-using YAMS;
-
-namespace YAMS.AddOns
-{
- class NBToolkit : App
- {
-
- public NBToolkit(MCServer s, string strParams = "mode=oregen")
- : base(s, "nbtoolkit", @"NBToolkit.exe", "NBToolkit", true, strParams) {}
-
- public override void DoWork()
- {
- bool bolStoppedServer = false;
-
- //We shouldn't run this if the server is online, so check
- if (this.Server.Running)
- {
- //It is running, if it's empty we could stop it
- if (this.Server.Players.Count == 0)
- {
- Database.AddLog("Stopping server for " + this.Name + ".", this.BaseName, "info", false, this.Server.ServerID);
- this.Server.Stop();
- bolStoppedServer = true;
- }
- else
- {
- //There are people on, so warn and dump out of here
- Database.AddLog("Couldn't run " + this.Name + " as server running and not empty.", this.BaseName, "warn", true, this.Server.ServerID);
- this.Complete = true;
- this.Result = false;
- return;
- }
- }
-
- //Build arguements
- string strArgs = "";
-
- //First run the biome extractor tool
- Process prc = new Process();
- prc.StartInfo.UseShellExecute = false;
- prc.StartInfo.FileName = this.FullExePath;
- prc.StartInfo.Arguments = strArgs;
- prc.StartInfo.CreateNoWindow = true;
- prc.StartInfo.RedirectStandardError = true;
- prc.StartInfo.RedirectStandardInput = true;
- prc.StartInfo.RedirectStandardOutput = true;
- prc.StartInfo.WorkingDirectory = this.FullFolderPath;
-
- //Set up events
- prc.OutputDataReceived += new DataReceivedEventHandler(ProcessOutput);
- prc.ErrorDataReceived += new DataReceivedEventHandler(ProcessError);
- prc.EnableRaisingEvents = true;
-
- //Finally start the thing
- prc.Start();
- prc.BeginOutputReadLine();
- prc.BeginErrorReadLine();
-
- Database.AddLog("Biome Extractor Started", this.BaseName);
-
- while (!prc.WaitForExit(1000)) ;
-
- if (prc.ExitCode == 0)
- {
- Database.AddLog("Biome Extractor Completed", this.BaseName);
- this.Complete = true;
- this.Result = true;
- }
- else
- {
- Database.AddLog("Biome Extractor Failed: " + prc.ExitCode, this.BaseName, "error");
- this.Complete = true;
- this.Result = false;
- }
-
- //Did we stop the server earlier?
- if (bolStoppedServer)
- {
- Database.AddLog("Restarting server after Biome Extractor completed.", this.BaseName, "info", false, this.Server.ServerID);
- this.Server.Start();
- }
-
- //Must always call this to let base class know we're done
- this.Finish();
- }
-
- //Catch what the process sends back
- private void ProcessOutput(object sender, DataReceivedEventArgs e)
- {
- DateTime datTimeStamp = DateTime.Now;
- if (e.Data != null) Database.AddLog(datTimeStamp, e.Data, this.BaseName, "info", false, this.Server.ServerID);
- }
- private void ProcessError(object sender, DataReceivedEventArgs e)
- {
- DateTime datTimeStamp = DateTime.Now;
- if (e.Data != null) Database.AddLog(datTimeStamp, e.Data, this.BaseName, "error", false, this.Server.ServerID);
- }
-
- }
-}
Oops, something went wrong.

0 comments on commit 1a6ceda

Please sign in to comment.